4 static const string SLOT_TEXTURE_DIGGED_WET_LIME =
"dz\\gear\\cultivation\\data\\soil_digged_wet_lime_CO.paa";
5 static const string SLOT_TEXTURE_DIGGED_WET_PLANT =
"dz\\gear\\cultivation\\data\\soil_digged_wet_plant_CO.paa";
8 static const string SLOT_MATERIAL_WET =
"dz\\gear\\cultivation\\data\\soil_cultivated_wet.rvmat";
9 static const string SLOT_MATERIAL_DRY =
"dz\\gear\\cultivation\\data\\soil_cultivated.rvmat";
11 static const string SLOT_MATERIAL_LIMED_WET =
"dz\\gear\\cultivation\\data\\soil_cultivated_limed_wet.rvmat";
12 static const string SLOT_MATERIAL_LIMED_DRY =
"dz\\gear\\cultivation\\data\\soil_cultivated_limed.rvmat";
13 static const string SLOT_MATERIAL_COMPOST_WET =
"dz\\gear\\cultivation\\data\\soil_cultivated_compost_wet.rvmat";
14 static const string SLOT_MATERIAL_COMPOST_DRY =
"dz\\gear\\cultivation\\data\\soil_cultivated_compost.rvmat";
17 private static const string SLOT_SELECTION_DIGGED_PREFIX =
"seedbase_";
18 private static const string SLOT_SELECTION_COVERED_PREFIX =
"slotCovered_";
19 private static const string SLOT_MEMORY_POINT_PREFIX =
"slot_";
20 private static const string SLOT_SEEDBASE_PREFIX =
"seedbase_";
23 private static const int CHECK_RAIN_INTERVAL = 15;
26 protected int m_SlotFertilityState = 0;
27 protected int m_SlotWateredState = 0;
28 protected int m_MaxWateredStateVal = 0;
29 protected float m_DefaultFertility = 1;
36 RegisterNetSyncVariableInt(
"m_SlotFertilityState");
37 RegisterNetSyncVariableInt(
"m_SlotWateredState");
47 string input = SLOT_SEEDBASE_PREFIX +
i.ToString();
48 string output = SLOT_MEMORY_POINT_PREFIX;
63 SetMaxWaterStateVal();
68 super.OnVariablesSynchronized();
85 m_DefaultFertility =
value;
90 return m_DefaultFertility;
96 UpdateTexturesOnAllSlots();
106 Slot slot =
new Slot(GetBaseFertility());
107 slot.SetSlotIndex(
i);
109 string name =
"SeedBase_" +
i1;
112 slot.SetGarden(
this);
113 slot.m_State =
Slot.STATE_DIGGED;
114 m_Slots.Insert(slot);
122 for (
int i = 0;
i < m_Slots.Count();
i++)
125 m_MaxWateredStateVal =
state;
130 return m_MaxWateredStateVal;
138 UpdateSlotTexture(
i);
146 if (!
super.OnStoreLoad(
ctx, version))
159 Slot slot = m_Slots.Get(
i);
161 if (!slot.OnStoreLoadCustom(
ctx, version))
169 ctx.Read(m_SlotFertilityState);
172 ctx.Read(m_SlotWateredState);
179 super.AfterStoreLoad();
185 super.EEOnAfterLoad();
201 m_Slots[
i].SetFertilityType(
"");
202 m_Slots[
i].SetFertilizerQuantity(0);
206 m_Slots[
i].SetWater(0);
208 UpdateSlotTexture(
i);
223 Slot slot = m_Slots.Get(
i);
225 slot.OnStoreSaveCustom(
ctx);
228 ctx.Write(m_SlotFertilityState);
230 ctx.Write(m_SlotWateredState);
235 Debug.
Log(
"PRINT ALL SLOTS FROM...");
237 int slots = GetInventory().GetAttachmentSlotsCount();
242 Slot slot = m_Slots.Get(
i);
271 Debug.
Log(
"///////////////////////////");
274 Debug.
Log(
"END OF ALL SLOTS FOR...");
280 if (!
super.CanPutInCargo(parent))
return false;
286 if (!
super.CanPutIntoHands(parent))
305 if (slot !=
NULL && slot.m_State ==
Slot.STATE_DIGGED)
328 string path =
string.
Format(
"CfgVehicles %1 Horticulture PlantType",
item.GetType());
347 else if (
g_Game.IsClient())
349 Slot slot = GetSlotByIndex(GetSlotIndexByAttachmentSlot(
slot_name) - 1);
352 slot.SetPlant(PlantBase.Cast(
item));
353 slot.m_State =
Slot.STATE_PLANTED;
364 string path =
string.
Format(
"CfgVehicles %1 Horticulture PlantType",
item.GetType());
375 slot.SetState(
Slot.STATE_DIGGED);
390 slot.SetState(
Slot.STATE_PLANTED);
394 if (!slot.NeedsWater())
412 seed.UnlockFromParent();
415 PlantBase
plant = PlantBase.Cast(GetInventory().CreateAttachmentEx(slot.m_PlantType, slot.GetSlotId()));
418 slot.SetPlant(
plant);
419 plant.Init(
this, slot.GetFertility(), slot.m_HarvestingEfficiency, slot.GetWater());
422 plant.LockToParent();
434 if (slot.GetFertilityType() ==
"" || slot.GetFertilityType() ==
item_type)
439 slot.m_FertilizerUsage =
GetGame().ConfigGetFloat(
string.Format(
"cfgVehicles %1 Horticulture ConsumedQuantity",
item_type));
447 if (slot.GetFertilizerQuantity() >= slot.GetFertilizerQuantityMax())
456 m_SlotFertilityState |= slot.GetFertilityState() << slot.GetSlotIndex();
466 slot.SetFertilizerQuantity(0);
467 slot.SetFertilityType(
"");
482 if (slot.GetFertilityType() ==
"" || slot.GetFertilityType() ==
item_type)
505 m_SlotWateredState |= slot.GetWateredState() << slot.GetSlotIndex();
516 if (slot.IsDigged() || slot.IsPlanted())
525 if (slot.GetFertilityType() !=
"")
526 SetSlotTextureFertilized(
slot_index, slot.GetFertilityType());
543 if (slot.GetWateredState() == 0)
546 SetObjectMaterial(
slot_index, SLOT_MATERIAL_DRY);
551 SetObjectMaterial(
slot_index, SLOT_MATERIAL_WET);
571 if (slot.GetWateredState() == 0)
574 if (slot.GetFertilityType() ==
"GardenLime")
576 else if (slot.GetFertilityType() ==
"PlantMaterial")
582 if (slot.GetFertilityType() ==
"GardenLime")
584 else if (slot.GetFertilityType() ==
"PlantMaterial")
594 PlantBase
plant = slot.GetPlant();
598 plant.UnlockFromParent();
599 plant.m_MarkForDeletion =
true;
603 slot.Init(GetBaseFertility());
607 m_SlotFertilityState &= ~(1 << slot.GetSlotIndex());
610 m_SlotWateredState &= ~(1 << slot.GetSlotIndex());
615 UpdateSlotTexture(
index);
673 int start =
"SeedBase_".Length();
687 for (
int i = 0;
i < m_Slots.Count();
i++)
706 Slot slot = m_Slots.Get(
i);
729 return this.ModelToWorld(pos);
734 if (!m_CheckRainTimer)
737 m_CheckRainTimer.Run(CHECK_RAIN_INTERVAL,
this,
"CheckRainTick",
NULL,
true);
750 wetness = -0.1 * CHECK_RAIN_INTERVAL;
764 Slot slot = m_Slots.Get(
i);
777 for (
int i = 0;
i < m_Slots.Count();
i++)
780 SetSlotWateredState(
state);
790 return m_Slots.Get(
index);
795 return m_SlotWateredState;
void AddAction(typename actionName)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
string ToStringLen(int len)
Integer to string with fixed length, padded with zeroes.
override void SyncSlots()
PluginBase GetPlugin(typename plugin_type)
class JsonUndergroundAreaTriggerData GetPosition
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
override int GetGardenSlotsCount()
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
override void EEItemAttached(EntityAI item, string slot_name)
override bool CanPutIntoHands(EntityAI player)
int GetSlotIndexBySelection(string selection_component)
Slot GetSlotByIndex(int index)
vector GetSlotPosition(int index)
void PlantSeed(ItemBase seed, string selection_component)
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Slot GetSlotBySelection(string selection_component)
override void EEOnAfterLoad()
void RemoveSlotPlant(Object plant)
override bool HasProxyParts()
int GetSlotWateredState()
int GetMaxWaterStateVal()
override bool CanRemoveFromHands(EntityAI player)
override void SetActions()
ref array< ref Slot > m_Slots
int GetSlotIndexByPlant(Object plant)
int GetNearestSlotIDByState(vector position, int slot_state)
int GetGardenSlotsCount()
bool NeedsFertilization(string selection_component)
bool IsCorrectFertilizer(ItemBase item, string selection_component)
array< ref Slot > GetSlots()
void SetBaseFertility(float value)
override int GetHideIconMask()
int GetSlotIndexByAttachmentSlot(string att_slot)
ref Timer m_CheckRainTimer
override void OnStoreSave(ParamsWriteContext ctx)
override void AfterStoreLoad()
void SetMaxWaterStateVal()
override void EEItemDetached(EntityAI item, string slot_name)
override void OnVariablesSynchronized()
void CreatePlant(Slot slot)
override bool CanPutInCargo(EntityAI parent)
void Fertilize(PlayerBase player, ItemBase item, float consumed_quantity, string selection_component)
void SetSlotTextureDigged(int slot_index)
void RemoveSlot(int index)
void SlotWaterStateUpdate(Slot slot)
void SetSlotWateredState(int newState)
bool CanPlantSeed(string selection_component)
void UpdateTexturesOnAllSlots()
override void EOnInit(IEntity other, int extra)
string ConvertAttSlotToPlantSlot(string attach_slot)
static ref map< string, string > m_map_slots
void UpdateSlotTexture(int slot_index)
void SetSlotTextureFertilized(int slot_index, string item_type)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Serialization general interface. Serializer API works with:
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
EntityEvent
Entity events for event-mask, or throwing event from code.
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float Pow(float v, float power)
Return power of v ^ power.
proto native int Length()
Returns length of string.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.