Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_PlayerController.c
Go to the documentation of this file.
2 {
3 };
4 
5 //------------------------------------------------------------------------------------------------
6 void OnControlledEntityChangedPlayerController(IEntity from, IEntity to);
8 typedef ScriptInvokerBase<OnControlledEntityChangedPlayerController> OnControlledEntityChangedPlayerControllerInvoker;
9 
10 //------------------------------------------------------------------------------------------------
11 void OwnershipChangedDelegate(bool isChanging, bool becameOwner);
13 typedef ScriptInvokerBase<OwnershipChangedDelegate> OnOwnershipChangedInvoker;
14 
15 //------------------------------------------------------------------------------------------------
16 void OnDestroyedPlayerController(Instigator killer, IEntity killerEntity);
18 typedef ScriptInvokerBase<OnDestroyedPlayerController> OnDestroyedPlayerControllerInvoker;
19 
20 //------------------------------------------------------------------------------------------------
21 void OnPossessed(IEntity entity);
22 typedef func OnPossessed;
23 typedef ScriptInvokerBase<OnPossessed> OnPossessedInvoker;
24 
25 //------------------------------------------------------------------------------------------------
26 void OnBeforePossessed(IEntity entity);
28 typedef ScriptInvokerBase<OnBeforePossessed> OnBeforePossessedInvoker;
29 
30 //------------------------------------------------------------------------------------------------
31 class SCR_PlayerController : PlayerController
32 {
33  static PlayerController s_pLocalPlayerController;
34  protected static const float WALK_SPEED = 0.5;
35  protected static const float FOCUS_ACTIVATION = 0.1;
36  protected static const float FOCUS_DEACTIVATION = 0.05;
37  protected static const float FOCUS_TIMEOUT = 0.3;
38  protected static const float FOCUS_TOLERANCE = 0.005;
39  protected static float s_fADSFocus = 0.7;
40  protected static float s_fFocusTimeout;
41  protected static float s_fFocusAnalogue;
42  protected static bool s_bWasADS;
43 
44  protected CharacterControllerComponent m_CharacterController;
45  protected bool m_bIsLocalPlayerController;
46  protected bool m_bIsPaused;
47  bool m_bRetain3PV;
48  protected bool m_bGadgetFocus;
49  protected bool m_bFocusToggle;
50  protected float m_fCharacterSpeed;
51 
52 
53  [RplProp(onRplName: "OnRplMainEntityFromID")]
54  protected RplId m_MainEntityID;
55  protected IEntity m_MainEntity;
56 
57  [RplProp()]
58  protected bool m_bIsPossessing;
59 
60  ref OnBeforePossessedInvoker m_OnBeforePossess = new OnBeforePossessedInvoker(); // Before an entity becomes possesed.
61  ref OnPossessedInvoker m_OnPossessed = new OnPossessedInvoker(); // when entity becomes possessed or control returns to the main entity
63  ref OnDestroyedPlayerControllerInvoker m_OnDestroyed = new OnDestroyedPlayerControllerInvoker(); // main entity is destroyed
64  ref OnOwnershipChangedInvoker m_OnOwnershipChangedInvoker = new OnOwnershipChangedInvoker();
65  //------------------------------------------------------------------------------------------------
69  OnOwnershipChangedInvoker GetOnOwnershipChangedInvoker()
70  {
71  return m_OnOwnershipChangedInvoker;
72  }
73 
74  //------------------------------------------------------------------------------------------------
78  protected override void OnOwnershipChanged(bool changing, bool becameOwner)
79  {
80  super.OnOwnershipChanged(changing, becameOwner);
81  m_OnOwnershipChangedInvoker.Invoke(changing, becameOwner);
82  }
83 
84  override void OnControlledEntityChanged(IEntity from, IEntity to)
85  {
86  // todo: react to change, inform fe. VONController
87  m_OnControlledEntityChanged.Invoke(from, to);
88  }
89 
90  //------------------------------------------------------------------------------------------------
93  void SetGameUserSettings()
94  {
95  IEntity controlledEntity = GetControlledEntity();
96  if (!controlledEntity)
97  {
98  return;
99  }
100  m_CharacterController = CharacterControllerComponent.Cast(controlledEntity.FindComponent(CharacterControllerComponent));
102  {
103  return;
104  }
105 
106  BaseContainer aimSensitivitySettings = GetGame().GetGameUserSettings().GetModule("SCR_AimSensitivitySettings");
107 
108  if (aimSensitivitySettings)
109  {
110  float aimSensitivityMouse;
111  float aimSensitivityGamepad;
112  float aimMultipADS;
113 
114  if (aimSensitivitySettings.Get("m_fMouseSensitivity", aimSensitivityMouse) &&
115  aimSensitivitySettings.Get("m_fStickSensitivity", aimSensitivityGamepad) &&
116  aimSensitivitySettings.Get("m_fAimADS", aimMultipADS))
117  {
118  m_CharacterController.SetAimingSensitivity(aimSensitivityMouse, aimSensitivityGamepad, aimMultipADS);
119  }
120 
121 
122  }
123 
124  BaseContainer gameplaySettings = GetGame().GetGameUserSettings().GetModule("SCR_GameplaySettings");
125 
126  if (gameplaySettings)
127  {
128  bool stickyADS = true;
129  if (gameplaySettings.Get("m_bStickyADS", stickyADS))
130  m_CharacterController.SetStickyADS(stickyADS);
131 
132  bool stickyGadgets = true;
133  if (gameplaySettings.Get("m_bStickyGadgets", stickyGadgets))
134  m_CharacterController.SetStickyGadget(stickyGadgets);
135 
136  bool mouseControlAircraft = true;
137  if (gameplaySettings.Get("m_bMouseControlAircraft", mouseControlAircraft))
138  m_CharacterController.SetMouseControlAircraft(mouseControlAircraft);
139 
140  EVehicleDrivingAssistanceMode drivingAssistance;
142  {
143  if (gameplaySettings.Get("m_eDrivingAssistance", drivingAssistance))
144  VehicleControllerComponent.SetDrivingAssistanceMode(drivingAssistance);
145  }
146  else
147  {
148  if (gameplaySettings.Get("m_eDrivingAssistance", drivingAssistance))
149  VehicleControllerComponent_SA.SetDrivingAssistanceMode(drivingAssistance);
150  }
151  }
152 
153  //TODO: we might want to set default focusInADS to 100 on XBOX and PSN ( default for mouse control should be 70 - see SCR_GameplaySettings )
154  BaseContainer fovSettings = GetGame().GetGameUserSettings().GetModule("SCR_FieldOfViewSettings");
155  if (fovSettings)
156  {
157  float focusInADS = 0.5;
158  if (fovSettings.Get("m_fFocusInADS", focusInADS))
159  s_fADSFocus = focusInADS;
160  }
161  }
162 
163  //------------------------------------------------------------------------------------------------
169  void SetPossessedEntity(IEntity entity)
170  {
171  if (!m_bIsPossessing)
172  {
173  if (entity)
174  {
175  m_OnBeforePossess.Invoke(entity);
176  //--- Start posessing
177  m_bIsPossessing = true;
178 
179  //--- Remember previously controlled entity
180  IEntity controlledEntity = GetControlledEntity();
181  m_MainEntityID = RplId.Invalid();
182  if (controlledEntity)
183  {
184  RplComponent rpl = RplComponent.Cast(controlledEntity.FindComponent(RplComponent));
185  if (rpl)
186  {
187  rpl.GiveExt(RplIdentity.Local(), false);
188  m_MainEntityID = rpl.Id();
189  }
190  }
191 
192  OnRplMainEntityFromID(); //--- ToDo: Remove? BumpMe should call it automatically.
193  Replication.BumpMe();
194 
195  //-- Tell manager we're possessing an entity
196  SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
197  if (possessingManager)
198  possessingManager.SetMainEntity(GetPlayerId(), entity, controlledEntity, m_bIsPossessing);
199 
200  //--- Switch control
201  RplComponent rpl = RplComponent.Cast(entity.FindComponent(RplComponent));
202  if (rpl)
203  rpl.GiveExt(GetRplIdentity(), false);
204  SetAIActivation(entity, false);
205  SetControlledEntity(entity);
206  m_OnPossessed.Invoke(entity);
207  }
208  }
209  else
210  {
211  if (!entity)
212  {
213  //--- Stop possessing
214  m_bIsPossessing = false;
215 
216  //--- Forget main entity
217  m_MainEntityID = RplId.Invalid();
218  OnRplMainEntityFromID(); //--- ToDo: Remove?
219  Replication.BumpMe();
220 
221  SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
222  if (possessingManager)
223  possessingManager.SetMainEntity(GetPlayerId(), GetControlledEntity(), m_MainEntity, m_bIsPossessing);
224 
225  //--- Switch control
226  IEntity controlledEntity = GetControlledEntity();
227  if (controlledEntity)
228  {
229  RplComponent rpl = RplComponent.Cast(controlledEntity.FindComponent(RplComponent));
230  if (rpl)
231  rpl.GiveExt(RplIdentity.Local(), false);
232 
233  SetAIActivation(controlledEntity, true);
234  }
235 
236  //--- Switch control
237  if (m_MainEntity)
238  {
239  RplComponent rpl = RplComponent.Cast(m_MainEntity.FindComponent(RplComponent));
240  if (rpl)
241  rpl.GiveExt(GetRplIdentity(), false);
242  }
243  SetControlledEntity(m_MainEntity);
244  m_OnPossessed.Invoke(m_MainEntity);
245 
246  //--- SetControlledEntity(null) doesn't work yet. ToDo: Remove this check once it's implemented
247  if (GetControlledEntity() != m_MainEntity)
248  Print(string.Format("Error when switching control back to m_MainEntity = %1!", m_MainEntity), LogLevel.WARNING);
249  }
250  else
251  {
252  //--- Switch possessing
253  SetPossessedEntity(null);
254  SetPossessedEntity(entity);
255  m_OnPossessed.Invoke(entity);
256  }
257  }
258  }
259 
260  //------------------------------------------------------------------------------------------------
265  void SetInitialMainEntity(notnull IEntity entity)
266  {
267  RplComponent rpl = RplComponent.Cast(entity.FindComponent(RplComponent));
268  if (!rpl)
269  return;
270 
271  m_MainEntityID = rpl.Id();
272  OnRplMainEntityFromID();
273  Replication.BumpMe();
274 
275  SCR_PossessingManagerComponent possessingManager = SCR_PossessingManagerComponent.GetInstance();
276  if (possessingManager)
277  possessingManager.SetMainEntity(GetPlayerId(), GetControlledEntity(), entity, m_bIsPossessing);
278 
279  rpl.GiveExt(GetRplIdentity(), false); // transfer ownership
280  SetAIActivation(entity, false);
281  SetControlledEntity(entity);
282 
283  m_OnPossessed.Invoke(entity);
284  }
285 
286  //------------------------------------------------------------------------------------------------
291  bool IsPossessing()
292  {
293  return m_bIsPossessing;
294  }
295  //------------------------------------------------------------------------------------------------
302  IEntity GetMainEntity()
303  {
304  if (m_bIsPossessing)
305  return m_MainEntity;
306  else
307  return GetControlledEntity();
308  }
309  //------------------------------------------------------------------------------------------------
310  protected void OnRplMainEntityFromID()
311  {
312  //m_MainEntity = IEntity.Cast(Replication.FindItem(m_MainEntityID));
313  RplComponent rpl = RplComponent.Cast(Replication.FindItem(m_MainEntityID));
314  if (rpl)
315  m_MainEntity = rpl.GetEntity();
316  }
317  //------------------------------------------------------------------------------------------------
318  protected void SetAIActivation(IEntity entity, bool activate)
319  {
320  if (!entity)
321  return;
322 
323  AIControlComponent aiControl = AIControlComponent.Cast(entity.FindComponent(AIControlComponent));
324  if (!aiControl)
325  return;
326 
327  if (activate)
328  aiControl.ActivateAI();
329  else
330  aiControl.DeactivateAI();
331  }
332 
333  //------------------------------------------------------------------------------------------------
335  static int GetLocalPlayerId()
336  {
337  PlayerController pPlayerController = GetGame().GetPlayerController();
338  if (!pPlayerController)
339  return 0;
340 
341  return pPlayerController.GetPlayerId();
342  }
343 
344  //------------------------------------------------------------------------------------------------
349  static IEntity GetLocalControlledEntity()
350  {
351  PlayerController pPlayerController = GetGame().GetPlayerController();
352  if (pPlayerController)
353  return pPlayerController.GetControlledEntity();
354 
355  return null;
356  }
363  static IEntity GetLocalMainEntity()
364  {
366  if (playerController)
367  return playerController.GetMainEntity();
368  else
369  return null;
370  }
371 
372  //------------------------------------------------------------------------------------------------
377  static Faction GetLocalControlledEntityFaction()
378  {
379  PlayerController playerController = GetGame().GetPlayerController();
380  if (!playerController)
381  return null;
382 
383  IEntity controlledEntity = playerController.GetControlledEntity();
384  if (!controlledEntity)
385  return null;
386 
387  FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(controlledEntity.FindComponent(FactionAffiliationComponent));
388  if (factionAffiliation)
389  return factionAffiliation.GetAffiliatedFaction();
390  else
391  return null;
392  }
399  static Faction GetLocalMainEntityFaction()
400  {
402  if (!playerController)
403  return null;
404 
405  IEntity controlledEntity = playerController.GetMainEntity();
406  if (!controlledEntity)
407  return null;
408 
409  FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(controlledEntity.FindComponent(FactionAffiliationComponent));
410  if (factionAffiliation)
411  return factionAffiliation.GetAffiliatedFaction();
412  else
413  return null;
414  }
415 
416  //------------------------------------------------------------------------------------------------
417  override void OnDestroyed(notnull Instigator killer)
418  {
419  super.OnDestroyed(killer);
420  IEntity killerEntity = killer.GetInstigatorEntity();
421  m_OnDestroyed.Invoke(killer, killerEntity);
422  }
423 
424  //------------------------------------------------------------------------------------------------
425  override void OnUpdate(float timeSlice)
426  {
427  if (!s_pLocalPlayerController)
428  UpdateLocalPlayerController();
429 
430  if (m_bIsLocalPlayerController)
431  {
432  UpdateControls();
433  //UpdateUI();
434  }
435  }
436 
438  protected void UpdateLocalPlayerController()
439  {
440  m_bIsLocalPlayerController = this == GetGame().GetPlayerController();
441  if (!m_bIsLocalPlayerController)
442  return;
443 
444  s_pLocalPlayerController = this;
445  InputManager inputManager = GetGame().GetInputManager();
446  if (!inputManager)
447  return;
448 
449  inputManager.AddActionListener("WeaponChangeMagnification", EActionTrigger.VALUE, ChangeMagnification);
450  inputManager.AddActionListener("CharacterWalk", EActionTrigger.DOWN, OnWalk);
451  inputManager.AddActionListener("CharacterWalk", EActionTrigger.UP, OnEndWalk);
452  inputManager.AddActionListener("FocusToggle", EActionTrigger.DOWN, ActionFocusToggle);
453  inputManager.AddActionListener("FocusToggleUnarmed", EActionTrigger.DOWN, ActionFocusToggleUnarmed);
454  inputManager.AddActionListener("Inventory", EActionTrigger.DOWN, ActionOpenInventory );
455  inputManager.AddActionListener("TacticalPing", EActionTrigger.DOWN, ActionGesturePing );
456  inputManager.AddActionListener("TacticalPingHold", EActionTrigger.DOWN, ActionGesturePingHold );
457  inputManager.AddActionListener("TacticalPingHold", EActionTrigger.UP, ActionGesturePingHold );
458  inputManager.AddActionListener("WeaponSwitchOptics", EActionTrigger.UP, ChangeWeaponOptics);
459  }
460 
462  protected void UpdateControls()
463  {
464  bool disableControls = GetGame().GetMenuManager().IsAnyMenuOpen();
465  if (m_bIsPaused != disableControls)
466  {
467  m_bIsPaused = disableControls;
468  SetDisableControls(disableControls);
469  }
470  }
471 
472  protected void UpdateUI()
473  {
474  ChimeraCharacter char = ChimeraCharacter.Cast(GetControlledEntity());
475  if (!char)
476  return;
477  CharacterAnimationComponent animComp = char.GetAnimationComponent();
478  if (!animComp)
479  return;
480  // Command ladder is present only when character is using ladder
481  CharacterCommandLadder ladderCMD = animComp.GetCommandHandler().GetCommandLadder();
482  if (!ladderCMD)
483  return;
484  int lrExitState = ladderCMD.CanExitLR();
485  if (lrExitState & 0x1)
486  {
487  Print("Can exit right");
488  }
489  if (lrExitState & 0x2)
490  {
491  Print("Can exit left");
492  }
493  }
494 
495  protected void ChangeMagnification(float value)
496  {
497  SCR_CharacterControllerComponent characterController = GetCharacterController();
498  if (characterController)
499  characterController.SetNextSightsFOVInfo(value);
500  }
501 
502  protected void ChangeWeaponOptics()
503  {
504  SCR_CharacterControllerComponent characterController = GetCharacterController();
505  if (characterController)
506  characterController.SetNextSights();
507  }
508 
509  protected SCR_CharacterControllerComponent GetCharacterController()
510  {
511  ChimeraCharacter char = ChimeraCharacter.Cast(GetControlledEntity());
512  if (!char)
513  return null;
514 
515  return SCR_CharacterControllerComponent.Cast(char.GetCharacterController());
516  }
517 
518  // Parameter value:
519  // TRUE: Disables the controls
520  // FALSE: Enables the controls
521  private void SetDisableControls(bool value)
522  {
523  SCR_CharacterControllerComponent characterController = GetCharacterController();
524  if (!characterController)
525  return;
526 
527  characterController.SetDisableViewControls(value);
528  characterController.SetDisableWeaponControls(value);
529  characterController.SetDisableMovementControls(value)
530  }
531 
532  //------------------------------------------------------------------------------------------------
538  float GetFocusValue(float adsProgress = 0, float dt = -1)
539  {
541  return 0;
542 
543  float focus;
544 
545  // Autofocus
546  if (adsProgress > 0)
547  focus = s_fADSFocus * Math.Min(adsProgress, 1);
548 
549  InputManager inputManager = GetGame().GetInputManager();
550 
551  // Cancel toggled focus when focus is held
552  bool inputDigital = inputManager.GetActionTriggered("Focus");
553  if (inputDigital && m_bFocusToggle)
554  m_bFocusToggle = false;
555 
556  // Conditions must be consistent with ActionFocusToggle and ActionFocusToggleUnarmed
557  ChimeraCharacter character = m_CharacterController.GetCharacter();
558  if (m_bFocusToggle && character)
559  {
560  if (character.IsInVehicle())
561  {
562  // Cancel toggle focus when in vehicle and aiming through gadget (binocular, compass)
563  if (m_bGadgetFocus)
564  m_bFocusToggle = false;
565 
566  // Cancel toggle focus when in vehicle and not in forced freelook
567  if (!m_CharacterController.IsFreeLookEnabled() && !m_CharacterController.GetFreeLookInput())
568  m_bFocusToggle = false;
569  }
570  else
571  {
572  // Cancel toggle focus when not in vehicle and holding item in hands
573  if (m_CharacterController.GetCurrentItemInHands())
574  m_bFocusToggle = false;
575 
576  // Cancel toggle focus when not in vehicle and holding gadget
577  if (m_CharacterController.IsGadgetInHands())
578  m_bFocusToggle = false;
579  }
580  }
581 
582  // Ground vehicles have different focus action to prevent conflict with brakes
583  float inputAnalogue;
584  if (!inputManager.IsContextActive("CarContext") && !inputManager.IsContextActive("HelicopterContext"))
585  {
586  // Square root input to focus mapping results in linear change of picture area
587  float focusAnalogue = Math.Sqrt(inputManager.GetActionValue("FocusAnalog"));
588 
589  // Tolerance to prevent jittering
590  if (focusAnalogue < FOCUS_DEACTIVATION)
591  s_fFocusAnalogue = 0;
592  else if (!float.AlmostEqual(s_fFocusAnalogue, focusAnalogue, FOCUS_TOLERANCE))
593  s_fFocusAnalogue = focusAnalogue;
594 
595  inputAnalogue = s_fFocusAnalogue;
596  }
597 
598  bool isADS = m_CharacterController.GetWeaponADSInput();
599 
600  // Check gadget ADS
601  if (!isADS && m_CharacterController.IsGadgetInHands())
602  isADS = m_CharacterController.IsGadgetRaisedModeWanted();
603 
604  // Verify turrets
605  if (!isADS && character)
606  {
607  CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
608 
609  BaseCompartmentSlot compartment;
610  if (compartmentAccess)
611  compartment = compartmentAccess.GetCompartment();
612 
613  TurretControllerComponent turretController;
614  if (compartment)
615  turretController = TurretControllerComponent.Cast(compartment.GetController());
616 
617  if (turretController)
618  isADS = turretController.IsWeaponADS();
619  }
620 
621  // Prevent focus warping back while toggling ADS on controller
622  // analogue: track timeout as we have no input filter that has thresholds or delays and returns axis value yet
623  if (inputAnalogue < FOCUS_DEACTIVATION)
624  s_fFocusTimeout = FOCUS_TIMEOUT; // Below deactivation threshold
625  else if (s_bWasADS != isADS && s_fFocusTimeout > 0)
626  s_fFocusTimeout = FOCUS_TIMEOUT; // ADS toggled
627  else if (inputAnalogue < FOCUS_ACTIVATION && s_fFocusTimeout > 0)
628  s_fFocusTimeout = FOCUS_TIMEOUT; // Below activation threshold and not active
629  else if (s_fFocusTimeout > dt)
630  s_fFocusTimeout -= dt; // Not yet active, decrementing
631  else
632  s_fFocusTimeout = 0; // Activated
633 
634  // Cancel toggle focus with analogue input
635  if (m_bFocusToggle && s_fFocusTimeout == 0)
636  m_bFocusToggle = false;
637 
638  s_bWasADS = isADS;
639 
640  // Combine all valid input sources
641  float input;
642  if (m_bFocusToggle || inputDigital)
643  input = 1;
644  else if (s_fFocusTimeout == 0)
645  input = inputAnalogue;
646 
647  if (input > 0)
648  focus = Math.Max(focus, input);
649 
650  // Ensure return value always within 0-1
651  focus = Math.Clamp(focus, 0, 1);
652  return focus;
653  }
654 
655  //------------------------------------------------------------------------------------------------
657  void SetGadgetFocus(bool gadgetFocus)
658  {
659  m_bGadgetFocus = gadgetFocus;
660  }
661 
662  //------------------------------------------------------------------------------------------------
664  bool GetGadgetFocus()
665  {
666  return m_bGadgetFocus;
667  }
668 
669  //------------------------------------------------------------------------------------------------
670  void ActionFocusToggle(float value = 0.0, EActionTrigger reason = 0)
671  {
673  return;
674 
675  // Conditions must be consistent with GetFocusValue logic
676  ChimeraCharacter character = m_CharacterController.GetCharacter();
677  if (character && !character.IsInVehicle())
678  return;
679 
680  // Cancel toggle focus when in vehicle and aiming through gadget (binocular, compass)
681  if (m_bGadgetFocus)
682  return;
683 
684  // Cancel toggle focus when in vehicle and not in forced freelook
685  if (!m_CharacterController.IsFreeLookEnabled() && !m_CharacterController.GetFreeLookInput())
686  return;
687 
688  m_bFocusToggle = !m_bFocusToggle;
689  }
690 
691  //------------------------------------------------------------------------------------------------
692  void ActionFocusToggleUnarmed(float value = 0.0, EActionTrigger reason = 0)
693  {
695  return;
696 
697  // Conditions must be consistent with GetFocusValue logic
698  ChimeraCharacter character = m_CharacterController.GetCharacter();
699  if (character && character.IsInVehicle())
700  return;
701 
702  // Cancel toggle focus when not in vehicle and holding item in hands
703  if (m_CharacterController.GetCurrentItemInHands())
704  return;
705 
706  // Cancel toggle focus when not in vehicle and holding gadget
707  if (m_CharacterController.IsGadgetInHands())
708  return;
709 
710  // Allow cancelling unarmed focus while picking up items
711  // Disallow enabling unarmed focus while picking up items, as it may become irreleant quickly
712  // Reason is player may want to enter ADS before ready, while intent is unclear
713  if (!m_bFocusToggle && m_CharacterController.IsPlayingItemGesture())
714  return;
715 
716  m_bFocusToggle = !m_bFocusToggle;
717  }
718 
719  //------------------------------------------------------------------------------------------------
720  void OnWalk()
721  {
722  if (!m_CharacterController || m_CharacterController.GetDynamicSpeed() == WALK_SPEED)
723  return;
724 
725  m_fCharacterSpeed = m_CharacterController.GetDynamicSpeed();
726  m_CharacterController.SetDynamicSpeed(WALK_SPEED);
727  m_CharacterController.SetShouldApplyDynamicSpeedOverride(true);
728  }
729 
730  //------------------------------------------------------------------------------------------------
731  void OnEndWalk()
732  {
733  if (!m_CharacterController || m_CharacterController.GetDynamicSpeed() == m_fCharacterSpeed)
734  return;
735 
736  m_CharacterController.SetDynamicSpeed(m_fCharacterSpeed);
737  m_CharacterController.SetShouldApplyDynamicSpeedOverride(false);
738  }
739 
740  //------------------------------------------------------------------------------------------------
741  void ActionOpenInventory()
742  {
743  IEntity entity = s_pLocalPlayerController.GetControlledEntity();
744  if (!entity)
745  return;
746 
747  SCR_InventoryStorageManagerComponent inventory = SCR_InventoryStorageManagerComponent.Cast(entity.FindComponent(SCR_InventoryStorageManagerComponent));
748  if (inventory)
749  inventory.Action_OpenInventory();
750  }
751 
752  //------------------------------------------------------------------------------------------------
753  void ActionGesturePing(float value = 0.0, EActionTrigger reason = 0)
754  {
756  return;
757 
758  // Press and forget variant... eg press comma once - character will point with it's finger for 1 second (including blending time from animation graph ~300ms)
759  m_CharacterController.TryStartCharacterGesture(ECharacterGestures.POINT_WITH_FINGER, 1500);
760  }
761 
762  //------------------------------------------------------------------------------------------------
763  void ActionGesturePingHold(float value = 0.0, EActionTrigger reason = 0)
764  {
766  return;
767 
768  // Hold key variant... hold period - character will point with it's finger until period key is released
769  if (reason == EActionTrigger.DOWN)
770  {
771  m_CharacterController.TryStartCharacterGesture(ECharacterGestures.POINT_WITH_FINGER);
772  } else if ( reason == EActionTrigger.UP)
773  {
774  m_CharacterController.StopCharacterGesture();
775  }
776  }
777 
778  //------------------------------------------------------------------------------------------------
779  override void EOnInit(IEntity owner)
780  {
781  super.EOnInit(owner);
782 
783  //HACK: SCR_PlayerController must insert SCR_InteractionHandlerComponent OnControlledEntityChanged into script invoker due to fact that the latter calls its OnInit only for the host
784  SCR_InteractionHandlerComponent handler = SCR_InteractionHandlerComponent.Cast(owner.FindComponent(SCR_InteractionHandlerComponent));
785  if (!handler)
786  return;
787 
788  m_OnControlledEntityChanged.Insert(handler.OnControlledEntityChanged);
789  }
790 }
OnOwnershipChangedInvoker
ScriptInvokerBase< OwnershipChangedDelegate > OnOwnershipChangedInvoker
Definition: SCR_PlayerController.c:13
m_OnDestroyed
protected ref ScriptInvokerEntity m_OnDestroyed
Definition: SCR_EditableCharacterComponent.c:25
SCR_PlayerController
Definition: SCR_PlayerController.c:31
OnPossessedInvoker
ScriptInvokerBase< OnPossessed > OnPossessedInvoker
Definition: SCR_PlayerController.c:23
OnBeforePossessed
func OnBeforePossessed
Definition: SCR_PlayerController.c:27
RplProp
SCR_RplTestEntityClass RplProp
Used for handling entity spawning requests for SCR_CatalogEntitySpawnerComponent and inherited classe...
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
OnControlledEntityChangedPlayerController
func OnControlledEntityChangedPlayerController
Definition: SCR_PlayerController.c:7
m_CharacterController
SCR_CharacterPerceivableComponentClass m_CharacterController
func
func
Definition: SCR_AIThreatSystem.c:5
SCR_CharacterControllerComponent
Definition: SCR_CharacterControllerComponent.c:35
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
Instigator
Definition: Instigator.c:6
OnPossessed
func OnPossessed
Definition: SCR_PlayerController.c:22
OnDestroyedPlayerControllerInvoker
ScriptInvokerBase< OnDestroyedPlayerController > OnDestroyedPlayerControllerInvoker
Definition: SCR_PlayerController.c:18
GetIsClientAuthority
override bool GetIsClientAuthority()
Definition: game.c:268
PlayerControllerClass
Definition: PlayerController.c:12
EVehicleDrivingAssistanceMode
EVehicleDrivingAssistanceMode
Player vehicle driving assistance modes. Individual features may become separate options in future.
Definition: EVehicleDrivingAssistanceMode.c:13
GetControlledEntity
SCR_EditableEntityComponent GetControlledEntity()
Returns the controlled entity or null if none.
Definition: SCR_EditablePlayerDelegateComponent.c:86
SCR_PlayerControllerClass
Definition: SCR_PlayerController.c:1
OnDestroyedPlayerController
func OnDestroyedPlayerController
Definition: SCR_PlayerController.c:17
Faction
Definition: Faction.c:12
TurretControllerComponent
Definition: TurretControllerComponent.c:12
OnBeforePossessedInvoker
ScriptInvokerBase< OnBeforePossessed > OnBeforePossessedInvoker
Definition: SCR_PlayerController.c:28
OwnershipChangedDelegate
func OwnershipChangedDelegate
Definition: SCR_PlayerController.c:12
SetControlledEntity
void SetControlledEntity(IEntity controlledEntity)
Definition: SCR_EditablePlayerDelegateComponent.c:68
GetRplIdentity
proto external int GetRplIdentity()
CharacterCommandLadder
Definition: CharacterCommandLadder.c:12
OnControlledEntityChangedPlayerControllerInvoker
ScriptInvokerBase< OnControlledEntityChangedPlayerController > OnControlledEntityChangedPlayerControllerInvoker
Definition: SCR_PlayerController.c:8
GetPlayerId
proto external int GetPlayerId()
Definition: SCR_SpawnRequestComponent.c:39