DayZ
1.24
Loading...
Searching...
No Matches
CAContinuousQuantityEdible.c
Go to the documentation of this file.
1
class
CAContinuousQuantityEdible
:
CAContinuousQuantityRepeat
2
{
3
protected
float
m_InitItemQuantity
;
4
protected
float
m_SpentQuantityTotal
;
5
6
void
CAContinuousQuantityEdible
(
float
quantity_used_per_second
,
float
time_to_repeat
)
7
{
8
m_QuantityUsedPerSecond
=
quantity_used_per_second
;
9
m_DefaultTimeToRepeat
=
time_to_repeat
;
10
m_InitItemQuantity
= -1;
11
m_SpentQuantityTotal
= 0;
12
}
13
14
override
void
Setup
(
ActionData
action_data
)
15
{
16
super
.Setup(
action_data
);
17
18
if
(
m_InitItemQuantity
< 0)
19
m_InitItemQuantity
=
action_data
.m_MainItem.GetQuantity();
20
}
21
22
override
void
CalcAndSetQuantity
(
ActionData
action_data
)
23
{
24
//Print("Munch!");
25
if
(
m_SpentUnits
)
26
{
27
m_SpentUnits
.param1 =
m_SpentQuantity
;
28
SetACData
(
m_SpentUnits
);
29
30
m_SpentQuantityTotal
+=
m_SpentQuantity
;
31
}
32
//m_SpentQuantity = Math.Floor(m_SpentQuantity);
33
34
PlayerBase
ntarget
=
PlayerBase
.Cast(
action_data
.m_Target.GetObject());
35
if
(
ntarget
)
36
{
37
if
(
GetGame
().IsServer())
38
{
39
//action_data.m_MainItem.Consume(targetObject, m_SpentQuantity);
40
ntarget
.Consume(
action_data
.m_MainItem,
m_SpentQuantity
,
EConsumeType
.ITEM_CONTINUOUS);
41
42
}
43
}
44
else
45
{
46
if
(
GetGame
().IsServer())
47
{
48
//action_data.m_MainItem.Consume(action_data.m_Player, m_SpentQuantity);
49
action_data
.m_Player.Consume(
action_data
.m_MainItem,
m_SpentQuantity
,
EConsumeType
.ITEM_CONTINUOUS);
50
}
51
}
52
}
53
54
override
float
GetProgress
()
55
{
56
//return super.GetProgress();
57
if
(
m_SpentQuantity
> 0)
58
return
Math
.
Clamp
((1 - (
m_InitItemQuantity
-
m_SpentQuantity
-
m_SpentQuantityTotal
) /
m_InitItemQuantity
), 0, 1);
59
else
60
return
Math
.
Clamp
((1 - (
m_InitItemQuantity
-
m_SpentQuantityTotal
) /
m_InitItemQuantity
), 0, 1);
61
}
62
};
EConsumeType
EConsumeType
Definition
EConsumeType.c:2
ActionData
Definition
ActionBase.c:21
CABase::SetACData
void SetACData(Param units)
Definition
CABase.c:38
CAContinuousQuantityEdible
Definition
CAContinuousQuantityEdible.c:2
CAContinuousQuantityEdible::CAContinuousQuantityEdible
void CAContinuousQuantityEdible(float quantity_used_per_second, float time_to_repeat)
Definition
CAContinuousQuantityEdible.c:6
CAContinuousQuantityEdible::m_SpentQuantityTotal
float m_SpentQuantityTotal
Definition
CAContinuousQuantityEdible.c:4
CAContinuousQuantityEdible::Setup
override void Setup(ActionData action_data)
Definition
CAContinuousQuantityEdible.c:14
CAContinuousQuantityEdible::CalcAndSetQuantity
override void CalcAndSetQuantity(ActionData action_data)
Definition
CAContinuousQuantityEdible.c:22
CAContinuousQuantityEdible::GetProgress
override float GetProgress()
Definition
CAContinuousQuantityEdible.c:54
CAContinuousQuantityEdible::m_InitItemQuantity
float m_InitItemQuantity
Definition
CAContinuousQuantityEdible.c:3
CAContinuousQuantityRepeat
Definition
CAContinuousQuantityRepeat.c:2
CAContinuousQuantityRepeat::m_SpentQuantity
float m_SpentQuantity
Definition
CAContinuousQuantityRepeat.c:4
CAContinuousQuantityRepeat::m_SpentUnits
ref Param1< float > m_SpentUnits
Definition
CAContinuousQuantityRepeat.c:10
CAContinuousQuantityRepeat::m_DefaultTimeToRepeat
float m_DefaultTimeToRepeat
Definition
CAContinuousQuantityRepeat.c:9
CAContinuousQuantityRepeat::m_QuantityUsedPerSecond
float m_QuantityUsedPerSecond
Definition
CAContinuousQuantityRepeat.c:7
Math
Definition
EnMath.c:7
Param3
Definition
EntityAI.c:95
PlayerBase
Definition
PlayerBaseClient.c:2
GetGame
proto native CGame GetGame()
Math::Clamp
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
scripts
4_World
Classes
UserActionsComponent
ActionComponents
CAContinuousQuantityEdible.c
Generated by
1.10.0