Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
remotelyactivateditembehaviour.c
Go to the documentation of this file.
2 {
3  protected EntityAI m_Parent;
4  protected EntityAI m_PairDevice;
5  protected int m_PairDeviceNetIdLow;
6  protected int m_PairDeviceNetIdHigh;
7 
8  void RemotelyActivatedItemBehaviour(notnull EntityAI pParent)
9  {
10  m_Parent = pParent;
11  m_PairDeviceNetIdLow = -1;
12  m_PairDeviceNetIdHigh = -1;
13  }
14 
15  void OnVariableSynchronized()
16  {
17  Pair();
18  }
19 
20  void Pair()
21  {
22  EntityAI device = EntityAI.Cast(GetGame().GetObjectByNetworkId(GetPairDeviceNetIdLow(), GetPairDeviceNetIdHigh()));
23  if (device)
24  {
25  Pair(device);
26  }
27  }
28 
29  void Pair(notnull EntityAI device)
30  {
31  m_PairDevice = device;
32  SetPairDeviceNetIds(device);
33 
34  if (!m_Parent.GetPairDevice() || m_Parent.GetPairDevice() != m_PairDevice)
35  {
36  m_PairDevice.PairRemote(m_Parent);
37  }
38 
39  m_PairDevice.SetSynchDirty();
40  m_Parent.SetSynchDirty();
41  }
42 
43  void Unpair()
44  {
45  m_PairDeviceNetIdLow = -1;
46  m_PairDeviceNetIdHigh = -1;
47 
48  if (m_PairDevice)
49  {
50  m_PairDevice.SetSynchDirty();
51  m_PairDevice = null;
52  }
53 
54  m_Parent.SetSynchDirty();
55  }
56 
57  EntityAI GetPairDevice()
58  {
59  return m_PairDevice;
60  }
61 
62  bool IsPaired()
63  {
64  return m_PairDevice != null;
65  }
66 
67  void SetPairDeviceNetIds(notnull EntityAI device)
68  {
69  device.GetNetworkID(m_PairDeviceNetIdLow, m_PairDeviceNetIdHigh);
70  }
71 
72  int GetPairDeviceNetIdLow()
73  {
74  return m_PairDeviceNetIdLow;
75  }
76 
77  int GetPairDeviceNetIdHigh()
78  {
79  return m_PairDeviceNetIdHigh;
80  }
81 }
GetGame
proto native CGame GetGame()
RemotelyActivatedItemBehaviour
Definition: remotelyactivateditembehaviour.c:1
m_Parent
protected Widget m_Parent
Definition: sizetochild.c:92
EntityAI
Definition: building.c:5