DayZ 1.24
Loading...
Searching...
No Matches
CAContinuousTransferQuantity.c
Go to the documentation of this file.
2{
3 protected float m_TargetUnits;
4 protected float m_SpentQuantity;
5 protected float m_ItemQuantity;
6 protected float m_SourceQuantity;
7 protected float m_QuantityFilledPerSecond;
8 protected float m_TimeToComplete;
10
15
17 {
19 if (!m_SpentUnits)
21 else
22 m_SpentUnits.param1 = 0;
23 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
25 if (Class.CastTo(trg, action_data.m_Target.GetObject()))
26 m_SourceQuantity = trg.GetQuantity();
27 m_TargetUnits = action_data.m_MainItem.GetQuantityMax();
29 }
30
32 {
33 if (!action_data.m_Player)
34 return UA_ERROR;
36 Class.CastTo(trg, action_data.m_Target.GetObject());
37 if (action_data.m_MainItem.GetQuantity() >= action_data.m_MainItem.GetQuantityMax() || trg.GetQuantity() == 0)
38 return UA_FINISHED;
39 else
40 {
42 {
45 if (m_Action) m_Action.SendMessageToClient(action_data.m_Player, val.ToString());
46 return UA_PROCESSING;
47 }
48 else
49 {
52 return UA_FINISHED;
53 }
54 }
55 }
56
57 override override int Cancel(ActionData action_data)
58 {
59 if (!action_data.m_Player)
60 return UA_ERROR;
61
63 return UA_CANCEL;
64 }
65
71 //---------------------------------------------------------------------------
72
74 {
75 if (GetGame().IsServer())
76 {
77 if (m_SpentUnits)
78 {
81 }
82 action_data.m_MainItem.AddQuantity(m_SpentQuantity);
84 if (Class.CastTo(trg, action_data.m_Target.GetObject()))
85 trg.AddQuantity(-m_SpentQuantity, false, false);
86 }
87 }
88};
void CalcAndSetQuantity()
void SetACData(Param units)
Definition CABase.c:38
ActionBase m_Action
Definition CABase.c:3
void OnCompletePogress(ActionData action_data)
override override int Cancel(ActionData action_data)
override int Execute(ActionData action_data)
void CAContinuousTransferQuantity(float quantity_filled_per_second)
void CalcAndSetQuantity(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
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 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
const int UA_CANCEL
Definition constants.c:437