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.

78 lines
2.2KB

  1. use crate::techblox::{SerializedEntityComponent, SerializedEntityDescriptor, Parsable};
  2. use libfj_parsable_macro_derive::*;
  3. /// Wire save data
  4. #[derive(Copy, Clone, Parsable)]
  5. pub struct SerializedWireEntity {
  6. /// Wiring save data component
  7. pub save_data_component: WireSaveDataStruct,
  8. }
  9. impl SerializedEntityDescriptor for SerializedWireEntity {
  10. fn serialized_components() -> u8 {
  11. 1
  12. }
  13. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  14. vec![&self.save_data_component]
  15. }
  16. fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
  17. vec![&mut self.save_data_component]
  18. }
  19. fn hash_name(&self) -> u32 {
  20. Self::hash("WireEntityDescriptorMock") // 1818308818
  21. }
  22. }
  23. /// Wire connection information that is saved.
  24. #[derive(Copy, Clone, Parsable)]
  25. pub struct WireSaveDataStruct {
  26. /// Wire source block index in save
  27. pub source_block_index: u32,
  28. /// Wire destination block index in save
  29. pub destination_block_index: u32,
  30. /// Wire source port index
  31. pub source_port_usage: u8,
  32. /// Wire destination port index
  33. pub destination_port_usage: u8,
  34. }
  35. impl SerializedEntityComponent for WireSaveDataStruct {}
  36. /// Wire settings data for a game
  37. #[derive(Copy, Clone, Parsable)]
  38. pub struct SerializedGlobalWireSettingsEntity {
  39. /// Global wire settings
  40. pub settings_component: GlobalWireSettingsEntityStruct,
  41. }
  42. impl SerializedEntityDescriptor for SerializedGlobalWireSettingsEntity {
  43. fn serialized_components() -> u8 {
  44. 1
  45. }
  46. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  47. vec![&self.settings_component]
  48. }
  49. fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
  50. vec![&mut self.settings_component]
  51. }
  52. fn hash_name(&self) -> u32 {
  53. Self::hash("GlobalWireSettingsEntityDescriptor") // 1820064641
  54. }
  55. }
  56. /// Wire settings applied to the whole game save
  57. #[derive(Copy, Clone, Parsable)]
  58. pub struct GlobalWireSettingsEntityStruct {
  59. /// Is using obsolete wiring system? (bool)
  60. pub obsolete: u8,
  61. }
  62. impl SerializedEntityComponent for GlobalWireSettingsEntityStruct {}