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";
48 RegisterNetSyncVariableInt(
"m_SlotState");
49 RegisterNetSyncVariableInt(
"m_SlotFertilityState");
50 RegisterNetSyncVariableInt(
"m_SlotWateredState");
52 RegisterNetSyncVariableInt(
"m_SlotWaterBitmap0");
53 RegisterNetSyncVariableInt(
"m_SlotWaterBitmap1");
54 RegisterNetSyncVariableInt(
"m_SlotWaterBitmap2");
56 RegisterNetSyncVariableInt(
"m_SlotFertilizerBitmap0");
57 RegisterNetSyncVariableInt(
"m_SlotFertilizerBitmap1");
58 RegisterNetSyncVariableInt(
"m_SlotFertilizerBitmap2");
72 output = output +
"0";
99 super.OnVariablesSynchronized();
111 for (
int i = 0; i < slotsCount; i++)
117 slot.SetFertilityState(fertilityState);
120 slot.SetWateredState(wateredState);
123 slot.SetWater(waterQuantity);
126 slot.SetFertilizerQuantity(fertilizerQuantity);
129 slot.SetState(slotState);
140 return EInventoryIconVisibility.HIDE_VICINITY;
163 for (
int i = 0; i < slots_count; i++)
166 slot.SetSlotIndex(i);
168 string name =
"SeedBase_" + i1;
170 slot.SetSlotId(slotID);
171 slot.SetGarden(
this);
172 slot.SetState(eGardenSlotState.STATE_DIGGED);
186 for (
int i = 0; i <
m_Slots.Count(); i++ )
204 if (!super.OnStoreLoad(ctx, version))
210 ctx.
Read(some_value);
214 for (
int i = 0; i < slots_count; i++)
217 if (!slot.OnStoreLoadCustom(ctx, version))
220 float waterQuantity = slot.GetWater();
223 float fertilizerQuantity = slot.GetFertilizerQuantity();
227 if ( version >= 119 )
233 if ( version >= 120 )
244 super.EEOnAfterLoad();
256 for (
int i = 0; i < slotsCount; ++i)
261 if (
g_Game.IsDedicatedServer())
268 super.OnStoreSave( ctx );
272 for (
int i = 0; i < slots_count; i++ )
276 slot.OnStoreSaveCustom( ctx );
286 Debug.
Log(
"PRINT ALL SLOTS FROM...");
288 int slots = GetInventory().GetAttachmentSlotsCount();
291 for (
int i = 0; i < slots ; i++ )
297 float slot_fertility = slot.GetFertility();
298 float slot_fertility_usage = slot.GetFertilityMax();
299 string slot_fertility_type = slot.GetFertilityType();
300 float slot_water = slot.GetWater();
301 float slot_water_usage = slot.GetWaterUsage();
302 ItemBase slot_seed = slot.GetSeed();
303 ItemBase slot_plant = slot.GetPlant();
305 float slot_slot_Index = slot.GetSlotIndex();
306 int slot_slot_ID = slot.GetSlotId();
307 int slot_wateredState = slot.GetWateredState();
308 int slot_FertilityState = slot.GetFertilityState();
310 Debug.
Log(
"Fertility : " + slot_fertility);
311 Debug.
Log(
"Fertility Usage : " + slot_fertility_usage);
312 Debug.
Log(
"Fertility Type : " + slot_fertility_type);
313 Debug.
Log(
"Fertility State : " + slot_FertilityState);
315 Debug.
Log(
"Water Usage : " + slot_water_usage);
316 Debug.
Log(
"Watered State : " +
typename.EnumToString(eWateredState, slot_wateredState));
319 if (slot_plant &&
PlantBase.Cast(slot_plant))
320 PlantBase.Cast(slot_plant).PrintValues();
322 Debug.
Log(
"Slot Index : " + slot_slot_Index);
323 Debug.
Log(
"Slot ID : " + slot_slot_ID);
324 Debug.
Log(
"///////////////////////////");
327 Debug.
Log(
"END OF ALL SLOTS FOR...");
333 if ( !super.CanPutInCargo(parent) ) {
return false;}
339 if ( !super.CanPutIntoHands( parent ) )
359 if (slot != NULL && slot.GetState() == eGardenSlotState.STATE_DIGGED)
375 string return_value =
m_map_slots.Get(attach_slot);
384 super.EEItemAttached(item, slot_name);
386 string path =
string.Format(
"CfgVehicles %1 Horticulture PlantType", item.GetType());
391 string converted_slot_name;
408 else if (
g_Game.IsClient())
414 slot.SetState(eGardenSlotState.STATE_PLANTED);
421 super.EEItemDetached(item, slot_name);
425 string path =
string.Format(
"CfgVehicles %1 Horticulture PlantType", item.GetType());
438 slot.SetState(eGardenSlotState.STATE_DIGGED);
447 if ( slot_index != -1 )
449 PluginHorticulture module_horticulture = PluginHorticulture.Cast(
GetPlugin( PluginHorticulture ) );
450 string plant_type = module_horticulture.GetPlantType( seed );
452 Slot slot =
m_Slots.Get( slot_index );
453 slot.SetState(eGardenSlotState.STATE_PLANTED);
454 slot.m_PlantType = plant_type;
457 if ( !slot.NeedsWater() || slot.GetWateredState() == eWateredState.WET)
460 if (slot.GetWateredState() == eWateredState.WET && slot.NeedsWater())
462 int waterMax = slot.GetWaterMax();
463 slot.SetWater(waterMax);
481 seed.UnlockFromParent();
484 PlantBase plant =
PlantBase.Cast( GetInventory().CreateAttachmentEx(slot.m_PlantType, slot.GetSlotId()));
485 int slot_index = slot.GetSlotIndex();
486 slot.SetPlant(plant);
487 slot.SetState(eGardenSlotState.STATE_PLANTED);
488 plant.Init(
this, slot.GetFertility(), slot.m_HarvestingEfficiency, slot.GetWater());
489 plant.LockToParent();
497 int shift = slotIndex * 2;
498 int mask = 3 << shift;
507 if (
g_Game.IsServer() && currentState != value)
513 int shift = slotIndex * 2;
514 int mask = 3 << shift;
521 int idx = slot.GetSlotIndex();
524 int newState = slot.GetWateredState();
531 if ((
g_Game.IsServer() || !
g_Game.IsMultiplayer()) && currentState != newState)
542 int idx = slot.GetSlotIndex();
545 int newState = slot.GetFertilityState();
553 if ((
g_Game.IsServer() || !
g_Game.IsMultiplayer()) && currentState != newState)
568 Slot slot =
m_Slots.Get( slot_index );
571 if ( slot.IsDigged() || slot.IsPlanted() )
576 HideSelection( str_hide );
577 ShowSelection( str_show );
580 if ( slot.GetFertilityState() ==
eFertlityState.FERTILIZED && slot.GetFertilityType() !=
"" )
596 ShowSelection( str_digged );
597 string texture = textures.Get(0);
598 SetObjectTexture( slot_index, texture );
600 Slot slot =
m_Slots.Get( slot_index );
602 if ( slot.GetWateredState() == 0 )
618 int tex_id =
GetGame().
ConfigGetInt(
string.Format(
"cfgVehicles %1 Horticulture TexId", item_type) );
622 ShowSelection( str_show );
623 SetObjectTexture( slot_index, textures.Get(tex_id) );
625 Slot slot =
m_Slots.Get( slot_index );
627 int slot_index_offset = 0;
630 if ( slot.GetWateredState() == 0 )
633 if ( slot.GetFertilityType() ==
"GardenLime" )
637 else if ( slot.GetFertilityType() ==
"PlantMaterial" )
645 if ( slot.GetFertilityType() ==
"GardenLime" )
649 else if ( slot.GetFertilityType() ==
"PlantMaterial" )
660 Slot slot =
m_Slots.Get(index);
663 if (plant && !plant.IsPendingDeletion())
665 plant.UnlockFromParent();
666 plant.m_MarkForDeletion =
true;
672 int idx = slot.GetSlotIndex();
709 if ( slot_index > -1 )
711 return m_Slots.Get( slot_index );
726 string selection_component_lower = selection_component;
727 selection_component_lower.
ToLower();
735 int length = selection_component.
Length();
739 int length_add = length - end;
740 int length_from_end = 2 + length_add;
741 string num_str = selection_component.
Substring( start, length_from_end );
742 slot_index = num_str.
ToInt();
744 slot_index = slot_index - 1;
756 int start =
"SeedBase_".Length();
757 int end = att_slot.
Length();
758 int len = end - start;
760 string num_str = att_slot.
Substring( start, len );
761 slot_index = num_str.
ToInt();
770 for (
int i = 0; i <
m_Slots.Count(); i++ )
774 if ( found_plant == plant )
786 float nearest_distance = 1000.0;
787 int nearest_slot_index = -1;
789 for (
int i = 0; i < slots_count; i++)
795 if (current_distance < nearest_distance)
797 if (slot != NULL && slot.GetState() == slot_state)
799 nearest_distance = current_distance;
800 nearest_slot_index = i;
805 return nearest_slot_index;
811 vector pos = this.GetSelectionPositionMS( memory_point );
813 return this.ModelToWorld( pos );
829 if (rainIntensity > 1 || rainIntensity < 0)
841 for (
int i = 0; i < slotsCount; i++)
936 int slotsPerInt = 32 / bitsPerSlot;
938 int groupIndex = slotIndex / slotsPerInt;
939 int bitOffset = (slotIndex % slotsPerInt) * bitsPerSlot;
941 int mask = 255 << bitOffset;
946 temp |= (value << bitOffset);
953 int slotsPerInt = 32 / bitsPerSlot;
955 int groupIndex = slotIndex / slotsPerInt;
956 int bitOffset = (slotIndex % slotsPerInt) * bitsPerSlot;
959 return (value >> bitOffset) & 255;
965 int slotsPerInt = 32 / bitsPerSlot;
967 int groupIndex = slotIndex / slotsPerInt;
968 int bitOffset = (slotIndex % slotsPerInt) * bitsPerSlot;
970 int mask = 255 << bitOffset;
975 temp |= (value << bitOffset);
982 int slotsPerInt = 32 / bitsPerSlot;
984 int groupIndex = slotIndex / slotsPerInt;
985 int bitOffset = (slotIndex % slotsPerInt) * bitsPerSlot;
988 return (value >> bitOffset) & 255;
999 string item_type = item.GetType();
1001 if ( slot.GetFertilityType() ==
"" || slot.GetFertilityType() == item_type )
1014 for (
int i = 0; i < slots_count; ++i)
1035 [
Obsolete(
"CAContinuousFertilizeGardenSlot::FertilizeSlot is used now instead.")]
1042 string item_type = item.GetType();
1044 if ( slot.GetFertilityType() ==
"" || slot.GetFertilityType() == item_type )
1046 slot.SetFertilityType(item_type);
1048 float add_energy_to_slot =
GetGame().
ConfigGetFloat(
string.Format(
"cfgVehicles %1 Horticulture AddEnergyToSlot", item_type) );
1049 slot.m_FertilizerUsage =
GetGame().
ConfigGetFloat(
string.Format(
"cfgVehicles %1 Horticulture ConsumedQuantity", item_type) );
1051 float coef =
Math.
Clamp( consumed_quantity / slot.m_FertilizerUsage, 0.0, 1.0 );
1052 add_energy_to_slot = coef * add_energy_to_slot;
1054 slot.m_FertilizerQuantity += consumed_quantity;
1055 slot.m_Fertility += add_energy_to_slot;
1057 if ( slot.GetFertilizerQuantity() >= slot.GetFertilizerQuantityMax() )
1059 int slot_index = slot.GetSlotIndex();
1061 if (slot_index > -1)
1072 slot.SetFertilizerQuantity(0);
1073 slot.SetFertilityType(
"");
1083 for (
int i = 0; i <
m_Slots.Count(); i++)
1089 slot.SetWateredState(eWateredState.WET);
void AddAction(typename actionName)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
string ToStringLen(int len)
Integer to string with fixed length, padded with zeroes.
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)
void SetWaterQuantity(int slotIndex, int value)
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)
int GetWaterQuantity(int slotIndex)
override bool HasProxyParts()
int GetMaxWaterStateVal()
static const string SLOT_MATERIAL_DRY
override bool CanPutIntoHands(EntityAI parent)
int GetWaterBitmapByIndex(int index)
override void SetActions()
static const float CREATE_PLANT_DELAY
ref array< ref Slot > m_Slots
int GetSlotIndexByPlant(Object plant)
int GetNearestSlotIDByState(vector position, int slot_state)
int GetSlotState(int slotIndex)
int GetGardenSlotsCount()
bool NeedsFertilization(string selection_component)
bool IsCorrectFertilizer(ItemBase item, string selection_component)
DEPRECATED.
array< ref Slot > GetSlots()
static const string SLOT_TEXTURE_DIGGED_WET_LIME
override bool CanRemoveFromHands(EntityAI parent)
static const float RAIN_INTENSITY_THRESHOLD
void SlotFertilityStateUpdate(Slot slot)
int m_SlotFertilizerBitmap1
void SetBaseFertility(float value)
void SetSlotState(int slotIndex, int value)
override int GetHideIconMask()
int m_SlotFertilizerBitmap0
int GetSlotIndexByAttachmentSlot(string att_slot)
ref Timer m_CheckRainTimer
override void OnStoreSave(ParamsWriteContext ctx)
static const string SLOT_SEEDBASE_PREFIX
void SetMaxWaterStateVal()
static const int CHECK_RAIN_INTERVAL
int GetFertilizerQuantity(int slotIndex)
static const string SLOT_SELECTION_COVERED_PREFIX
int GetFertilizerBitmapByIndex(int index)
static ref map< string, string > m_map_slots
void SetWaterBitmapByIndex(int index, int value)
static const string SLOT_MATERIAL_COMPOST_WET
override void EEItemDetached(EntityAI item, string slot_name)
override void OnVariablesSynchronized()
int m_SlotFertilizerBitmap2
void CreatePlant(Slot slot)
static const string SLOT_TEXTURE_DIGGED_WET_PLANT
void SetFertilizerBitmapByIndex(int index, int value)
void SetFertilizerQuantity(int slotIndex, int value)
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)
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)
This should be only called on server as the selections are synced to clients in C++.
void SetSlotTextureFertilized(int slot_index, string item_type)
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
void Obsolete(string msg="")
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.