18 if (
Class.
CastTo(targetGB, action_data.m_Target.GetObject()))
31 if (action_data.m_MainItem)
37 targetGB.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
39 for (
int s = 0; s < selections.Count(); s++)
47 string itemType = action_data.m_MainItem.GetType();
48 float consumedQuantity =
GetGame().
ConfigGetFloat(
"cfgVehicles " + itemType +
" Horticulture ConsumedQuantity");
49 float actionLength =
GetGame().
ConfigGetFloat(
"cfgVehicles " + itemType +
" Horticulture FertilizeLength");
50 if (actionLength == 0)
53 m_Slot.SetFertilizerQuantityMax(consumedQuantity);
59 float speedMultiplier = defaultTimeComplete / actionLength;
67 if (!action_data.m_Player)
81 string itemType = action_data.m_MainItem.GetType();
82 if (
m_Slot.GetFertilityType() !=
"" &&
m_Slot.GetFertilityType() != itemType)
84 m_Slot.SetFertilityType(itemType);
90 if (!
Class.
CastTo(gardenBase, action_data.m_Target.GetObject()))
117 string itemType = item.GetType();
118 if (
m_Slot.GetFertilityType() ==
"" ||
m_Slot.GetFertilityType() == itemType)
120 m_Slot.SetFertilityType(itemType);
122 float addEnergyToSlot =
GetGame().
ConfigGetFloat(
string.Format(
"cfgVehicles %1 Horticulture AddEnergyToSlot", itemType));
125 float coef =
Math.
Clamp(consumedQuantity /
m_Slot.m_FertilizerUsage, 0.0, 1.0);
126 addEnergyToSlot = coef * addEnergyToSlot;
128 float fertilizerMax =
m_Slot.GetFertilizerQuantityMax();
129 float newFertilizerQuantity = (
m_Slot.m_FertilizerQuantity + consumedQuantity);
130 newFertilizerQuantity =
Math.
Clamp(newFertilizerQuantity, 0.0, fertilizerMax);
131 m_Slot.SetFertilizerQuantity(newFertilizerQuantity);
133 float newfertility = (
m_Slot.m_Fertility + addEnergyToSlot);
134 float fertilityMax =
m_Slot.GetFertilityMax();
135 newfertility =
Math.
Clamp(newfertility, 0.0, fertilityMax);
136 m_Slot.SetFertility(newfertility);
void CalcAndSetQuantity()
void OnCompletePogress(ActionData action_data)
void CAContinuousFertilizeGardenSlot(float quantity_used_per_second)
void FertilizeSlot(ItemBase item, GardenBase gardenBase, float consumedQuantity)
override int Execute(ActionData action_data)
override float GetProgress()
float m_AlreadyFilledAmount
float m_SpentQuantityTotal
DEPRECATED.
override void Setup(ActionData action_data)
float m_SlotFertilizerNeed
ref Param1< float > m_SpentUnits
float m_QuantityUsedPerSecond
void CAContinuousQuantity(float quantity_used_per_second)
proto native float ConfigGetFloat(string path)
Get float value from config on path.
Super root of all classes in Enforce script.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
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'.