17 static const int STATE_DIGGED = 1;
18 static const int STATE_PLANTED = 2;
20 private int m_WaterQuantity;
21 static private int m_WaterNeeded = 190;
22 static private int m_WaterMax = 200;
25 float m_FertilizerUsage;
26 float m_FertilizerQuantity;
30 string m_FertilizerType;
32 int m_WateredState = eWateredState.DRY;
33 string m_DiggedSlotComponent;
38 float m_HarvestingEfficiency;
42 private PlantBase m_Plant;
44 void Slot(
float base_fertility )
48 m_WaterQuantity = 0.0;
49 Init( base_fertility );
56 GetGame().ObjectDelete( GetPlant() );
65 void SetSlotIndex(
int index)
75 void SetSlotId(
int id)
100 void SetPlant(PlantBase plant)
111 void SetWater(
int val )
113 val =
Math.Clamp( val, 0, m_WaterMax );
114 m_WaterQuantity = val;
130 void GiveWater(
float consumed_quantity )
132 bool needed_water = NeedsWater();
133 m_WaterQuantity += consumed_quantity;
135 if (m_WaterQuantity >= GetWaterMax())
136 m_WaterQuantity = GetWaterMax();
138 if (m_WaterQuantity < 0)
147 GetGarden().CreatePlant(
this);
154 if ( needed_water != NeedsWater() )
156 SetWateredState( eWateredState.WET );
157 GetGarden().UpdateSlotTexture( GetSlotIndex() );
158 if ( m_Garden.GetSlotWateredState() != m_Garden.GetMaxWaterStateVal() )
159 m_Garden.SlotWaterStateUpdate(
this );
165 if ( m_WaterQuantity < GetWaterUsage() )
177 if ( m_WaterQuantity < GetWaterMax() )
189 return m_WaterQuantity;
197 float GetFertilityMax()
199 return m_FertilizerUsage;
202 void SetFertility(
float fertility)
204 m_Fertility = fertility;
207 float GetFertilizerQuantity()
209 return m_FertilizerQuantity;
212 float GetFertilizerQuantityMax()
214 return m_FertilizerUsage;
217 void SetFertilizerQuantity(
float fertility)
219 m_FertilizerQuantity = fertility;
222 string GetFertilityType()
224 return m_FertilizerType;
227 void SetFertilityType(
string type)
229 m_FertilizerType = type;
232 int GetFertilityState()
234 return m_FertilityState;
237 void SetFertilityState(
int newState )
239 m_FertilityState = newState;
242 int GetWateredState()
244 return m_WateredState;
247 void SetWateredState(
int newState )
249 m_WateredState = newState;
250 if ( m_WateredState == eWateredState.WET )
251 SetWater( GetWaterMax() );
254 float GetWaterUsage()
256 return m_WaterNeeded;
293 void Init(
float base_fertility )
295 m_Fertility = base_fertility;
296 m_FertilizerUsage = 200;
297 m_FertilizerQuantity = 0.0;
298 m_FertilizerType =
"";
302 m_WateredState = eWateredState.DRY;
304 m_HarvestingEfficiency = 1.0;
315 string GetSlotComponent()
317 return m_DiggedSlotComponent;
324 ctx.Read( m_Fertility );
325 ctx.Read( m_FertilizerUsage );
326 ctx.Read( m_FertilizerQuantity );
328 if ( !ctx.Read( m_FertilizerType ) )
329 m_FertilizerType =
"";
331 ctx.Read( m_HarvestingEfficiency );
335 if ( version >= 102 )
337 ctx.Read( m_Fertility );
338 ctx.Read( m_FertilizerUsage );
339 ctx.Read( m_FertilizerQuantity );
340 ctx.Read( m_HarvestingEfficiency );
343 if ( !ctx.Read( m_FertilizerType ) )
345 m_FertilizerType =
"";
354 ctx.Write( m_Fertility );
355 ctx.Write( m_FertilizerUsage );
356 ctx.Write( m_FertilizerQuantity );
357 ctx.Write( m_HarvestingEfficiency );
359 ctx.Write( m_FertilizerType );