DayZ 1.24
Loading...
Searching...
No Matches
CAContinuousWaterSlot Class Reference
Inheritance diagram for CAContinuousWaterSlot:
[legend]
Collaboration diagram for CAContinuousWaterSlot:
[legend]

Protected Member Functions

void CAContinuousWaterSlot (float quantity_used_per_second)
 
override void Setup (ActionData action_data)
 
override int Execute (ActionData action_data)
 
override float GetProgress ()
 

Protected Attributes

float m_PlantThirstyness
 
float m_TimeToComplete
 
float m_SpentQuantityTotal
 
float m_StartQuantity
 
Slot m_Slot
 

Additional Inherited Members

- Private Member Functions inherited from CAContinuousQuantity
void CAContinuousQuantity (float quantity_used_per_second)
 
override void Setup (ActionData action_data)
 
override int Execute (ActionData action_data)
 
override int Cancel (ActionData action_data)
 
override float GetProgress ()
 
void CalcAndSetQuantity (ActionData action_data)
 
- Private Attributes inherited from CAContinuousQuantity
float m_ItemQuantity
 
float m_SpentQuantity
 
float m_ItemMaxQuantity
 
float m_QuantityUsedPerSecond
 
float m_AdjustedQuantityUsedPerSecond
 
ref Param1< floatm_SpentUnits
 

Detailed Description

Definition at line 1 of file CAContinuousWaterSlot.c.

Constructor & Destructor Documentation

◆ CAContinuousWaterSlot()

void CAContinuousWaterSlot::CAContinuousWaterSlot ( float quantity_used_per_second)
inlineprotected

Member Function Documentation

◆ Execute()

override int CAContinuousWaterSlot::Execute ( ActionData action_data)
inlineprotected

Definition at line 53 of file CAContinuousWaterSlot.c.

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 }
void CalcAndSetQuantity()
ActionBase m_Action
Definition CABase.c:3
void OnCompletePogress(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int UA_FINISHED
Definition constants.c:436
const int UA_ERROR
Definition constants.c:455
const int UA_PROCESSING
Definition constants.c:434

References CalcAndSetQuantity(), Class::CastTo(), CABase::m_Action, CAContinuousQuantity::m_ItemMaxQuantity, CAContinuousQuantity::m_ItemQuantity, CAContinuousQuantity::m_QuantityUsedPerSecond, m_Slot, CAContinuousQuantity::m_SpentQuantity, m_SpentQuantityTotal, CAContinuousBase::OnCompletePogress(), UA_ERROR, UA_FINISHED, and UA_PROCESSING.

◆ GetProgress()

override float CAContinuousWaterSlot::GetProgress ( )
inlineprotected

Definition at line 90 of file CAContinuousWaterSlot.c.

91 {
92 if (m_ItemQuantity <= 0)
93 return 1;
95 return progress;
96 }

References CAContinuousQuantity::m_ItemQuantity, m_SpentQuantityTotal, and m_StartQuantity.

◆ Setup()

override void CAContinuousWaterSlot::Setup ( ActionData action_data)
inlineprotected

Definition at line 14 of file CAContinuousWaterSlot.c.

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 }
ref Param1< float > m_SpentUnits
Definition EnMath.c:7
static proto float Min(float x, float y)
Returns smaller of two given values.

References Class::CastTo(), CAContinuousQuantity::m_ItemQuantity, m_PlantThirstyness, CAContinuousQuantity::m_QuantityUsedPerSecond, m_Slot, CAContinuousQuantity::m_SpentQuantity, CAContinuousQuantity::m_SpentUnits, m_StartQuantity, m_TimeToComplete, and Math::Min().

Member Data Documentation

◆ m_PlantThirstyness

float CAContinuousWaterSlot::m_PlantThirstyness
protected

Definition at line 3 of file CAContinuousWaterSlot.c.

Referenced by Setup().

◆ m_Slot

Slot CAContinuousWaterSlot::m_Slot
protected

Definition at line 7 of file CAContinuousWaterSlot.c.

Referenced by Execute(), and Setup().

◆ m_SpentQuantityTotal

float CAContinuousWaterSlot::m_SpentQuantityTotal
protected

Definition at line 5 of file CAContinuousWaterSlot.c.

Referenced by Execute(), and GetProgress().

◆ m_StartQuantity

float CAContinuousWaterSlot::m_StartQuantity
protected

Definition at line 6 of file CAContinuousWaterSlot.c.

Referenced by GetProgress(), and Setup().

◆ m_TimeToComplete

float CAContinuousWaterSlot::m_TimeToComplete
protected

Definition at line 4 of file CAContinuousWaterSlot.c.

Referenced by Setup().


The documentation for this class was generated from the following file: