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