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.

62 lines
1.7KB

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