DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
RemoteDetonator.c
См. документацию.
6
7class RemoteDetonator : Inventory_Base
8{
9 const string COLOR_LED_OFF = "#(argb,8,8,3)color(0,0,0,1.0,co)";
10 const string COLOR_LED_LIT = "#(argb,8,8,3)color(1,0,0,1.0,co)";
11 const string SELECTION_NAME_LED = "LED";
12
14
15 bool IsKit()
16 {
17 return true;
18 }
19
20 void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced = false)
21 {
22 int selectionIdx = GetHiddenSelectionIndex(SELECTION_NAME_LED);
23
24 switch (pState)
25 {
27 SetObjectTexture(selectionIdx, COLOR_LED_LIT);
28 break;
29 default:
30 SetObjectTexture(selectionIdx, COLOR_LED_OFF);
31 }
32
33 m_LastLEDState = pState;
34 SetSynchDirty();
35 }
36
37 override void SetActions()
38 {
39 super.SetActions();
40
43 }
44}
45
46class RemoteDetonatorTrigger : RemoteDetonator
47{
48 protected const string ANIM_PHASE_TRIGGER = "trigger";
49
50 protected bool m_LED;
52
54 {
56 m_RAIB.SetTrigger();
57
58 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdLow");
59 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdHigh");
60 RegisterNetSyncVariableInt("m_LastLEDState", 0, EnumTools.GetEnumSize(ERemoteDetonatorLEDState));
61
63 }
64
65 override bool IsKit()
66 {
67 return false;
68 }
69
71 {
72 super.OnVariablesSynchronized();
73
74 if (m_RAIB)
75 {
76 m_RAIB.OnVariableSynchronized();
77 }
78
80 }
81
82 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
83 {
84 super.EEItemLocationChanged(oldLoc, newLoc);
85
86 if (m_RAIB)
87 {
88 m_RAIB.Pair();
89 }
90 }
91
96
97 override void OnCEUpdate()
98 {
99 super.OnCEUpdate();
100
101 if (!IsRuined() && IsConnected() && GetControlledDevice())
102 {
104 {
106
107 return;
108 }
109 }
110
112 }
113
114 override void PairRemote(notnull EntityAI trigger)
115 {
116 m_RAIB.Pair(trigger);
117 }
118
119 override void UnpairRemote()
120 {
122 m_RAIB.Unpair();
123 }
124
125 override void OnActivatedByItem(notnull ItemBase item)
126 {
127 if (GetGame().IsServer())
128 {
129 if (m_RAIB.IsPaired() && !IsRuined())
130 {
131 ItemBase device = ItemBase.Cast(GetControlledDevice());
132 if (device && vector.DistanceSq(GetPosition(), device.GetPosition()) <= Math.SqrFloat(UAMaxDistances.EXPLOSIVE_REMOTE_ACTIVATION))
133 {
134 device.OnActivatedByItem(this);
135 }
136 }
137 }
138 }
139
141 {
142 m_RAIB.Pair(pDevice);
143 }
144
146 {
147 return m_RAIB.IsPaired();
148 }
149
151 {
152 return m_RAIB.GetPairDevice();
153 }
154
155 static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity, EntityAI deviceToPair = null)
156 {
157 string type = "RemoteDetonatorTrigger";
159 PlayerBase player = PlayerBase.Cast(pEntity);
160 if (player)
161 {
162 ItemBase inHandsItem = player.GetItemInHands();
163 if (inHandsItem)
164 {
165 if (deviceToPair)
166 {
167 ReplaceDetonatorItemOnArmLambda onArmLambda = new ReplaceDetonatorItemOnArmLambda(inHandsItem, type);
168 onArmLambda.SetPairDevice(deviceToPair);
169 MiscGameplayFunctions.TurnItemIntoItemEx(player, onArmLambda);
170 }
171 else
172 {
173 ReplaceDetonatorItemLambda lambda = new ReplaceDetonatorItemLambda(inHandsItem, type);
174 MiscGameplayFunctions.TurnItemIntoItemEx(player, lambda);
175 }
176
177
178 rdt = RemoteDetonatorTrigger.Cast(player.GetItemInHands());
179 }
180 else
181 rdt = RemoteDetonatorTrigger.Cast(player.GetHumanInventory().CreateInHands(type));
182
184 if (player.GetItemInHands())
185 player.GetItemAccessor().OnItemInHandsChanged();
186 }
187
188 return rdt;
189 }
190
191 override void OnAnimationPhaseStarted(string animSource, float phase)
192 {
193 if (animSource == ANIM_PHASE_TRIGGER)
194 {
195 if (phase > 0.01)
196 {
198 }
199 }
200 }
201
212
213#ifdef DIAG_DEVELOPER
214 override protected string GetDebugText()
215 {
216 string debug_output;
217 debug_output += string.Format("low net id: %1\n", m_RAIB.GetPairDeviceNetIdLow());
218 debug_output += string.Format("high net id: %1\n", m_RAIB.GetPairDeviceNetIdHigh());
219 debug_output += string.Format("pair device: %1\n", m_RAIB.GetPairDevice());
220 return debug_output;
221 }
222#endif
223}
224
225class RemoteDetonatorReceiver : RemoteDetonator
226{
232 override bool IsKit()
234 return false;
235 }
236
237 override void OnWasDetached(EntityAI parent, int slot_id)
238 {
240 }
241
242 override void EEKilled(Object killer)
243 {
244 super.EEKilled(killer);
245
247 }
248
249 override void SetActions()
251 super.SetActions();
252
255 }
256}
257
259{
260 override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
261 {
262 super.CopyOldPropertiesToNew(old_item, new_item);
263
264 MiscGameplayFunctions.TransferItemProperties(old_item, new_item);
265 }
266}
267
268class ReplaceDetonatorItemOnArmLambda : ReplaceDetonatorItemLambda
269{
270 EntityAI m_PairDevice
271
274 m_PairDevice = device;
275 }
276
277 override void OnSuccess(EntityAI new_item)
278 {
279 super.OnSuccess(new_item);
280
281 RemoteDetonator detonator = RemoteDetonator.Cast(new_item);
282 if (detonator)
283 {
284 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
285 if (explosive)
286 {
287 ItemBase receiver = ItemBase.Cast(explosive.GetInventory().CreateAttachment("RemoteDetonatorReceiver"));
288 if (receiver)
289 {
290 MiscGameplayFunctions.TransferItemProperties(detonator, receiver);
291 receiver.LockToParent();
292 explosive.SetTakeable(false);
293 explosive.PairWithDevice(detonator);
294 explosive.Arm();
295 }
296 }
297 }
298 }
300 override void OnAbort()
301 {
302 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
303 if (explosive)
304 {
305 explosive.LockTriggerSlots();
306 explosive.SetTakeable(true);
307 }
308 }
309}
310
312{
313 override void OnSuccess(EntityAI new_item)
314 {
315 super.OnSuccess(new_item);
316
317 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);
318 if (detonator)
319 {
320 if (detonator.GetRemotelyActivatedItemBehaviour())
321 {
322 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());
323 if (explosive)
324 {
325 explosive.Disarm();
326 }
327 }
328 }
329 }
331 override void OnAbort()
332 {
333 super.OnAbort();
334
335 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);
336 if (detonator)
337 {
338 if (detonator.GetRemotelyActivatedItemBehaviour())
339 {
340 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());
341 if (explosive)
342 {
343 explosive.LockExplosivesSlots();
344 }
345 }
346 }
347 }
348}
class LogManager EntityAI
ActionAttachExplosivesTriggerCB ActionContinuousBaseCB ActionAttachExplosivesTrigger()
Определения ActionAttachExplosivesTrigger.c:11
ActionDisarmExplosiveWithRemoteDetonatorCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonator()
ActionDisarmExplosiveWithRemoteDetonatorUnpairedCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonatorUnpaired()
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
void SetActions()
Определения AdvancedCommunication.c:213
class EconomyOutputStrings OFF
override void EEKilled(Object killer)
Определения ExplosivesBase.c:100
void ExplosivesBase()
Определения ExplosivesBase.c:42
const string COLOR_LED_OFF
Определения Land_Underground_Panel.c:21
void UpdateLED(string selection, string color)
Определения Land_Underground_Panel.c:331
string GetDebugText()
Определения ModifierBase.c:71
void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced=false)
Определения RemoteDetonator.c:20
RemoteDetonatorTrigger RemoteDetonator RemoteDetonatorReceiver()
Определения RemoteDetonator.c:227
bool IsKit()
Определения RemoteDetonator.c:15
ERemoteDetonatorLEDState m_LastLEDState
Определения RemoteDetonator.c:13
ERemoteDetonatorLEDState
Определения RemoteDetonator.c:2
@ LIT
Определения RemoteDetonator.c:4
const string COLOR_LED_LIT
Определения RemoteDetonator.c:10
override void OnWasDetached(EntityAI parent, int slot_id)
Определения RemoteDetonator.c:237
ref RemotelyActivatedItemBehaviour m_RAIB
Определения RemoteDetonator.c:231
const string SELECTION_NAME_LED
Определения RemoteDetonator.c:11
ReplaceDetonatorItemLambda ReplaceItemWithNewLambdaBase SetPairDevice(EntityAI device)
Определения RemoteDetonator.c:272
Определения Building.c:6
static int GetEnumSize(typename e)
Return amount of values in enum.
Определения EnConvert.c:623
Определения EnConvert.c:590
InventoryLocation.
Определения InventoryLocation.c:29
Определения InventoryItem.c:731
Определения EnMath.c:7
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения RemoteDetonator.c:82
override void SetActions()
Определения RemoteDetonator.c:202
EntityAI GetControlledDevice()
Определения RemoteDetonator.c:150
static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity, EntityAI deviceToPair=null)
Определения RemoteDetonator.c:155
override void OnActivatedByItem(notnull ItemBase item)
Определения RemoteDetonator.c:125
bool m_LED
Определения RemoteDetonator.c:50
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:92
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
override void OnCEUpdate()
Определения RemoteDetonator.c:97
override void OnAnimationPhaseStarted(string animSource, float phase)
Определения RemoteDetonator.c:191
override void UnpairRemote()
Определения RemoteDetonator.c:119
const string ANIM_PHASE_TRIGGER
Определения RemoteDetonator.c:48
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:53
ref RemotelyActivatedItemBehaviour m_RAIB
Определения RemoteDetonator.c:51
override bool IsKit()
Определения RemoteDetonator.c:65
override void PairRemote(notnull EntityAI trigger)
Определения RemoteDetonator.c:114
bool IsConnected()
Определения RemoteDetonator.c:145
override void OnVariablesSynchronized()
Определения RemoteDetonator.c:70
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Определения RemoteDetonator.c:260
override void OnSuccess(EntityAI new_item)
Определения RemoteDetonator.c:313
override void OnAbort()
Определения RemoteDetonator.c:331
void ReplaceItemWithNewLambdaBase(EntityAI old_item, string new_item_type)
Определения ReplaceItemWithNewLambdaBase.c:13
void OnAbort()
Step Out - notification on abort.
Определения ReplaceItemWithNewLambdaBase.c:226
void OnSuccess(EntityAI new_item)
Step H. - notification on finish.
Определения ReplaceItemWithNewLambdaBase.c:216
const float EXPLOSIVE_REMOTE_ACTIVATION
Определения ActionConstants.c:118
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
Определения EnConvert.c:106
proto native CGame GetGame()
static proto float SqrFloat(float f)
Returns squared value.
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.