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.

53 lines
1.4KB

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