DayZ 1.24
Loading...
Searching...
No Matches
RemoteDetonator.c File Reference

Go to the source code of this file.

Classes

class  RemoteDetonatorTrigger
 
class  ReplaceDetonatorItemLambda
 
class  ReplaceDetonatorItemOnDisarmLambda
 

Enumerations

enum  ERemoteDetonatorLEDState { OFF = 0 , LIT }
 

Functions

bool IsKit ()
 
void UpdateLED (ERemoteDetonatorLEDState pState, bool pForced=false)
 
override void SetActions ()
 
RemoteDetonatorTrigger RemoteDetonator RemoteDetonatorReceiver ()
 
void RemoteDetonatorTrigger ()
 
override void OnVariablesSynchronized ()
 
override void EEItemLocationChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
 
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour ()
 
override void OnCEUpdate ()
 
override void PairRemote (notnull EntityAI trigger)
 
override void UnpairRemote ()
 
override void OnActivatedByItem (notnull ItemBase item)
 Called when this item is activated by other.
 
void SetControlledDevice (EntityAI pDevice)
 
bool IsConnected ()
 
EntityAI GetControlledDevice ()
 
static RemoteDetonatorTrigger SpawnInPlayerHands (notnull EntityAI pEntity, EntityAI deviceToPair=null)
 
override void OnAnimationPhaseStarted (string animSource, float phase)
 
override void OnWasDetached (EntityAI parent, int slot_id)
 
override void EEKilled (Object killer)
 
ReplaceDetonatorItemLambda ReplaceItemWithNewLambdaBase SetPairDevice (EntityAI device)
 
override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
 
override void OnSuccess (EntityAI new_item)
 
override void OnAbort ()
 

Variables

enum ERemoteDetonatorLEDState COLOR_LED_OFF = "#(argb,8,8,3)color(0,0,0,1.0,co)"
 
const string COLOR_LED_LIT = "#(argb,8,8,3)color(1,0,0,1.0,co)"
 
const string SELECTION_NAME_LED = "LED"
 
ERemoteDetonatorLEDState m_LastLEDState
 
const string ANIM_PHASE_TRIGGER = "trigger"
 
bool m_LED
 
ref RemotelyActivatedItemBehaviour m_RAIB
 

Enumeration Type Documentation

◆ ERemoteDetonatorLEDState

Enumerator
OFF 
LIT 

Definition at line 1 of file RemoteDetonator.c.

2{
3 OFF = 0,
4 LIT,
5}
@ LIT
@ OFF

Function Documentation

◆ CopyOldPropertiesToNew()

override void SetPairDevice::CopyOldPropertiesToNew ( notnull EntityAI old_item,
EntityAI new_item )

Definition at line 265 of file RemoteDetonator.c.

265 {
266 m_PairDevice = device;
267 }
268
269 override void OnSuccess(EntityAI new_item)
270 {
override void OnSuccess(EntityAI new_item)

◆ EEItemLocationChanged()

override void RemoteDetonatorReceiver::EEItemLocationChanged ( notnull InventoryLocation oldLoc,
notnull InventoryLocation newLoc )
protected

Definition at line 252 of file RemoteDetonator.c.

253 {
254 super.CopyOldPropertiesToNew(old_item, new_item);
255
256 MiscGameplayFunctions.TransferItemProperties(old_item, new_item);
257 }
258}

◆ EEKilled()

override void EEKilled ( Object killer)
protected

Definition at line 234 of file RemoteDetonator.c.

235 {
236 super.EEKilled(killer);
237
239 }
void UpdateLED(ERemoteDetonatorLEDState pState, bool pForced=false)
ERemoteDetonatorLEDState

References UpdateLED().

◆ GetControlledDevice()

EntityAI RemoteDetonatorReceiver::GetControlledDevice ( )
protected

Definition at line 316 of file RemoteDetonator.c.

◆ GetRemotelyActivatedItemBehaviour()

override RemotelyActivatedItemBehaviour RemoteDetonatorReceiver::GetRemotelyActivatedItemBehaviour ( )
protected

◆ IsConnected()

bool RemoteDetonatorReceiver::IsConnected ( )
protected

Definition at line 311 of file RemoteDetonator.c.

311 {
312 if (detonator.GetRemotelyActivatedItemBehaviour())
313 {
314 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());

◆ IsKit()

override bool IsKit ( )
protected

Definition at line 15 of file RemoteDetonator.c.

16 {
17 return true;
18 }

◆ OnAbort()

override void OnAbort ( )
protected

Definition at line 292 of file RemoteDetonator.c.

293 {
294 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
295 if (explosive)
296 {
297 explosive.LockTriggerSlots();
298 explosive.SetTakeable(true);
299 }
300 }

◆ OnActivatedByItem()

override void OnActivatedByItem ( notnull ItemBase item)
protected

Called when this item is activated by other.

Definition at line 293 of file RemoteDetonator.c.

293 {
294 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
295 if (explosive)
296 {
297 explosive.LockTriggerSlots();
298 explosive.SetTakeable(true);
299 }
300 }
301}
302
304{

◆ OnAnimationPhaseStarted()

override void RemoteDetonatorReceiver::OnAnimationPhaseStarted ( string animSource,
float phase )
protected

Definition at line 357 of file RemoteDetonator.c.

358{
359 OFF = 0,
360 LIT,
361}
362
363class RemoteDetonator : Inventory_Base
364{
365 const string COLOR_LED_OFF = "#(argb,8,8,3)color(0,0,0,1.0,co)";
366 const string COLOR_LED_LIT = "#(argb,8,8,3)color(1,0,0,1.0,co)";
367 const string SELECTION_NAME_LED = "LED";
368
370
371 bool IsKit()
372 {
373 return true;
374 }
375
377 {
378 int selectionIdx = GetHiddenSelectionIndex(SELECTION_NAME_LED);
379
380 switch (pState)
381 {
383 SetObjectTexture(selectionIdx, COLOR_LED_LIT);
384 break;
385 default:
386 SetObjectTexture(selectionIdx, COLOR_LED_OFF);
387 }
388
390 SetSynchDirty();
391 }
392
393 override void SetActions()
394 {
395 super.SetActions();
396
399 }
400}
401
402class RemoteDetonatorTrigger : RemoteDetonator
403{
404 protected const string ANIM_PHASE_TRIGGER = "trigger";
405
406 protected bool m_LED;
408
410 {
412 m_RAIB.SetTrigger();
413
414 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdLow");
415 RegisterNetSyncVariableInt("m_RAIB.m_PairDeviceNetIdHigh");
416 RegisterNetSyncVariableInt("m_LastLEDState", 0, EnumTools.GetEnumSize(ERemoteDetonatorLEDState));
417
419 }
420
421 override bool IsKit()
422 {
423 return false;
424 }
425
426 override void OnVariablesSynchronized()
427 {
428 super.OnVariablesSynchronized();
429
430 if (m_RAIB)
431 m_RAIB.OnVariableSynchronized();
432
434 }
435
437 {
438 super.EEItemLocationChanged(oldLoc, newLoc);
439
440 if (m_RAIB)
441 m_RAIB.Pair();
442 }
443
445 {
446 return m_RAIB;
447 }
448
449 override void OnCEUpdate()
450 {
451 super.OnCEUpdate();
452
453 if (!IsRuined() && IsConnected() && GetControlledDevice())
454 {
456 {
458
459 return;
460 }
461 }
462
464 }
465
466 override void PairRemote(notnull EntityAI trigger)
467 {
468 m_RAIB.Pair(trigger);
469 }
470
471 override void UnpairRemote()
472 {
474 m_RAIB.Unpair();
475 }
476
478 {
479 if (GetGame().IsServer())
480 {
481 if (m_RAIB.IsPaired() && !IsRuined())
482 {
485 device.OnActivatedByItem(this);
486 }
487 }
488 }
489
491 {
492 m_RAIB.Pair(pDevice);
493 }
494
495 bool IsConnected()
496 {
497 return m_RAIB.IsPaired();
498 }
499
501 {
502 return m_RAIB.GetPairDevice();
503 }
504
506 {
507 string type = "RemoteDetonatorTrigger";
510 if (player)
511 {
512 ItemBase inHandsItem = player.GetItemInHands();
513 if (inHandsItem)
514 {
515 if (deviceToPair)
516 {
518 onArmLambda.SetPairDevice(deviceToPair);
519 MiscGameplayFunctions.TurnItemIntoItemEx(player, onArmLambda);
520 }
521 else
522 {
524 MiscGameplayFunctions.TurnItemIntoItemEx(player, lambda);
525 }
526
527
528 rdt = RemoteDetonatorTrigger.Cast(player.GetItemInHands());
529 }
530 else
531 rdt = RemoteDetonatorTrigger.Cast(player.GetHumanInventory().CreateInHands(type));
532
534 if (player.GetItemInHands())
535 player.GetItemAccessor().OnItemInHandsChanged();
536 }
537
538 return rdt;
539 }
540
541 override void OnAnimationPhaseStarted(string animSource, float phase)
542 {
544 {
545 if (phase > 0.01)
547 }
548 }
549
550 override void SetActions()
551 {
552 super.SetActions();
553
555
559 }
560
561#ifdef DIAG_DEVELOPER
562 override protected string GetDebugText()
563 {
564 string debug_output;
565 debug_output += string.Format("low net id: %1\n", m_RAIB.GetPairDeviceNetIdLow());
566 debug_output += string.Format("high net id: %1\n", m_RAIB.GetPairDeviceNetIdHigh());
567 debug_output += string.Format("pair device: %1\n", m_RAIB.GetPairDevice());
568 return debug_output;
569 }
570#endif
571}
572
573class RemoteDetonatorReceiver : RemoteDetonator
574{
576 {
578 }
579
580 override bool IsKit()
581 {
582 return false;
583 }
584
585 override void OnWasDetached(EntityAI parent, int slot_id)
586 {
588 }
589
590 override void EEKilled(Object killer)
591 {
592 super.EEKilled(killer);
593
595 }
596
597 override void SetActions()
598 {
599 super.SetActions();
600
603 }
604}
605
607{
609 {
610 super.CopyOldPropertiesToNew(old_item, new_item);
611
612 MiscGameplayFunctions.TransferItemProperties(old_item, new_item);
613 }
614}
615
617{
618 EntityAI m_PairDevice
619
621 {
622 m_PairDevice = device;
623 }
624
625 override void OnSuccess(EntityAI new_item)
626 {
627 super.OnSuccess(new_item);
628
629 RemoteDetonator detonator = RemoteDetonator.Cast(new_item);
630 if (detonator)
631 {
632 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
633 if (explosive)
634 {
635 ItemBase receiver = ItemBase.Cast(explosive.GetInventory().CreateAttachment("RemoteDetonatorReceiver"));
636 if (receiver)
637 {
638 MiscGameplayFunctions.TransferItemProperties(detonator, receiver);
639 receiver.LockToParent();
640 explosive.SetTakeable(false);
641 explosive.PairWithDevice(detonator);
642 explosive.Arm();
643 }
644 }
645 }
646 }
647
648 override void OnAbort()
649 {
650 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
651 if (explosive)
652 {
653 explosive.LockTriggerSlots();
654 explosive.SetTakeable(true);
655 }
656 }
657}
658
660{
661 override void OnSuccess(EntityAI new_item)
662 {
663 super.OnSuccess(new_item);
664
665 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);
666 if (detonator)
667 {
668 if (detonator.GetRemotelyActivatedItemBehaviour())
669 {
670 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());
671 if (explosive)
672 explosive.Disarm();
673 }
674 }
675 }
676
677 override void OnAbort()
678 {
679 super.OnAbort();
680
681 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);
682 if (detonator)
683 {
684 if (detonator.GetRemotelyActivatedItemBehaviour())
685 {
686 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());
687 if (explosive)
688 explosive.LockExplosivesSlots();
689 }
690 }
691 }
692}
ActionAttachExplosivesTriggerCB ActionContinuousBaseCB ActionAttachExplosivesTrigger()
ActionDisarmExplosiveWithRemoteDetonatorCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonator()
ActionDisarmExplosiveWithRemoteDetonatorUnpairedCB ActionDisarmExplosiveCB ActionDisarmExplosiveWithRemoteDetonatorUnpaired()
override void OnSuccess(EntityAI new_item)
void AddAction(typename actionName)
void RemoveAction(typename actionName)
void SetActions()
override void EEKilled(Object killer)
const string COLOR_LED_OFF
void UpdateLED(string selection, string color)
string GetDebugText()
RemoteDetonatorTrigger RemoteDetonator RemoteDetonatorReceiver()
bool IsKit()
ERemoteDetonatorLEDState m_LastLEDState
override void OnAbort()
const string COLOR_LED_LIT
override void OnWasDetached(EntityAI parent, int slot_id)
const string SELECTION_NAME_LED
ReplaceDetonatorItemLambda ReplaceItemWithNewLambdaBase SetPairDevice(EntityAI device)
class JsonUndergroundAreaTriggerData GetPosition
static int GetEnumSize(typename e)
Return amount of values in enum.
Definition EnConvert.c:620
InventoryLocation.
Definition EnMath.c:7
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
override void SetActions()
static RemoteDetonatorTrigger SpawnInPlayerHands(notnull EntityAI pEntity, EntityAI deviceToPair=null)
override void OnActivatedByItem(notnull ItemBase item)
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
void SetControlledDevice(EntityAI pDevice)
override void OnCEUpdate()
override void OnAnimationPhaseStarted(string animSource, float phase)
override void UnpairRemote()
const string ANIM_PHASE_TRIGGER
ref RemotelyActivatedItemBehaviour m_RAIB
override void PairRemote(notnull EntityAI trigger)
override void OnVariablesSynchronized()
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
override void OnSuccess(EntityAI new_item)
base class for transformation operations (creating one item from another)
const float EXPLOSIVE_REMOTE_ACTIVATION
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto native CGame GetGame()
static proto float SqrFloat(float f)
Returns squared value.

◆ OnCEUpdate()

override void RemoteDetonatorReceiver::OnCEUpdate ( )
protected

Definition at line 265 of file RemoteDetonator.c.

265 {
266 m_PairDevice = device;
267 }
268
269 override void OnSuccess(EntityAI new_item)
270 {
271 super.OnSuccess(new_item);
272
273 RemoteDetonator detonator = RemoteDetonator.Cast(new_item);
274 if (detonator)
275 {
276 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
277 if (explosive)
278 {
279 ItemBase receiver = ItemBase.Cast(explosive.GetInventory().CreateAttachment("RemoteDetonatorReceiver"));
280 if (receiver)

◆ OnSuccess()

override void OnSuccess ( EntityAI new_item)
protected

Definition at line 269 of file RemoteDetonator.c.

270 {
271 super.OnSuccess(new_item);
272
273 RemoteDetonator detonator = RemoteDetonator.Cast(new_item);
274 if (detonator)
275 {
276 ExplosivesBase explosive = ExplosivesBase.Cast(m_PairDevice);
277 if (explosive)
278 {
279 ItemBase receiver = ItemBase.Cast(explosive.GetInventory().CreateAttachment("RemoteDetonatorReceiver"));
280 if (receiver)
281 {
282 MiscGameplayFunctions.TransferItemProperties(detonator, receiver);
283 receiver.LockToParent();
284 explosive.SetTakeable(false);
285 explosive.PairWithDevice(detonator);
286 explosive.Arm();
287 }
288 }
289 }
290 }

◆ OnVariablesSynchronized()

◆ OnWasDetached()

override void OnWasDetached ( EntityAI parent,
int slot_id )
protected

Definition at line 229 of file RemoteDetonator.c.

230 {
232 }

References UpdateLED().

Referenced by Entity::EEItemLocationChanged().

◆ PairRemote()

override void RemoteDetonatorReceiver::PairRemote ( notnull EntityAI trigger)
protected

Definition at line 282 of file RemoteDetonator.c.

◆ RemoteDetonatorReceiver()

◆ RemoteDetonatorTrigger()

void RemoteDetonatorReceiver::RemoteDetonatorTrigger ( )
protected

Definition at line 225 of file RemoteDetonator.c.

225 {
226 return false;
227 }
228
229 override void OnWasDetached(EntityAI parent, int slot_id)
230 {
232 }
233
234 override void EEKilled(Object killer)
235 {
override void EEKilled(Object killer)

◆ SetActions()

override void SetActions ( )
protected

◆ SetControlledDevice()

void RemoteDetonatorReceiver::SetControlledDevice ( EntityAI pDevice)
protected

Definition at line 306 of file RemoteDetonator.c.

306 {
307 super.OnSuccess(new_item);
308
309 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);

References ReplaceItemWithNewLambdaBase::m_OldItem.

◆ SetPairDevice()

Definition at line 241 of file RemoteDetonator.c.

265 {
266 m_PairDevice = device;
267 }

Referenced by GetRemotelyActivatedItemBehaviour().

◆ SpawnInPlayerHands()

static RemoteDetonatorTrigger RemoteDetonatorReceiver::SpawnInPlayerHands ( notnull EntityAI pEntity,
EntityAI deviceToPair = null )
staticprotected

item replaced, use different IK

Definition at line 321 of file RemoteDetonator.c.

322 {
323 super.OnAbort();
324
325 RemoteDetonator detonator = RemoteDetonator.Cast(m_OldItem);
326 if (detonator)
327 {
328 if (detonator.GetRemotelyActivatedItemBehaviour())
329 {
330 ExplosivesBase explosive = ExplosivesBase.Cast(detonator.GetRemotelyActivatedItemBehaviour().GetPairDevice());
331 if (explosive)
332 explosive.LockExplosivesSlots();
333 }
334 }
335 }
336}

◆ UnpairRemote()

override void RemoteDetonatorReceiver::UnpairRemote ( )
protected

Definition at line 287 of file RemoteDetonator.c.

◆ UpdateLED()

void UpdateLED ( ERemoteDetonatorLEDState pState,
bool pForced = false )
protected

Definition at line 20 of file RemoteDetonator.c.

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
34 SetSynchDirty();
35 }
enum ERemoteDetonatorLEDState COLOR_LED_OFF

References COLOR_LED_LIT, COLOR_LED_OFF, m_LastLEDState, and SELECTION_NAME_LED.

Referenced by RemoteDetonatorTrigger::OnAnimationPhaseStarted(), RemoteDetonatorTrigger::OnCEUpdate(), RemoteDetonatorTrigger::OnVariablesSynchronized(), RemoteDetonatorTrigger::RemoteDetonatorTrigger(), and RemoteDetonatorTrigger::UnpairRemote().

Variable Documentation

◆ ANIM_PHASE_TRIGGER

const string ANIM_PHASE_TRIGGER = "trigger"
protected

Definition at line 220 of file RemoteDetonator.c.

◆ COLOR_LED_LIT

const string COLOR_LED_LIT = "#(argb,8,8,3)color(1,0,0,1.0,co)"

Definition at line 10 of file RemoteDetonator.c.

Referenced by UpdateLED().

◆ COLOR_LED_OFF

enum ERemoteDetonatorLEDState COLOR_LED_OFF = "#(argb,8,8,3)color(0,0,0,1.0,co)"

◆ m_LastLEDState

◆ m_LED

bool m_LED
protected

Definition at line 222 of file RemoteDetonator.c.

◆ m_RAIB

Definition at line 223 of file RemoteDetonator.c.

◆ SELECTION_NAME_LED

const string SELECTION_NAME_LED = "LED"

Definition at line 11 of file RemoteDetonator.c.

Referenced by UpdateLED().