Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
Crosshair.c
Go to the documentation of this file.
1// Todo: PerFrame Optimization and Refactor
2class 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 {
61 m_CharacterController = SCR_CharacterControllerComponent.Cast(character.FindComponent(SCR_CharacterControllerComponent));
62 m_DamageManager = DamageManagerComponent.Cast(character.FindComponent(DamageManagerComponent));
63
64 if (!m_CharacterController)
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};
ArmaReforgerScripted GetGame()
Definition game.c:1398
Widget m_wRoot
bool m_bShown
override void Show()
Definition gameLib.c:262
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14