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.

75 lines
2.2KB

  1. use crate::techblox::{SerializedEntityDescriptor, Parsable, SerializedEntityComponent,
  2. blocks::{BlockEntity, TweakableJointDampingComponent}};
  3. use libfj_parsable_macro_derive::*;
  4. /// Wheel rig entity descriptor
  5. #[derive(Copy, Clone, Parsable)]
  6. pub struct WheelRigEntity {
  7. /// parent block entity
  8. pub block: BlockEntity,
  9. /// Wheel tweakables component
  10. pub tweak_component: WheelRigTweakableStruct,
  11. /// Joint tweakables component
  12. pub joint_component: TweakableJointDampingComponent,
  13. }
  14. impl SerializedEntityDescriptor for WheelRigEntity {
  15. fn serialized_components() -> u8 {
  16. BlockEntity::serialized_components() + 2
  17. }
  18. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  19. let mut c = self.block.components();
  20. c.push(&self.tweak_component);
  21. c.push(&self.joint_component);
  22. return c;
  23. }
  24. fn hash_name(&self) -> u32 {
  25. Self::hash("WheelRigEntityDescriptor") // 1156723746
  26. }
  27. }
  28. /// Wheel rig entity descriptor
  29. #[derive(Copy, Clone, Parsable)]
  30. pub struct WheelRigSteerableEntity {
  31. /// parent wheel rig entity
  32. pub block: WheelRigEntity,
  33. /// Steering tweakables component
  34. pub tweak_component: WheelRigSteerableTweakableStruct,
  35. }
  36. impl SerializedEntityDescriptor for WheelRigSteerableEntity {
  37. fn serialized_components() -> u8 {
  38. WheelRigEntity::serialized_components() + 1
  39. }
  40. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  41. let mut c = self.block.components();
  42. c.push(&self.tweak_component);
  43. return c;
  44. }
  45. fn hash_name(&self) -> u32 {
  46. Self::hash("WheelRigSteerableEntityDescriptor") // 1864425618
  47. }
  48. }
  49. /// Wheel rig settings entity component.
  50. #[derive(Copy, Clone, Parsable)]
  51. pub struct WheelRigTweakableStruct {
  52. /// Brake force (percent?)
  53. pub braking_strength: f32,
  54. }
  55. impl SerializedEntityComponent for WheelRigTweakableStruct {}
  56. /// Steering wheel rig settings entity component.
  57. #[derive(Copy, Clone, Parsable)]
  58. pub struct WheelRigSteerableTweakableStruct {
  59. /// Wheel steering angle (max?)
  60. pub steer_angle: f32,
  61. }
  62. impl SerializedEntityComponent for WheelRigSteerableTweakableStruct {}