DayZ 1.24
Loading...
Searching...
No Matches
EffectArea Class Reference
Inheritance diagram for EffectArea:
[legend]
Collaboration diagram for EffectArea:
[legend]

Private Member Functions

void EffectArea ()
 
void ~EffectArea ()
 
void SetupZoneData (EffectAreaParams params)
 
void Tick ()
 
override void OnCEUpdate ()
 
void InitZone ()
 
void InitZoneServer ()
 
void InitZoneClient ()
 
override bool CanPutInCargo (EntityAI parent)
 
override bool CanPutIntoHands (EntityAI parent)
 
override bool DisableVicinityIcon ()
 
override bool CanBeTargetedByAI (EntityAI ai)
 
void PlaceParticles (vector pos, float radius, int nbRings, int innerSpacing, bool outerToggle, int outerSpacing, int outerOffset, int partId)
 
void OnParticleAllocation (ParticleManager pm, array< ParticleSource > particles)
 
int GetRequesterIndex (string type)
 
void CreateTrigger (vector pos, int radius)
 
override void EEDelete (EntityAI parent)
 
void OnPlayerEnterServer (PlayerBase player, EffectTrigger trigger)
 
void OnPlayerExitServer (PlayerBase player, EffectTrigger trigger)
 

Private Attributes

string m_Name = "Default setup"
 
int m_Type = eZoneType.STATIC
 
vector m_Position
 
float m_Radius = 100
 
float m_PositiveHeight = 25
 
float m_NegativeHeight = 10
 
int m_InnerRings = 1
 
int m_InnerSpacing = 35
 
bool m_OuterRingToggle = true
 
int m_OuterRingOffset = -5
 
int m_OuterSpacing = 20
 
int m_VerticalLayers = 0
 
int m_VerticalOffset = 10
 
int m_ParticleID = ParticleList.CONTAMINATED_AREA_GAS_BIGASS
 
int m_AroundParticleID = ParticleList.CONTAMINATED_AREA_GAS_AROUND
 
int m_TinyParticleID = ParticleList.CONTAMINATED_AREA_GAS_TINY
 
string m_PPERequesterType
 
int m_PPERequesterIdx = -1
 
int m_EffectsPriority
 
string m_TriggerType = "ContaminatedTrigger"
 
EffectTrigger m_Trigger
 
ref array< Particlem_ToxicClouds
 

Detailed Description

Definition at line 36 of file EffectArea.c.

Constructor & Destructor Documentation

◆ EffectArea()

void EffectArea::EffectArea ( )
inlineprivate

Definition at line 79 of file EffectArea.c.

80 {
81 RegisterNetSyncVariableFloat("m_Radius", 0, 0, 2);
82 RegisterNetSyncVariableFloat("m_PositiveHeight", 0, 0, 2);
83 RegisterNetSyncVariableFloat("m_NegativeHeight", 0, 0, 2);
84
85 RegisterNetSyncVariableInt("m_InnerRings");
86 RegisterNetSyncVariableInt("m_InnerSpacing");
87 RegisterNetSyncVariableInt("m_OuterRingOffset");
88 RegisterNetSyncVariableInt("m_OuterSpacing");
89 RegisterNetSyncVariableInt("m_VerticalLayers");
90 RegisterNetSyncVariableInt("m_VerticalOffset");
91
92 RegisterNetSyncVariableInt("m_ParticleID");
93 /*
94 RegisterNetSyncVariableInt("m_AroundParticleID");
95 RegisterNetSyncVariableInt("m_TinyParticleID");
96 RegisterNetSyncVariableInt("m_PPERequesterIdx");
97 */
98 RegisterNetSyncVariableBool("m_OuterRingToggle");
99 }

◆ ~EffectArea()

void EffectArea::~EffectArea ( )
inlineprivate

Definition at line 101 of file EffectArea.c.

102 {
103
104 }

Member Function Documentation

◆ CanBeTargetedByAI()

override bool EffectArea::CanBeTargetedByAI ( EntityAI ai)
inlineprivate

Definition at line 209 of file EffectArea.c.

210 {
211 return false;
212 }

◆ CanPutInCargo()

override bool EffectArea::CanPutInCargo ( EntityAI parent)
inlineprivate

Definition at line 194 of file EffectArea.c.

195 {
196 return false;
197 }

◆ CanPutIntoHands()

override bool EffectArea::CanPutIntoHands ( EntityAI parent)
inlineprivate

Definition at line 199 of file EffectArea.c.

200 {
201 return false;
202 }

◆ CreateTrigger()

void EffectArea::CreateTrigger ( vector pos,
int radius )
inlineprivate

Definition at line 391 of file EffectArea.c.

392 {
393 // The trigger pos is based on lwer end, but we want to stretch downwards
394 pos[1] = pos[1] - m_NegativeHeight;
395
396 // Create new trigger of specified type
397 if (Class.CastTo(m_Trigger, GetGame().CreateObjectEx(m_TriggerType, pos, ECE_NONE)))
398 {
399 // We finalize trigger dimension setup
400 m_Trigger.SetCollisionCylinder(radius, (m_NegativeHeight + m_PositiveHeight));
401
402 // If the trigger is lower in hierarchy and can see it's local effects customized, we pass the new parameters
403 if (m_Trigger.IsInherited(EffectTrigger))
404 {
405 //Debug.Log("We override area local effects");
407 }
409 //Debug.Log("We created the trigger at : " + m_Trigger.GetWorldPosition() );
410 }
411 }
const int ECE_NONE
Super root of all classes in Enforce script.
Definition EnScript.c:11
float m_NegativeHeight
Definition EffectArea.c:46
float m_PositiveHeight
Definition EffectArea.c:45
EffectTrigger m_Trigger
Definition EffectArea.c:70
string m_TriggerType
Definition EffectArea.c:69
int m_PPERequesterIdx
Definition EffectArea.c:65
int m_EffectsPriority
Definition EffectArea.c:66
int m_TinyParticleID
Definition EffectArea.c:63
int m_AroundParticleID
Definition EffectArea.c:62
void SetLocalEffects(int aroundPartId, int tinyPartId, int ppeRequesterIdx)
void Init(EffectArea area, int priority)
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), ECE_NONE, GetGame(), EffectTrigger::Init(), m_AroundParticleID, m_EffectsPriority, m_NegativeHeight, m_PositiveHeight, m_PPERequesterIdx, m_TinyParticleID, m_Trigger, m_TriggerType, and EffectTrigger::SetLocalEffects().

◆ DisableVicinityIcon()

override bool EffectArea::DisableVicinityIcon ( )
inlineprivate

Definition at line 204 of file EffectArea.c.

205 {
206 return true;
207 }

◆ EEDelete()

override void EffectArea::EEDelete ( EntityAI parent)
inlineprivate

Definition at line 417 of file EffectArea.c.

418 {
419 if (m_Trigger)
420 GetGame().ObjectDelete(m_Trigger);
421
422 // We stop playing particles on this client when the base object is deleted ( out of range for example )
423 if ((GetGame().IsClient() || !GetGame().IsMultiplayer()) && m_ToxicClouds)
424 {
425 foreach (Particle p : m_ToxicClouds)
426 p.Stop();
427 }
428
429 super.EEDelete(parent);
430 }
void Stop()
Stops all elements this effect consists of.
Definition Effect.c:175
ref array< Particle > m_ToxicClouds
Definition EffectArea.c:72
Legacy way of using particles in the game.
Definition Particle.c:7

References GetGame(), m_ToxicClouds, and m_Trigger.

◆ GetRequesterIndex()

int EffectArea::GetRequesterIndex ( string type)
inlineprivate

Definition at line 375 of file EffectArea.c.

376 {
377 typename t = type.ToType();
378 if (!t)
379 return - 1;
380 PPERequesterBase req = PPERequesterBank.GetRequester(t);
381 if (req)
382 return req.GetRequesterIDX();
383 return -1;
384 }
proto native ToType()
Returns internal type representation. Can be used in runtime, or cached in variables and used for fas...

References string::ToType().

Referenced by ContaminatedArea_Dynamic::EEOnCECreate(), and SetupZoneData().

◆ InitZone()

void EffectArea::InitZone ( )
inlineprivate

Definition at line 168 of file EffectArea.c.

169 {
170 //Debug.Log("------------------------------------------");
171 //Debug.Log( "We have created the zone : " + m_Name );
172
173 m_Position = GetWorldPosition();
174
175 if (!GetGame().IsDedicatedServer())
177
178 if (GetGame().IsServer())
180
181 //Debug.Log("------------------------------------------");
182 }
vector m_Position
Definition EffectArea.c:41
void InitZoneServer()
Definition EffectArea.c:186
void InitZoneClient()
Definition EffectArea.c:188

References GetGame(), InitZoneClient(), InitZoneServer(), and m_Position.

Referenced by SpookyArea::EEInit(), and SetupZoneData().

◆ InitZoneClient()

void EffectArea::InitZoneClient ( )
inlineprivate

Definition at line 188 of file EffectArea.c.

188{};

Referenced by InitZone().

◆ InitZoneServer()

void EffectArea::InitZoneServer ( )
inlineprivate

Definition at line 186 of file EffectArea.c.

186{};

Referenced by InitZone().

◆ OnCEUpdate()

override void EffectArea::OnCEUpdate ( )
inlineprivate

Definition at line 162 of file EffectArea.c.

163 {
164 super.OnCEUpdate();
165 Tick();
166 }
void Tick()
Definition EffectArea.c:158

References Tick().

◆ OnParticleAllocation()

void EffectArea::OnParticleAllocation ( ParticleManager pm,
array< ParticleSource > particles )
inlineprivate

Definition at line 366 of file EffectArea.c.

367 {
368 foreach (ParticleSource p : particles)
369 {
370 if (p.GetOwner() == this) // Safety, since it can be unrelated particles when done through event
371 m_ToxicClouds.Insert(p);
372 }
373 }
Entity which has the particle instance as an ObjectComponent.

References m_ToxicClouds.

Referenced by PlaceParticles().

◆ OnPlayerEnterServer()

void EffectArea::OnPlayerEnterServer ( PlayerBase player,
EffectTrigger trigger )
inlineprivate

Definition at line 432 of file EffectArea.c.

433 {
434 player.IncreaseEffectAreaCount();
435 }

◆ OnPlayerExitServer()

void EffectArea::OnPlayerExitServer ( PlayerBase player,
EffectTrigger trigger )
inlineprivate

Definition at line 436 of file EffectArea.c.

437 {
438 player.DecreaseEffectAreaCount();
439 }

◆ PlaceParticles()

void EffectArea::PlaceParticles ( vector pos,
float radius,
int nbRings,
int innerSpacing,
bool outerToggle,
int outerSpacing,
int outerOffset,
int partId )
inlineprivate

Definition at line 218 of file EffectArea.c.

219 {
220#ifdef NO_GUI
221 return; // do not place any particles if there is no GUI
222#endif
223 if (partId == 0)
224 {
225 Error("[WARNING] :: [EffectArea PlaceParticles] :: no particle defined, skipping area particle generation");
226 return;
227 }
228 // Determine if we snap first layer to ground
229 bool snapFirstLayer = true;
230 if (m_Type == eZoneType.STATIC && pos[1] != GetGame().SurfaceRoadY(pos[0], pos[2]))
231 snapFirstLayer = false;
232
233 // BEGINNING OF SAFETY NET
234 // We want to prevent divisions by 0
235 if (radius == 0)
236 {
237 // In specific case of radius, we log an error and return as it makes no sense
238 Error("[WARNING] :: [EffectArea PlaceParticles] :: Radius of contaminated zone is set to 0, this should not happen");
239 return;
240 }
241
242 if (outerToggle && radius == outerOffset)
243 {
244 Error("[WARNING] :: [EffectArea PlaceParticles] :: Your outerOffset is EQUAL to your Radius, this will result in division by 0");
245 return;
246 }
247
248 // Inner spacing of 0 would cause infinite loops as no increment would happen
249 if (innerSpacing == 0)
250 innerSpacing = 1;
251
252 // END OF SAFETY NET
253
254 int partCounter = 0; // Used for debugging, allows one to know how many emitters are spawned in zone
255 int numberOfEmitters = 1; // We always have the central emitter
256
257 //Debug.Log("We have : " + nbRings + " rings");
258 //Debug.Log("We have : " + m_VerticalLayers + " layers");
259
260 float angle = 0; // Used in for loop to know where we are in terms of angle spacing ( RADIANS )
261
263
264 // We also populate vertically, layer 0 will be snapped to ground, subsequent layers will see particles floating and relevant m_VerticalOffset
265 for (int k = 0; k <= m_VerticalLayers; k++)
266 {
267 vector partPos = pos;
268 // We prevent division by 0
269 // We don't want to tamper with ground layer vertical positioning
270 if (k != 0)
271 partPos[1] = partPos[1] + (m_VerticalOffset * k);
272
273 // We will want to start by placing a particle at center of area
274 props.Insert(ParticleProperties(partPos, ParticlePropertiesFlags.PLAY_ON_CREATION, null, vector.Zero, this));
275 partCounter++;
276
277 // For each concentric ring, we place a particle emitter at a set offset
278 for (int i = 1; i <= nbRings + outerToggle; i++)
279 {
280 //Debug.Log("We are on iteration I : " + i );
281
282 // We prepare the variables to use later in calculation
283 float angleIncrement; // The value added to the offset angle to place following particle
284 float ab; // Length of a side of triangle used to calculate particle positionning
285 vector temp = vector.Zero; // Vector we rotate to position next spawn point
286
287 // The particle density is not the same on the final ring which will only happen if toggled
288 // Toggle uses bool parameter treated as int, thus i > nbRings test ( allows to limit branching )
289 if (i > nbRings)
290 {
291 ab = radius - outerOffset; // We want to leave some space to better see area demarcation
292
293 // We calculate the rotation angle depending on particle spacing and distance from center
295 temp[2] = temp[2] + ab;
296
297 //Debug.Log("Radius of last circle " + i + " is : " + ab);
298 }
299 else
300 {
301 ab = (radius / (nbRings + 1)) * i; // We add the offset from one ring to another
302
303 // We calculate the rotation angle depending on particle spacing and distance from center
305 temp[2] = temp[2] + ab;
306
307 //Debug.Log("Radius of inner circle " + i + " is : " + ab);
308 }
309
310 for (int j = 0; j <= (Math.PI2 / angleIncrement); j++)
311 {
312 // Determine position of particle emitter
313 // Use offset of current ring for vector length
314 // Use accumulated angle for vector direction
315
316 float sinAngle = Math.Sin(angle);
317 float cosAngle = Math.Cos(angle);
318
320 partPos += pos;
321
322 // We snap first layer to ground if specified
323 if (k == 0 && snapFirstLayer == true)
324 partPos[1] = GetGame().SurfaceY(partPos[0], partPos[2]);
325 else if (k == 0 && snapFirstLayer == false)
327
328 // We check the particle is indeed in the trigger to make it consistent
329 if (partPos[1] <= pos[1] + m_PositiveHeight && partPos[1] >= pos[1] - m_NegativeHeight)
330 {
331 // Place emitter at vector end ( coord )
332 props.Insert(ParticleProperties(partPos, ParticlePropertiesFlags.PLAY_ON_CREATION, null, GetGame().GetSurfaceOrientation(partPos[0], partPos[2]), this));
333
334 ++partCounter;
335 }
336
337 // Increase accumulated angle
339 }
340
341 angle = 0; // We reset our accumulated angle for the next ring
342 }
343 }
344
345 m_ToxicClouds.Reserve(partCounter);
346
347 ParticleManager gPM = ParticleManager.GetInstance();
348
350 if (createdParticles.Count() != partCounter)
351 {
352 if (gPM.IsFinishedAllocating())
353 {
354 ErrorEx(string.Format("Not enough particles in pool for EffectArea: %1", m_Name));
356 }
357 else
358 gPM.GetEvents().Event_OnAllocation.Insert(OnParticleAllocation);
359 }
360 else
362
363 //Debug.Log("Emitter count : " + partCounter );
364 }
eZoneType
Definition EffectArea.c:3
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
string m_Name
Definition EffectArea.c:39
int m_VerticalLayers
Definition EffectArea.c:57
int m_VerticalOffset
Definition EffectArea.c:58
void OnParticleAllocation(ParticleManager pm, array< ParticleSource > particles)
Definition EffectArea.c:366
Definition EnMath.c:7
static const vector Zero
Definition EnConvert.c:110
static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
Rotate a vector around 0,0,0.
Definition EnConvert.c:478
static const vector Up
Definition EnConvert.c:107
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
enum ShapeType ErrorEx
static const float PI2
Definition EnMath.c:13
static proto float Acos(float c)
Returns angle in radians from cosinus.
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static proto int SqrInt(int i)
Returns squared value.

References Math::Acos(), Math::Cos(), Error(), ErrorEx, GetGame(), m_Name, m_NegativeHeight, m_PositiveHeight, m_ToxicClouds, m_Type, m_VerticalLayers, m_VerticalOffset, OnParticleAllocation(), ParticleManager(), Math::PI2, vector::RotateAroundZero(), Math::Sin(), Math::SqrInt(), vector::Up, and vector::Zero.

Referenced by ContaminatedArea_Dynamic::InitZoneClient(), and SpookyArea::InitZoneClient().

◆ SetupZoneData()

void EffectArea::SetupZoneData ( EffectAreaParams params)
inlineprivate

Definition at line 106 of file EffectArea.c.

107 {
108 // A lot of branching, allowing to use default values on specified params
109 if (params.m_ParamName != "")
110 m_Name = params.m_ParamName;
111 if (params.m_ParamTriggerType != "")
112 m_TriggerType = params.m_ParamTriggerType;
113
114 if (params.m_ParamRadius > 0)
115 m_Radius = params.m_ParamRadius;
116 if (params.m_ParamPosHeight > -1)
117 m_PositiveHeight = params.m_ParamPosHeight;
118 if (params.m_ParamNegHeight > -1)
119 m_NegativeHeight = params.m_ParamNegHeight;
120
121 m_InnerRings = params.m_ParamInnerRings;
122 if (params.m_ParamInnerSpace > -1)
123 m_InnerSpacing = params.m_ParamInnerSpace;
124
125 m_OuterRingToggle = params.m_ParamOuterToggle;
126 if (params.m_ParamOuterSpace > -1)
127 m_OuterSpacing = params.m_ParamOuterSpace;
128 m_OuterRingOffset = params.m_ParamOuterOffset;
129
130 if (params.m_ParamVertLayers > 0)
131 m_VerticalLayers = params.m_ParamVertLayers;
132 if (params.m_ParamVerticalOffset > 0)
133 m_VerticalOffset = params.m_ParamVerticalOffset;
134
135 m_ParticleID = params.m_ParamPartId;
136 m_AroundParticleID = params.m_ParamAroundPartId;
137 m_TinyParticleID = params.m_ParamTinyPartId;
138
139 if (params.m_ParamPpeRequesterType != "")
140 {
141 m_PPERequesterType = params.m_ParamPpeRequesterType;
143 }
144 // We get the PPE index for future usage and synchronization
145
146
147 // DEVELOPER NOTE :
148 // If you cannot register a new requester, add your own indexation and lookup methods to get an index and synchronize it
149 // EXAMPLE : m_PPERequesterIdx = MyLookupMethod()
150
151 // We sync our data
152 SetSynchDirty();
153
154 // Now that everything is ready, we finalize setup
155 InitZone();
156 }
int GetRequesterIndex(string type)
Definition EffectArea.c:375
bool m_OuterRingToggle
Definition EffectArea.c:53
int m_InnerRings
Definition EffectArea.c:50
string m_PPERequesterType
Definition EffectArea.c:64
float m_Radius
Definition EffectArea.c:44
int m_OuterRingOffset
Definition EffectArea.c:54
int m_InnerSpacing
Definition EffectArea.c:51
void InitZone()
Definition EffectArea.c:168
int m_ParticleID
Definition EffectArea.c:61
int m_OuterSpacing
Definition EffectArea.c:55

References GetRequesterIndex(), InitZone(), m_AroundParticleID, m_InnerRings, m_InnerSpacing, m_Name, m_NegativeHeight, m_OuterRingOffset, m_OuterRingToggle, m_OuterSpacing, m_ParticleID, m_PositiveHeight, m_PPERequesterIdx, m_PPERequesterType, m_Radius, m_TinyParticleID, m_TriggerType, m_VerticalLayers, and m_VerticalOffset.

◆ Tick()

void EffectArea::Tick ( )
inlineprivate

Definition at line 158 of file EffectArea.c.

158{};

Referenced by OnCEUpdate().

Member Data Documentation

◆ m_AroundParticleID

int EffectArea::m_AroundParticleID = ParticleList.CONTAMINATED_AREA_GAS_AROUND
private

◆ m_EffectsPriority

int EffectArea::m_EffectsPriority
private

Definition at line 66 of file EffectArea.c.

Referenced by ContaminatedArea_Local::ContaminatedArea_Local(), and CreateTrigger().

◆ m_InnerRings

int EffectArea::m_InnerRings = 1
private

◆ m_InnerSpacing

int EffectArea::m_InnerSpacing = 35
private

◆ m_Name

string EffectArea::m_Name = "Default setup"
private

Definition at line 39 of file EffectArea.c.

Referenced by ContaminatedArea_Dynamic::EEInit(), PlaceParticles(), and SetupZoneData().

◆ m_NegativeHeight

float EffectArea::m_NegativeHeight = 10
private

◆ m_OuterRingOffset

int EffectArea::m_OuterRingOffset = -5
private

◆ m_OuterRingToggle

bool EffectArea::m_OuterRingToggle = true
private

◆ m_OuterSpacing

int EffectArea::m_OuterSpacing = 20
private

◆ m_ParticleID

◆ m_Position

◆ m_PositiveHeight

float EffectArea::m_PositiveHeight = 25
private

◆ m_PPERequesterIdx

int EffectArea::m_PPERequesterIdx = -1
private

◆ m_PPERequesterType

string EffectArea::m_PPERequesterType
private

Definition at line 64 of file EffectArea.c.

Referenced by ContaminatedArea_Dynamic::EEOnCECreate(), and SetupZoneData().

◆ m_Radius

◆ m_TinyParticleID

int EffectArea::m_TinyParticleID = ParticleList.CONTAMINATED_AREA_GAS_TINY
private

◆ m_ToxicClouds

◆ m_Trigger

◆ m_TriggerType

string EffectArea::m_TriggerType = "ContaminatedTrigger"
private

◆ m_Type

int EffectArea::m_Type = eZoneType.STATIC
private

Definition at line 40 of file EffectArea.c.

Referenced by ContaminatedArea_Dynamic::EEInit(), and PlaceParticles().

◆ m_VerticalLayers

int EffectArea::m_VerticalLayers = 0
private

Definition at line 57 of file EffectArea.c.

Referenced by PlaceParticles(), and SetupZoneData().

◆ m_VerticalOffset

int EffectArea::m_VerticalOffset = 10
private

Definition at line 58 of file EffectArea.c.

Referenced by PlaceParticles(), and SetupZoneData().


The documentation for this class was generated from the following file: