DayZ 1.24
Loading...
Searching...
No Matches
CAContinuousQuantityLiquidTransfer.c
Go to the documentation of this file.
2{
3 protected int m_TendencyDrain; //1 == drain, 0 == pour, -1 == cancel!
4 protected float m_ItemQuantity;
5 protected float m_SpentQuantity;
6 protected float m_SpentQuantity_total;
7 protected float m_ItemMaxQuantity; //basically free capacity
8 protected float m_TimeElpased;
9 protected float m_QuantityUsedPerSecond;
11 protected float m_DefaultTimeStep;
13
14 void CAContinuousQuantityLiquidTransfer(float quantity_used_per_second, float time_to_progress, int drain = -1) //-1 used as a safeguard; if no valid value arrives, callback is canceled
15 {
19 }
20
22 {
23 ItemBase target_item = ItemBase.Cast(action_data.m_Target.GetObject());
24
25 m_TimeElpased = 0;
27
28 if (!m_SpentUnits)
30 else
31 m_SpentUnits.param1 = 0;
32
33 m_QuantityUsedPerSecond *= Math.Min(action_data.m_MainItem.GetLiquidThroughputCoef(), target_item.GetLiquidThroughputCoef());
34
35 if (m_TendencyDrain == 1)
36 {
37 if (target_item.GetQuantity() > (action_data.m_MainItem.GetQuantityMax() - action_data.m_MainItem.GetQuantity()))
38 m_ItemMaxQuantity = action_data.m_MainItem.GetQuantityMax() - action_data.m_MainItem.GetQuantity();
39 else
40 m_ItemMaxQuantity = target_item.GetQuantity();
41
43 }
44 else if (m_TendencyDrain == 0)
45 {
46 if (action_data.m_MainItem.GetQuantity() > (target_item.GetQuantityMax() - target_item.GetQuantity()))
47 m_ItemMaxQuantity = target_item.GetQuantityMax() - target_item.GetQuantity();
48 else
49 m_ItemMaxQuantity = action_data.m_MainItem.GetQuantity();
50
52 }
53 }
54
55
57 {
58 ItemBase target_item = ItemBase.Cast(action_data.m_Target.GetObject());
59
60 if (!action_data.m_Player || m_TendencyDrain == -1 || !action_data.m_Target)
61 return UA_ERROR;
62
63 if (m_ItemQuantity <= 0)
64 return UA_FINISHED;
65 else
66 {
68 {
69 m_AdjustedQuantityUsedPerSecond = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus(m_QuantityUsedPerSecond, m_Action.GetSpecialtyWeight(), true);
71 m_TimeElpased += action_data.m_Player.GetDeltaT();
72
74 {
76 m_TimeElpased = 0;
77 }
78
79 return UA_PROCESSING;
80 }
81 else
82 {
85 return UA_FINISHED;
86 }
87 }
88 }
89
91 {
92 if (!action_data.m_Player || m_TendencyDrain == -1 || !action_data.m_Target || !action_data.m_Target.GetObject())
93 return UA_ERROR;
94
96 return UA_INTERRUPT;
97 }
98
99 override float GetProgress()
100 {
101 if (m_TendencyDrain)
103 else
105 }
106
107 //---------------------------------------------------------------------------
108
110 {
111 ItemBase target_item = ItemBase.Cast(action_data.m_Target.GetObject());
113
114 if (GetGame().IsServer())
115 {
116 if (m_SpentUnits)
117 {
120 }
121
122 //could move following stuff to action itself, if needed
123 if (m_TendencyDrain)
125 else
127 }
128 m_SpentQuantity = 0;
129 }
130}
void CalcAndSetQuantity()
void SetACData(Param units)
Definition CABase.c:38
ActionBase m_Action
Definition CABase.c:3
void OnCompletePogress(ActionData action_data)
override int Cancel(ActionData action_data)
override void Setup(ActionData action_data)
override int Execute(ActionData action_data)
void CAContinuousQuantityLiquidTransfer(float quantity_used_per_second, float time_to_progress, int drain=-1)
Definition Liquid.c:2
static void Transfer(ItemBase source_ent, ItemBase target_ent, float quantity=-1)
Definition Liquid.c:37
Definition EnMath.c:7
proto native CGame GetGame()
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_INTERRUPT
Definition constants.c:438
const int UA_PROCESSING
Definition constants.c:434