Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FlareEffectComponent.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted", color: "0 0 255 255")]
3{
4 [Attribute("0", UIWidgets.EditBox, "Lifetime of light in seconds")]
5 protected float m_iLightLifetime;
6
7 //------------------------------------------------------------------------------------------------
9 {
10 return m_iLightLifetime;
11 }
12}
13
14class SCR_FlareEffectComponent : SCR_BaseInteractiveLightComponent
15{
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 {
40 }
41 else
42 {
44 }
45 }
46
47 //------------------------------------------------------------------------------------------------
49 {
51
52 if (componentData)
53 {
54 m_fCompDataLV = componentData.GetLightLV();
56 }
57
58 SetEventMask(GetOwner(), EntityEvent.FIXEDFRAME);
59 }
60
61 //------------------------------------------------------------------------------------------------
63 {
64 ClearEventMask(GetOwner(), EntityEvent.FIXEDFRAME);
65 }
66
67 //------------------------------------------------------------------------------------------------
68 override void OnPostInit(IEntity owner)
69 {
72 m_fCurLV = m_ComponentData.GetLightLV();
73
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}
SCR_BaseInteractiveLightComponentClass m_aLights
SCR_CharacterSoundComponentClass GetComponentData()
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
float m_fCompDataLV
override void ToggleLight(bool turnOn, bool skipTransition=false, bool playSound=true)
override void EOnVisible(IEntity owner, int frameNumber)
void TurnLightOff()
float m_fBottomLightLV
override void EOnFixedFrame(IEntity owner, float timeSlice)
void TurnLightOn()
SCR_FuelConsumptionComponentClass m_ComponentData
Definition Color.c:13
Definition Math.c:13
Light parameters.
IEntity GetOwner()
Owner entity of the fuel tank.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14