Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Crosshair.c
Go to the documentation of this file.
1 // Todo: PerFrame Optimization and Refactor
2 class SCR_Crosshair : SCR_InfoDisplay
3 {
4  private const float m_fFadeRate = 8;
5  private SCR_CharacterControllerComponent m_CharacterController;
6  private DamageManagerComponent m_DamageManager;
7  private SCR_PlayerController m_PlayerController;
8  private BaseInteractionHandlerComponent m_InteractionComponent;
9 
10  //------------------------------------------------------------------------------------------------
11  override event void UpdateValues(IEntity owner, float timeSlice)
12  {
13  if (!m_CharacterController || !m_InteractionComponent)
14  return;
15  /*
16  // Todo: Remove this per frame check and rewrite it at event base system
17  // Todo: OnWeaponModeChanged
18  bool ads = m_CharacterController.IsWeaponADS();
19  // Todo: OnFreelookToggle( bool enabled )
20  bool freeLook = m_CharacterController.IsFreeLookEnabled();
21  // Todo: OnWeaponModeChanged
22  bool weaponRaised = m_CharacterController.IsWeaponRaised();
23  // Todo: OnCharacterStateChanged
24  bool playingGesture = m_CharacterController.IsPlayingGesture();
25  // Todo: OnCharacterStateChanged
26  bool sprinting = m_CharacterController.GetSprinting();
27  // Todo: OnCharacterDie
28  bool alive = true;
29  if (m_DamageManager && m_DamageManager.GetState() != EDamageState.ALIVE)
30  alive = false;
31  */
32 
33  // TODO: Check why some methods are not working
34  //bool show = /*weaponRaised && */!ads && !playingGesture && /*!sprinting &&*/ !freeLook && alive;
35 
36  bool show = m_InteractionComponent.IsInteractionAvailable();
37  Show(show, m_fFadeRate);
38  }
39 
40  //------------------------------------------------------------------------------------------------
41  override event void OnStartDraw(IEntity owner)
42  {
43  super.OnStartDraw(owner);
44  if (m_wRoot)
45  {
46  m_wRoot.SetOpacity(0);
47  m_bShown = false;
48  }
49 
50  ChimeraGame g = GetGame();
51  if (g)
52  {
53  PlayerController controller = g.GetPlayerController();
54  if (controller)
55  m_InteractionComponent = BaseInteractionHandlerComponent.Cast(controller.FindComponent(BaseInteractionHandlerComponent));
56  }
57 
58  ChimeraCharacter character = ChimeraCharacter.Cast(owner);
59  if (character)
60  {
62  m_DamageManager = DamageManagerComponent.Cast(character.FindComponent(DamageManagerComponent));
63 
65  {
66  Print(string.Format("Character Controller not found in %1 for %2, HUD will not work.", "CharacterUnitInfoDisplay", character.GetName()), LogLevel.WARNING);
67  return;
68  }
69  }
70  }
71 };
m_bShown
protected bool m_bShown
Definition: SCR_InfoDisplay.c:61
SCR_PlayerController
Definition: SCR_PlayerController.c:31
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
ChimeraGame
Definition: ChimeraGame.c:7
m_CharacterController
SCR_CharacterPerceivableComponentClass m_CharacterController
SCR_CharacterControllerComponent
Definition: SCR_CharacterControllerComponent.c:35
Show
override void Show(WorkspaceWidget pWorkspace, Widget pToolTipWidget, float desiredPosX, float desiredPosY)
Definition: SCR_ScriptedWidgetTooltip.c:55
SCR_Crosshair
Definition: Crosshair.c:2
DamageManagerComponent
Definition: DamageManagerComponent.c:12
m_DamageManager
DamageManagerComponent m_DamageManager
Definition: SCR_AITargetInfo.c:19