Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
CharacterCameraBinoculars.c
Go to the documentation of this file.
2 {
3  // ! This is just a prototype functionality for binocs, should be moved to sightscomponent when possible
4 
5  protected float m_fBinocFOV;
6 
7  protected SCR_BinocularsComponent m_binoculars;
8  protected SCR_2DOpticsComponent m_Optics;
9  protected IEntity m_ePlayer;
10 
11  //-----------------------------------------------------------------------------
12  // constructor
13  void CharacterCameraBinoculars(CameraHandlerComponent pCameraHandler)
14  {
15  }
16 
17  //-----------------------------------------------------------------------------
18  override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
19  {
20  super.OnActivate(pPrevCamera, pPrevCameraResult);
21 
22  m_ePlayer = SCR_PlayerController.GetLocalControlledEntity();
23  if (!m_ePlayer)
24  return;
25 
26  m_Optics = FindOpticsComponent(m_ePlayer);
27 
28  if (!m_Optics)
29  {
30  Print("Optics wasn't found in binoculars!", LogLevel.WARNING);
31  return;
32  }
33 
34  // Getting optics variables
35  m_fBinocFOV = m_Optics.GetFovZoomed();
36  }
37 
38  //------------------------------------------------------------------------------------------------
42  protected SCR_2DOpticsComponent FindOpticsComponent(IEntity owner)
43  {
44  // Finding gadget manager
45  SCR_GadgetManagerComponent gadgetManager = SCR_GadgetManagerComponent.Cast( m_ePlayer.FindComponent(SCR_GadgetManagerComponent) );
46  if (!gadgetManager)
47  return null;
48 
49  // Getting binoculars componenet
50  SCR_BinocularsComponent binoculars = SCR_BinocularsComponent.Cast(gadgetManager.GetHeldGadgetComponent());
51  if (!binoculars)
52  return null;
53 
54  IEntity entityBinocular = binoculars.GetOwner();
55  if (!entityBinocular)
56  return null;
57 
58  // Getting optics component
59  SCR_2DOpticsComponent optic = SCR_2DOpticsComponent.Cast(entityBinocular.FindComponent(SCR_2DOpticsComponent));
60 
61  return optic;
62  }
63 
64  //-----------------------------------------------------------------------------
65  override void OnUpdate(float pDt, out ScriptedCameraItemResult pOutResult)
66  {
67  super.OnUpdate(pDt, pOutResult);
68 
69  pOutResult.m_fFOV = m_fBinocFOV;
70  pOutResult.m_bBlendFOV = false;
71 
72  if (m_pCompartmentAccess.IsInCompartment())
73  pOutResult.m_fUseHeading = 0;
74 
75  // Near plane
76  if (m_Optics)
77  pOutResult.m_fNearPlane = m_Optics.GetNearPlane();
78  else
79  {
80  pOutResult.m_fNearPlane = 0.05;
81  }
82  }
83 }
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_GadgetManagerComponent
Definition: SCR_GadgetManagerComponent.c:138
SCR_2DOpticsComponent
Definition: SCR_2DOpticsComponent.c:12
CharacterCamera1stPerson
Definition: CharacterCamera1stPerson.c:106
CharacterCameraBinoculars
Definition: CharacterCameraBinoculars.c:1