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.

74 lines
2.1KB

  1. use crate::techblox::{SerializedEntityDescriptor, Parsable, SerializedEntityComponent, UnityFloat3, UnityHalf3};
  2. use libfj_parsable_macro_derive::*;
  3. /// Player editing camera entity descriptor.
  4. #[derive(Copy, Clone, Parsable)]
  5. pub struct SerializedFlyCamEntity {
  6. /// Player camera in-game location
  7. pub rb_component: SerializedRigidBodyEntityStruct,
  8. }
  9. impl SerializedEntityDescriptor for SerializedFlyCamEntity {
  10. fn serialized_components() -> u8 {
  11. 2
  12. }
  13. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  14. vec![&self.rb_component]
  15. }
  16. fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
  17. vec![&mut self.rb_component]
  18. }
  19. fn hash_name(&self) -> u32 {
  20. Self::hash("FlyCamEntityDescriptorV0") // 252528354
  21. }
  22. }
  23. /// Physical object info for simulation
  24. #[derive(Copy, Clone, Parsable)]
  25. pub struct SerializedRigidBodyEntityStruct {
  26. /// Rigid body location
  27. pub position: UnityFloat3,
  28. }
  29. impl SerializedEntityComponent for SerializedRigidBodyEntityStruct {}
  30. /// Player simulation camera entity descriptor.
  31. #[derive(Copy, Clone, Parsable)]
  32. pub struct SerializedPhysicsCameraEntity {
  33. /// In-game camera location information
  34. pub cam_component: SerializedCameraEntityStruct,
  35. }
  36. impl SerializedEntityDescriptor for SerializedPhysicsCameraEntity {
  37. fn serialized_components() -> u8 {
  38. 1
  39. }
  40. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  41. vec![&self.cam_component]
  42. }
  43. fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
  44. vec![&mut self.cam_component]
  45. }
  46. fn hash_name(&self) -> u32 {
  47. Self::hash("CharacterCameraEntityDescriptorV1") // 3850144645
  48. }
  49. }
  50. /// Physics camera component
  51. #[derive(Copy, Clone, Parsable)]
  52. pub struct SerializedCameraEntityStruct {
  53. /// Camera position in game world
  54. pub position: UnityHalf3,
  55. /// Camera euler rotation in game world
  56. pub rotation: UnityHalf3,
  57. }
  58. impl SerializedEntityComponent for SerializedCameraEntityStruct {}