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.

58 lines
1.6KB

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