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_FireplaceComponent.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted"
, color:
"0 0 255 255"
)]
2
class
SCR_FireplaceComponentClass
:
SCR_BaseInteractiveLightComponentClass
3
{
4
[
Attribute
(
"{C0E2E7DC28B71E2C}Particles/Enviroment/Campfire_medium_normal.ptc"
,
UIWidgets
.ResourceNamePicker,
"Prefab of fire particle used for a fire action."
,
"ptc"
)]
5
protected
ResourceName
m_sParticle
;
6
7
[
Attribute
(
"0 0.2 0"
,
UIWidgets
.EditBox,
"Particle offset in local space from the origin of the entity"
)]
8
protected
vector
m_vParticleOffset
;
9
10
//------------------------------------------------------------------------------------------------
12
ResourceName
GetParticle
()
13
{
14
return
m_sParticle
;
15
}
16
17
//------------------------------------------------------------------------------------------------
19
vector
GetParticleOffset
()
20
{
21
return
m_vParticleOffset
;
22
}
23
}
24
25
class
SCR_FireplaceComponent : SCR_BaseInteractiveLightComponent
26
{
27
private
ParticleEffectEntity
m_pFireParticle
;
28
protected
SCR_BaseInteractiveLightComponentClass
m_ComponentData
;
29
protected
IEntity
m_DecalEntity
;
30
protected
float
m_fTimer
;
31
protected
float
m_fCompDataLV
;
32
33
protected
static
const
float
FLICKER_STEP = 0.05;
34
protected
static
const
float
FLICKER_THRESHOLD = 0.35;
35
protected
static
const
float
FLICKER_FREQUENCY = 1 / 30;
36
37
//------------------------------------------------------------------------------------------------
38
override
void
ToggleLight
(
bool
turnOn,
bool
skipTransition =
false
,
bool
playSound =
true
)
39
{
40
if
(
m_bIsOn
== turnOn)
41
return
;
42
43
super.ToggleLight(turnOn, skipTransition, playSound);
44
45
// don't continue if DS server is running in console (particles, decals)
46
if
(
System
.IsConsoleApp())
47
return
;
48
49
if
(turnOn)
50
{
51
TurnOn
();
52
}
53
else
54
{
55
TurnOff
();
56
}
57
}
58
59
//------------------------------------------------------------------------------------------------
61
void
TurnOn
()
62
{
63
SCR_FireplaceComponentClass
componentData =
SCR_FireplaceComponentClass
.Cast(
GetComponentData
(
GetOwner
()));
64
if
(!
m_pFireParticle
&& componentData)
65
{
66
ParticleEffectEntitySpawnParams
spawnParams =
new
ParticleEffectEntitySpawnParams
();
67
spawnParams.TargetWorld =
GetOwner
().
GetWorld
();
68
spawnParams.Parent =
GetOwner
();
69
Math3D
.MatrixIdentity4(spawnParams.Transform);
70
spawnParams.Transform[3] = componentData.
GetParticleOffset
();
71
72
m_pFireParticle
=
ParticleEffectEntity
.SpawnParticleEffect(componentData.
GetParticle
(), spawnParams);
73
}
74
else
if
(
m_pFireParticle
)
75
{
76
m_pFireParticle
.Play();
77
}
78
79
// Show decals
80
if
(
m_DecalEntity
)
81
m_DecalEntity
.SetFlags(
EntityFlags
.VISIBLE,
false
);
82
83
if
(componentData)
84
m_fCompDataLV
= componentData.GetLightLV();
85
86
SetEventMask(
GetOwner
(),
EntityEvent
.VISIBLE);
87
}
88
89
//------------------------------------------------------------------------------------------------
91
void
TurnOff
()
92
{
93
// Hide decals
94
if
(
m_DecalEntity
)
95
m_DecalEntity
.ClearFlags(
EntityFlags
.VISIBLE,
false
);
96
97
//Reset fire particles
98
if
(
m_pFireParticle
)
99
{
100
m_pFireParticle
.Stop();
101
}
102
103
ClearEventMask(
GetOwner
(),
EntityEvent
.VISIBLE);
104
}
105
106
//------------------------------------------------------------------------------------------------
107
override
void
OnPostInit
(
IEntity
owner)
108
{
109
BaseSlotComponent
decalComponent =
BaseSlotComponent
.Cast(
GetOwner
().FindComponent(
BaseSlotComponent
));
110
if
(decalComponent)
111
m_DecalEntity
= decalComponent.GetAttachedEntity();
112
113
m_ComponentData
=
SCR_BaseInteractiveLightComponentClass
.Cast(
GetComponentData
(
GetOwner
()));
114
if
(
m_ComponentData
)
115
m_fCurLV
=
m_ComponentData
.GetLightLV();
116
117
if
(
m_DecalEntity
)
118
m_DecalEntity
.ClearFlags(
EntityFlags
.VISIBLE,
false
);
119
120
super.OnPostInit(owner);
121
}
122
123
//------------------------------------------------------------------------------------------------
124
override
void
EOnVisible
(
IEntity
owner,
int
frameNumber)
125
{
126
super.EOnVisible(owner, frameNumber);
127
128
if
(
GetOwner
().GetWorld().IsEditMode() || !IsOn() ||
m_aLights
.IsEmpty())
129
return
;
130
131
float
timeSlice =
GetOwner
().
GetWorld
().GetTimeSlice();
132
133
m_fTimer
+= timeSlice;
134
135
if
(
m_fTimer
< FLICKER_FREQUENCY)
136
return
;
137
138
m_fTimer
= 0;
139
bool
canFlickerBrighter =
m_fCurLV
<
m_fCompDataLV
* (1 + FLICKER_THRESHOLD);
140
bool
canFlickerDimmer =
m_fCurLV
>
m_fCompDataLV
* (1 - FLICKER_THRESHOLD);
141
142
if
(canFlickerBrighter && canFlickerDimmer)
143
{
144
if
(
Math
.RandomIntInclusive(0, 1) == 0)
145
m_fCurLV
+= FLICKER_STEP;
146
else
147
m_fCurLV
-= FLICKER_STEP;
148
}
149
else
if
(canFlickerBrighter)
150
m_fCurLV
+= FLICKER_STEP;
151
else
152
m_fCurLV
-= FLICKER_STEP;
153
154
array<ref SCR_BaseLightData> lightData =
m_ComponentData
.GetLightData();
155
for
(
int
i =
Math
.Min(
m_aLights
.Count(), lightData.Count()) -1; i >= 0; i--)
156
{
157
auto
ld = lightData[i];
// make sure that data is loaded
158
if
(ld)
159
m_aLights
[i].SetColor(
Color
.FromVector(ld.GetLightColor()),
m_fCurLV
);
160
}
161
}
162
163
//------------------------------------------------------------------------------------------------
164
override
bool
RplLoad
(
ScriptBitReader
reader)
165
{
166
// Can't relay on RplLoad method of base class as with the fireplace we have to execute ToggleLight method in both on / off state.
167
bool
isOn =
false
;
168
reader.ReadBool(isOn);
169
ToggleLight
(isOn,
true
);
170
171
return
true
;
172
}
173
174
override
void
OnDelete
(
IEntity
owner)
175
{
176
super.OnDelete(owner);
177
178
RemoveLights();
179
180
if
(
m_pFireParticle
)
181
RplComponent.DeleteRplEntity(
m_pFireParticle
,
false
);
182
}
183
}
RplLoad
override bool RplLoad(ScriptBitReader reader)
Definition
SCR_AIGroupInfoComponent.c:149
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
TurnOn
void TurnOn()
Definition
SCR_FireplaceComponent.c:61
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
m_DecalEntity
IEntity m_DecalEntity
Definition
SCR_FireplaceComponent.c:29
m_pFireParticle
SCR_FireplaceComponentClass m_pFireParticle
EOnVisible
override void EOnVisible(IEntity owner, int frameNumber)
Definition
SCR_FireplaceComponent.c:124
m_ComponentData
SCR_FuelConsumptionComponentClass m_ComponentData
Definition
SCR_FuelConsumptionComponent.c:28
ParticleEffectEntity
void ParticleEffectEntity(IEntitySource src, IEntity parent)
Definition
SCR_RepeatingParticleEffectEntity.c:65
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
BaseSlotComponent
Definition
BaseSlotComponent.c:13
Color
Definition
Color.c:13
IEntity
Definition
IEntity.c:13
IEntity::GetWorld
proto external BaseWorld GetWorld()
Math3D
Definition
Math3D.c:13
Math
Definition
Math.c:13
ParticleEffectEntitySpawnParams
Definition
ParticleEffectEntitySpawnParams.c:13
ResourceName
Definition
ResourceName.c:13
SCR_BaseInteractiveLightComponentClass
Definition
SCR_BaseInteractiveLightComponent.c:3
SCR_FireplaceComponentClass
Definition
SCR_FireplaceComponent.c:3
SCR_FireplaceComponentClass::m_vParticleOffset
vector m_vParticleOffset
Definition
SCR_FireplaceComponent.c:8
SCR_FireplaceComponentClass::m_sParticle
ResourceName m_sParticle
Definition
SCR_FireplaceComponent.c:5
SCR_FireplaceComponentClass::GetParticle
ResourceName GetParticle()
Definition
SCR_FireplaceComponent.c:12
SCR_FireplaceComponentClass::GetParticleOffset
vector GetParticleOffset()
Definition
SCR_FireplaceComponent.c:19
ScriptBitReader
Definition
EnNetwork.c:199
System
Definition
System.c:13
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
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
EntityFlags
EntityFlags
Various entity flags.
Definition
EntityFlags.c:14
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
OnDelete
@ OnDelete
Definition
SndComponentCallbacks.c:16
TurnOff
void TurnOff()
Remove every particle associed with this effect.
Definition
SCR_FireplaceComponent.c:91
scripts
Game
Components
SCR_FireplaceComponent.c
Generated by
1.17.0