Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_VONController.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
4 {
5  NONE,
7  CHANNEL,
9 }
10 
11 //------------------------------------------------------------------------------------------------
12 // invoker typedefs
13 void OnVONActiveToggled(bool isToggledDirect, bool isToggledChannel); // when direct toggle activates
15 
16 void OnEntriesChanged(SCR_VONEntry entry, bool state);
18 
19 //------------------------------------------------------------------------------------------------
21 {}
22 
23 //------------------------------------------------------------------------------------------------
25 class 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  protected const string VON_DIRECT_HOLD = "VONDirect";
33  protected const string VON_CHANNEL_HOLD = "VONChannel";
34  protected const string VON_LONG_RANGE_HOLD = "VONLongRange";
35  protected const float TOGGLE_OFF_DELAY = 0.5; // seconds, delay before toggle state can get canceled, to avoid collision of double click and press
36 
37  static bool s_bIsInit; // component init done, static so its only done once
38  protected bool m_bIsDisabled; // VON control is disabled
39  protected bool m_bIsPauseDisabled; // disabled by pause menu
40  protected bool m_bIsUnconscious; // Character is unconscious --> VON control is disabled
41  protected bool m_bIsActive; // VON is active
42  protected bool m_bIsToggledDirect; // VON direct speech toggle is active
43  protected bool m_bIsToggledChannel; // VON channel speech toggle is active
44  protected bool m_bIsUsingGamepad; // is using gamepad / KBM
45  protected bool m_bIsActiveModeDirect; // used for controller, switch between direct VON = true / channel VON = false
46  protected bool m_bIsActiveModeLong; // used for controller, switch between long range VON = true / channel VON = false
47  protected float m_fToggleOffDelay; // used to track delay before toggle can be cancelled
48  protected string m_sActiveHoldAction; // tracker for ending the hold action VON
49  protected string m_sLocalEncryptionKey; // local players faction encryption key
50  protected EVONTransmitType m_eVONType; // currently active VON type
51  protected InputManager m_InputManager;
52 
53  protected SCR_VoNComponent m_VONComp; // VON component used for transmission
54  protected SCR_VonDisplay m_VONDisplay; // VON transmission display
55  protected SCR_VONEntry m_ActiveEntry; // active entry (non direct speech)
56  protected SCR_VONEntry m_LongRangeEntry; // entry for long range radio, if available
57  protected SCR_VONEntry m_SavedEntry; // entry used for switching to different active entry after current one is done, f.e. after VONLongRange
58  protected ref SCR_VONEntry m_DirectSpeechEntry; // separate direct speech entry
59  protected ref array<ref SCR_VONEntry> m_aEntries = {}; // all entries except direct
60 
61 
62  protected ref ScriptInvokerBase<OnEntriesChanged> m_OnEntriesChanged = new ScriptInvokerBase<OnEntriesChanged>(); // when entry array is modified (SCR_VONEntry entry, bool isAdded)
63  protected ref ScriptInvokerBase<OnEntriesChanged> m_OnEntriesActiveChanged = new ScriptInvokerBase<OnEntriesChanged>(); // when entry array is modified (SCR_VONEntry entry, bool isActive)
64  protected ref ScriptInvokerBase<OnVONActiveToggled> m_OnVONActiveToggled = new ScriptInvokerBase<OnVONActiveToggled>(); // when direct toggle activates (bool isToggledDirect, bool isToggledChannel)
65 
66  //------------------------------------------------------------------------------------------------
67  ScriptInvokerBase<OnEntriesChanged> GetOnEntriesChangedInvoker()
68  {
69  return m_OnEntriesChanged;
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  ScriptInvokerBase<OnEntriesChanged> GetOnEntriesActiveChangedInvoker()
74  {
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  ScriptInvokerBase<OnVONActiveToggled> GetOnVONActiveToggledInvoker()
80  {
81  return m_OnVONActiveToggled;
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  void SetDisplay(SCR_VonDisplay display)
86  {
87  m_VONDisplay = display;
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  SCR_VonDisplay GetDisplay()
92  {
93  return m_VONDisplay;
94  }
95 
96  //------------------------------------------------------------------------------------------------
98  {
99  return m_VONMenu;
100  }
101 
102  //------------------------------------------------------------------------------------------------
106  bool SetVONDisabled(bool state)
107  {
108  if (m_bIsDisabled == state)
109  return false;
110 
111  m_bIsDisabled = state;
113  return true;
114  }
115 
116  //------------------------------------------------------------------------------------------------
119  {
120  return m_bIsDisabled;
121  }
122 
123  //------------------------------------------------------------------------------------------------
125  SCR_VoNComponent GetVONComponent()
126  {
127  return m_VONComp;
128  }
129 
130  //------------------------------------------------------------------------------------------------
133  void SetVONComponent(SCR_VoNComponent VONComp)
134  {
135  m_VONComp = VONComp;
136  }
137 
138 
139  //------------------------------------------------------------------------------------------------
142  int GetVONEntries(inout array<ref SCR_VONEntry> entries)
143  {
144  int count = m_aEntries.Count();
145  for (int i = 0; i < count; i++)
146  {
147  entries.Insert(m_aEntries[i]);
148  }
149 
150  return count;
151  }
152 
153  //------------------------------------------------------------------------------------------------
156  {
157  return m_aEntries.Count();
158  }
159 
160  //------------------------------------------------------------------------------------------------
164  {
165  return m_ActiveEntry;
166  }
167 
168  //------------------------------------------------------------------------------------------------
170  bool IsUsingLRR()
171  {
172  if (!m_ActiveEntry)
173  return false;
174 
176  }
177 
178  //------------------------------------------------------------------------------------------------
181  {
182  return m_LongRangeEntry != null;
183  }
184 
185  //------------------------------------------------------------------------------------------------
189  void SetEntryActive(SCR_VONEntry entry, bool setFromMenu = false)
190  {
191  if (entry == m_ActiveEntry)
192  return;
193 
194  if (m_ActiveEntry)
195  {
197  m_ActiveEntry.SetActive(false);
198  }
199 
200  entry.SetActive(true);
201  m_ActiveEntry = entry;
202  m_OnEntriesActiveChanged.Invoke(entry, true);
203 
204  if (m_ActiveEntry && !m_ActiveEntry.IsUsable()) // turn off toggle when switching to disabled entry
205  OnVONToggle(0,0);
206 
207  if (m_VONDisplay)
208  m_VONDisplay.ShowSelectedVONHint(m_ActiveEntry);
209 
210  if (m_bIsUsingGamepad && setFromMenu) // cancel long range state if switching to personal radio
211  {
212  SCR_VONEntryRadio radioEntry = SCR_VONEntryRadio.Cast(entry);
213  if (radioEntry && !radioEntry.IsLongRange())
214  SetGamepadLRRMode(false, true);
215  }
216  }
217 
218  //------------------------------------------------------------------------------------------------
222  void AddEntry(SCR_VONEntry entry)
223  {
224  m_aEntries.Insert(entry);
225  entry.InitEntry();
226 
227  if (SCR_VONEntryRadio.Cast(entry) && SCR_VONEntryRadio.Cast(entry).IsLongRange()) // if long range entry, set it here
228  m_LongRangeEntry = entry;
229 
230  m_OnEntriesChanged.Invoke(entry, true);
231 
232  if (!m_ActiveEntry)
233  SetEntryActive(entry);
234  }
235 
236  //------------------------------------------------------------------------------------------------
241  {
242  m_OnEntriesChanged.Invoke(entry, false);
243 
244  //Deactivate if the entry being removed is active
245  if (entry == m_ActiveEntry)
246  {
248  OnVONToggle(2, 0);
249  else
250  DeactivateVON();
251 
252  m_ActiveEntry = null;
253  }
254 
255  if (entry == m_LongRangeEntry) // unset long range entry
256  m_LongRangeEntry = null;
257 
258  if (m_VONMenu)
259  {
260  SCR_RadialMenu vonRadial = m_VONMenu.GetRadialMenu();
261  if (vonRadial && vonRadial.IsOpened())
262  vonRadial.Close();
263  }
264 
265  m_aEntries.RemoveItem(entry);
266  }
267 
268  //------------------------------------------------------------------------------------------------
270  protected void SetGamepadLRRMode(bool state, bool isSwitch = false)
271  {
272  m_bIsActiveModeLong = state;
273 
274  if (m_SavedEntry && !isSwitch) // restore last saved entry if there is one
276  }
277 
278  //------------------------------------------------------------------------------------------------
280  protected void OnVONDirect(float value, EActionTrigger reason)
281  {
282  if (reason == EActionTrigger.DOWN)
283  VONDirect(true);
284  else
285  VONDirect(false);
286  }
287 
288  //------------------------------------------------------------------------------------------------
290  protected void OnVONChannel(float value, EActionTrigger reason)
291  {
292  if (reason == EActionTrigger.DOWN)
293  VONChannel(true);
294  else
295  VONChannel(false);
296  }
297 
298  //------------------------------------------------------------------------------------------------
300  protected void OnVONLongRange(float value, EActionTrigger reason)
301  {
302  if (reason == EActionTrigger.DOWN)
303  VONLongRange(true);
304  else
305  VONLongRange(false);
306  }
307 
308  //------------------------------------------------------------------------------------------------
310  protected void OnVONGamepad(float value, EActionTrigger reason)
311  {
313  {
314  if (reason == EActionTrigger.PRESSED && m_eVONType == EVONTransmitType.LONG_RANGE)
315  return;
316 
317  if (reason == EActionTrigger.PRESSED)
318  VONLongRange(true);
319  else
320  VONLongRange(false);
321  }
322  else if (m_bIsActiveModeDirect)
323  {
324  if (reason == EActionTrigger.PRESSED && m_eVONType == EVONTransmitType.DIRECT)
325  return;
326 
327  if (reason == EActionTrigger.PRESSED)
328  VONDirect(true);
329  else
330  VONDirect(false);
331  }
332  else
333  {
334  if (reason == EActionTrigger.PRESSED && m_eVONType == EVONTransmitType.CHANNEL)
335  return;
336 
337  if (reason == EActionTrigger.PRESSED)
338  VONChannel(true);
339  else
340  VONChannel(false);
341  }
342  }
343 
344  //------------------------------------------------------------------------------------------------
345  protected void OnVONLongRangeGamepadToggle(float value, EActionTrigger reason)
346  {
348  SetGamepadLRRMode(true);
349  else
350  SetGamepadLRRMode(false);
351  }
352 
353  //------------------------------------------------------------------------------------------------
355  protected void OnVONToggle(float value, EActionTrigger reason)
356  {
357  if (!m_VONComp)
358  return;
359 
360  if (value == 0)
361  {
362  m_fToggleOffDelay = 0;
363  m_bIsToggledDirect = false;
364  m_bIsToggledChannel = false;
365  DeactivateVON();
366  }
367  else if (value == 1)
368  {
371  m_bIsToggledChannel = false;
372 
373  if (m_bIsToggledDirect)
375  else
376  DeactivateVON();
377  }
378  else
379  {
380  SetGamepadLRRMode(false);
381 
382  if (!m_ActiveEntry || !m_ActiveEntry.IsUsable())
383  return;
384 
386  m_bIsToggledDirect = false;
388 
390  ActivateVON(EVONTransmitType.CHANNEL);
391  else
392  DeactivateVON();
393  }
394 
396  }
397 
398  //------------------------------------------------------------------------------------------------
400  protected void OnVONToggleGamepad(float value, EActionTrigger reason)
401  {
403  OnVONToggle(1, EActionTrigger.DOWN); // direct toggle
404  else
405  OnVONToggle(2, EActionTrigger.DOWN); // channel toggle
406  }
407 
408  //------------------------------------------------------------------------------------------------
410  protected void OnVONSwitch(float value, EActionTrigger reason)
411  {
413 
415  OnVONToggleGamepad(0, EActionTrigger.UP);
416  else if (m_VONDisplay)
417  {
419  m_VONDisplay.ShowSelectedVONHint(m_DirectSpeechEntry);
420  else if (m_ActiveEntry)
421  m_VONDisplay.ShowSelectedVONHint(m_ActiveEntry);
422  }
423  }
424 
425  //------------------------------------------------------------------------------------------------
426  protected void VONDirect(bool activate)
427  {
428  if (!m_VONComp)
429  return;
430 
431  if (m_bIsToggledDirect && m_fToggleOffDelay <= 0) // direct speech toggle is active, cancel it
432  OnVONToggle(0,0);
433 
434  if (!m_DirectSpeechEntry.IsUsable())
435  return;
436 
438 
439  if (activate)
441  else
443  }
444 
445  //------------------------------------------------------------------------------------------------
446  protected void VONChannel(bool activate)
447  {
448  if (!m_VONComp)
449  return;
450 
451  if (m_bIsToggledChannel && m_fToggleOffDelay <= 0) // channel speech toggle is active, cancel it
452  OnVONToggle(0,0);
453 
454  if (!m_ActiveEntry || !m_ActiveEntry.IsUsable()) // if active entry disabled, use direct instead
455  {
456  VONDirect(activate);
457  m_VONDisplay.ShowSelectedVONDisabledHint();
458  return;
459  }
460 
462 
463  if (activate)
464  ActivateVON(EVONTransmitType.CHANNEL);
465  else
467  }
468 
469  //------------------------------------------------------------------------------------------------
470  protected void VONLongRange(bool activate)
471  {
472  if (!m_VONComp)
473  return;
474 
476  OnVONToggle(0,0);
477 
478  if (!m_LongRangeEntry || !m_LongRangeEntry.IsUsable()) // if active entry disabled, use direct instead
479  {
480  VONDirect(activate);
481  m_VONDisplay.ShowSelectedVONDisabledHint();
482  return;
483  }
484 
486 
487  if (activate)
488  {
489  if (!m_SavedEntry) // saved entry to switch back to after using long range mode
491 
492  m_bIsActiveModeDirect = false;
493 
494  ActivateVON(EVONTransmitType.LONG_RANGE);
495  }
496  else
497  {
498  DeactivateVON(EVONTransmitType.LONG_RANGE);
499 
500  if (m_SavedEntry && !m_bIsUsingGamepad) // restore last saved entry if there is one
502  }
503  }
504 
505  //------------------------------------------------------------------------------------------------
508  protected void ActivateVON(EVONTransmitType transmitType)
509  {
510  if (!m_VONComp)
511  return;
512 
513  m_eVONType = transmitType;
514  SCR_VONEntry entry = GetEntryByTransmitType(transmitType);
515 
516  if (!GetGame().GetVONCanTransmitCrossFaction()) // is cross faction transmit disabled
517  {
520 
521  SCR_VONEntryRadio radioEntry = SCR_VONEntryRadio.Cast(entry);
522  if (radioEntry && m_sLocalEncryptionKey != string.Empty && radioEntry.GetTransceiver().GetRadio().GetEncryptionKey() != m_sLocalEncryptionKey)
523  {
524  m_VONDisplay.ShowSelectedVONDisabledHint(true);
525  return;
526  }
527  }
528 
529  SetActiveTransmit(entry);
530  m_VONComp.SetCapture(true);
531  m_bIsActive = true;
532  }
533 
534  //------------------------------------------------------------------------------------------------
536  protected void DeactivateVON(EVONTransmitType transmitType = EVONTransmitType.NONE)
537  {
538  if (!m_VONComp)
539  return;
540 
541  if (transmitType != EVONTransmitType.NONE && transmitType != m_eVONType) // only deactivate target type, in case other type was activated already
542  return;
543 
545  m_bIsActive = false;
546  m_VONComp.SetCapture(false);
547  m_sActiveHoldAction = string.Empty;
548 
549  if (m_bIsToggledDirect) // direct toggle is active so ending VON should not end capture
551  else if (m_bIsToggledChannel) // channel toggle is active so ending VON should not end capture
552  ActivateVON(EVONTransmitType.CHANNEL);
553  }
554 
555  //------------------------------------------------------------------------------------------------
557  {
558  switch (type)
559  {
560  case EVONTransmitType.CHANNEL:
561  return m_ActiveEntry;
562 
563  case EVONTransmitType.LONG_RANGE:
564  return m_LongRangeEntry;
565 
566  default:
567  return m_DirectSpeechEntry;
568  }
569 
570  return null;
571  }
572 
573  //------------------------------------------------------------------------------------------------
575  protected void SetActiveTransmit(notnull SCR_VONEntry entry)
576  {
577  if (entry.GetVONMethod() == ECommMethod.SQUAD_RADIO)
578  {
579  m_VONComp.SetCommMethod(ECommMethod.SQUAD_RADIO);
580  m_VONComp.SetTransmitRadio(SCR_VONEntryRadio.Cast(entry).GetTransceiver());
581  SetEntryActive(entry);
582  }
583  else
584  {
585  m_VONComp.SetCommMethod(ECommMethod.DIRECT);
586  m_VONComp.SetTransmitRadio(null);
587  }
588 
589  if (entry == m_SavedEntry)
590  m_SavedEntry = null;
591  }
592 
593  //------------------------------------------------------------------------------------------------
595  protected void TimeoutVON()
596  {
597  DeactivateVON();
598  }
599 
600  //------------------------------------------------------------------------------------------------
603  protected void OnControlledEntityChanged(IEntity from, IEntity to)
604  {
606  OnVONToggle(0,0);
607 
608  m_sLocalEncryptionKey = string.Empty;
609 
610  if (to)
611  SetVONComponent(SCR_VoNComponent.Cast(to.FindComponent(SCR_VoNComponent)));
612  else
613  SetVONComponent(null);
614 
615  if (from)
616  {
617  ChimeraCharacter character = ChimeraCharacter.Cast(from);
618  if (character)
619  {
620  SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
621  if (controller)
622  controller.m_OnLifeStateChanged.Remove(OnLifeStateChanged);
623  }
624  }
625 
626  bool unconsciousVONEnabled;
627  SCR_BaseGameMode baseGameMode = SCR_BaseGameMode.Cast(GetGame().GetGameMode());
628  if (!baseGameMode)
629  return;
630 
631  SCR_GameModeHealthSettings healthSettingsComp = SCR_GameModeHealthSettings.Cast(baseGameMode.GetGameModeHealthSettings());
632  if (healthSettingsComp)
633  unconsciousVONEnabled = healthSettingsComp.IsUnconsciousVONPermitted();
634 
635  if (unconsciousVONEnabled)
636  return;
637 
638  if (to)
639  {
640  ChimeraCharacter character = ChimeraCharacter.Cast(to);
641  if (!character)
642  return;
643 
644  SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
645  if (controller)
646  {
647  m_bIsUnconscious = controller.IsUnconscious();
648  controller.m_OnLifeStateChanged.Insert(OnLifeStateChanged);
649  }
650 
652  }
653  }
654 
655  //------------------------------------------------------------------------------------------------
658  protected void OnDestroyed(Instigator killer, IEntity killerEntity)
659  {
661  OnVONToggle(0,0);
662  }
663 
664  //------------------------------------------------------------------------------------------------
667  protected void OnPlayerDeleted(int playerId, IEntity player)
668  {
669  if (playerId != GetGame().GetPlayerController().GetPlayerId())
670  return;
671 
673  OnVONToggle(0,0);
674 
675  m_ActiveEntry = null;
676  m_LongRangeEntry = null;
677 
678  m_aEntries.Clear();
679  }
680 
681  //------------------------------------------------------------------------------------------------
683  protected void OnInputDeviceIsGamepad(bool isGamepad)
684  {
685  m_bIsUsingGamepad = isGamepad;
686 
687  if (!isGamepad)
688  {
689  m_bIsActiveModeDirect = false;
690  m_bIsActiveModeLong = false;
691  }
692  }
693 
694  //------------------------------------------------------------------------------------------------
696  protected void OnPauseMenuOpened()
697  {
698  if (SetVONDisabled(true))
699  m_bIsPauseDisabled = true;
700  }
701 
702  //------------------------------------------------------------------------------------------------
704  protected void OnPauseMenuClosed()
705  {
706  if (m_bIsPauseDisabled)
707  SetVONDisabled(false);
708 
709  m_bIsPauseDisabled = false;
710  }
711 
712  //------------------------------------------------------------------------------------------------
715  {
716  IEntity controlledEnt = SCR_PlayerController.Cast(GetOwner()).GetControlledEntity();
717  if (controlledEnt)
718  SetVONComponent(SCR_VoNComponent.Cast(controlledEnt.FindComponent(SCR_VoNComponent)));
719 
720  if(!m_VONComp)
721  return false;
722 
723  return true;
724  }
725 
726  //------------------------------------------------------------------------------------------------
727  void OnLifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
728  {
729  m_bIsUnconscious = newLifeState == ECharacterLifeState.INCAPACITATED;
730 
732 
733  if (newLifeState == ECharacterLifeState.ALIVE)
734  return;
735 
737  OnVONToggle(0,0);
738 
739  TimeoutVON();
740  }
741 
742  //------------------------------------------------------------------------------------------------
743  protected void InitEncryptionKey()
744  {
745  SCR_FactionManager fManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
746  if (fManager)
747  {
748  SCR_Faction faction = SCR_Faction.Cast(fManager.GetLocalPlayerFaction());
749  if (faction)
750  m_sLocalEncryptionKey = faction.GetFactionRadioEncryptionKey();
751  }
752  }
753 
754  //------------------------------------------------------------------------------------------------
756  protected void Init(IEntity owner)
757  {
758  if (s_bIsInit || System.IsConsoleApp()) // hosted server will have multiple controllers, init just the first one // dont init on dedicated server
759  {
760  Deactivate(owner);
761  return;
762  }
763 
764  m_InputManager = GetGame().GetInputManager();
765  if (!m_InputManager)
766  return;
767 
768  m_InputManager.AddActionListener(VON_DIRECT_HOLD, EActionTrigger.DOWN, OnVONDirect);
769  m_InputManager.AddActionListener(VON_DIRECT_HOLD, EActionTrigger.UP, OnVONDirect);
770  m_InputManager.AddActionListener(VON_CHANNEL_HOLD, EActionTrigger.DOWN, OnVONChannel);
771  m_InputManager.AddActionListener(VON_CHANNEL_HOLD, EActionTrigger.UP, OnVONChannel);
772  m_InputManager.AddActionListener(VON_LONG_RANGE_HOLD, EActionTrigger.DOWN, OnVONLongRange);
773  m_InputManager.AddActionListener(VON_LONG_RANGE_HOLD, EActionTrigger.UP, OnVONLongRange);
774  m_InputManager.AddActionListener("VONGamepad", EActionTrigger.PRESSED, OnVONGamepad);
775  m_InputManager.AddActionListener("VONGamepad", EActionTrigger.UP, OnVONGamepad);
776  m_InputManager.AddActionListener("VONGamepadLongRange", EActionTrigger.DOWN, OnVONLongRangeGamepadToggle);
777  m_InputManager.AddActionListener("VONDirectToggle", EActionTrigger.DOWN, OnVONToggle);
778  m_InputManager.AddActionListener("VONChannelToggle", EActionTrigger.DOWN, OnVONToggle);
779  m_InputManager.AddActionListener("VONToggleGamepad", EActionTrigger.DOWN, OnVONToggleGamepad);
780  m_InputManager.AddActionListener("VONSwitch", EActionTrigger.DOWN, OnVONSwitch);
781 
782  SCR_PlayerController playerController = SCR_PlayerController.Cast(GetOwner());
783  playerController.m_OnControlledEntityChanged.Insert(OnControlledEntityChanged);
784  playerController.m_OnDestroyed.Insert(OnDestroyed);
785  PauseMenuUI.m_OnPauseMenuOpened.Insert(OnPauseMenuOpened);
786  PauseMenuUI.m_OnPauseMenuClosed.Insert(OnPauseMenuClosed);
787  GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
788 
790  if (gameMode)
791  gameMode.GetOnPlayerDeleted().Insert(OnPlayerDeleted);
792 
793  m_DirectSpeechEntry = new SCR_VONEntry(); // Init direct speech entry
794 
796 
797  s_bIsInit = true;
798 
799  if (m_VONMenu)
800  m_VONMenu.Init(this);
801 
803  }
804 
805  //------------------------------------------------------------------------------------------------
807  protected void Cleanup()
808  {
809  m_VONMenu = null;
810 
812 
813  m_InputManager = GetGame().GetInputManager();
814  if (!m_InputManager)
815  return;
816 
817  m_InputManager.RemoveActionListener(VON_DIRECT_HOLD, EActionTrigger.DOWN, OnVONDirect);
818  m_InputManager.RemoveActionListener(VON_DIRECT_HOLD, EActionTrigger.UP, OnVONDirect);
819  m_InputManager.RemoveActionListener(VON_CHANNEL_HOLD, EActionTrigger.DOWN, OnVONChannel);
820  m_InputManager.RemoveActionListener(VON_CHANNEL_HOLD, EActionTrigger.UP, OnVONChannel);
821  m_InputManager.RemoveActionListener(VON_LONG_RANGE_HOLD, EActionTrigger.DOWN, OnVONLongRange);
822  m_InputManager.RemoveActionListener(VON_LONG_RANGE_HOLD, EActionTrigger.UP, OnVONLongRange);
823  m_InputManager.RemoveActionListener("VONGamepad", EActionTrigger.PRESSED, OnVONGamepad);
824  m_InputManager.RemoveActionListener("VONGamepad", EActionTrigger.UP, OnVONGamepad);
825  m_InputManager.RemoveActionListener("VONGamepadLongRange", EActionTrigger.DOWN, OnVONLongRangeGamepadToggle);
826  m_InputManager.RemoveActionListener("VONDirectToggle", EActionTrigger.DOWN, OnVONToggle);
827  m_InputManager.RemoveActionListener("VONDChannelToggle", EActionTrigger.DOWN, OnVONToggle);
828  m_InputManager.RemoveActionListener("VONToggleGamepad", EActionTrigger.DOWN, OnVONToggleGamepad);
829  m_InputManager.RemoveActionListener("VONSwitch", EActionTrigger.DOWN, OnVONSwitch);
830 
831  IEntity ent = PlayerController.Cast(GetOwner()).GetControlledEntity();
832  if (ent)
833  {
834  ChimeraCharacter character = ChimeraCharacter.Cast(ent);
835  if (character)
836  {
837  SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
838  if (controller)
839  controller.m_OnLifeStateChanged.Remove(OnLifeStateChanged);
840  }
841  }
842 
844  if (gameMode)
845  gameMode.GetOnPlayerDeleted().Remove(OnPlayerDeleted);
846  }
847 
848  //------------------------------------------------------------------------------------------------
850  protected void UpdateDebug()
851  {
852  DbgUI.Begin("VON debug");
853  string dbg = "VONcomp: %1 | entries: %2";
854  DbgUI.Text( string.Format( dbg, m_VONComp, m_aEntries.Count() ) );
855  string dbg2 = "Gpad Direct mode: %1 | Gpad LRR mode: %2";
856  DbgUI.Text( string.Format( dbg2, m_bIsActiveModeDirect, m_bIsActiveModeLong ) );
857  string dbg3 = "Activ: %1";
858  DbgUI.Text( string.Format( dbg3, m_ActiveEntry ) );
859  string dbg4 = "LRRad: %1";
860  DbgUI.Text( string.Format( dbg4, m_LongRangeEntry ) );
861  string dbg5 = "Saved: %1";
862  DbgUI.Text( string.Format( dbg5, m_SavedEntry ) );
863 
864  string line = "freq: %2 | active: %3 | class: %4 | type: %1 ";
865  foreach ( SCR_VONEntry entry : m_aEntries )
866  {
867  SCR_VONEntryRadio radio = SCR_VONEntryRadio.Cast(entry);
868  DbgUI.Text( string.Format( line, SCR_Enum.GetEnumName(EGadgetType, radio.GetGadget().GetType()), radio.GetEntryFrequency(), radio.IsActive(), radio.ToString()));
869  }
870 
871  DbgUI.End();
872  }
873 
874  //------------------------------------------------------------------------------------------------
875  override protected void OnPostInit(IEntity owner)
876  {
877  Init(owner);
878  }
879 
880  //------------------------------------------------------------------------------------------------
881  override protected void EOnDeactivate(IEntity owner)
882  {
883  Cleanup();
884  }
885 
886  //------------------------------------------------------------------------------------------------
887  protected void UpdateSystemState()
888  {
891  else
893  }
894 
895  //------------------------------------------------------------------------------------------------
897  {
898  World world = GetOwner().GetWorld();
900  if (!updateSystem)
901  return;
902 
903  updateSystem.Register(this);
904  }
905 
906  //------------------------------------------------------------------------------------------------
908  {
909  World world = GetOwner().GetWorld();
911  if (!updateSystem)
912  return;
913 
914  updateSystem.Unregister(this);
915  }
916 
917  //------------------------------------------------------------------------------------------------
918  void Update(float timeSlice)
919  {
921  {
922  m_InputManager.ActivateContext("VONContext");
923  m_InputManager.ActivateContext(VON_MENU_OPENING_CONTEXT);
924 
925  if (m_fToggleOffDelay > 0)
926  m_fToggleOffDelay -= timeSlice;
927 
928  /* 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
929  This timeouts it in such case so the VON will not be stuck in an active state */
930  if (m_sActiveHoldAction != string.Empty)
931  {
932  if (!m_InputManager.IsActionActive(m_sActiveHoldAction))
933  TimeoutVON();
934  }
935  }
936 
937  if (m_VONMenu)
938  m_VONMenu.Update(timeSlice);
939 
940  #ifdef VON_DEBUG
941  UpdateDebug();
942  #endif
943  }
944 
945  //------------------------------------------------------------------------------------------------
946  override void OnDelete(IEntity owner)
947  {
948  s_bIsInit = false;
949  Cleanup();
951 
952  super.OnDelete(owner);
953  }
954 };
SetVONDisabled
bool SetVONDisabled(bool state)
Definition: SCR_VONController.c:106
GetOnVONActiveToggledInvoker
ScriptInvokerBase< OnVONActiveToggled > GetOnVONActiveToggledInvoker()
Definition: SCR_VONController.c:79
ActivateVON
protected void ActivateVON(EVONTransmitType transmitType)
Definition: SCR_VONController.c:508
m_SavedEntry
protected SCR_VONEntry m_SavedEntry
Definition: SCR_VONController.c:57
LONG_RANGE
LONG_RANGE
Definition: SCR_VONController.c:6
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
SetDisplay
void SetDisplay(SCR_VonDisplay display)
Definition: SCR_VONController.c:85
SetGamepadLRRMode
protected void SetGamepadLRRMode(bool state, bool isSwitch=false)
Sets long rang radio mode for gamepad input scheme.
Definition: SCR_VONController.c:270
m_bIsUsingGamepad
protected bool m_bIsUsingGamepad
Definition: SCR_VONController.c:44
GetActiveEntry
SCR_VONEntry GetActiveEntry()
Definition: SCR_VONController.c:163
VONChannel
protected void VONChannel(bool activate)
Definition: SCR_VONController.c:446
GetVONEntryCount
int GetVONEntryCount()
Get number of entries.
Definition: SCR_VONController.c:155
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_VONControllerClass
Definition: SCR_VONController.c:20
SCR_Enum
Definition: SCR_Enum.c:1
m_eVONType
protected EVONTransmitType m_eVONType
Definition: SCR_VONController.c:50
m_InputManager
protected InputManager m_InputManager
Definition: SCR_VONController.c:51
HandleUpdateVONControllersSystem
Definition: HandleUpdateVONControllersSystem.c:1
OnPlayerDeleted
protected void OnPlayerDeleted(int playerId, IEntity player)
Definition: SCR_VONController.c:667
GetVONEntries
int GetVONEntries(inout array< ref SCR_VONEntry > entries)
Definition: SCR_VONController.c:142
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
ECharacterLifeState
ECharacterLifeState
Definition: ECharacterLifeState.c:12
OnControlledEntityChanged
protected void OnControlledEntityChanged(IEntity from, IEntity to)
Runs every time the controlled entity has been changed.
Definition: SCR_VONController.c:603
OnInputDeviceIsGamepad
protected void OnInputDeviceIsGamepad(bool isGamepad)
Game Event.
Definition: SCR_VONController.c:683
OnVONActiveToggled
func OnVONActiveToggled
Definition: SCR_VONController.c:14
m_bIsActiveModeLong
protected bool m_bIsActiveModeLong
Definition: SCR_VONController.c:46
GetDisplay
SCR_VonDisplay GetDisplay()
Definition: SCR_VONController.c:91
AssignVONComponent
bool AssignVONComponent()
Assign VON comp by fetching it from controlled entity.
Definition: SCR_VONController.c:714
NONE
NONE
Definition: SCR_VONController.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
OnVONToggle
protected void OnVONToggle(float value, EActionTrigger reason)
VON toggle val 0 = off / 1 = direct / 2 = channel.
Definition: SCR_VONController.c:355
ScriptGameComponentClass
Definition: ScriptGameComponent.c:12
DeactivateVON
protected void DeactivateVON(EVONTransmitType transmitType=EVONTransmitType.NONE)
Current VON deactivation.
Definition: SCR_VONController.c:536
PauseMenuUI
Definition: SCR_PauseMenuUI.c:2
m_bIsPauseDisabled
protected bool m_bIsPauseDisabled
Definition: SCR_VONController.c:39
OnEntriesChanged
func OnEntriesChanged
Definition: SCR_VONController.c:17
SetVONComponent
void SetVONComponent(SCR_VoNComponent VONComp)
Definition: SCR_VONController.c:133
Init
protected void Init(IEntity owner)
Initialize component, done once per controller.
Definition: SCR_VONController.c:756
EVONTransmitType
EVONTransmitType
Type of a players current VON transmission.
Definition: SCR_VONController.c:3
OnDelete
override void OnDelete(IEntity owner)
Definition: SCR_VONController.c:946
Cleanup
protected void Cleanup()
Cleanup component.
Definition: SCR_VONController.c:807
ConnectToHandleUpdateVONControllersSystem
protected void ConnectToHandleUpdateVONControllersSystem()
Definition: SCR_VONController.c:896
m_VONMenu
protected ref SCR_VONMenu m_VONMenu
Definition: SCR_VONController.c:30
OnVONLongRange
protected void OnVONLongRange(float value, EActionTrigger reason)
VON channel speech listener callback for long range radios.
Definition: SCR_VONController.c:300
m_bIsToggledChannel
protected bool m_bIsToggledChannel
Definition: SCR_VONController.c:43
VON_DIRECT_HOLD
const protected string VON_DIRECT_HOLD
Definition: SCR_VONController.c:32
SetActiveTransmit
protected void SetActiveTransmit(notnull SCR_VONEntry entry)
Set transmission method depending on entry type when starting VON transmit.
Definition: SCR_VONController.c:575
SCR_VONEntryRadio
VONEntry class for radio entries.
Definition: SCR_VONEntryRadio.c:3
m_sActiveHoldAction
protected string m_sActiveHoldAction
Definition: SCR_VONController.c:48
func
func
Definition: SCR_AIThreatSystem.c:5
GetOnEntriesActiveChangedInvoker
ScriptInvokerBase< OnEntriesChanged > GetOnEntriesActiveChangedInvoker()
Definition: SCR_VONController.c:73
SCR_CharacterControllerComponent
Definition: SCR_CharacterControllerComponent.c:35
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
Instigator
Definition: Instigator.c:6
m_LongRangeEntry
protected SCR_VONEntry m_LongRangeEntry
Definition: SCR_VONController.c:56
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
OnVONSwitch
protected void OnVONSwitch(float value, EActionTrigger reason)
VON switch between direct/channel mode.
Definition: SCR_VONController.c:410
m_aEntries
protected ref array< ref SCR_VONEntry > m_aEntries
Definition: SCR_VONController.c:59
UpdateSystemState
protected void UpdateSystemState()
Definition: SCR_VONController.c:887
m_OnEntriesActiveChanged
protected ref ScriptInvokerBase< OnEntriesChanged > m_OnEntriesActiveChanged
Definition: SCR_VONController.c:63
m_VONDisplay
protected SCR_VonDisplay m_VONDisplay
Definition: SCR_VONController.c:54
TOGGLE_OFF_DELAY
const protected float TOGGLE_OFF_DELAY
Definition: SCR_VONController.c:35
OnVONGamepad
protected void OnVONGamepad(float value, EActionTrigger reason)
VON channel speech listener callback.
Definition: SCR_VONController.c:310
GetEntryByTransmitType
protected SCR_VONEntry GetEntryByTransmitType(EVONTransmitType type)
Definition: SCR_VONController.c:556
VONLongRange
protected void VONLongRange(bool activate)
Definition: SCR_VONController.c:470
IsVONDisabled
bool IsVONDisabled()
Is VON disabled.
Definition: SCR_VONController.c:118
VON_LONG_RANGE_HOLD
const protected string VON_LONG_RANGE_HOLD
Definition: SCR_VONController.c:34
EOnDeactivate
override protected void EOnDeactivate(IEntity owner)
Definition: SCR_VONController.c:881
m_bIsUnconscious
protected bool m_bIsUnconscious
Definition: SCR_VONController.c:40
UpdateDebug
protected void UpdateDebug()
Debug.
Definition: SCR_VONController.c:850
m_bIsToggledDirect
protected bool m_bIsToggledDirect
Definition: SCR_VONController.c:42
IsUsingLRR
bool IsUsingLRR()
Using long range radio.
Definition: SCR_VONController.c:170
Attribute
typedef Attribute
Post-process effect of scripted camera.
CHANNEL
CHANNEL
Definition: SCR_VONController.c:4
OnVONLongRangeGamepadToggle
protected void OnVONLongRangeGamepadToggle(float value, EActionTrigger reason)
Definition: SCR_VONController.c:345
m_bIsActive
protected bool m_bIsActive
Definition: SCR_VONController.c:41
OnVONToggleGamepad
protected void OnVONToggleGamepad(float value, EActionTrigger reason)
VON toggle controller.
Definition: SCR_VONController.c:400
DIRECT
DIRECT
Definition: SCR_VONController.c:3
m_OnVONActiveToggled
protected ref ScriptInvokerBase< OnVONActiveToggled > m_OnVONActiveToggled
Definition: SCR_VONController.c:64
OnPostInit
override protected void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_VONController.c:875
OnVONChannel
protected void OnVONChannel(float value, EActionTrigger reason)
VON channel speech listener callback.
Definition: SCR_VONController.c:290
m_DirectSpeechEntry
protected ref SCR_VONEntry m_DirectSpeechEntry
Definition: SCR_VONController.c:58
Deactivate
protected void Deactivate()
Definition: SCR_BaseHintCondition.c:27
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
m_bIsActiveModeDirect
protected bool m_bIsActiveModeDirect
Definition: SCR_VONController.c:45
IsLRRAvailable
bool IsLRRAvailable()
Long range raido entry is available.
Definition: SCR_VONController.c:180
m_fToggleOffDelay
protected float m_fToggleOffDelay
Definition: SCR_VONController.c:47
RemoveEntry
void RemoveEntry(SCR_VONEntry entry)
Definition: SCR_VONController.c:240
OnDestroyed
protected void OnDestroyed(Instigator killer, IEntity killerEntity)
Definition: SCR_VONController.c:658
m_VONComp
protected SCR_VoNComponent m_VONComp
Definition: SCR_VONController.c:53
m_bIsDisabled
protected bool m_bIsDisabled
Definition: SCR_VONController.c:38
m_ActiveEntry
protected SCR_VONEntry m_ActiveEntry
Definition: SCR_VONController.c:55
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
OnVONDirect
protected void OnVONDirect(float value, EActionTrigger reason)
VON direct speech listener callback.
Definition: SCR_VONController.c:280
SetEntryActive
void SetEntryActive(SCR_VONEntry entry, bool setFromMenu=false)
Definition: SCR_VONController.c:189
Update
void Update(float timeSlice)
Definition: SCR_VONController.c:918
OnPauseMenuClosed
protected void OnPauseMenuClosed()
PauseMenuUI Event.
Definition: SCR_VONController.c:704
TimeoutVON
protected void TimeoutVON()
VON hold timeout, stops active von transmission in case of specific condition which would prevent for...
Definition: SCR_VONController.c:595
GetVONComponent
SCR_VoNComponent GetVONComponent()
Get active VON component for transmit.
Definition: SCR_VONController.c:125
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
OnPauseMenuOpened
protected void OnPauseMenuOpened()
PauseMenuUI Event.
Definition: SCR_VONController.c:696
DisconnectFromHandleUpdateVONControllersSystem
protected void DisconnectFromHandleUpdateVONControllersSystem()
Definition: SCR_VONController.c:907
VONDirect
protected void VONDirect(bool activate)
Definition: SCR_VONController.c:426
ECommMethod
ECommMethod
Definition: ECommMethod.c:7
m_sLocalEncryptionKey
protected string m_sLocalEncryptionKey
Definition: SCR_VONController.c:49
GetVONMenu
SCR_VONMenu GetVONMenu()
Definition: SCR_VONController.c:97
m_OnEntriesChanged
protected ref ScriptInvokerBase< OnEntriesChanged > m_OnEntriesChanged
Definition: SCR_VONController.c:62
SCR_VONMenu
Definition: SCR_VONMenu.c:3
OnLifeStateChanged
void OnLifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
Will be called when the life state of the character changes.
Definition: SCR_VONController.c:727
SCR_VONEntry
Voice over network entry data class, used for management of communication methods.
Definition: SCR_VONEntry.c:3
VON_CHANNEL_HOLD
const protected string VON_CHANNEL_HOLD
Definition: SCR_VONController.c:33
AddEntry
void AddEntry(SCR_VONEntry entry)
Definition: SCR_VONController.c:222
InitEncryptionKey
protected void InitEncryptionKey()
Definition: SCR_VONController.c:743
SCR_Faction
Definition: SCR_Faction.c:6
SCR_RadialMenu
Definition: SCR_RadialMenu.c:8
GetPlayerId
proto external int GetPlayerId()
Definition: SCR_SpawnRequestComponent.c:39
VON_MENU_OPENING_CONTEXT
SCR_VONControllerClass VON_MENU_OPENING_CONTEXT
Scripted VON input and control, attached to SCR_PlayerController.
GetOnEntriesChangedInvoker
ScriptInvokerBase< OnEntriesChanged > GetOnEntriesChangedInvoker()
Definition: SCR_VONController.c:67