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.

43 lines
1.2KB

  1. use crate::techblox::{SerializedEntityDescriptor, Parsable, SerializedEntityComponent, blocks::BlockEntity};
  2. use libfj_parsable_macro_derive::*;
  3. /// Pilot seat entity descriptor (V4)
  4. #[derive(Copy, Clone, Parsable)]
  5. pub struct PilotSeatEntity {
  6. /// parent block entity
  7. pub block: BlockEntity,
  8. /// Seat following camera component
  9. pub cam_component: SeatFollowCamComponent,
  10. }
  11. impl SerializedEntityDescriptor for PilotSeatEntity {
  12. fn serialized_components() -> u8 {
  13. BlockEntity::serialized_components() + 1
  14. }
  15. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  16. let mut c = self.block.components();
  17. c.push(&self.cam_component);
  18. return c;
  19. }
  20. fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
  21. let mut c = self.block.components_mut();
  22. c.push(&mut self.cam_component);
  23. return c;
  24. }
  25. fn hash_name(&self) -> u32 {
  26. Self::hash("PilotSeatEntityDescriptorV4") // 2281299333
  27. }
  28. }
  29. /// Seat settings entity component.
  30. #[derive(Copy, Clone, Parsable)]
  31. pub struct SeatFollowCamComponent {
  32. /// Should the camera follow the seat? (bool)
  33. pub follow: u8,
  34. }
  35. impl SerializedEntityComponent for SeatFollowCamComponent {}