4 protected bool m_IsTrigger;
6 protected int m_PairDeviceNetIdLow;
7 protected int m_PairDeviceNetIdHigh;
8 protected int m_PersistentPairID =
int.MIN;
16 m_PairDeviceNetIdLow = -1;
17 m_PairDeviceNetIdHigh = -1;
31 void OnVariableSynchronized()
38 ctx.Write(m_PersistentPairID);
43 if (!ctx.Read(m_PersistentPairID))
46 if (m_PersistentPairID ==
int.
MIN)
51 EntityAI receiver = m_RemoteReceivers.Get(m_PersistentPairID);
57 m_RemoteReceivers.Insert(m_PersistentPairID,
m_Parent);
65 if (m_IsTrigger && m_PersistentPairID !=
int.
MIN && !m_PairDevice)
67 EntityAI receiver = m_RemoteReceivers.Get(m_PersistentPairID);
81 static int GeneratePersistentID()
83 int randomID =
Math.RandomInt(0,
int.
MAX);
84 if (m_RemoteReceivers.Contains(randomID))
87 return GeneratePersistentID();
93 void SetPersistentPairID(
int id)
95 m_PersistentPairID = id;
98 m_RemoteReceivers.Insert(
id,
m_Parent);
103 EntityAI device =
EntityAI.Cast(
GetGame().GetObjectByNetworkId(GetPairDeviceNetIdLow(), GetPairDeviceNetIdHigh()));
112 m_PairDevice = device;
113 SetPairDeviceNetIds(device);
118 m_PairDevice.SetSynchDirty();
124 m_PairDeviceNetIdLow = -1;
125 m_PairDeviceNetIdHigh = -1;
129 m_PairDevice.SetSynchDirty();
133 if (m_PersistentPairID !=
int.
MIN)
135 if (m_RemoteReceivers.Contains(m_PersistentPairID))
136 m_RemoteReceivers.Remove(m_PersistentPairID);
139 m_PersistentPairID =
int.MIN;
150 return m_PairDevice !=
null;
153 void SetPairDeviceNetIds(notnull
EntityAI device)
155 device.GetNetworkID(m_PairDeviceNetIdLow, m_PairDeviceNetIdHigh);
158 int GetPairDeviceNetIdLow()
160 return m_PairDeviceNetIdLow;
163 int GetPairDeviceNetIdHigh()
165 return m_PairDeviceNetIdHigh;