Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BinocularsComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Gadgets", description: "Binoculars gadget", color: "0 0 255 255")]
3 {
4 }
5 
6 class 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  protected static bool m_bZoomed = false; // local character zoomed state
13 
14  // Optics reference
16 
17  //------------------------------------------------------------------------------------------------
19  static bool IsZoomedView()
20  {
21  return m_bZoomed;
22  }
23 
24  //------------------------------------------------------------------------------------------------
27  private void SetZoomedView(bool state)
28  {
29  // Check for optics
30  if (!m_Optic)
32 
33  if (!m_Optic)
34  {
35  Print("Optic component in binoculars was not found!", LogLevel.ERROR);
36  return;
37  }
38 
39  // Activate optics
40  if (state)
41  {
42  m_Optic.OnSightADSActivated();
43  m_bZoomed = true;
44  }
45  else
46  {
47  m_Optic.OnSightADSDeactivated();
48  m_bZoomed = false;
49  }
50 
51  // Invoke use
52  if (GetOwner().GetParent() == SCR_PlayerController.GetLocalControlledEntity())
53  s_OnBinocToggled.Invoke(state);
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
58  {
59  super.ModeSwitch(mode, charOwner);
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  override void ModeClear(EGadgetMode mode)
64  {
65  // not current player
66  IEntity controlledEnt = SCR_PlayerController.GetLocalControlledEntity();
67  if ( !controlledEnt || controlledEnt != m_CharacterOwner )
68  {
69  super.ModeClear(mode);
70  return;
71  }
72 
73  if (m_iMode == EGadgetMode.IN_HAND && m_bZoomed)
74  ToggleFocused(false);
75 
76  super.ModeClear(mode);
77  }
78 
79  //------------------------------------------------------------------------------------------------
80  override void ToggleFocused(bool enable)
81  {
82  super.ToggleFocused(enable);
83 
84  SetZoomedView(enable);
85  }
86 
87  //------------------------------------------------------------------------------------------------
88  override EGadgetType GetType()
89  {
90  return EGadgetType.BINOCULARS;
91  }
92 
93  //------------------------------------------------------------------------------------------------
94  override bool CanBeRaised()
95  {
96  return true;
97  }
98 
99  //------------------------------------------------------------------------------------------------
100  override bool IsUsingADSControls()
101  {
102  return true;
103  }
104 
105  //------------------------------------------------------------------------------------------------
106  override bool IsVisibleEquipped()
107  {
108  return true;
109  }
110 
111  //------------------------------------------------------------------------------------------------
112  // destructor
114  {
115  if (m_RootWidget)
116  {
117  m_RootWidget.SetVisible(false);
118  delete m_RootWidget;
119  }
120  }
121 }
s_OnBinocToggled
SCR_BinocularsComponentClass s_OnBinocToggled
m_RootWidget
protected Widget m_RootWidget
Definition: SCR_BinocularsComponent.c:10
SCR_PlayerController
Definition: SCR_PlayerController.c:31
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
ModeClear
override void ModeClear(EGadgetMode mode)
Definition: SCR_BinocularsComponent.c:63
SCR_GadgetComponentClass
Definition: SCR_GadgetComponent.c:2
m_Optic
protected SCR_2DOpticsComponent m_Optic
Definition: SCR_BinocularsComponent.c:15
SCR_2DOpticsComponent
Definition: SCR_2DOpticsComponent.c:12
IsVisibleEquipped
override bool IsVisibleEquipped()
Definition: SCR_BinocularsComponent.c:106
m_CharacterOwner
SCR_RplTestComponentClass m_CharacterOwner
SCR_BinocularsComponentClass
Definition: SCR_BinocularsComponent.c:2
SetZoomedView
private void SetZoomedView(bool state)
Definition: SCR_BinocularsComponent.c:27
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
ToggleFocused
override void ToggleFocused(bool enable)
Definition: SCR_BinocularsComponent.c:80
IsUsingADSControls
override bool IsUsingADSControls()
Definition: SCR_BinocularsComponent.c:100
GetType
override EGadgetType GetType()
Definition: SCR_BinocularsComponent.c:88
~SCR_BinocularsComponent
void ~SCR_BinocularsComponent()
Definition: SCR_BinocularsComponent.c:113
ModeSwitch
override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
Definition: SCR_BinocularsComponent.c:57
CanBeRaised
override bool CanBeRaised()
Definition: SCR_BinocularsComponent.c:94
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180