Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_LightHitZone.c
Go to the documentation of this file.
1
//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
2
class
SCR_LightHitZone
:
SCR_VehicleHitZone
3
{
4
private
BaseLightManagerComponent
m_LightManager;
5
private
ref array<BaseLightSlot> m_aLightSlots = {};
6
protected
string
m_sSurfaceName
;
7
protected
int
m_iParentSurfaceID
;
8
9
//------------------------------------------------------------------------------------------------
10
void
SetSurfaceName
(
string
surfaceName)
11
{
12
m_aLightSlots.Clear();
13
m_iParentSurfaceID
= -1;
14
if
(surfaceName ==
string
.Empty)
15
return
;
16
17
m_sSurfaceName
= surfaceName;
18
IEntity
parent =
GetOwner
();
19
while
(parent && !m_LightManager)
20
{
21
m_LightManager =
BaseLightManagerComponent
.Cast(parent.
FindComponent
(
BaseLightManagerComponent
));
22
if
(!m_LightManager)
23
parent = parent.
GetParent
();
24
}
25
26
if
(!m_LightManager)
27
return
;
28
29
SCR_LightSlot
scrLightSlot;
30
array<BaseLightSlot> lights = {};
31
m_LightManager.GetLights(lights);
32
foreach
(
BaseLightSlot
lightSlot : lights)
33
{
34
scrLightSlot =
SCR_LightSlot
.Cast(lightSlot);
35
if
(scrLightSlot &&
m_sSurfaceName
.Compare(scrLightSlot.GetParentSurfaceName(),
false
) == 0)
36
{
37
m_aLightSlots.Insert(lightSlot);
38
if
(
m_iParentSurfaceID
== -1)
39
m_iParentSurfaceID
= lightSlot.GetSurfaceID();
40
41
#ifdef WORKBENCH
42
if
(
m_iParentSurfaceID
!= -1 &&
m_iParentSurfaceID
!= lightSlot.GetSurfaceID())
43
Print
(
"WARNING! Multiple lights tied to the hit zone from this entity: "
+
GetOwner
()+
" while having different parent surface id ("
+
m_iParentSurfaceID
+
" != "
+lightSlot.GetSurfaceID()+
")"
,
LogLevel
.ERROR);
44
#endif
45
}
46
}
47
48
UpdateLightState
(GetDamageState());
49
}
50
51
//------------------------------------------------------------------------------------------------
52
override
void
OnDamageStateChanged
(
EDamageState
newState,
EDamageState
previousDamageState,
bool
isJIP)
53
{
54
super.OnDamageStateChanged(newState, previousDamageState, isJIP);
55
56
UpdateLightState
(newState);
57
}
58
59
//------------------------------------------------------------------------------------------------
60
void
UpdateLightState
(
EDamageState
newState)
61
{
62
if
(!m_LightManager)
63
return
;
64
65
RplComponent rplComp =
SCR_EntityHelper
.
GetEntityRplComponent
(
GetOwner
());
66
if
(rplComp && rplComp.IsProxy())
67
return
;
68
69
bool
isAlive = newState !=
EDamageState
.DESTROYED;
70
71
bool
functionalityStateChanged;
72
if
(
m_iParentSurfaceID
> -1)
73
functionalityStateChanged = m_LightManager.TrySetSurfaceFunctional(
m_iParentSurfaceID
, isAlive);
74
75
int
lightSide;
76
bool
lastState;
77
foreach
(
BaseLightSlot
lightSlot : m_aLightSlots)
78
{
79
if
(!lightSlot)
80
continue
;
81
82
lightSlot.SetLightFunctional(isAlive);
83
if
(isAlive && functionalityStateChanged && lightSlot.GetLightType() ==
ELightType
.Hazard)
84
{
//hazards need to be reset as its possible that they will get out of sync
85
lightSide = lightSlot.GetLightSide();
86
lastState = m_LightManager.GetLightsState(lightSlot.GetLightType(), lightSide);
87
if
(lightSide != -1)
88
{
//check if other side is also turned on and in such case we need to reset both sides
89
if
(lightSide == 0)
90
lightSide = 1;
//right
91
else
92
lightSide = 0;
//left
93
94
if
(lastState == m_LightManager.GetLightsState(lightSlot.GetLightType(), lightSide))
95
lightSide = -1;
//all sides
96
else
97
lightSide = lightSlot.GetLightSide();
98
}
99
100
if
(!lastState)
101
return
;
102
103
m_LightManager.SetLightsState(lightSlot.GetLightType(),
false
, lightSide);
//first we need to turn them off or else they will blink faster
104
m_LightManager.SetLightsState(lightSlot.GetLightType(), lastState, lightSide);
105
106
functionalityStateChanged =
false
;
107
}
108
}
109
}
110
111
//------------------------------------------------------------------------------------------------
112
void
~SCR_LightHitZone
()
113
{
114
m_aLightSlots.Clear();
115
m_aLightSlots = null;
116
}
117
}
118
//---- REFACTOR NOTE END ----
ELightType
ELightType
Definition
ELightType.c:8
BaseLightManagerComponent
Definition
BaseLightManagerComponent.c:13
BaseLightSlot
Definition
BaseLightSlot.c:8
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetParent
proto external IEntity GetParent()
SCR_EntityHelper
Definition
SCR_EntityHelper.c:2
SCR_EntityHelper::GetEntityRplComponent
static RplComponent GetEntityRplComponent(notnull IEntity entity)
Definition
SCR_EntityHelper.c:451
SCR_HitZone::GetOwner
IEntity GetOwner()
Definition
SCR_HitZone.c:42
SCR_LightHitZone
Definition
SCR_LightHitZone.c:3
SCR_LightHitZone::SetSurfaceName
void SetSurfaceName(string surfaceName)
Definition
SCR_LightHitZone.c:10
SCR_LightHitZone::UpdateLightState
void UpdateLightState(EDamageState newState)
Definition
SCR_LightHitZone.c:60
SCR_LightHitZone::~SCR_LightHitZone
void ~SCR_LightHitZone()
Definition
SCR_LightHitZone.c:112
SCR_LightHitZone::m_iParentSurfaceID
int m_iParentSurfaceID
Definition
SCR_LightHitZone.c:7
SCR_LightHitZone::m_sSurfaceName
string m_sSurfaceName
Definition
SCR_LightHitZone.c:6
SCR_LightHitZone::OnDamageStateChanged
override void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
Definition
SCR_LightHitZone.c:52
SCR_LightSlot
Definition
SCR_LightSlot.c:2
SCR_VehicleHitZone
Definition
SCR_VehicleHitZone.c:2
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
EDamageState
EDamageState
Definition
EDamageState.c:13
scripts
Game
HitZone
SCR_LightHitZone.c
Generated by
1.17.0