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_FlareEffectComponent.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted"
, color:
"0 0 255 255"
)]
2
class
SCR_FlareEffectComponentClass
:
SCR_BaseInteractiveLightComponentClass
3
{
4
[
Attribute
(
"0"
,
UIWidgets
.EditBox,
"Lifetime of light in seconds"
)]
5
protected
float
m_iLightLifetime
;
6
7
//------------------------------------------------------------------------------------------------
8
float
GetLightLifeTime
()
9
{
10
return
m_iLightLifetime
;
11
}
12
}
13
14
class
SCR_FlareEffectComponent : SCR_BaseInteractiveLightComponent
15
{
16
protected
SCR_BaseInteractiveLightComponentClass
m_ComponentData
;
17
protected
float
m_fTimer
;
18
protected
float
m_fCompDataLV
;
19
protected
float
m_fBottomLightLV
;
20
21
protected
static
const
float
FLICKER_STEP = 0.15;
22
protected
static
const
float
FLICKER_THRESHOLD = 0.15;
23
protected
static
const
float
FLICKER_FREQUENCY = 1 / 20;
24
25
//------------------------------------------------------------------------------------------------
26
override
void
ToggleLight
(
bool
turnOn,
bool
skipTransition =
false
,
bool
playSound =
true
)
27
{
28
if
(
m_bIsOn
== turnOn)
29
return
;
30
31
super.ToggleLight(turnOn, skipTransition, playSound);
32
33
// don't continue if DS server is running in console (particles, decals)
34
if
(
System
.IsConsoleApp())
35
return
;
36
37
if
(turnOn)
38
{
39
TurnLightOn
();
40
}
41
else
42
{
43
TurnLightOff
();
44
}
45
}
46
47
//------------------------------------------------------------------------------------------------
48
void
TurnLightOn
()
49
{
50
SCR_FlareEffectComponentClass
componentData =
SCR_FlareEffectComponentClass
.Cast(
GetComponentData
(
GetOwner
()));
51
52
if
(componentData)
53
{
54
m_fCompDataLV
= componentData.GetLightLV();
55
m_fBottomLightLV
=
m_fCompDataLV
;
56
}
57
58
SetEventMask(
GetOwner
(),
EntityEvent
.FIXEDFRAME);
59
}
60
61
//------------------------------------------------------------------------------------------------
62
void
TurnLightOff
()
63
{
64
ClearEventMask(
GetOwner
(),
EntityEvent
.FIXEDFRAME);
65
}
66
67
//------------------------------------------------------------------------------------------------
68
override
void
OnPostInit
(
IEntity
owner)
69
{
70
m_ComponentData
=
SCR_BaseInteractiveLightComponentClass
.Cast(
GetComponentData
(
GetOwner
()));
71
if
(
m_ComponentData
)
72
m_fCurLV
=
m_ComponentData
.GetLightLV();
73
74
TurnLightOn
();
75
76
super.OnPostInit(owner);
77
}
78
79
//------------------------------------------------------------------------------------------------
80
override
void
EOnVisible
(
IEntity
owner,
int
frameNumber)
81
{
82
// needs to be empty to prevent duplicate effects. Moved into EOnFixedFrame
83
}
84
85
//------------------------------------------------------------------------------------------------
86
override
void
EOnFixedFrame
(
IEntity
owner,
float
timeSlice)
87
{
88
if
(!
m_bIsOn
||
m_aLights
.IsEmpty())
89
return
;
90
91
m_fTimer
+= timeSlice;
92
93
if
(
m_fTimer
< FLICKER_FREQUENCY)
94
return
;
95
96
// Needs to be redone to be more realistic and correctly replicated
97
// Lowering the light intensity by flare timer
98
/*
99
SCR_FlareEffectComponentClass componentData = SCR_FlareEffectComponentClass.Cast(GetComponentData(GetOwner()));
100
m_fBottomLightLV -= m_fCompDataLV / (componentData.GetLightLifeTime() + 1) * m_fTimer;
101
*/
102
103
//flicker
104
if
(
Math
.RandomIntInclusive(0, 1) == 0)
105
m_fCurLV
+= FLICKER_STEP;
106
else
107
m_fCurLV
-= FLICKER_STEP;
108
109
m_fCurLV
=
Math
.Clamp(
m_fCurLV
,
m_fBottomLightLV
* (1 - FLICKER_THRESHOLD),
m_fBottomLightLV
* (1 + FLICKER_THRESHOLD));
110
m_fCurLV
=
Math
.Clamp(
m_fCurLV
, 0, 20);
// needed to avoid going over engine limits for LVs
111
112
//reset timer
113
m_fTimer
= 0;
114
115
//set light
116
array<ref SCR_BaseLightData> lightData =
m_ComponentData
.GetLightData();
117
for
(
int
i =
Math
.Min(
m_aLights
.Count(), lightData.Count()) -1; i >= 0; i--)
118
{
119
SCR_BaseLightData
ld = lightData[i];
// make sure that data is loaded
120
if
(ld)
121
m_aLights
[i].SetColor(
Color
.FromVector(ld.GetLightColor()),
m_fCurLV
);
122
}
123
}
124
125
//------------------------------------------------------------------------------------------------
126
override
void
OnDelete
(
IEntity
owner)
127
{
128
super.OnDelete(owner);
129
130
RemoveLights();
131
}
132
}
m_bIsOn
bool m_bIsOn
Definition
SCR_BaseInteractiveLightComponent.c:60
m_aLights
SCR_BaseInteractiveLightComponentClass m_aLights
m_fCurLV
float m_fCurLV
Definition
SCR_BaseInteractiveLightComponent.c:57
m_fTimer
float m_fTimer
Definition
SCR_CampaignMilitaryBaseComponent.c:82
GetComponentData
SCR_CharacterSoundComponentClass GetComponentData()
Definition
SCR_CharacterSoundComponent.c:132
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
m_fCompDataLV
float m_fCompDataLV
Definition
SCR_FireplaceComponent.c:31
ToggleLight
override void ToggleLight(bool turnOn, bool skipTransition=false, bool playSound=true)
Definition
SCR_FireplaceComponent.c:38
EOnVisible
override void EOnVisible(IEntity owner, int frameNumber)
Definition
SCR_FireplaceComponent.c:124
TurnLightOff
void TurnLightOff()
Definition
SCR_FlareEffectComponent.c:62
m_fBottomLightLV
float m_fBottomLightLV
Definition
SCR_FlareEffectComponent.c:19
EOnFixedFrame
override void EOnFixedFrame(IEntity owner, float timeSlice)
Definition
SCR_FlareEffectComponent.c:86
TurnLightOn
void TurnLightOn()
Definition
SCR_FlareEffectComponent.c:48
m_ComponentData
SCR_FuelConsumptionComponentClass m_ComponentData
Definition
SCR_FuelConsumptionComponent.c:28
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
Color
Definition
Color.c:13
IEntity
Definition
IEntity.c:13
Math
Definition
Math.c:13
SCR_BaseInteractiveLightComponentClass
Definition
SCR_BaseInteractiveLightComponent.c:3
SCR_BaseLightData
Light parameters.
Definition
SCR_BaseLightData.c:6
SCR_FlareEffectComponentClass
Definition
SCR_FlareEffectComponent.c:3
SCR_FlareEffectComponentClass::GetLightLifeTime
float GetLightLifeTime()
Definition
SCR_FlareEffectComponent.c:8
SCR_FlareEffectComponentClass::m_iLightLifetime
float m_iLightLifetime
Definition
SCR_FlareEffectComponent.c:5
System
Definition
System.c:13
UIWidgets
Definition
attributes.c:40
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition
SCR_FuelNode.c:128
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EntityEvent
EntityEvent
Various entity events.
Definition
EntityEvent.c:14
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
OnDelete
@ OnDelete
Definition
SndComponentCallbacks.c:16
scripts
Game
Components
SCR_FlareEffectComponent.c
Generated by
1.17.0