Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_LightManagerInfo.c
Go to the documentation of this file.
2 {
3  [Attribute(SCR_Enum.GetDefault(ELightType.NoLight), UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(ELightType))]
4  protected ELightType m_eLightType;
5 
6  [Attribute(SCR_Enum.GetDefault(ELightType.NoLight), UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(ELightType))]
7  protected ELightType m_eSuppressedBy;
8 
9  [Attribute("-1", uiwidget: UIWidgets.ComboBox, enums: { ParamEnum("Either", "-1"), ParamEnum("Left", "0"), ParamEnum("Right", "1")})]
10  protected int m_iLightSide;
11 
12  protected BaseLightManagerComponent m_LightManager;
13  protected BaseLightSlot m_LightSlot;
14  protected ref ScriptInvoker m_OnLightStateChanged;
15 
16  protected bool m_bIsLit = true;
17 
18  //------------------------------------------------------------------------------------------------
20  override EVehicleInfoState GetState()
21  {
22  // Light manager does not have events yet
23  bool isSuppressed;
24  if (m_eSuppressedBy != ELightType.NoLight)
25  isSuppressed = m_LightManager && m_LightManager.GetLightsState(m_eSuppressedBy, m_iLightSide);
26 
27  // TODO: Beam lights should be dark blue!
28  if (m_bIsLit && !isSuppressed && m_LightManager && m_LightManager.GetLightsState(m_eLightType, m_iLightSide))
29  return EVehicleInfoState.ENABLED;
30  else
31  return EVehicleInfoState.DISABLED;
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  override bool DisplayStartDrawInit(IEntity owner)
36  {
37  // Terminate if there is no light manager
38  if (!m_LightManager)
39  return false;
40 
41  array<BaseLightSlot> outLights = new array<BaseLightSlot>;
42  int iLights = m_LightManager.GetLights(outLights);
43 
44  BaseLightSlot lightSlot;
45  ELightType lightType;
46  int lightSide;
47 
48  for (int i = 0; i < iLights; i++)
49  {
50  lightSlot = outLights.Get(i);
51 
52  lightType = lightSlot.GetLightType();
53  lightSide = lightSlot.GetLightSide();
54 
55  if ((m_eLightType == lightType) && (m_iLightSide == -1 || m_iLightSide == lightSide))
56  {
57  #ifdef DEBUG_VEHICLE_UI
58  PrintFormat("[%1] BaseLightSlot detected %2 | type: %3 | side: %4", i, lightSlot, lightType, lightSide);
59  #endif
60 
61  m_LightSlot = lightSlot;
62 
63  if (SCR_LightSlot.Cast(m_LightSlot))
64  m_OnLightStateChanged = SCR_LightSlot.Cast(m_LightSlot).GetOnLightStateChanged();
65 
66  break;
67  };
68  }
69 
70  // Terminate if there is no light slot associated with the setup
71  if (!m_LightSlot)
72  return false;
73 
74  // Add monitoring of light states changes
75  if (m_OnLightStateChanged)
76  m_OnLightStateChanged.Insert(OnLightStateChanged);
77 
78  return super.DisplayStartDrawInit(owner);
79  }
80 
81  //------------------------------------------------------------------------------------------------
82  override void DisplayStopDraw(IEntity owner)
83  {
84  // Remove monitoring of light states changes
85  if (m_OnLightStateChanged)
86  m_OnLightStateChanged.Remove(OnLightStateChanged);
87 
88  super.DisplayStopDraw(owner);
89  }
90 
91  //------------------------------------------------------------------------------------------------
93  void OnLightStateChanged(bool state)
94  {
95  m_bIsLit = state;
96 
97  #ifdef DEBUG_VEHICLE_UI
98  PrintFormat("%1 OnLightStateChanged: %2", this, m_bIsLit);
99  #endif
100  }
101 
102  //------------------------------------------------------------------------------------------------
104  override void DisplayInit(IEntity owner)
105  {
106  super.DisplayInit(owner);
107 
108  m_LightManager = BaseLightManagerComponent.Cast(owner.FindComponent(BaseLightManagerComponent));
109  }
110 }
SCR_Enum
Definition: SCR_Enum.c:1
SCR_BaseVehicleInfo
Base class for all vehicle UI state and damage indicators.
Definition: SCR_BaseVehicleInfo.c:28
BaseLightSlot
Definition: BaseLightSlot.c:7
ELightType
ELightType
Definition: ELightType.c:7
Attribute
typedef Attribute
Post-process effect of scripted camera.
EVehicleInfoState
EVehicleInfoState
UI indicator state, controlling colors and opacity.
Definition: SCR_BaseVehicleInfo.c:5
SCR_LightSlot
Definition: SCR_LightSlot.c:1
SCR_LightManagerInfo
Definition: SCR_LightManagerInfo.c:1