An unofficial collection of APIs used in FreeJam games and mods
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.1KB

  1. use crate::techblox::{Parsable, SerializedEntityComponent, UnityFloat3,
  2. UnityQuaternion, UnityFloat4x4};
  3. use libfj_parsable_macro_derive::*;
  4. /// Database entity component.
  5. #[derive(Copy, Clone, Parsable)]
  6. pub struct DBEntityStruct {
  7. /// Database identifier
  8. pub dbid: u32,
  9. }
  10. impl SerializedEntityComponent for DBEntityStruct {}
  11. /// Position entity component.
  12. #[derive(Copy, Clone, Parsable)]
  13. pub struct PositionEntityStruct {
  14. /// Entity position
  15. pub position: UnityFloat3,
  16. }
  17. impl SerializedEntityComponent for PositionEntityStruct {}
  18. /// Scaling entity component.
  19. #[derive(Copy, Clone, Parsable)]
  20. pub struct ScalingEntityStruct {
  21. /// Entity position
  22. pub scale: UnityFloat3,
  23. }
  24. impl SerializedEntityComponent for ScalingEntityStruct {}
  25. /// Scaling entity component.
  26. #[derive(Copy, Clone, Parsable)]
  27. pub struct RotationEntityStruct {
  28. /// Entity position
  29. pub rotation: UnityQuaternion,
  30. }
  31. impl SerializedEntityComponent for RotationEntityStruct {}
  32. /// Block skew component.
  33. #[derive(Copy, Clone, Parsable)]
  34. pub struct SkewComponent {
  35. /// Block skew matrix
  36. pub skew_matrix: UnityFloat4x4,
  37. }
  38. impl SerializedEntityComponent for SkewComponent {}
  39. /// Block placement grid rotation component.
  40. #[derive(Copy, Clone, Parsable)]
  41. pub struct GridRotationStruct {
  42. /// Grid rotation
  43. pub rotation: UnityQuaternion,
  44. /// Grid position
  45. pub position: UnityFloat3,
  46. }
  47. impl SerializedEntityComponent for GridRotationStruct {}
  48. // *** These don't contain anything but the game thinks they do ***
  49. // GridConnectionsEntityStruct is not serialized to disk
  50. // BlockPlacementInfoStruct has a disk serializer that does nothing (?)
  51. /// Empty, basically useless except that Techblox says it exists while serializing.
  52. #[derive(Copy, Clone, Parsable)]
  53. pub struct SerializedGridConnectionsEntityStruct {}
  54. impl SerializedEntityComponent for SerializedGridConnectionsEntityStruct {}
  55. /// Empty, basically useless except that Techblox says it exists while serializing.
  56. #[derive(Copy, Clone, Parsable)]
  57. pub struct SerializedBlockPlacementInfoStruct {}
  58. impl SerializedEntityComponent for SerializedBlockPlacementInfoStruct {}
  59. // *** These do contain data again ***
  60. /// Block material component.
  61. #[derive(Copy, Clone, Parsable)]
  62. pub struct SerializedCubeMaterialStruct {
  63. /// Material identifier
  64. pub material_id: u8,
  65. }
  66. impl SerializedEntityComponent for SerializedCubeMaterialStruct {}
  67. /// Block uniform scale component.
  68. #[derive(Copy, Clone, Parsable)]
  69. pub struct SerializedUniformBlockScaleEntityStruct {
  70. /// Uniform scale factor
  71. pub scale_factor: u8,
  72. }
  73. impl SerializedEntityComponent for SerializedUniformBlockScaleEntityStruct {}
  74. /// Block colour component.
  75. #[derive(Copy, Clone, Parsable)]
  76. pub struct SerializedColourParameterEntityStruct {
  77. /// Index of colour in Techblox palette
  78. pub index_in_palette: u8,
  79. }
  80. impl SerializedEntityComponent for SerializedColourParameterEntityStruct {}
  81. /// Block group component.
  82. #[derive(Copy, Clone, Parsable)]
  83. pub struct BlockGroupEntityComponent {
  84. /// Index of colour in Techblox palette
  85. pub current_block_group: i32,
  86. }
  87. impl SerializedEntityComponent for BlockGroupEntityComponent {}