DayZ 1.24
Loading...
Searching...
No Matches
PluginObjectsInteractionManager.c
Go to the documentation of this file.
1class PluginObjectsInteractionManager extends PluginBase
2{
5 private const float TIME_TO_FORCED_UNLOCK = 60;
6 private const float TICK_RATE = 10;
8
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
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
32 {
33 if (target && !IsFree(target))
34 {
35 m_LockedObjects.Insert(target);
36 m_LockedObjectsDecay.Insert(0);
37 }
38 }
39
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};
float m_DecayTimer
void Release(Object target)
bool IsFree(Object target)
ref array< float > m_LockedObjectsDecay
ref array< Object > m_LockedObjects
void Lock(Object target)