DayZ
1.24
Loading...
Searching...
No Matches
PluginObjectsInteractionManager.c
Go to the documentation of this file.
1
class
PluginObjectsInteractionManager
extends
PluginBase
2
{
3
private
ref
array<Object>
m_LockedObjects
;
4
private
ref
array<float>
m_LockedObjectsDecay
;
5
private
const
float
TIME_TO_FORCED_UNLOCK = 60;
6
private
const
float
TICK_RATE = 10;
7
private
ref
Timer
m_DecayTimer
;
8
9
void
PluginObjectsInteractionManager
()
10
{
11
m_LockedObjects =
new
array<Object>
;
12
m_LockedObjectsDecay =
new
array<float>
;
13
//TIMERDEPRECATED - timer for decaying objects
14
m_DecayTimer
=
new
Timer
();
15
m_DecayTimer
.Run(TICK_RATE,
this
,
"Decay"
,
NULL
,
true
);
16
}
17
18
bool
IsFree
(
Object
target
)
19
{
20
if
(
target
&& m_LockedObjects.Count() > 0)
21
{
22
for
(
int
i
= 0;
i
< m_LockedObjects.Count();
i
++)
23
{
24
if
(m_LockedObjects.Get(
i
) ==
target
)
25
return
false
;
26
}
27
}
28
return
true
;
29
}
30
31
void
Lock
(
Object
target
)
32
{
33
if
(
target
&& !
IsFree
(
target
))
34
{
35
m_LockedObjects.Insert(
target
);
36
m_LockedObjectsDecay.Insert(0);
37
}
38
}
39
40
void
Release
(
Object
target
)
41
{
42
if
(
target
&& m_LockedObjects.Count() > 0)
43
{
44
for
(
int
i
= 0;
i
< m_LockedObjects.Count();
i
++)
45
{
46
if
(m_LockedObjects.Get(
i
) ==
target
)
47
{
48
m_LockedObjects.Remove(
i
);
49
m_LockedObjectsDecay.Remove(
i
);
50
break
;
51
}
52
}
53
}
54
}
55
56
//FAILSAFE - checks periodically locked objects and releases them automaticaly if given time has passed
57
void
Decay
()
58
{
59
if
(m_LockedObjectsDecay.Count() > 0)
60
{
61
for
(
int
i
= 0;
i
< m_LockedObjectsDecay.Count();
i
++)
62
{
63
if
(m_LockedObjectsDecay.Get(
i
) >= TIME_TO_FORCED_UNLOCK)
64
{
65
m_LockedObjects.Remove(
i
);
66
m_LockedObjectsDecay.Remove(
i
);
67
}
68
else
69
m_LockedObjectsDecay.Get(
i
) +=
TICK_RATE
;
70
}
71
}
72
}
73
};
m_DecayTimer
float m_DecayTimer
Definition
Edible_Base.c:764
Object
Definition
ObjectTyped.c:2
Param3
Definition
EntityAI.c:95
PluginBase
Definition
PluginBase.c:2
PluginBase::Release
void Release(Object target)
Definition
PluginObjectsInteractionManager.c:40
PluginBase::IsFree
bool IsFree(Object target)
Definition
PluginObjectsInteractionManager.c:18
PluginBase::m_LockedObjectsDecay
ref array< float > m_LockedObjectsDecay
Definition
PluginObjectsInteractionManager.c:4
PluginBase::m_LockedObjects
ref array< Object > m_LockedObjects
Definition
PluginObjectsInteractionManager.c:3
PluginBase::Decay
void Decay()
Definition
PluginObjectsInteractionManager.c:57
PluginBase::m_DecayTimer
ref Timer m_DecayTimer
Definition
PluginObjectsInteractionManager.c:7
PluginBase::TICK_RATE
const float TICK_RATE
Definition
PluginObjectsInteractionManager.c:6
PluginBase::Lock
void Lock(Object target)
Definition
PluginObjectsInteractionManager.c:31
PluginBase::PluginObjectsInteractionManager
void PluginObjectsInteractionManager()
Definition
PluginObjectsInteractionManager.c:9
Timer
Definition
DayZPlayerImplement.c:61
scripts
4_World
Plugins
PluginBase
PluginObjectsInteractionManager.c
Generated by
1.10.0