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";
36 RegisterNetSyncVariableInt(
"m_SlotFertilityState");
37 RegisterNetSyncVariableInt(
"m_SlotWateredState");
51 output = output +
"0";
70 super.OnVariablesSynchronized();
82 return EInventoryIconVisibility.HIDE_VICINITY;
106 for (
int i = 0; i < slots_count; i++ )
109 slot.SetSlotIndex(i);
111 string name =
"SeedBase_" + i1;
113 slot.SetSlotId(slot_id);
114 slot.SetGarden(
this);
115 slot.m_State = Slot.STATE_DIGGED;
116 slot.SetWateredState(eWateredState.DRY);
126 for (
int i = 0; i <
m_Slots.Count(); i++ )
143 for (
int i = 0; i < slots_count; i++ )
151 if ( version <= 118 )
154 if ( !super.OnStoreLoad( ctx, version ) )
160 ctx.
Read( some_value );
165 for (
int i = 0; i < slots_count; i++ )
169 if ( !slot.OnStoreLoadCustom( ctx, version ) )
173 if ( version >= 119 )
176 if ( version >= 120 )
184 super.AfterStoreLoad();
190 super.EEOnAfterLoad();
208 super.OnStoreSave( ctx );
212 for (
int i = 0; i < slots_count; i++ )
216 slot.OnStoreSaveCustom( ctx );
226 Debug.
Log(
"PRINT ALL SLOTS FROM...");
228 int slots = GetInventory().GetAttachmentSlotsCount();
231 for (
int i = 0; i < slots ; i++ )
237 float slot_fertility = slot.GetFertility();
238 float slot_fertility_usage = slot.GetFertilityMax();
239 string slot_fertility_type = slot.GetFertilityType();
240 float slot_water = slot.GetWater();
241 float slot_water_usage = slot.GetWaterUsage();
242 ItemBase slot_seed = slot.GetSeed();
243 ItemBase slot_plant = slot.GetPlant();
245 float slot_slot_Index = slot.GetSlotIndex();
246 float slot_slot_ID = slot.GetSlotId();
247 int slot_wateredState = slot.GetWateredState();
248 int slot_FertilityState = slot.GetFertilityState();
250 Debug.
Log(
"Fertility : " + slot_fertility);
251 Debug.
Log(
"Fertility Usage : " + slot_fertility_usage);
252 Debug.
Log(
"Fertility Type : " + slot_fertility_type);
253 Debug.
Log(
"Fertility State : " + slot_FertilityState);
255 Debug.
Log(
"Water Usage : " + slot_water_usage);
256 Debug.
Log(
"Watered State : " + slot_wateredState);
260 Debug.
Log(
"Slot Index : " + slot_slot_Index);
261 Debug.
Log(
"Slot ID : " + slot_slot_ID);
262 Debug.
Log(
"///////////////////////////");
265 Debug.
Log(
"END OF ALL SLOTS FOR...");
271 if ( !super.CanPutInCargo(parent) ) {
return false;}
277 if ( !super.CanPutIntoHands( parent ) )
298 if ( slot != NULL && slot.m_State == Slot.STATE_DIGGED )
314 string return_value =
m_map_slots.Get(attach_slot);
323 super.EEItemAttached(item, slot_name);
325 string path =
string.Format(
"CfgVehicles %1 Horticulture PlantType", item.GetType());
332 string converted_slot_name;
348 else if (
g_Game.IsClient())
354 slot.m_State = Slot.STATE_PLANTED;
361 super.EEItemDetached(item, slot_name);
365 string path =
string.Format(
"CfgVehicles %1 Horticulture PlantType", item.GetType());
378 slot.SetState(Slot.STATE_DIGGED);
387 if ( slot_index != -1 )
389 PluginHorticulture module_horticulture = PluginHorticulture.Cast(
GetPlugin( PluginHorticulture ) );
390 string plant_type = module_horticulture.GetPlantType( seed );
392 Slot slot =
m_Slots.Get( slot_index );
393 slot.SetState(Slot.STATE_PLANTED);
394 slot.m_PlantType = plant_type;
397 if ( !slot.NeedsWater() )
401 Timer growthTimer = NULL;
403 Param createPlantParam =
new Param1<Slot>(slot);
404 growthTimer.Run( 0.1,
this,
"CreatePlant", createPlantParam,
false );
415 seed.UnlockFromParent();
418 PlantBase plant =
PlantBase.Cast( GetInventory().CreateAttachmentEx( slot.m_PlantType, slot.GetSlotId()) );
420 int slot_index = slot.GetSlotIndex();
421 slot.SetPlant(plant);
422 plant.Init(
this, slot.GetFertility(), slot.m_HarvestingEfficiency, slot.GetWater() );
425 plant.LockToParent();
435 string item_type = item.GetType();
437 if ( slot.GetFertilityType() ==
"" || slot.GetFertilityType() == item_type )
439 slot.SetFertilityType(item_type);
441 float add_energy_to_slot =
GetGame().
ConfigGetFloat(
string.Format(
"cfgVehicles %1 Horticulture AddEnergyToSlot", item_type) );
442 slot.m_FertilizerUsage =
GetGame().
ConfigGetFloat(
string.Format(
"cfgVehicles %1 Horticulture ConsumedQuantity", item_type) );
444 float coef =
Math.
Clamp( consumed_quantity / slot.m_FertilizerUsage, 0.0, 1.0 );
445 add_energy_to_slot = coef * add_energy_to_slot;
447 slot.m_FertilizerQuantity += consumed_quantity;
448 slot.m_Fertility += add_energy_to_slot;
450 if ( slot.GetFertilizerQuantity() >= slot.GetFertilizerQuantityMax() )
452 int slot_index = slot.GetSlotIndex();
465 slot.SetFertilizerQuantity(0);
466 slot.SetFertilityType(
"");
479 string item_type = item.GetType();
481 if ( slot.GetFertilityType() ==
"" || slot.GetFertilityType() == item_type )
514 Slot slot =
m_Slots.Get( slot_index );
518 if ( slot.IsDigged() || slot.IsPlanted() )
523 HideSelection( str_hide );
524 ShowSelection( str_show );
527 if ( slot.GetFertilityState() ==
eFertlityState.FERTILIZED && slot.GetFertilityType() !=
"" )
543 ShowSelection( str_digged );
544 string texture = textures.Get(0);
545 SetObjectTexture( slot_index, texture );
547 Slot slot =
m_Slots.Get( slot_index );
549 if ( slot.GetWateredState() == 0 )
565 int tex_id =
GetGame().
ConfigGetInt(
string.Format(
"cfgVehicles %1 Horticulture TexId", item_type) );
569 ShowSelection( str_show );
570 SetObjectTexture( slot_index, textures.Get(tex_id) );
572 Slot slot =
m_Slots.Get( slot_index );
574 int slot_index_offset = 0;
577 if ( slot.GetWateredState() == 0 )
580 if ( slot.GetFertilityType() ==
"GardenLime" )
584 else if ( slot.GetFertilityType() ==
"PlantMaterial" )
592 if ( slot.GetFertilityType() ==
"GardenLime" )
596 else if ( slot.GetFertilityType() ==
"PlantMaterial" )
607 Slot slot =
m_Slots.Get( index );
612 plant.UnlockFromParent();
613 plant.m_MarkForDeletion =
true;
623 slot.SetFertilityType(
string.
Empty);
624 slot.SetFertilizerQuantity(0);
626 slot.SetWateredState( eWateredState.DRY );
651 if ( slot_index > -1 )
653 return m_Slots.Get( slot_index );
668 string selection_component_lower = selection_component;
669 selection_component_lower.
ToLower();
677 int length = selection_component.
Length();
681 int length_add = length - end;
682 int length_from_end = 2 + length_add;
683 string num_str = selection_component.
Substring( start, length_from_end );
684 slot_index = num_str.
ToInt();
686 slot_index = slot_index - 1;
698 int start =
"SeedBase_".Length();
699 int end = att_slot.
Length();
700 int len = end - start;
702 string num_str = att_slot.
Substring( start, len );
703 slot_index = num_str.
ToInt();
712 for (
int i = 0; i <
m_Slots.Count(); i++ )
716 if ( found_plant == plant )
728 float nearest_distance = 1000.0;
729 int nearest_slot_index = -1;
731 for (
int i = 0; i < slots_count; i++ )
738 if ( current_distance < nearest_distance )
740 if ( slot != NULL && slot.m_State == slot_state )
742 nearest_distance = current_distance;
743 nearest_slot_index = i;
748 return nearest_slot_index;
754 vector pos = this.GetSelectionPositionMS( memory_point );
756 return this.ModelToWorld( pos );
773 if (rain_intensity > 1 || rain_intensity < 0)
781 if ( rain_intensity > 0 )
787 for (
int i = 0; i < slots_count; i++ )
806 for (
int i = 0; i <
m_Slots.Count(); i++ )
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)
proto native float ConfigGetFloat(string path)
Get float value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
proto native bool ConfigIsExisting(string path)
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto native Weather GetWeather()
Returns weather controller object.
proto native void ObjectDelete(Object obj)
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()
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
provides access to slot configuration
override void EEItemAttached(EntityAI item, string slot_name)
int GetSlotIndexBySelection(string selection_component)
static const string SLOT_MATERIAL_COMPOST_DRY
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()
static const string SLOT_MATERIAL_DRY
override bool CanPutIntoHands(EntityAI parent)
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()
static const string SLOT_TEXTURE_DIGGED_WET_LIME
override bool CanRemoveFromHands(EntityAI parent)
void SetBaseFertility(float value)
override int GetHideIconMask()
int GetSlotIndexByAttachmentSlot(string att_slot)
ref Timer m_CheckRainTimer
override void OnStoreSave(ParamsWriteContext ctx)
override void AfterStoreLoad()
static const string SLOT_SEEDBASE_PREFIX
void SetMaxWaterStateVal()
static const int CHECK_RAIN_INTERVAL
static const string SLOT_SELECTION_COVERED_PREFIX
static ref map< string, string > m_map_slots
static const string SLOT_MATERIAL_COMPOST_WET
override void EEItemDetached(EntityAI item, string slot_name)
override void OnVariablesSynchronized()
void CreatePlant(Slot slot)
static const string SLOT_TEXTURE_DIGGED_WET_PLANT
override bool CanPutInCargo(EntityAI parent)
static const string SLOT_MATERIAL_LIMED_DRY
void Fertilize(PlayerBase player, ItemBase item, float consumed_quantity, string selection_component)
void SetSlotTextureDigged(int slot_index)
void RemoveSlot(int index)
static const string SLOT_MEMORY_POINT_PREFIX
static const string SLOT_MATERIAL_WET
static const string SLOT_MATERIAL_LIMED_WET
void SlotWaterStateUpdate(Slot slot)
void SetSlotWateredState(int newState)
bool CanPlantSeed(string selection_component)
void UpdateTexturesOnAllSlots()
override void EOnInit(IEntity other, int extra)
static const string SLOT_SELECTION_DIGGED_PREFIX
string ConvertAttSlotToPlantSlot(string attach_slot)
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...
proto void CallLater(func fn, int delay=0, bool repeat=false, 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)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto bool Write(void value_out)
proto bool Read(void value_in)
proto native Rain GetRain()
Returns a rain phenomenon object.
proto native float GetActual()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Serializer ParamsReadContext
proto native CGame GetGame()
Serializer ParamsWriteContext
array< string > TStringArray
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.
class JsonUndergroundAreaTriggerData GetPosition
proto native int Length()
Returns length of string.
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.
proto native int ToInt()
Converts string to integer.
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto native int IndexOf(string sample)
Finds 'sample' in 'str'. Returns -1 when not found.
proto int ToLower()
Changes string to lowercase. Returns length.