gardenplot.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. class GardenPlot extends GardenBase
  2. {
  3. Object m_ClutterCutter;
  4. private const int GARDEN_SLOT_COUNT = 9;
  5. void GardenPlot()
  6. {
  7. SetBaseFertility(0.5);
  8. }
  9. override void EEInit()
  10. {
  11. super.EEInit();
  12. }
  13. override bool OnStoreLoad( ParamsReadContext ctx, int version )
  14. {
  15. if ( !super.OnStoreLoad(ctx, version) )
  16. return false;
  17. if ( !m_ClutterCutter )
  18. {
  19. m_ClutterCutter = GetGame().CreateObjectEx( "ClutterCutter6x6", GetPosition(), ECE_PLACE_ON_SURFACE );
  20. m_ClutterCutter.SetOrientation( GetOrientation() );
  21. }
  22. return true;
  23. }
  24. override void EEDelete(EntityAI parent)
  25. {
  26. super.EEDelete(parent);
  27. if (m_ClutterCutter && GetGame())
  28. {
  29. GetGame().ObjectDelete(m_ClutterCutter);
  30. m_ClutterCutter = NULL;
  31. }
  32. }
  33. override bool IsInventoryVisible()
  34. {
  35. return true;
  36. }
  37. override int GetGardenSlotsCount()
  38. {
  39. return GARDEN_SLOT_COUNT;
  40. }
  41. void RefreshSlots()
  42. {
  43. HideSelection("SeedBase_1");
  44. HideSelection("SeedBase_2");
  45. HideSelection("SeedBase_3");
  46. HideSelection("SeedBase_4");
  47. HideSelection("SeedBase_5");
  48. HideSelection("SeedBase_6");
  49. HideSelection("SeedBase_7");
  50. HideSelection("SeedBase_8");
  51. HideSelection("SeedBase_9");
  52. HideSelection("slotCovered_01");
  53. HideSelection("slotCovered_02");
  54. HideSelection("slotCovered_03");
  55. HideSelection("slotCovered_04");
  56. HideSelection("slotCovered_05");
  57. HideSelection("slotCovered_06");
  58. HideSelection("slotCovered_07");
  59. HideSelection("slotCovered_08");
  60. HideSelection("slotCovered_09");
  61. }
  62. //================================================================
  63. // ADVANCED PLACEMENT
  64. //================================================================
  65. override void OnPlacementStarted( Man player )
  66. {
  67. RefreshSlots();
  68. }
  69. override void OnHologramBeingPlaced( Man player )
  70. {
  71. RefreshSlots();
  72. }
  73. override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
  74. {
  75. super.OnPlacementComplete( player, position, orientation );
  76. PlayerBase player_base = PlayerBase.Cast( player );
  77. //vector pos = player_base.GetLocalProjectionPosition();
  78. //vector ori = player_base.GetLocalProjectionOrientation();
  79. if ( GetGame().IsServer() )
  80. {
  81. // To properly move the clutter cutter from spawn position, it must be deleted and created again.
  82. if (m_ClutterCutter)
  83. {
  84. GetGame().ObjectDelete(m_ClutterCutter);
  85. m_ClutterCutter = NULL;
  86. }
  87. if (!m_ClutterCutter)
  88. {
  89. m_ClutterCutter = GetGame().CreateObjectEx( "ClutterCutter6x6", GetPosition(), ECE_PLACE_ON_SURFACE );
  90. m_ClutterCutter.SetOrientation( orientation );
  91. }
  92. }
  93. }
  94. override bool CanBePlaced( Man player, vector position )
  95. {
  96. string surface_type;
  97. GetGame().SurfaceGetType3D( position[0], position[1], position[2], surface_type );
  98. return GetGame().IsSurfaceFertile(surface_type);
  99. }
  100. override bool IsTakeable()
  101. {
  102. return false;
  103. }
  104. override bool CanPutInCargo( EntityAI parent )
  105. {
  106. return false;
  107. }
  108. override bool CanRemoveFromCargo( EntityAI parent )
  109. {
  110. return false;
  111. }
  112. //hands
  113. override bool CanPutIntoHands( EntityAI parent )
  114. {
  115. return false;
  116. }
  117. }
  118. //class GardenPlotOutside : GardenPlot {}
  119. class GardenPlotPolytunnel : GardenPlot
  120. {
  121. private const int POLYTUNNEL_SLOT_COUNT = 13;
  122. override int GetGardenSlotsCount()
  123. {
  124. return POLYTUNNEL_SLOT_COUNT;
  125. }
  126. override void RefreshSlots()
  127. {
  128. HideSelection("SeedBase_1");
  129. HideSelection("SeedBase_2");
  130. HideSelection("SeedBase_3");
  131. HideSelection("SeedBase_4");
  132. HideSelection("SeedBase_5");
  133. HideSelection("SeedBase_6");
  134. HideSelection("SeedBase_7");
  135. HideSelection("SeedBase_8");
  136. HideSelection("SeedBase_9");
  137. HideSelection("SeedBase_10");
  138. HideSelection("SeedBase_11");
  139. HideSelection("SeedBase_12");
  140. HideSelection("SeedBase_13");
  141. }
  142. }
  143. class GardenPlotGreenhouse : GardenPlot {}
  144. class GardenPlotPlacing extends GardenPlot
  145. {
  146. override void EOnInit(IEntity other, int extra) {};
  147. override void RefreshSlots() {};
  148. override void SyncSlots() {};
  149. }