DayZ 1.24
Loading...
Searching...
No Matches
EffectParticle Class Reference

Wrapper class for managing particles through SEffectManager. More...

Inheritance diagram for EffectParticle:
[legend]
Collaboration diagram for EffectParticle:
[legend]

Protected Member Functions

EffectType

Information about what type of effect the Effect is, without the need for casting

override EffectType GetEffectType ()
 Get what type of effect the Effect is.
 
override bool IsParticle ()
 Check whether the Effect is EffectParticle without casting.
 
Main particle

Set or get the main particle which this Effect will manage

void SetParticle (Particle p)
 Sets the main particle which this Effect will manage.
 
Particle GetParticle ()
 Gets the main particle which this Effect is managing.
 
Playback

Methods to Play/Stop Effect Generally, SEffectManager.Play methods are used instead of Start

override void Start ()
 Plays all elements this effect consists of.
 
override void Stop ()
 Stops all elements this effect consists of.
 
Attach

Helper methods for attaching to prent

void AttachTo (Object obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_to_world=false)
 Read Particle.AddAsChild.
 
void ReAttach ()
 Helper method to attach to parent using stored settings.
 
void AddAsChild (Object obj, vector local_pos, vector local_ori, bool force_rotation_to_world)
 Helper method to attach to parent.
 
Events

Various events that can be overriden for custom behaviour

void Event_OnPlayStart ()
 Event which just simply exists (DEPRECATED)
 
void Event_OnPlayStarted ()
 Event which just simply exists (DEPRECATED)
 
Generic API

Setters and getters for generic data and properties

void SetParticleID (int id)
 Sets the id of the particle to be used.
 
int GetParticleID ()
 Gets the id of the particle to be used.
 
void SetCurrentParticleID (int id)
 Sets the id of the particle to be used.
 
int GetCurrentParticleID ()
 Gets the current id of the managed Particle.
 
override void SetCurrentParent (Object parent_obj, bool updateCached=true)
 Set current parent of the managed Particle.
 
override Object GetCurrentParent ()
 Get the current parent of the managed Particle.
 
override void SetCurrentPosition (vector pos, bool updateCached=true)
 Set the current world position of the managed Particle.
 
override vector GetCurrentPosition ()
 Get the current world position of the managed Particle.
 
override void SetCurrentLocalPosition (vector pos, bool updateCached=true)
 Set the current local position of the managed Particle.
 
override vector GetCurrentLocalPosition ()
 Get the current local position of the managed Particle.
 
void SetOrientation (vector ori)
 Set orientation of the EffectParticle.
 
vector GetOrientation ()
 Get the orientation of the EffectParticle.
 
void SetCurrentOrientation (vector ori, bool updateCached=true)
 Set the current orientation of the managed Particle.
 
vector GetCurrentOrientation ()
 Get the current orientation of the managed Particle.
 
void ForceParticleRotationRelativeToWorld (bool state)
 Set orientation setting to be used by the effect when the Effect starts.
 
bool IsParticleRotationRelativeToWorld ()
 Get the orientation setting to be used by the effect when the Effect starts.
 
bool IsParticleCurrentRotationRelativeToWorld ()
 Get the current orientation setting to be used by the managed Particle.
 

Protected Attributes

Particle m_ParticleObj
 The main Particle effect that this Effect wrapper manages.
 
Generic data

Generic data for the particle

int m_ParticleID
 The ID in the ParticleList to create Particle from.
 
vector m_Orientation
 Orientation set by SetOrientation.
 
bool m_ForceRotationRelativeToWorld
 Orientation setting to be used by the effect when the Effect starts.
 

DEPRECATED

Methods which exist for backwards compatibility and are no longer in use or have never been in use

vector m_ParticleOrientation
 
Object m_Object
 
void EffectParticle ()
 ctor
 
void ~EffectParticle ()
 dtor
 
override void InitEffect ()
 init
 
override string GetDebugName ()
 Override when getting debug information.
 
override void ValidateStart ()
 Validation whether an effect truly started playing or if the Effect should stop as none is present.
 
void CheckLifeSpan ()
 Was never called and probably should never be called.
 
void SetDecalOwner (Object o)
 

Detailed Description

Wrapper class for managing particles through SEffectManager.

Definition at line 4 of file EffectParticle.c.

Constructor & Destructor Documentation

◆ EffectParticle()

void EffectParticle::EffectParticle ( )
inlineprotected

ctor

Definition at line 33 of file EffectParticle.c.

34 {
35
36 }

◆ ~EffectParticle()

void EffectParticle::~EffectParticle ( )
inlineprotected

dtor

Definition at line 41 of file EffectParticle.c.

42 {
43
44 }

Member Function Documentation

◆ AddAsChild()

void EffectParticle::AddAsChild ( Object obj,
vector local_pos,
vector local_ori,
bool force_rotation_to_world )
inlineprotected

Helper method to attach to parent.

Definition at line 242 of file EffectParticle.c.

243 {
245 if (p)
246 p.AddAsChild(obj, local_pos, local_ori, force_rotation_to_world);
247 }
Particle GetParticle()
Gets the main particle which this Effect is managing.
Legacy way of using particles in the game.
Definition Particle.c:7

References GetParticle().

Referenced by AttachTo(), and ReAttach().

◆ AttachTo()

void EffectParticle::AttachTo ( Object obj,
vector local_pos = "0 0 0",
vector local_ori = "0 0 0",
bool force_rotation_to_world = false )
inlineprotected

Read Particle.AddAsChild.

Definition at line 218 of file EffectParticle.c.

219 {
220 // Update the cached variables...
221 SetParent(obj);
225
226 // Now attach it
228 }
void SetParent(Object parent_obj)
Set parent of the Effect.
Definition Effect.c:378
void SetLocalPosition(vector pos)
Set the local position of the Effect.
Definition Effect.c:460
void SetAttachedLocalOri(vector ori)
Set local orientation for the Effectparticle to attach to when the Effect is started.
Definition Effect.c:583
void ForceParticleRotationRelativeToWorld(bool state)
Set orientation setting to be used by the effect when the Effect starts.
void AddAsChild(Object obj, vector local_pos, vector local_ori, bool force_rotation_to_world)
Helper method to attach to parent.

References AddAsChild(), ForceParticleRotationRelativeToWorld(), SetAttachedLocalOri(), SetLocalPosition(), and SetParent().

◆ CheckLifeSpan()

void EffectParticle::CheckLifeSpan ( )
inlineprotected

Was never called and probably should never be called.

Warning
Emptied the functionality as it is relatively unsafe...

Definition at line 530 of file EffectParticle.c.

531 {
532 /*
533 if ( !m_ParticleObj )
534 {
535 delete this;
536 }
537
538 OnCheckUpdate();
539 */
540 }

◆ Event_OnPlayStart()

void EffectParticle::Event_OnPlayStart ( )
inlineprotected

Event which just simply exists (DEPRECATED)

Warning
Never called or used
Note
Use Event_OnStarted instead

Definition at line 262 of file EffectParticle.c.

263 {
264
265 }

◆ Event_OnPlayStarted()

void EffectParticle::Event_OnPlayStarted ( )
inlineprotected

Event which just simply exists (DEPRECATED)

Warning
Never called or used
Note
Use Event_OnStarted instead

Definition at line 272 of file EffectParticle.c.

273 {
274
275 }

◆ ForceParticleRotationRelativeToWorld()

void EffectParticle::ForceParticleRotationRelativeToWorld ( bool state)
inlineprotected

Set orientation setting to be used by the effect when the Effect starts.

Warning
Only caches it into a variable to be used by Start, does not live update when called afterwards
Note
There is no way to update this immediately
Parameters
statebool Whether to keep WS orientation when attaching it to parent

Definition at line 484 of file EffectParticle.c.

485 {
487 }
bool m_ForceRotationRelativeToWorld
Orientation setting to be used by the effect when the Effect starts.

References m_ForceRotationRelativeToWorld.

Referenced by AttachTo().

◆ GetCurrentLocalPosition()

override vector EffectParticle::GetCurrentLocalPosition ( )
inlineprotected

Get the current local position of the managed Particle.

Returns
vector The current local position of the managed Particle

Definition at line 412 of file EffectParticle.c.

413 {
415
416 if (p)
417 {
418 Object parent = GetParent();
419
420 if (parent)
421 return parent.WorldToModel(p.GetPosition());
422 else
423 return p.GetPosition();
424 }
425 else
426 return super.GetLocalPosition();
427 }
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389

References GetParent(), and GetParticle().

◆ GetCurrentOrientation()

vector EffectParticle::GetCurrentOrientation ( )
inlineprotected

Get the current orientation of the managed Particle.

Returns
vector The current orientation of the managed Particle

Definition at line 468 of file EffectParticle.c.

469 {
471
472 if (p)
473 return p.GetOrientation();
474 else
475 return vector.Zero;
476 }
static const vector Zero
Definition EnConvert.c:110

References GetParticle(), and vector::Zero.

◆ GetCurrentParent()

override Object EffectParticle::GetCurrentParent ( )
inlineprotected

Get the current parent of the managed Particle.

Returns
Object The currrent parent of the Particle

Definition at line 348 of file EffectParticle.c.

349 {
351
352 if (p)
353 return Object.Cast(p.GetParent());
354 else
355 return super.GetParent();
356 }

References GetParticle().

◆ GetCurrentParticleID()

int EffectParticle::GetCurrentParticleID ( )
inlineprotected

Gets the current id of the managed Particle.

Returns
int Particle ID registered in ParticleList

Definition at line 323 of file EffectParticle.c.

324 {
326 if (p)
327 return p.GetParticleID();
328 else
329 return ParticleList.INVALID;
330 }
static const int INVALID

References GetParticle(), and ParticleList::INVALID.

◆ GetCurrentPosition()

override vector EffectParticle::GetCurrentPosition ( )
inlineprotected

Get the current world position of the managed Particle.

Returns
vector The current world position of the managed Particle

Definition at line 377 of file EffectParticle.c.

378 {
380
381 if (p)
382 return p.GetPosition();
383 else
384 return super.GetPosition();
385 }

References GetParticle().

◆ GetDebugName()

override string EffectParticle::GetDebugName ( )
inlineprotected

Override when getting debug information.

Definition at line 66 of file EffectParticle.c.

67 {
68 string identifier;
69 if (GetParticle())
70 identifier = GetParticle().GetDebugNameNative();
71 else
72 identifier = "NO_PARTICLE";
73
74 return string.Format("%1:%2:%3", super.GetDebugName(), m_ParticleID, identifier);
75 }
int m_ParticleID
The ID in the ParticleList to create Particle from.

References GetParticle(), and m_ParticleID.

Referenced by ValidateStart().

◆ GetEffectType()

override EffectType EffectParticle::GetEffectType ( )
inlineprotected

Get what type of effect the Effect is.

Returns
EffectType What type of effect the Effect is

Definition at line 101 of file EffectParticle.c.

102 {
103 return EffectType.PARTICLE;
104 }
EffectType
Enum to determine what type of effect the Effect is.
Definition Effect.c:3

◆ GetOrientation()

vector EffectParticle::GetOrientation ( )
inlineprotected

Get the orientation of the EffectParticle.

Warning
Only gets the cached variable, for immediate effect use GetCurrent variant
Returns
vector The orientation of EffectParticle

Definition at line 444 of file EffectParticle.c.

445 {
446 return m_Orientation;
447 }
vector m_Orientation
Orientation set by SetOrientation.

References m_Orientation.

Referenced by Start().

◆ GetParticle()

Particle EffectParticle::GetParticle ( )
inlineprotected

◆ GetParticleID()

int EffectParticle::GetParticleID ( )
inlineprotected

Gets the id of the particle to be used.

Warning
Only gets the cached variable, for immediate effect use GetCurrent variant
Returns
int Particle ID registered in ParticleList

Definition at line 300 of file EffectParticle.c.

301 {
302 return m_ParticleID;
303 }

References m_ParticleID.

◆ InitEffect()

override void EffectParticle::InitEffect ( )
inlineprotected

init

Definition at line 49 of file EffectParticle.c.

50 {
51 super.InitEffect();
52
53 // Would be neat, but since particles are often already playing
54 // BEFORE they are even registered as the particle for the Effect
55 // Better to just keep that one I guess..
56 // Event_OnStarted.Remove(Event_OnEffectStarted);
57
58 // Will be called by the particle events
60 }
ref ScriptInvoker Event_OnEffectEnded
Event used when the actual effect stopped playing.
Definition Effect.c:25
ref ScriptInvoker Event_OnStopped
Event used when Stop was called.
Definition Effect.c:23

References Event_OnEffectEnded, and Event_OnStopped.

◆ IsParticle()

override bool EffectParticle::IsParticle ( )
inlineprotected

Check whether the Effect is EffectParticle without casting.

Returns
bool Whether the Effect is EffectParticle

Definition at line 110 of file EffectParticle.c.

111 {
112 return true;
113 }

◆ IsParticleCurrentRotationRelativeToWorld()

bool EffectParticle::IsParticleCurrentRotationRelativeToWorld ( )
inlineprotected

Get the current orientation setting to be used by the managed Particle.

Returns
bool Whether the managed Particle is only updating position from parent

Definition at line 508 of file EffectParticle.c.

509 {
511
512 if (p)
513 return p.IsHierarchyPositionOnly();
514 else
515 return false;
516 }

References GetParticle().

◆ IsParticleRotationRelativeToWorld()

bool EffectParticle::IsParticleRotationRelativeToWorld ( )
inlineprotected

Get the orientation setting to be used by the effect when the Effect starts.

Warning
Only gets the cached variable, for immediate effect use IsParticleCurrentRotationRelativeToWorld
Returns
bool Whether to keep WS orientation when attaching it to parent

Definition at line 494 of file EffectParticle.c.

495 {
497
498 if (p)
499 return p.IsHierarchyPositionOnly();
500 else
502 }

References GetParticle(), and m_ForceRotationRelativeToWorld.

Referenced by ReAttach(), and Start().

◆ ReAttach()

void EffectParticle::ReAttach ( )
inlineprotected

Helper method to attach to parent using stored settings.

Definition at line 233 of file EffectParticle.c.

234 {
235 // Skip the updating, as we are going to reuse what was set before
237 }
vector GetLocalPosition()
Get the local position of the Effect.
Definition Effect.c:470
vector GetAttachedLocalOri()
Get the local orientation set by SetAttachedLocalOri.
Definition Effect.c:593
bool IsParticleRotationRelativeToWorld()
Get the orientation setting to be used by the effect when the Effect starts.

References AddAsChild(), GetAttachedLocalOri(), GetLocalPosition(), GetParent(), and IsParticleRotationRelativeToWorld().

Referenced by SetCurrentLocalPosition(), and SetCurrentParent().

◆ SetCurrentLocalPosition()

override void EffectParticle::SetCurrentLocalPosition ( vector pos,
bool updateCached = true )
inlineprotected

Set the current local position of the managed Particle.

Parameters
posvector The current local position for the managed Particle
updateCachedbool Whether to update the cached variable

Definition at line 392 of file EffectParticle.c.

393 {
394 super.SetCurrentLocalPosition(pos, updateCached);
395
397 if (p)
398 {
399 Object parent = GetParent();
400
401 if (parent)
402 ReAttach();
403 else
404 p.SetPosition(pos);
405 }
406 }
void ReAttach()
Helper method to attach to parent using stored settings.

References GetParent(), GetParticle(), and ReAttach().

◆ SetCurrentOrientation()

void EffectParticle::SetCurrentOrientation ( vector ori,
bool updateCached = true )
inlineprotected

Set the current orientation of the managed Particle.

Parameters
orivector Orientation in degrees (yaw, pitch, roll)

Definition at line 453 of file EffectParticle.c.

454 {
455 if (updateCached)
457
459
460 if (p)
461 p.SetOrientation(ori);
462 }
void SetOrientation(vector ori)
Set orientation of the EffectParticle.

References GetParticle(), and SetOrientation().

◆ SetCurrentParent()

override void EffectParticle::SetCurrentParent ( Object parent_obj,
bool updateCached = true )
inlineprotected

Set current parent of the managed Particle.

Parameters
parent_objObject The parent for the Particle
updateCachedbool Whether to update the cached variable

Definition at line 337 of file EffectParticle.c.

338 {
339 super.SetCurrentParent(parent_obj, updateCached);
340
341 ReAttach();
342 }

References ReAttach().

◆ SetCurrentParticleID()

void EffectParticle::SetCurrentParticleID ( int id)
inlineprotected

Sets the id of the particle to be used.

Note
Particle will not update immediately, but ParticleSource will
Parameters
idint Particle ID registered in ParticleList

Definition at line 310 of file EffectParticle.c.

311 {
313
315 if (p)
316 p.SetSource(id);
317 }

References GetParticle(), and m_ParticleID.

◆ SetCurrentPosition()

override void EffectParticle::SetCurrentPosition ( vector pos,
bool updateCached = true )
inlineprotected

Set the current world position of the managed Particle.

Parameters
posvector The current world position for the Particle
updateCachedbool Whether to update the cached variable

Definition at line 363 of file EffectParticle.c.

364 {
365 super.SetCurrentPosition(pos, updateCached);
366
368
369 if (p)
370 p.SetPosition(pos);
371 }

References GetParticle().

◆ SetDecalOwner()

void EffectParticle::SetDecalOwner ( Object o)
inlineprotected

Definition at line 542 of file EffectParticle.c.

543 {
544 m_Object = o;
545 }

References m_Object.

◆ SetOrientation()

void EffectParticle::SetOrientation ( vector ori)
inlineprotected

Set orientation of the EffectParticle.

Warning
Only sets the cached variable, for immediate effect use SetCurrent variant
Parameters
orivector Orientation in degrees (yaw, pitch, roll)

Definition at line 434 of file EffectParticle.c.

435 {
437 }

References m_Orientation.

Referenced by SetCurrentOrientation().

◆ SetParticle()

void EffectParticle::SetParticle ( Particle p)
inlineprotected

Sets the main particle which this Effect will manage.

Parameters
pParticle Main particle which this Effect will manage

Definition at line 127 of file EffectParticle.c.

128 {
129 // Unregister the events on the old
130 if (m_ParticleObj)
131 {
132 ParticleEvents ope = m_ParticleObj.GetEvents();
133 ope.Event_OnParticleStart.Remove(Event_OnEffectStarted);
134 ope.Event_OnParticleStop.Remove(Event_OnEffectEnded);
135 }
136
137 // Assign the new main Particle
139
140 // Register the events on the new
141 if (m_ParticleObj)
142 {
143 ParticleEvents npe = m_ParticleObj.GetEvents();
144 npe.Event_OnParticleStart.Insert(Event_OnEffectStarted);
145 // We will use Stop instead of End, as old particles were destroyed when they stopped
146 // And this system kinda relies on that
147 npe.Event_OnParticleStop.Insert(Event_OnEffectEnded);
148 }
149 }
ref ScriptInvoker Event_OnEffectStarted
Event used when the actual effect started playing.
Definition Effect.c:24
Invokers for ParticleBase events, called from events.

References Event_OnEffectEnded, Event_OnEffectStarted, and m_ParticleObj.

Referenced by EffBulletImpactBase::Event_OnStarted(), Start(), and Stop().

◆ SetParticleID()

◆ Start()

override void EffectParticle::Start ( )
inlineprotected

Plays all elements this effect consists of.

Note
Is called by SEffectManager.Play methods

Definition at line 173 of file EffectParticle.c.

174 {
175 if (m_ParticleID > 0)
176 {
177 vector pos = GetPosition();
179
180 if (m_ParentObject)
181 {
182 pos = GetLocalPosition();
184 }
185
186 SetParticle(ParticleManager.GetInstance().CreateParticle(m_ParticleID, pos, true, GetParent(), ori, IsParticleRotationRelativeToWorld()));
187 }
188
189 super.Start();
190 }
Object m_ParentObject
Cached parent.
Definition Effect.c:39
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
class JsonUndergroundAreaTriggerData GetPosition
vector GetOrientation()
Get the orientation of the EffectParticle.
void SetParticle(Particle p)
Sets the main particle which this Effect will manage.

References GetAttachedLocalOri(), GetLocalPosition(), GetOrientation(), GetParent(), GetPosition, IsParticleRotationRelativeToWorld(), m_ParentObject, m_ParticleID, ParticleManager(), and SetParticle().

Referenced by EffVehicleSmoke::SetParticleState().

◆ Stop()

override void EffectParticle::Stop ( )
inlineprotected

Stops all elements this effect consists of.

Note
Alternatively use SEffectManager.Stop( effect_id )

Definition at line 196 of file EffectParticle.c.

197 {
198 if (GetParticle())
199 {
200 GetParticle().Stop();
202 }
203
204 super.Stop();
205 }
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition Particle.c:262

References GetParticle(), SetParticle(), and Particle::Stop().

Referenced by EffVehicleSmoke::SetParticleState(), and ValidateStart().

◆ ValidateStart()

override void EffectParticle::ValidateStart ( )
inlineprotected

Validation whether an effect truly started playing or if the Effect should stop as none is present.

Note
Override this when inheriting to create own validation check
Is called from Event_OnStarted invoker after Event_OnStarted has been performed

Definition at line 82 of file EffectParticle.c.

83 {
84 if (!GetParticle())
85 {
86 ErrorEx(string.Format("No Particle started playing, stopping EffectParticle: %1", GetDebugName()), ErrorExSeverity.WARNING);
87 Stop();
88 }
89 }
override string GetDebugName()
Override when getting debug information.
override void Stop()
Stops all elements this effect consists of.
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx

References ErrorEx, GetDebugName(), GetParticle(), and Stop().

Member Data Documentation

◆ m_ForceRotationRelativeToWorld

bool EffectParticle::m_ForceRotationRelativeToWorld
protected

Orientation setting to be used by the effect when the Effect starts.

Definition at line 18 of file EffectParticle.c.

Referenced by ForceParticleRotationRelativeToWorld(), and IsParticleRotationRelativeToWorld().

◆ m_Object

Object EffectParticle::m_Object
protected

Definition at line 26 of file EffectParticle.c.

Referenced by SetDecalOwner().

◆ m_Orientation

vector EffectParticle::m_Orientation
protected

Orientation set by SetOrientation.

Definition at line 16 of file EffectParticle.c.

Referenced by GetOrientation(), and SetOrientation().

◆ m_ParticleID

int EffectParticle::m_ParticleID
protected

The ID in the ParticleList to create Particle from.

Definition at line 14 of file EffectParticle.c.

Referenced by GetDebugName(), GetParticleID(), SetCurrentParticleID(), SetParticleID(), and Start().

◆ m_ParticleObj

Particle EffectParticle::m_ParticleObj
protected

The main Particle effect that this Effect wrapper manages.

Definition at line 7 of file EffectParticle.c.

Referenced by GetParticle(), and SetParticle().

◆ m_ParticleOrientation

vector EffectParticle::m_ParticleOrientation
protected

Definition at line 25 of file EffectParticle.c.


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