Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_LightHitZone.c
Go to the documentation of this file.
2 {
3  private BaseLightManagerComponent m_pLightManager;
4  private ref array<BaseLightSlot> m_aLightSlots = {};
5 
6  override void OnInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
7  {
8  super.OnInit(pOwnerEntity, pManagerComponent);
9 
10  IEntity parent = pOwnerEntity;
11  while (parent && !m_pLightManager)
12  {
13  m_pLightManager = BaseLightManagerComponent.Cast(parent.FindComponent(BaseLightManagerComponent));
14  parent = parent.GetParent();
15  }
16 
17  if (!m_pLightManager)
18  return;
19 
20  SCR_LightSlot scrLightSlot;
21  string name = GetName();
22  array<BaseLightSlot> lights = {}; m_pLightManager.GetLights(lights);
23  foreach (BaseLightSlot lightSlot: lights)
24  {
25  scrLightSlot = SCR_LightSlot.Cast(lightSlot);
26  if (scrLightSlot && name.Compare(scrLightSlot.GetHitZoneName(), false) == 0)
27  m_aLightSlots.Insert(lightSlot);
28  }
29 
30  UpdateLightState();
31  }
32 
33  override void OnDamageStateChanged()
34  {
35  super.OnDamageStateChanged();
36 
37  UpdateLightState();
38  }
39 
40  void UpdateLightState()
41  {
42  bool isAlive = GetDamageState() != EDamageState.DESTROYED;
43  int surfaceID;
44  foreach (BaseLightSlot lightSlot: m_aLightSlots)
45  {
46  if (!lightSlot)
47  continue;
48 
49  lightSlot.SetLightFunctional(isAlive);
50 
51  if (!m_pLightManager)
52  continue;
53 
54  surfaceID = lightSlot.GetSurfaceID();
55  if (surfaceID > -1)
56  m_pLightManager.TrySetSurfaceFunctional(surfaceID, isAlive);
57  }
58  }
59 
60  void ~SCR_LightHitZone()
61  {
62  m_aLightSlots.Clear();
63  m_aLightSlots = null;
64  }
65 };
GetName
string GetName()
Definition: SCR_ScenarioFrameworkLayerBase.c:85
SCR_LightHitZone
Definition: SCR_LightHitZone.c:1
SCR_DestructibleHitzone
Definition: SCR_DestructibleHitzone.c:3
BaseLightSlot
Definition: BaseLightSlot.c:7
EDamageState
EDamageState
Definition: EDamageState.c:12
SCR_LightSlot
Definition: SCR_LightSlot.c:1