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.

54 lines
1.6KB

  1. use crate::techblox::{UnityFloat3, UnityQuaternion, SerializedEntityComponent, SerializedEntityDescriptor, Parsable};
  2. use libfj_parsable_macro_derive::*;
  3. /// Block group entity descriptor.
  4. #[derive(Clone, Copy, Parsable)]
  5. pub struct BlockGroupEntity {
  6. /// Block group identifier
  7. pub saved_block_group_id: SavedBlockGroupIdComponent,
  8. /// Block group location information
  9. pub block_group_transform: BlockGroupTransformEntityComponent,
  10. }
  11. impl BlockGroupEntity {}
  12. impl SerializedEntityDescriptor for BlockGroupEntity {
  13. fn serialized_components() -> u8 {
  14. 2
  15. }
  16. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  17. vec![&self.saved_block_group_id,
  18. &self.block_group_transform]
  19. }
  20. fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
  21. vec![&mut self.saved_block_group_id,
  22. &mut self.block_group_transform]
  23. }
  24. fn hash_name(&self) -> u32 {
  25. Self::hash("BlockGroupEntityDescriptorV0")
  26. }
  27. }
  28. /// Saved block group identifier entity component.
  29. #[derive(Clone, Copy, Parsable)]
  30. pub struct SavedBlockGroupIdComponent {
  31. /// Block group identifier
  32. pub saved_block_group_id: i32,
  33. }
  34. impl SerializedEntityComponent for SavedBlockGroupIdComponent {}
  35. /// Block group entity component for storing position and rotation.
  36. #[derive(Clone, Copy, Parsable)]
  37. pub struct BlockGroupTransformEntityComponent {
  38. /// Block group position
  39. pub block_group_grid_position: UnityFloat3,
  40. /// Block group rotation
  41. pub block_group_grid_rotation: UnityQuaternion,
  42. }
  43. impl SerializedEntityComponent for BlockGroupTransformEntityComponent {}