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.

66 lines
1.8KB

  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 hash_name(&self) -> u32 {
  17. Self::hash("FlyCamEntityDescriptorV0") // 252528354
  18. }
  19. }
  20. /// Physical object info for simulation
  21. #[derive(Copy, Clone, Parsable)]
  22. pub struct SerializedRigidBodyEntityStruct {
  23. /// Rigid body location
  24. pub position: UnityFloat3,
  25. }
  26. impl SerializedEntityComponent for SerializedRigidBodyEntityStruct {}
  27. /// Player simulation camera entity descriptor.
  28. #[derive(Copy, Clone, Parsable)]
  29. pub struct SerializedPhysicsCameraEntity {
  30. /// In-game camera location information
  31. pub cam_component: SerializedCameraEntityStruct,
  32. }
  33. impl SerializedEntityDescriptor for SerializedPhysicsCameraEntity {
  34. fn serialized_components() -> u8 {
  35. 1
  36. }
  37. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  38. vec![&self.cam_component]
  39. }
  40. fn hash_name(&self) -> u32 {
  41. Self::hash("CharacterCameraEntityDescriptorV1") // 3850144645
  42. }
  43. }
  44. /// Physics camera component
  45. #[derive(Copy, Clone, Parsable)]
  46. pub struct SerializedCameraEntityStruct {
  47. /// Camera position in game world
  48. pub position: UnityHalf3,
  49. /// Camera euler rotation in game world
  50. pub rotation: UnityHalf3,
  51. }
  52. impl SerializedEntityComponent for SerializedCameraEntityStruct {}