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.

40 lines
1.2KB

  1. use crate::techblox::{SerializedEntityDescriptor, Parsable, SerializedEntityComponent,
  2. blocks::{BlockEntity}};
  3. use libfj_parsable_macro_derive::*;
  4. /// Engine entity descriptor
  5. #[derive(Copy, Clone, Parsable)]
  6. pub struct EngineBlockEntity {
  7. /// parent block entity
  8. pub block: BlockEntity,
  9. /// Engine tweakables component
  10. pub tweak_component: EngineBlockTweakableComponent,
  11. }
  12. impl SerializedEntityDescriptor for EngineBlockEntity {
  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.tweak_component);
  19. return c;
  20. }
  21. fn hash_name(&self) -> u32 {
  22. Self::hash("EngineBlockEntityDescriptor") // 1757314505
  23. }
  24. }
  25. /// Engine settings entity component.
  26. #[derive(Copy, Clone, Parsable)]
  27. pub struct EngineBlockTweakableComponent {
  28. /// Engine power (percent?)
  29. pub power: f32,
  30. /// Is the engine's transmission automatic? (bool)
  31. pub automatic_gears: u32, // why is this not stored as u8 like the other bools?
  32. }
  33. impl SerializedEntityComponent for EngineBlockTweakableComponent {}