DayZ 1.24
Loading...
Searching...
No Matches
CAContinuousWaterSlot.c
Go to the documentation of this file.
2{
3 protected float m_PlantThirstyness;
4 protected float m_TimeToComplete;
5 protected float m_SpentQuantityTotal;
6 protected float m_StartQuantity;
7 protected Slot m_Slot;
8
13
15 {
17
18 if (Class.CastTo(target_GB, action_data.m_Target.GetObject()))
19 {
21 m_StartQuantity = action_data.m_MainItem.GetQuantity();
22 if (!m_SpentUnits)
24 else
25 m_SpentUnits.param1 = 0;
26
27 if (action_data.m_MainItem)
28 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
29
30 if (target_GB)
31 {
33 target_GB.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
34
35 for (int s = 0; s < selections.Count(); s++)
36 {
37 string selection = selections[s];
38 m_Slot = target_GB.GetSlotBySelection(selection);
39 if (m_Slot)
40 break;
41 }
42
43 m_PlantThirstyness = m_Slot.GetWaterUsage() - m_Slot.GetWater();
44 }
45
47
48 if (m_TimeToComplete <= 0.1) // Division by zero prevention
49 m_TimeToComplete = 0.1;
50 }
51 }
52
54 {
56 Class.CastTo(target_GB, action_data.m_Target.GetObject());
57 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
58 m_ItemMaxQuantity = action_data.m_MainItem.GetQuantityMax();
59
60 if (!action_data.m_Player)
61 return UA_ERROR;
62
63 if (m_ItemQuantity <= 0)
64 return UA_FINISHED;
65 else
66 {
68 {
69 m_SpentQuantity += m_QuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
70 float water = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus(m_SpentQuantity, m_Action.GetSpecialtyWeight(), true);
71 m_Slot.GiveWater(water);
72
75
77
78 return UA_PROCESSING;
79 }
80 else
81 {
84
85 return UA_FINISHED;
86 }
87 }
88 }
89
90 override float GetProgress()
91 {
92 if (m_ItemQuantity <= 0)
93 return 1;
95 return progress;
96 }
97};
void CalcAndSetQuantity()
ActionBase m_Action
Definition CABase.c:3
void OnCompletePogress(ActionData action_data)
ref Param1< float > m_SpentUnits
void CAContinuousWaterSlot(float quantity_used_per_second)
override int Execute(ActionData action_data)
override void Setup(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Min(float x, float y)
Returns smaller of two given values.
const int UA_FINISHED
Definition constants.c:436
const int UA_ERROR
Definition constants.c:455
const int UA_PROCESSING
Definition constants.c:434