Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_VONController.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
10
11//------------------------------------------------------------------------------------------------
12// invoker typedefs
13void OnVONActiveToggled(bool isToggledDirect, bool isToggledChannel); // when direct toggle activates
15
16void OnEntriesChanged(SCR_VONEntry entry, bool state);
18
19//------------------------------------------------------------------------------------------------
22
23//------------------------------------------------------------------------------------------------
25class SCR_VONController : ScriptComponent
26{
27 protected const string VON_MENU_OPENING_CONTEXT = "VONMenuOpeningContext";
28
29 [Attribute("", UIWidgets.Object)]
30 protected ref SCR_VONMenu m_VONMenu;
31
32 [Attribute()]
34
35 bool m_bIsEditorRadioAdded; // True if editor radio transceivers are added to m_aEntries
36
37 protected const string VON_CONTEXT = "VONContext";
38 protected const string ACTION_DIRECT = "VONDirect";
39 protected const string ACTION_DIRECT_TOGGLE = "VONDirectToggle";
40 protected const string ACTION_CHANNEL = "VONChannel";
41 protected const string ACTION_TRANSCEIVER_CYCLE = "VONTransceiverCycle";
42 protected const string ACTION_LONG_RANGE_TOGGLE = "VONLongRangeToggle";
43
44 protected const float TOGGLE_OFF_DELAY = 0.5; // seconds, delay before toggle state can get canceled, to avoid collision of double click and press
45
46 protected static bool s_bUnconsciousVONPermitted = true;
47 protected static bool s_bIsInit; // component init done, static so its only done once
48 protected bool m_bIsDisabled; // VON control is disabled
49 protected bool m_bIsPauseDisabled; // disabled by pause menu
50 protected bool m_bIsUnconscious; // Character is unconscious --> VON control is disabled
51 protected ECharacterLifeState m_eLifeState; // Life state of controlled character
52 protected bool m_bIsActive; // VON is active
53 protected bool m_bIsToggledDirect; // VON direct speech toggle is active
54 protected bool m_bIsLongRangeToggled; // VON long range radio is selected
55 protected float m_fToggleOffDelay; // used to track delay before toggle can be cancelled
56 protected string m_sActiveHoldAction; // tracker for ending the hold action VON
57 protected string m_sLocalEncryptionKey; // local players faction encryption key
58 protected EVONTransmitType m_eVONType; // currently active VON type
60
61 protected SCR_VoNComponent m_VONComp; // VON component used for transmission
62 protected SCR_VonDisplay m_VONDisplay; // VON transmission display
63 protected SCR_VONEntry m_ActiveEntry; // active entry (non direct speech)
64 protected SCR_VONEntry m_LongRangeEntry; // entry for long range radio, if available
65 protected SCR_VONEntry m_SavedEntry; // entry used for switching to different active entry after current one is done, f.e. after VONLongRange
66 protected ref SCR_VONEntry m_DirectSpeechEntry; // separate direct speech entry
67 protected ref array<ref SCR_VONEntry> m_aEntries = {}; // all entries except direct
68
69
70 protected ref ScriptInvokerBase<OnEntriesChanged> m_OnEntriesChanged = new ScriptInvokerBase<OnEntriesChanged>(); // when entry array is modified (SCR_VONEntry entry, bool isAdded)
71 protected ref ScriptInvokerBase<OnEntriesChanged> m_OnEntriesActiveChanged = new ScriptInvokerBase<OnEntriesChanged>(); // when entry array is modified (SCR_VONEntry entry, bool isActive)
72 protected ref ScriptInvokerBase<OnVONActiveToggled> m_OnVONActiveToggled = new ScriptInvokerBase<OnVONActiveToggled>(); // when direct toggle activates (bool isToggledDirect, bool isToggledChannel)
73
74 //------------------------------------------------------------------------------------------------
75 ScriptInvokerBase<OnEntriesChanged> GetOnEntriesChangedInvoker()
76 {
77 return m_OnEntriesChanged;
78 }
79
80 //------------------------------------------------------------------------------------------------
81 ScriptInvokerBase<OnEntriesChanged> GetOnEntriesActiveChangedInvoker()
82 {
84 }
85
86 //------------------------------------------------------------------------------------------------
87 ScriptInvokerBase<OnVONActiveToggled> GetOnVONActiveToggledInvoker()
88 {
90 }
91
92 //------------------------------------------------------------------------------------------------
93 void SetDisplay(SCR_VonDisplay display)
94 {
95 m_VONDisplay = display;
96 }
97
98 //------------------------------------------------------------------------------------------------
99 SCR_VonDisplay GetDisplay()
100 {
101 return m_VONDisplay;
102 }
103
104 //------------------------------------------------------------------------------------------------
106 {
107 return m_VONMenu;
108 }
109
110 //------------------------------------------------------------------------------------------------
114 bool SetVONDisabled(bool state)
115 {
116 if (m_bIsDisabled == state)
117 return false;
118
119 m_bIsDisabled = state;
121 return true;
122 }
123
124 //------------------------------------------------------------------------------------------------
127 {
128 return m_bIsDisabled;
129 }
130
131 //------------------------------------------------------------------------------------------------
133 SCR_VoNComponent GetVONComponent()
134 {
135 return m_VONComp;
136 }
137
138 //------------------------------------------------------------------------------------------------
141 void SetVONComponent(SCR_VoNComponent VONComp)
142 {
143 m_VONComp = VONComp;
144 }
145
146
147 //------------------------------------------------------------------------------------------------
150 int GetVONEntries(inout array<ref SCR_VONEntry> entries)
151 {
152 int count = m_aEntries.Count();
153 for (int i = 0; i < count; i++)
154 {
155 entries.Insert(m_aEntries[i]);
156 }
157
158 return count;
159 }
160
161 //------------------------------------------------------------------------------------------------
164 {
165 return m_aEntries.Count();
166 }
167
168 //------------------------------------------------------------------------------------------------
172 {
173 return m_ActiveEntry;
174 }
175
176 //------------------------------------------------------------------------------------------------
179 {
180 if (!m_ActiveEntry)
181 return false;
182
184 }
185
186 //------------------------------------------------------------------------------------------------
189 {
190 return m_LongRangeEntry != null;
191 }
192
193 //------------------------------------------------------------------------------------------------
197 void SetEntryActive(SCR_VONEntry entry, bool setFromMenu = false)
198 {
199 if (entry == m_ActiveEntry)
200 return;
201
202 if (m_ActiveEntry)
203 {
205 m_ActiveEntry.SetActive(false);
206 }
207
208 entry.SetActive(true);
209 m_ActiveEntry = entry;
210 m_OnEntriesActiveChanged.Invoke(entry, true);
211
212 if (m_ActiveEntry && !m_ActiveEntry.IsUsable()) // turn off toggle when switching to disabled entry
214
215 if (m_VONDisplay)
216 m_VONDisplay.ShowSelectedVONHint(m_ActiveEntry);
217
218 SCR_VONEntryRadio radioEntry = SCR_VONEntryRadio.Cast(entry);
219 if (radioEntry)
220 {
222 SetVONLongRange(radioEntry.IsLongRange(), false);
223 }
224 }
225
226 //------------------------------------------------------------------------------------------------
231 {
232 m_aEntries.Insert(entry);
233 entry.InitEntry();
234
235 if (SCR_VONEntryRadio.Cast(entry) && SCR_VONEntryRadio.Cast(entry).IsLongRange()) // if long range entry, set it here
236 m_LongRangeEntry = entry;
237
238 m_OnEntriesChanged.Invoke(entry, true);
239
240 if (!m_ActiveEntry)
241 SetEntryActive(entry);
242 }
243
244 //------------------------------------------------------------------------------------------------
249 {
250 m_OnEntriesChanged.Invoke(entry, false);
251
252 //Deactivate if the entry being removed is active
253 if (entry == m_ActiveEntry)
254 {
256
257 m_ActiveEntry = null;
258 }
259
260 if (entry == m_LongRangeEntry) // unset long range entry
261 m_LongRangeEntry = null;
262
263 if (m_VONMenu)
264 {
265 SCR_RadialMenu vonRadial = m_VONMenu.GetRadialMenu();
266 if (vonRadial && vonRadial.IsOpened())
267 vonRadial.Close();
268 }
269
270 m_aEntries.RemoveItem(entry);
271 }
272
273 //------------------------------------------------------------------------------------------------
277 {
278 foreach (SCR_VONEntry entry : m_aEntries)
279 {
280 SCR_VONEntryRadio radioEntry = SCR_VONEntryRadio.Cast(entry);
281 if (!radioEntry || radioEntry.GetIsMuted())
282 continue;
283
284 SetEntryActive(entry, true);
285
286 bool longRange = radioEntry.IsLongRange();
287 if (longRange)
288 {
289 return EVONTransmitType.LONG_RANGE;
290 }
291 else
292 {
293 return EVONTransmitType.CHANNEL;
294 }
295 }
296
297 return EVONTransmitType.NONE;
298 }
299
300 //------------------------------------------------------------------------------------------------
301 protected void SetVONProximity(bool activate)
302 {
303 if (!m_VONComp)
304 return;
305
306 if (!m_DirectSpeechEntry.IsUsable())
307 return;
308
309 if (activate && m_eVONType == EVONTransmitType.DIRECT)
310 return;
311
312 if (activate)
314 else
316 }
317
318 //------------------------------------------------------------------------------------------------
319 protected void SetVONProximityToggle(bool activate)
320 {
321 if (!m_VONComp)
322 return;
323
324 if (!m_DirectSpeechEntry.IsUsable())
325 return;
326
327 if (m_bIsToggledDirect == activate)
328 return;
329
330 m_bIsToggledDirect = activate;
331
332 if (activate)
334 else
336
338 }
339
340 //------------------------------------------------------------------------------------------------
341 protected void SetVONBroadcast(bool activate, EVONTransmitType transmitType = EVONTransmitType.CHANNEL)
342 {
343 if (!m_VONComp)
344 return;
345
346 // If active entry is null, attempt to select another.
347 if (!m_ActiveEntry)
348 transmitType = SelectFirstUnmutedEntry();
349
350 // if active entry disabled or character is incapacitated, use direct instead
351 if (m_eLifeState != ECharacterLifeState.ALIVE || !m_ActiveEntry || !m_ActiveEntry.IsUsable())
352 {
353 SetVONProximity(activate && !m_bIsUnconscious);
354
355 if (m_VONDisplay)
356 m_VONDisplay.ShowSelectedVONDisabledHint();
357
358 return;
359 }
360
361 if (activate)
362 ActivateVON(transmitType);
363 else
364 DeactivateVON(transmitType);
365 }
366
367 //------------------------------------------------------------------------------------------------
368 protected void SetVONLongRange(bool longRange, bool restorePrevious = true)
369 {
370 if (m_bIsLongRangeToggled == longRange)
371 return;
372
373 if (!m_LongRangeEntry || !m_LongRangeEntry.IsUsable())
374 return;
375
376 m_bIsLongRangeToggled = longRange;
377
378 if (longRange)
379 {
380 // saved entry to switch back to after using long range mode
383
385
386 if (m_VONDisplay)
387 m_VONDisplay.ShowSelectedVONHint(m_LongRangeEntry);
388 }
389 else
390 {
391 // restore last saved entry
392 if (restorePrevious)
393 {
394 if (!m_SavedEntry)
395 {
396 // Select first non-longrange entry
397 SCR_VONEntryRadio radioEntry;
398 foreach (SCR_VONEntry entry : m_aEntries)
399 {
400 radioEntry = SCR_VONEntryRadio.Cast(entry);
401 if (radioEntry && !radioEntry.IsLongRange())
402 {
403 m_SavedEntry = entry;
404 break;
405 }
406 }
407 }
408
409 if (m_VONDisplay)
410 m_VONDisplay.ShowSelectedVONHint(m_SavedEntry);
411
413 }
414 }
415
417 }
418
419 //------------------------------------------------------------------------------------------------
420 protected void ActionVONProximity(float value, EActionTrigger reason = EActionTrigger.UP)
421 {
422 if (!m_VONComp)
423 return;
424
425 bool activate = reason != EActionTrigger.UP;
426
427 // Cancel toggle
428 if (activate && m_bIsToggledDirect && m_fToggleOffDelay <= 0)
430
432
433 if (reason != EActionTrigger.UP)
435 }
436
437 //------------------------------------------------------------------------------------------------
439 {
440 if (!m_VONComp)
441 return;
442
444
447 }
448
449 //------------------------------------------------------------------------------------------------
450 protected void ActionVONBroadcast(float value, EActionTrigger reason = EActionTrigger.UP)
451 {
452 if (!m_VONComp)
453 return;
454
455 EVONTransmitType transmitType;
456
458 transmitType = EVONTransmitType.LONG_RANGE;
459 else
460 transmitType = EVONTransmitType.CHANNEL;
461
462 if (reason != EActionTrigger.UP && m_eVONType == transmitType)
463 return;
464
465 SetVONBroadcast(reason != EActionTrigger.UP, transmitType);
466
467 if (reason != EActionTrigger.UP)
469 }
470
471 //------------------------------------------------------------------------------------------------
473 {
475 }
476
477 //------------------------------------------------------------------------------------------------
478 protected void TransceiverCycle()
479 {
480 SCR_VONEntryRadio activeRadioEntry = SCR_VONEntryRadio.Cast(m_ActiveEntry);
481 if (!activeRadioEntry)
482 return;
483
484 bool isLongRange = activeRadioEntry.IsLongRange();
485
486 BaseRadioComponent radio = activeRadioEntry.GetTransceiver().GetRadio();
487 array<SCR_VONEntry> entries = {};
488
489 SCR_VONEntryRadio radioEntry;
490 foreach (SCR_VONEntry entry : m_aEntries)
491 {
492 radioEntry = SCR_VONEntryRadio.Cast(entry);
493 if (radioEntry && radioEntry.GetTransceiver().GetRadio() == radio)
494 entries.Insert(entry);
495 }
496
497 SCR_VONEntry newEntry = m_ActiveEntry;
498
499 if (!entries.IsEmpty())
500 {
501 int nextEntryID = (entries.Find(m_ActiveEntry) + 1) % entries.Count();
502 newEntry = entries[nextEntryID];
503
504 if (newEntry != m_ActiveEntry && m_eVONType != EVONTransmitType.DIRECT)
506 }
507
508 if (!ActivateVON(newEntry))
509 return;
510
511 if (m_VONDisplay)
512 m_VONDisplay.ShowSelectedVONHint(newEntry);
513 }
514
515 //------------------------------------------------------------------------------------------------
520
521 //------------------------------------------------------------------------------------------------
524 protected void ActivateVON(EVONTransmitType transmitType)
525 {
526 SCR_VONEntry entry = GetEntryByTransmitType(transmitType);
527 if (!entry)
528 return;
529
530 ActivateVON(entry, transmitType);
531 }
532
533 //------------------------------------------------------------------------------------------------
538 protected bool ActivateVON(notnull SCR_VONEntry entry, EVONTransmitType transmitType = EVONTransmitType.NONE)
539 {
540 if (!m_VONComp)
541 return false;
542
543 if (transmitType == EVONTransmitType.NONE)
544 {
545 if (entry.GetVONMethod() == ECommMethod.SQUAD_RADIO)
546 transmitType = EVONTransmitType.CHANNEL;
547 else
548 transmitType = EVONTransmitType.DIRECT;
549 }
550
551 m_eVONType = transmitType;
552 if (transmitType != EVONTransmitType.DIRECT && !GetGame().GetVONCanTransmitCrossFaction() && !SCR_Global.IsAdmin()) // is cross faction transmit disabled
553 {
555
556 SCR_VONEntryRadio radioEntry = SCR_VONEntryRadio.Cast(entry);
557 if (radioEntry && m_sLocalEncryptionKey != string.Empty && radioEntry.GetTransceiver().GetRadio().GetEncryptionKey() != m_sLocalEncryptionKey)
558 {
559 SetVONProximity(true);
560 if (m_VONDisplay)
561 m_VONDisplay.ShowSelectedVONDisabledHint(true);
562
563 return false;
564 }
565 }
566
567 SetActiveTransmit(entry);
568 m_VONComp.SetCapture(true);
569 m_bIsActive = true;
570 return true;
571 }
572
573 //------------------------------------------------------------------------------------------------
575 protected void DeactivateVON(EVONTransmitType transmitType = EVONTransmitType.NONE)
576 {
577 if (!m_VONComp)
578 return;
579
580 if (transmitType != EVONTransmitType.NONE && transmitType != m_eVONType) // only deactivate target type, in case other type was activated already
581 return;
582
584 m_bIsActive = false;
585 m_VONComp.SetCapture(false);
586 m_sActiveHoldAction = string.Empty;
587
588 // direct toggle is active so ending VON should not end capture
591 }
592
593 //------------------------------------------------------------------------------------------------
595 {
596 switch (type)
597 {
598 case EVONTransmitType.CHANNEL:
599 return m_ActiveEntry;
600
601 case EVONTransmitType.LONG_RANGE:
602 return m_LongRangeEntry;
603
604 default:
605 return m_DirectSpeechEntry;
606 }
607
608 return null;
609 }
610
611 //------------------------------------------------------------------------------------------------
613 protected void SetActiveTransmit(notnull SCR_VONEntry entry)
614 {
615 if (entry.GetVONMethod() == ECommMethod.SQUAD_RADIO)
616 {
617 m_VONComp.SetCommMethod(ECommMethod.SQUAD_RADIO);
618 m_VONComp.SetTransmitRadio(SCR_VONEntryRadio.Cast(entry).GetTransceiver());
619 SetEntryActive(entry);
620 }
621 else
622 {
623 m_VONComp.SetCommMethod(ECommMethod.DIRECT);
624 m_VONComp.SetTransmitRadio(null);
625 }
626
627 if (entry == m_SavedEntry)
628 m_SavedEntry = null;
629 }
630
631 //------------------------------------------------------------------------------------------------
634 void SetActiveChannel(int channelId)
635 {
636 Rpc(RpcAsk_SetActiveChannel, channelId);
637 }
638
639 //------------------------------------------------------------------------------------------------
640 [RplRpc(RplChannel.Reliable, RplRcver.Owner)]
641 protected void RpcAsk_SetActiveChannel(int channelId)
642 {
643 if (!m_aEntries.IsIndexValid(channelId))
644 return;
645
646 SetEntryActive(m_aEntries.Get(channelId));
647 }
648
649 //------------------------------------------------------------------------------------------------
650 // Reset VON input states and stop transmission
651 protected void ResetVON()
652 {
654 SetVONLongRange(false, false);
656 }
657
658 //------------------------------------------------------------------------------------------------
662 {
663 ResetVON();
664
665 m_sLocalEncryptionKey = string.Empty;
666
667 if (to)
668 {
669 // Only set new VONComponent if the player is not an active edtior, otherwise the SCR_EditorManagerEntity will take care of this.
670 if (!m_VONComp || !m_VONComp.IsLocalActiveEditor())
671 SetVONComponent(SCR_VoNComponent.Cast(to.FindComponent(SCR_VoNComponent)));
672 }
673 else
674 SetVONComponent(null);
675
676 ChimeraCharacter previous = ChimeraCharacter.Cast(from);
677 if (previous)
678 {
679 SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(previous.GetCharacterController());
680 if (controller)
681 controller.m_OnLifeStateChanged.Remove(OnLifeStateChanged);
682 }
683
684 ChimeraCharacter character = ChimeraCharacter.Cast(to);
685 if (character)
686 {
687 SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
688 if (controller)
689 {
690 ECharacterLifeState lifeState = controller.GetLifeState();
691 OnLifeStateChanged(lifeState, lifeState);
692 controller.m_OnLifeStateChanged.Insert(OnLifeStateChanged);
693 }
694 }
695
697 }
698
699 //------------------------------------------------------------------------------------------------
702 protected void OnPlayerDeleted(int playerId, IEntity player)
703 {
704 if (playerId != GetGame().GetPlayerController().GetPlayerId())
705 return;
706
707 ResetVON();
708
709 m_ActiveEntry = null;
710 m_LongRangeEntry = null;
711
712 m_aEntries.Clear();
713 }
714
715 //------------------------------------------------------------------------------------------------
717 protected void OnPauseMenuOpened()
718 {
719 if (SetVONDisabled(true))
720 m_bIsPauseDisabled = true;
721 }
722
723 //------------------------------------------------------------------------------------------------
725 protected void OnPauseMenuClosed()
726 {
728 SetVONDisabled(false);
729
730 m_bIsPauseDisabled = false;
731 }
732
733 //------------------------------------------------------------------------------------------------
736 {
737 IEntity controlledEnt = SCR_PlayerController.Cast(GetOwner()).GetControlledEntity();
738 if (controlledEnt)
739 SetVONComponent(SCR_VoNComponent.Cast(controlledEnt.FindComponent(SCR_VoNComponent)));
740
741 if(!m_VONComp)
742 return false;
743
744 return true;
745 }
746
747 //------------------------------------------------------------------------------------------------
748 protected void OnLifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
749 {
750 UpdateUnconsciousVONPermitted();
751
752 m_eLifeState = newLifeState;
753
754 if (s_bUnconsciousVONPermitted)
756 else
758
760 {
761 // Who has died, does not live. - Franz
764 }
765 else if (m_eLifeState == ECharacterLifeState.INCAPACITATED)
766 {
767 // allow proximity voice chat if incapacitated
768 if (m_eVONType != EVONTransmitType.DIRECT)
770 }
771
773 }
774
775 //------------------------------------------------------------------------------------------------
776 static void UpdateUnconsciousVONPermitted()
777 {
778 SCR_BaseGameMode gameMode = SCR_BaseGameMode.Cast(GetGame().GetGameMode());
779 if (!gameMode)
780 return;
781
782 SCR_GameModeHealthSettings healthSettings = gameMode.GetGameModeHealthSettings();
783 if (healthSettings)
784 s_bUnconsciousVONPermitted = healthSettings.IsUnconsciousVONPermitted();
785 }
786
787 //------------------------------------------------------------------------------------------------
788 protected void InitEncryptionKey()
789 {
790 SCR_FactionManager fManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
791 if (fManager)
792 {
793 SCR_Faction faction = SCR_Faction.Cast(fManager.GetLocalPlayerFaction());
794 if (faction)
795 m_sLocalEncryptionKey = faction.GetFactionRadioEncryptionKey();
796 }
797 }
798
799 //------------------------------------------------------------------------------------------------
801 protected void Init(IEntity owner)
802 {
803 if (s_bIsInit || System.IsConsoleApp()) // hosted server will have multiple controllers, init just the first one // dont init on dedicated server
804 {
805 Deactivate(owner);
806 return;
807 }
808
809 UpdateUnconsciousVONPermitted();
810
811 m_InputManager = GetGame().GetInputManager();
812 if (m_InputManager)
813 {
821 }
822
823 SCR_PlayerController playerController = SCR_PlayerController.Cast(GetOwner());
824 if (playerController)
825 {
826 OnControlledEntityChanged(null, playerController.GetControlledEntity());
828 }
829
832
834 if (gameMode)
835 gameMode.GetOnPlayerDeleted().Insert(OnPlayerDeleted);
836
837 m_DirectSpeechEntry = new SCR_VONEntry(); // Init direct speech entry
838
840
841 s_bIsInit = true;
842
843 if (m_VONMenu)
844 m_VONMenu.Init(this);
845
846 if (m_VONAutoTune)
847 m_VONAutoTune.Init(owner, this);
848
850 }
851
852 //------------------------------------------------------------------------------------------------
854 protected void Cleanup()
855 {
856 m_VONMenu = null;
857
859
860 m_InputManager = GetGame().GetInputManager();
861 if (m_InputManager)
862 {
870 }
871
872 IEntity ent = PlayerController.Cast(GetOwner()).GetControlledEntity();
873 if (ent)
874 {
875 ChimeraCharacter character = ChimeraCharacter.Cast(ent);
876 if (character)
877 {
878 SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
879 if (controller)
880 controller.m_OnLifeStateChanged.Remove(OnLifeStateChanged);
881 }
882 }
883
885 if (gameMode)
886 gameMode.GetOnPlayerDeleted().Remove(OnPlayerDeleted);
887 }
888
889 //------------------------------------------------------------------------------------------------
891 protected void UpdateDebug()
892 {
893 DbgUI.Begin("VON debug");
894 const string dbg = "VONcomp: %1 | entries: %2";
895 DbgUI.Text( string.Format( dbg, m_VONComp, m_aEntries.Count() ) );
896 const string dbg2 = "Direct mode: %1 | LRR mode: %2";
897 DbgUI.Text( string.Format( dbg2, m_bIsToggledDirect, m_bIsLongRangeToggled ) );
898 const string dbg3 = "Activ: %1";
899 DbgUI.Text( string.Format( dbg3, m_ActiveEntry ) );
900 const string dbg4 = "LRRad: %1";
901 DbgUI.Text( string.Format( dbg4, m_LongRangeEntry ) );
902 const string dbg5 = "Saved: %1";
903 DbgUI.Text( string.Format( dbg5, m_SavedEntry ) );
904
905 const string line = "freq: %2 | active: %3 | class: %4 | type: %1 ";
906 foreach ( SCR_VONEntry entry : m_aEntries )
907 {
908 SCR_VONEntryRadio radio = SCR_VONEntryRadio.Cast(entry);
909 DbgUI.Text( string.Format( line, SCR_Enum.GetEnumName(EGadgetType, radio.GetGadget().GetType()), radio.GetEntryFrequency(), radio.IsActive(), radio.ToString()));
910 }
911
912 DbgUI.End();
913 }
914
915 //------------------------------------------------------------------------------------------------
916 override protected void OnPostInit(IEntity owner)
917 {
918 Init(owner);
919 }
920
921 //------------------------------------------------------------------------------------------------
922 override protected void EOnDeactivate(IEntity owner)
923 {
924 Cleanup();
925 }
926
927 //------------------------------------------------------------------------------------------------
935
936 //------------------------------------------------------------------------------------------------
938 {
939 World world = GetOwner().GetWorld();
941 if (!updateSystem)
942 return;
943
944 updateSystem.Register(this);
945 }
946
947 //------------------------------------------------------------------------------------------------
949 {
950 World world = GetOwner().GetWorld();
952 if (!updateSystem)
953 return;
954
955 updateSystem.Unregister(this);
956 }
957
958 //------------------------------------------------------------------------------------------------
959 void Update(float timeSlice)
960 {
962 {
963 m_InputManager.ActivateContext(VON_CONTEXT);
965
966 if (m_fToggleOffDelay > 0)
967 m_fToggleOffDelay -= timeSlice;
968
969 /* When non overlaying context such as chat is activated during hold action, we will no longer receive the EActionTrigger.UP callback from the previous context, which is currently intended
970 This timeouts it in such case so the VON will not be stuck in an active state */
971 if (!m_sActiveHoldAction.IsEmpty() && !m_InputManager.IsActionActive(m_sActiveHoldAction))
973 }
974
975 if (m_VONMenu)
976 m_VONMenu.Update(timeSlice);
977
978 if (m_VONAutoTune)
979 m_VONAutoTune.Update(timeSlice);
980
981 #ifdef VON_DEBUG
982 UpdateDebug();
983 #endif
984 }
985
986 //------------------------------------------------------------------------------------------------
987 override void OnDelete(IEntity owner)
988 {
989 s_bIsInit = false;
990 Cleanup();
992
993 if (m_VONAutoTune)
994 m_VONAutoTune.Deinit();
995
996 super.OnDelete(owner);
997 }
998
999 //------------------------------------------------------------------------------------------------
1001 {
1002 return m_VONAutoTune;
1003 }
1004};
override void Init()
ECommMethod
Definition ECommMethod.c:8
@ DIRECT
Definition ECommMethod.c:12
ArmaReforgerScripted GetGame()
Definition game.c:1398
void UpdateDebug()
SCR_BaseGameMode GetGameMode()
void Deactivate()
InputManager m_InputManager
EDamageType type
void RemoveEntry(notnull SCR_DownloadManagerEntry entry)
Widget AddEntry(ResourceName entryPath, SCR_WorkshopItemActionDownload action)
Add new widget in category based based on category type.
void SCR_FactionManager(IEntitySource src, IEntity parent)
SCR_HintSequenceComponentClass m_bIsActive
bool m_bIsUnconscious
void OnPlayerDeleted(int playerId, IEntity player)
void SetVONComponent(SCR_VoNComponent VONComp)
int GetVONEntries(inout array< ref SCR_VONEntry > entries)
SCR_VONEntry m_SavedEntry
void SetVONProximity(bool activate)
ref SCR_VONEntry m_DirectSpeechEntry
ScriptInvokerBase< OnVONActiveToggled > GetOnVONActiveToggledInvoker()
void ConnectToHandleUpdateVONControllersSystem()
ref SCR_VONMenu m_VONMenu
bool IsUsingLRR()
Using long range radio.
float m_fToggleOffDelay
void SetVONProximityToggle(bool activate)
const string VON_CONTEXT
int GetVONEntryCount()
Get number of entries.
void ActivateVON(EVONTransmitType transmitType)
string m_sLocalEncryptionKey
ref ScriptInvokerBase< OnEntriesChanged > m_OnEntriesChanged
void SetActiveChannel(int channelId)
SCR_VONEntry GetActiveEntry()
void SetVONBroadcast(bool activate, EVONTransmitType transmitType=EVONTransmitType.CHANNEL)
void DisconnectFromHandleUpdateVONControllersSystem()
void OnPauseMenuClosed()
PauseMenuUI Event.
const string ACTION_DIRECT_TOGGLE
ref ScriptInvokerBase< OnEntriesChanged > m_OnEntriesActiveChanged
ScriptInvokerBase< OnEntriesChanged > GetOnEntriesChangedInvoker()
SCR_VONEntry m_LongRangeEntry
EVONTransmitType m_eVONType
void DeactivateVON(EVONTransmitType transmitType=EVONTransmitType.NONE)
Current VON deactivation.
void ResetVON()
func OnVONActiveToggled
bool SetVONDisabled(bool state)
bool m_bIsPauseDisabled
ECharacterLifeState m_eLifeState
void InitEncryptionKey()
void SetVONLongRange(bool longRange, bool restorePrevious=true)
SCR_VoNComponent m_VONComp
ref SCR_VONAutoTune m_VONAutoTune
void RpcAsk_SetActiveChannel(int channelId)
EVONTransmitType
Type of a players current VON transmission.
void SetEntryActive(SCR_VONEntry entry, bool setFromMenu=false)
func OnEntriesChanged
SCR_VONControllerClass VON_MENU_OPENING_CONTEXT
Scripted VON input and control, attached to SCR_PlayerController.
SCR_VONAutoTune GetAutoTune()
EVONTransmitType SelectFirstUnmutedEntry()
void UpdateSystemState()
ScriptInvokerBase< OnEntriesChanged > GetOnEntriesActiveChangedInvoker()
bool m_bIsDisabled
void ActionVONTransceiverCycle(float value, EActionTrigger reason=EActionTrigger.UP)
void OnPauseMenuOpened()
PauseMenuUI Event.
const string ACTION_CHANNEL
SCR_VonDisplay m_VONDisplay
bool m_bIsToggledDirect
bool m_bIsEditorRadioAdded
void SetDisplay(SCR_VonDisplay display)
bool m_bIsLongRangeToggled
SCR_VONEntry GetEntryByTransmitType(EVONTransmitType type)
const string ACTION_LONG_RANGE_TOGGLE
SCR_VONMenu GetVONMenu()
bool IsLRRAvailable()
Long range raido entry is available.
void ActionVONProximityToggle(float value, EActionTrigger reason=EActionTrigger.UP)
void ActionVONBroadcast(float value, EActionTrigger reason=EActionTrigger.UP)
const float TOGGLE_OFF_DELAY
void ActionVONProximity(float value, EActionTrigger reason=EActionTrigger.UP)
void TransceiverCycle()
void SetActiveTransmit(notnull SCR_VONEntry entry)
Set transmission method depending on entry type when starting VON transmit.
void ActionVONLongRangeToggle(float value, EActionTrigger reason=EActionTrigger.UP)
SCR_VonDisplay GetDisplay()
void Cleanup()
Cleanup component.
LONG_RANGE
bool AssignVONComponent()
Assign VON comp by fetching it from controlled entity.
bool IsVONDisabled()
Is VON disabled.
ref ScriptInvokerBase< OnVONActiveToggled > m_OnVONActiveToggled
SCR_VONEntry m_ActiveEntry
const string ACTION_TRANSCEIVER_CYCLE
string m_sActiveHoldAction
const string ACTION_DIRECT
Definition DbgUI.c:66
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
void Register(SCR_VONController component)
void Unregister(SCR_VONController component)
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
Input management system for user interactions.
static ref ScriptInvoker m_OnPauseMenuClosed
static ref ScriptInvoker m_OnPauseMenuOpened
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerDeleted()
SCR_GameModeHealthSettings GetGameModeHealthSettings()
ref OnLifeStateChangedInvoker m_OnLifeStateChanged
static bool IsAdmin(int playerID)
Definition Functions.c:1927
ref OnControlledEntityChangedPlayerControllerInvoker m_OnControlledEntityChanged
Voice over network entry data class, used for management of communication methods.
Definition SCR_VONEntry.c:4
void InitEntry()
void SetActive(bool state)
Activate entry.
VONEntry class for radio entries.
BaseTransceiver GetTransceiver()
Associated transceiver.
SCR_GadgetComponent GetGadget()
Gadget component associated with this entry.
bool GetIsMuted()
bool IsLongRange()
Is long range backpack radio type.
int GetEntryFrequency()
Local frequency getter since atm the transceiver getter is delayed (network?) and not sufficient for ...
proto external GenericEntity GetOwner()
Get owner entity.
void EOnDeactivate(IEntity owner)
Definition World.c:16
ECharacterLifeState
proto external VoNComponent GetVONComponent()
Get active VON component for transmit.
@ NONE
When Shape is created and not initialized yet.
Definition ShapeType.c:15
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()
EActionTrigger
void OnControlledEntityChanged(IEntity from, IEntity to)
Runs every time the controlled entity has been changed.
proto external int GetPlayerId()
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14