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

Protected Member Functions

void CAContinuousQuantityLiquidTransfer (float quantity_used_per_second, float time_to_progress, int drain=-1)
 
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)
 

Protected Attributes

int m_TendencyDrain
 
float m_ItemQuantity
 
float m_SpentQuantity
 
float m_SpentQuantity_total
 
float m_ItemMaxQuantity
 
float m_TimeElpased
 
float m_QuantityUsedPerSecond
 
float m_AdjustedQuantityUsedPerSecond
 
float m_DefaultTimeStep
 
ref Param1< floatm_SpentUnits
 

Detailed Description

Definition at line 1 of file CAContinuousQuantityLiquidTransfer.c.

Constructor & Destructor Documentation

◆ CAContinuousQuantityLiquidTransfer()

void CAContinuousQuantityLiquidTransfer::CAContinuousQuantityLiquidTransfer ( float quantity_used_per_second,
float time_to_progress,
int drain = -1 )
inlineprotected

Member Function Documentation

◆ CalcAndSetQuantity()

void CAContinuousQuantityLiquidTransfer::CalcAndSetQuantity ( ActionData action_data)
inlineprotected

Definition at line 109 of file CAContinuousQuantityLiquidTransfer.c.

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 }
void SetACData(Param units)
Definition CABase.c:38
Definition Liquid.c:2
static void Transfer(ItemBase source_ent, ItemBase target_ent, float quantity=-1)
Definition Liquid.c:37
proto native CGame GetGame()

References GetGame(), m_SpentQuantity, m_SpentQuantity_total, m_SpentUnits, m_TendencyDrain, CABase::SetACData(), and Liquid::Transfer().

◆ Cancel()

override int CAContinuousQuantityLiquidTransfer::Cancel ( ActionData action_data)
inlineprotected

Definition at line 90 of file CAContinuousQuantityLiquidTransfer.c.

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 }
void CalcAndSetQuantity()
const int UA_ERROR
Definition constants.c:455
const int UA_INTERRUPT
Definition constants.c:438

References CalcAndSetQuantity(), m_TendencyDrain, UA_ERROR, and UA_INTERRUPT.

◆ Execute()

override int CAContinuousQuantityLiquidTransfer::Execute ( ActionData action_data)
inlineprotected

Definition at line 56 of file CAContinuousQuantityLiquidTransfer.c.

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 }
ActionBase m_Action
Definition CABase.c:3
void OnCompletePogress(ActionData action_data)
const int UA_FINISHED
Definition constants.c:436
const int UA_PROCESSING
Definition constants.c:434

References CalcAndSetQuantity(), CABase::m_Action, m_AdjustedQuantityUsedPerSecond, m_DefaultTimeStep, m_ItemQuantity, m_QuantityUsedPerSecond, m_SpentQuantity, m_SpentQuantity_total, m_TendencyDrain, m_TimeElpased, CAContinuousBase::OnCompletePogress(), UA_ERROR, UA_FINISHED, and UA_PROCESSING.

◆ GetProgress()

override float CAContinuousQuantityLiquidTransfer::GetProgress ( )
inlineprotected

◆ Setup()

override void CAContinuousQuantityLiquidTransfer::Setup ( ActionData action_data)
inlineprotected

Definition at line 21 of file CAContinuousQuantityLiquidTransfer.c.

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

References m_ItemMaxQuantity, m_ItemQuantity, m_QuantityUsedPerSecond, m_SpentQuantity, m_SpentUnits, m_TendencyDrain, m_TimeElpased, and Math::Min().

Member Data Documentation

◆ m_AdjustedQuantityUsedPerSecond

float CAContinuousQuantityLiquidTransfer::m_AdjustedQuantityUsedPerSecond
protected

Definition at line 10 of file CAContinuousQuantityLiquidTransfer.c.

Referenced by Execute().

◆ m_DefaultTimeStep

float CAContinuousQuantityLiquidTransfer::m_DefaultTimeStep
protected

◆ m_ItemMaxQuantity

float CAContinuousQuantityLiquidTransfer::m_ItemMaxQuantity
protected

Definition at line 7 of file CAContinuousQuantityLiquidTransfer.c.

Referenced by GetProgress(), and Setup().

◆ m_ItemQuantity

float CAContinuousQuantityLiquidTransfer::m_ItemQuantity
protected

Definition at line 4 of file CAContinuousQuantityLiquidTransfer.c.

Referenced by Execute(), and Setup().

◆ m_QuantityUsedPerSecond

float CAContinuousQuantityLiquidTransfer::m_QuantityUsedPerSecond
protected

◆ m_SpentQuantity

float CAContinuousQuantityLiquidTransfer::m_SpentQuantity
protected

Definition at line 5 of file CAContinuousQuantityLiquidTransfer.c.

Referenced by CalcAndSetQuantity(), Execute(), and Setup().

◆ m_SpentQuantity_total

float CAContinuousQuantityLiquidTransfer::m_SpentQuantity_total
protected

Definition at line 6 of file CAContinuousQuantityLiquidTransfer.c.

Referenced by CalcAndSetQuantity(), Execute(), and GetProgress().

◆ m_SpentUnits

ref Param1<float> CAContinuousQuantityLiquidTransfer::m_SpentUnits
protected

Definition at line 12 of file CAContinuousQuantityLiquidTransfer.c.

Referenced by CalcAndSetQuantity(), and Setup().

◆ m_TendencyDrain

int CAContinuousQuantityLiquidTransfer::m_TendencyDrain
protected

◆ m_TimeElpased

float CAContinuousQuantityLiquidTransfer::m_TimeElpased
protected

Definition at line 8 of file CAContinuousQuantityLiquidTransfer.c.

Referenced by Execute(), and Setup().


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