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.

59 lines
2.2KB

  1. use crate::techblox::{SerializedEntityDescriptor, Parsable, SerializedEntityComponent};
  2. use crate::techblox::blocks::{DBEntityStruct, PositionEntityStruct, ScalingEntityStruct, RotationEntityStruct,
  3. SkewComponent, GridRotationStruct, SerializedGridConnectionsEntityStruct, SerializedBlockPlacementInfoStruct,
  4. SerializedCubeMaterialStruct, SerializedUniformBlockScaleEntityStruct, SerializedColourParameterEntityStruct,
  5. BlockGroupEntityComponent};
  6. use libfj_parsable_macro_derive::*;
  7. /// Block entity descriptor.
  8. #[derive(Copy, Clone, Parsable)]
  9. pub struct BlockEntity {
  10. /// Database component
  11. pub db_component: DBEntityStruct,
  12. /// Position component
  13. pub pos_component: PositionEntityStruct,
  14. /// Scale component
  15. pub scale_component: ScalingEntityStruct,
  16. /// Rotation component
  17. pub rot_component: RotationEntityStruct,
  18. /// Skew matrix component
  19. pub skew_component: SkewComponent,
  20. /// Grid component
  21. pub grid_component: GridRotationStruct,
  22. // GridConnectionsEntityStruct is not serialized to disk
  23. /// No-op serializer (this has no data!)
  24. pub grid_conn_component: SerializedGridConnectionsEntityStruct,
  25. // BlockPlacementInfoStruct has a disk serializer that does nothing (?)
  26. /// No-op serializer (this has no data!)
  27. pub placement_component: SerializedBlockPlacementInfoStruct,
  28. /// Cube material component
  29. pub material_component: SerializedCubeMaterialStruct,
  30. /// Uniform scale component
  31. pub uscale_component: SerializedUniformBlockScaleEntityStruct,
  32. /// Colour component
  33. pub colour_component: SerializedColourParameterEntityStruct,
  34. /// Group component
  35. pub group_component: BlockGroupEntityComponent,
  36. }
  37. impl SerializedEntityDescriptor for BlockEntity {
  38. fn serialized_components() -> u8 {
  39. 12
  40. }
  41. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  42. vec![&self.db_component,
  43. &self.pos_component,
  44. &self.scale_component,
  45. &self.rot_component,
  46. &self.skew_component,
  47. &self.grid_component,
  48. &self.grid_conn_component,
  49. &self.placement_component,
  50. &self.material_component,
  51. &self.uscale_component,
  52. &self.colour_component,
  53. &self.group_component]
  54. }
  55. }