constructionpart.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. class ConstructionPart
  2. {
  3. string m_Name; //localized text name that is displayed ingame
  4. int m_Id; //a number used for synchronization and persistence purposes, must be unique and withing sync limit (total number of bits in all sync/persistence variables)
  5. string m_PartName; //config class name
  6. string m_MainPartName; //main (parent) config class name
  7. bool m_IsBuilt; //defines part build state
  8. bool m_IsBase; //defines if this part is the foundation of the whole construction
  9. bool m_IsGate; //defines part gate state
  10. ref array<string> m_RequiredParts; //list of parts required by this part
  11. void ConstructionPart( string name, string part_name, string main_part_name, int id, bool is_built, bool is_base, bool is_gate, array<string> required_parts )
  12. {
  13. m_Name = name;
  14. m_PartName = part_name;
  15. m_MainPartName = main_part_name;
  16. m_Id = id;
  17. m_IsBuilt = is_built;
  18. m_IsBase = is_base;
  19. m_IsGate = is_gate;
  20. m_RequiredParts = required_parts;
  21. }
  22. string GetName()
  23. {
  24. string ret = Widget.TranslateString(m_Name);
  25. return ret;
  26. }
  27. string GetPartName()
  28. {
  29. return m_PartName;
  30. }
  31. string GetMainPartName()
  32. {
  33. return m_MainPartName;
  34. }
  35. int GetId()
  36. {
  37. return m_Id;
  38. }
  39. bool IsBuilt()
  40. {
  41. return m_IsBuilt;
  42. }
  43. void SetBuiltState( bool is_built )
  44. {
  45. if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] SetBuildState=" + is_built + " part=" + m_PartName);
  46. m_IsBuilt = is_built;
  47. }
  48. void SetRequestBuiltState( bool req_built )
  49. {
  50. if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] SetRequestBuiltState=" + req_built + " part=" + m_PartName);
  51. if (GetGame().IsMultiplayer())
  52. SetBuiltState(req_built);
  53. else
  54. ; // skip set to true in single player - will be synced later
  55. }
  56. bool IsBase()
  57. {
  58. return m_IsBase;
  59. }
  60. bool IsGate()
  61. {
  62. return m_IsGate;
  63. }
  64. array<string> GetRequiredParts()
  65. {
  66. return m_RequiredParts;
  67. }
  68. }