Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BinocularsComponent.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/Gadgets", description: "Binoculars gadget", color: "0 0 255 255")]
5
6class SCR_BinocularsComponent : SCR_GadgetComponent
7{
8 protected static ref ScriptInvoker s_OnBinocToggled = new ScriptInvoker();
9
10 protected Widget m_RootWidget = null; // binoculars layout
11
12 // Optics reference
14
15 //------------------------------------------------------------------------------------------------
17 protected void SetZoomedViewPlayer(bool value)
18 {
19 SCR_PlayerController.s_pLocalPlayerController.SetIsBinocularsZoomed(value);
20 }
21
22 //------------------------------------------------------------------------------------------------
25 private void SetZoomedView(bool state)
26 {
27 // Check for optics
28 if (!m_Optic)
29 m_Optic = SCR_2DOpticsComponent.Cast(GetOwner().FindComponent(SCR_2DOpticsComponent));
30
31 if (!m_Optic)
32 {
33 Print("Optic component in binoculars was not found!", LogLevel.ERROR);
34 return;
35 }
36
37 // Activate optics
38 if (state)
40 else
42
44
45 // Invoke use
46 if (GetOwner().GetParent() == SCR_PlayerController.GetLocalControlledEntity())
47 s_OnBinocToggled.Invoke(state);
48 }
49
50 //------------------------------------------------------------------------------------------------
51 override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
52 {
53 super.ModeSwitch(mode, charOwner);
54 }
55
56 //------------------------------------------------------------------------------------------------
57 override void ModeClear(EGadgetMode mode)
58 {
59 // not current player
60 IEntity controlledEnt = SCR_PlayerController.GetLocalControlledEntity();
61 if ( !controlledEnt || controlledEnt != m_CharacterOwner )
62 {
63 super.ModeClear(mode);
64 return;
65 }
66
67 if (m_iMode == EGadgetMode.IN_HAND && SCR_PlayerController.s_pLocalPlayerController && SCR_PlayerController.s_pLocalPlayerController.GetIsBinocularsZoomed())
68 ToggleFocused(false);
69
70 super.ModeClear(mode);
71 }
72
73 //------------------------------------------------------------------------------------------------
74 override void ToggleFocused(bool enable)
75 {
76 super.ToggleFocused(enable);
77
78 SetZoomedView(enable);
79 }
80
81 //------------------------------------------------------------------------------------------------
82 override EGadgetType GetType()
83 {
84 return EGadgetType.BINOCULARS;
85 }
86
87 //------------------------------------------------------------------------------------------------
88 override bool CanBeRaised()
89 {
90 return true;
91 }
92
93 //------------------------------------------------------------------------------------------------
94 override bool IsUsingADSControls()
95 {
96 return true;
97 }
98
99 //------------------------------------------------------------------------------------------------
100 override bool IsVisibleEquipped()
101 {
102 return true;
103 }
104
105 //------------------------------------------------------------------------------------------------
106 // destructor
107 void ~SCR_BinocularsComponent()
108 {
109 if (m_RootWidget)
110 {
111 m_RootWidget.SetVisible(false);
112 delete m_RootWidget;
113 }
114 }
115}
SCR_RplTestComponentClass m_CharacterOwner
void SetZoomedViewPlayer(bool value)
Set whether the local character is zoomed in with the binoculars.
SCR_2DOpticsComponent m_Optic
SCR_BinocularsComponentClass s_OnBinocToggled
Widget m_RootWidget
void ModeClear(EGadgetMode mode)
override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
override EGadgetType GetType()
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
override bool IsVisibleEquipped()
override bool CanBeRaised()
Faction GetParent()
override bool IsUsingADSControls()
enum EVehicleType IEntity
override void OnSightADSActivated()
override void OnSightADSDeactivated()
IEntity GetOwner()
Owner entity of the fuel tank.
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
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134