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.

70 lines
1.9KB

  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 hash_name(&self) -> u32 {
  17. Self::hash("WireEntityDescriptorMock") // 1818308818
  18. }
  19. }
  20. /// Wire connection information that is saved.
  21. #[derive(Copy, Clone, Parsable)]
  22. pub struct WireSaveDataStruct {
  23. /// Wire source block index in save
  24. pub source_block_index: u32,
  25. /// Wire destination block index in save
  26. pub destination_block_index: u32,
  27. /// Wire source port index
  28. pub source_port_usage: u8,
  29. /// Wire destination port index
  30. pub destination_port_usage: u8,
  31. }
  32. impl SerializedEntityComponent for WireSaveDataStruct {}
  33. /// Wire settings data for a game
  34. #[derive(Copy, Clone, Parsable)]
  35. pub struct SerializedGlobalWireSettingsEntity {
  36. /// Global wire settings
  37. pub settings_component: GlobalWireSettingsEntityStruct,
  38. }
  39. impl SerializedEntityDescriptor for SerializedGlobalWireSettingsEntity {
  40. fn serialized_components() -> u8 {
  41. 1
  42. }
  43. fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
  44. vec![&self.settings_component]
  45. }
  46. fn hash_name(&self) -> u32 {
  47. Self::hash("GlobalWireSettingsEntityDescriptor") // 1820064641
  48. }
  49. }
  50. /// Wire settings applied to the whole game save
  51. #[derive(Copy, Clone, Parsable)]
  52. pub struct GlobalWireSettingsEntityStruct {
  53. /// Is using obsolete wiring system? (bool)
  54. pub obsolete: u8,
  55. }
  56. impl SerializedEntityComponent for GlobalWireSettingsEntityStruct {}