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.

45 lines
1.2KB

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