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

Legacy way of using particles in the game. More...

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

Protected Member Functions

Playback

Methods regarding playing/stopping of particle

override void PlayParticle (int particle_id=-1)
 Method to tell the particle to start playing.
 
override bool PlayParticleEx (int particle_id=-1, int flags=0)
 Method to tell the particle to start playing.
 
void Play (int particle_id=-1)
 Legacy function for backwards compatibility with 1.01 and below.
 
override bool StopParticle (int flags=0)
 Method to tell the particle to stop playing.
 
void Stop ()
 Legacy function for backwards compatibility with 1.14 and below.
 
Properties and state

Obtain information or set properties regarding the state of the Particle

void SetSource (int particle_id)
 Sets particle id.
 
int GetParticleID ()
 Gets particle id.
 
Object GetDirectParticleEffect ()
 Returns direct particle effect entity which is usually handled by this class 'Particle' if there is one.
 
Object GetParticleParent ()
 Returns the parent of this Particle if there is one.
 
bool HasActiveParticle ()
 Returns if there is any particle active.
 
int GetParticleCount ()
 Returns the total count of active particles in all emitors.
 
bool IsRepeat ()
 Returns whether there is a repeating particle.
 
float GetMaxLifetime ()
 Returns the approx. max lifetime.
 

Static Protected Member Functions

Create a particle (static)

You can create a particle either at some position, or create it as a child on some object.

static Particle CreateOnObject (int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_world_rotation=false)
 Creates a particle emitter and attaches it on the given object.
 
static Particle Create (int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0")
 Legacy function for backwards compatibility.
 
static Particle CreateInWorld (int particle_id, vector global_pos, vector global_ori="0 0 0", bool force_world_rotation=false)
 Creates a particle emitter on the given position.
 
static Particle Create (int particle_id, vector global_pos, vector global_ori="0 0 0")
 Legacy function for backwards compatibility with 1.01 and below.
 
Static play on creation

You can use the following Play(...) functions to create and activate a particle in 1 line of your script.

static Particle PlayOnObject (int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_world_rotation=false)
 Creates a particle emitter, attaches it on the given object and activates it.
 
static Particle Play (int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0")
 Legacy function for backwards compatibility with 1.01 and below.
 
static Particle PlayInWorld (int particle_id, vector global_pos)
 Creates a particle emitter on the given position and activates it.
 
static Particle Play (int particle_id, vector global_pos)
 Legacy function for backwards compatibility with 1.01 and below.
 

Private Member Functions

Misc

Various helpers

void AddAsChild (Object parent, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_to_world=false)
 Attaches this particle onto some object. If null value is provided then the particle will be detached from the current parent.
 
Parameter API

Helpful methods for getting or setting parameters

void SetParticleParam (int parameter_id, float value)
 Set the value of a parameter of all emitors in the particle.
 
void SetParameter (int emitter, int parameter, float value)
 Set the value of a parameter of an emitor in the particle.
 
void GetParameter (int emitter, int parameter, out float value)
 Get the value of a parameter of an emitor in the particle.
 
float GetParameterEx (int emitter, int parameter)
 Get the value of a parameter of an emitor in the particle.
 
void ScaleParticleParamFromOriginal (int parameter_id, float coef)
 Scales the given parameter on all emitors relatively to their ORIGINAL value.
 
void ScaleParticleParam (int parameter_id, float coef)
 Scales the given parameter on all emitors relatively to their CURRENT value.
 
void IncrementParticleParamFromOriginal (int parameter_id, float value)
 Increments the value of the given parameter relatively from the ORIGINAL value.
 
void IncrementParticleParam (int parameter_id, float value)
 Increments the value of the given parameter relatively from the CURRENT value.
 

Generic data

Generic data for the Particle

int m_ParticleID
 ID from ParticleList if assigned.
 
float m_Lifetime
 Approx. remaining lifetime of particle.
 
bool m_IsRepeat
 Whether this particle repeats.
 
bool m_MarkedForDeletion
 Whether this particle is queued for deletion.
 

Wiggle API

Settings to make the Particle wiggle

Object m_ParentObject
 Parent Object the Particle is child of.
 
Object m_ParticleEffect
 The child object which contains the actual particle.
 
int m_PreviousFrame
 DEPRECATED.
 
bool m_WiggleProcessing
 Used for Wiggle API, to signal that wiggle API is currently doing work.
 
bool m_ForceOrientationRelativeToWorld
 Used for Wiggle API, to restore after unparenting.
 
vector m_DefaultOri
 Used for Wiggle API, to restore after unparenting.
 
vector m_DefaultPos
 Used for Wiggle API, to restore after unparenting.
 
vector m_DefaultWorldOri
 Used for Wiggle API, to restore after unparenting.
 
vector m_DefaultWorldPos
 Used for Wiggle API, to restore after unparenting.
 
float m_MaxOriWiggle
 Used for Wiggle API, Wiggle room [-m_MaxOriWiggle, m_MaxOriWiggle].
 
float m_MaxOriInterval
 Used for Wiggle API, Interval for wiggling [0, m_MaxOriInterval[.
 
ref Timer m_RandomizeOri
 Used for Wiggle API, calls the Wiggle functionality.
 
vector m_GlobalPosPreviousFrame
 DEPRECATED.
 
const int MAX_EMITORS = 30
 DEPRECATED.
 
void Particle ()
 ctor
 
bool IsWiggling ()
 Checks if particle is currently wiggling.
 
void SetWiggle (float random_angle, float random_interval)
 Makes the particle change direction by random_angle every random_interval seconds.
 
void StopWiggle ()
 Stops randomized wiggle.
 
void RandomizeOrientation ()
 Randomizes a new orientation and applies it.
 
void ParticleInit ()
 Purely here so that it can be emptied in ParticleSource.
 
vector RandWiggleVector ()
 Helper to get a randomized wiggle vector.
 
float RandWiggleFloat ()
 Helper to get a randomized wiggle float value.
 

Misc Particle specific helpers

Functionality specific for Particle

void CreateParticleEffect ()
 Creates ParticleEffect child, called from UpdateState.
 
void DestroyParticleEffect ()
 Destroys ParticleEffect child, called from UpdateState.
 
override void EOnFrame (IEntity other, float timeSlice)
 OnFrame update event decrementing the stored approx. lifetime and checking for deletion.
 
void OnCheckAutoDelete ()
 Creates ParticleEffect child, called from UpdateState.
 
void OnToDelete ()
 Called before deletion from OnCheckAutoDelete.
 
void UpdateState ()
 Creates/Destroys ParticleEffect child according to current state.
 

Detailed Description

Legacy way of using particles in the game.

Note
They work okay when just needing to play a particle once every once in a while But are extremely wasteful when it comes to playing multiple Particles at the same time

Definition at line 6 of file Particle.c.

Constructor & Destructor Documentation

◆ Particle()

void Particle::Particle ( )
inlineprivate

ctor

Definition at line 61 of file Particle.c.

62 {
64 }
void ParticleInit()
Purely here so that it can be emptied in ParticleSource.
Definition Particle.c:67

References ParticleInit().

Member Function Documentation

◆ AddAsChild()

void Particle::AddAsChild ( Object parent,
vector local_pos = "0 0 0",
vector local_ori = "0 0 0",
bool force_rotation_to_world = false )
inlineprivate

Attaches this particle onto some object. If null value is provided then the particle will be detached from the current parent.

Note
Due to the members being filled in, AddChild/RemoveChild cannot be used with Particle when using Wiggle
Parameters
parentObject Parent onto which this particle will be attached
local_posvector Attachment position local to the parent (optional)
local_orivector Orientation local to the parent (Pitch, Yawn, Roll in degrees) (Optional)
force_rotation_to_worldbool Force rotation to be in WS (Optional)

Definition at line 542 of file Particle.c.

543 {
544 if (ToDelete())
545 return;
546
547 if (parent)
548 {
549 // AddAsChild method is sometimes called from a timer.
550 // Due to that it is necesarry to use ToDelete() here to check if the parent object is flagged for deletion or not on client,
551 // because sometimes this code is executed before the parent's destructor from where this would normally be handled.
552 if (!parent.ToDelete())
553 {
555 SetOrientation(local_ori);
556 m_ParentObject = parent;
559
562
563 parent.AddChild(this, -1, false);
564 }
565 }
566 else
567 {
568 if (m_ParentObject && !m_ParentObject.ToDelete())
569 {
570 m_ParentObject.RemoveChild(this, true);
572 }
573 }
574 }
vector m_DefaultPos
Used for Wiggle API, to restore after unparenting.
Definition Particle.c:33
Object m_ParticleEffect
The child object which contains the actual particle.
Definition Particle.c:50
bool m_ForceOrientationRelativeToWorld
Used for Wiggle API, to restore after unparenting.
Definition Particle.c:29
Object m_ParentObject
Parent Object the Particle is child of.
Definition Particle.c:48
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition Effect.c:420
proto native void AddChild(Widget child, bool immedUpdate=true)

References AddChild(), m_DefaultPos, m_ForceOrientationRelativeToWorld, m_ParentObject, m_ParticleEffect, and SetPosition().

Referenced by RandomizeOrientation().

◆ Create() [1/2]

static Particle Particle::Create ( int particle_id,
Object parent_obj,
vector local_pos = "0 0 0",
vector local_ori = "0 0 0" )
inlinestaticprotected

Legacy function for backwards compatibility.

Definition at line 104 of file Particle.c.

105 {
107 }
int particle_id
static Particle CreateOnObject(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_world_rotation=false)
Creates a particle emitter and attaches it on the given object.
Definition Particle.c:88

References CreateOnObject(), and particle_id.

◆ Create() [2/2]

static Particle Particle::Create ( int particle_id,
vector global_pos,
vector global_ori = "0 0 0" )
inlinestaticprotected

Legacy function for backwards compatibility with 1.01 and below.

Definition at line 129 of file Particle.c.

130 {
132 }
static Particle CreateInWorld(int particle_id, vector global_pos, vector global_ori="0 0 0", bool force_world_rotation=false)
Creates a particle emitter on the given position.
Definition Particle.c:117

References CreateInWorld(), and particle_id.

◆ CreateInWorld()

static Particle Particle::CreateInWorld ( int particle_id,
vector global_pos,
vector global_ori = "0 0 0",
bool force_world_rotation = false )
inlinestaticprotected

Creates a particle emitter on the given position.

Parameters
particle_idint Particle ID registered in ParticleList
global_posVector Position where the particel will be created
global_orivector Orientation (Pitch, Yawn, Roll in degrees) (Optional)
force_world_rotationbool Forces particle's orientation to rotate relative to the world and not with the object (Optional)
Returns
Particle Created particle instance

Definition at line 117 of file Particle.c.

118 {
119 Particle p = Particle.Cast(GetGame().CreateObjectEx("Particle", global_pos, ECE_LOCAL));
120 p.SetSource(particle_id);
121 p.SetOrientation(global_ori);
122 p.m_ForceOrientationRelativeToWorld = force_world_rotation;
123 return p;
124 }
const int ECE_LOCAL
Legacy way of using particles in the game.
Definition Particle.c:7
proto native CGame GetGame()

References ECE_LOCAL, GetGame(), and particle_id.

Referenced by Create(), CreateOnObject(), and PlayInWorld().

◆ CreateOnObject()

static Particle Particle::CreateOnObject ( int particle_id,
Object parent_obj,
vector local_pos = "0 0 0",
vector local_ori = "0 0 0",
bool force_world_rotation = false )
inlinestaticprotected

Creates a particle emitter and attaches it on the given object.

Parameters
particle_idint Particle ID registered in ParticleList
parent_objObject Instance on which this particle will be attached
local_posvector Attachment position local to the parent (Optional)
local_orivector Orientation local to the parent (Pitch, Yawn, Roll in degrees) (Optional)
force_world_rotationbool Forces particle's orientation to rotate relative to the world and not with the object (Optional)
Returns
Particle Created particle instance

Definition at line 88 of file Particle.c.

89 {
90 if (!parent_obj)
91 Error("ERROR when creating a particle! Parameter parent_obj is NULL!");
92
93 vector global_pos = parent_obj.GetPosition();
96 p.m_DefaultOri = local_ori;
97
98 return p;
99 }
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
proto native vector Vector(float x, float y, float z)
Vector constructor from components.

References CreateInWorld(), Error(), particle_id, and Vector().

Referenced by Create(), and PlayOnObject().

◆ CreateParticleEffect()

void Particle::CreateParticleEffect ( )
inlineprivate

Creates ParticleEffect child, called from UpdateState.

Definition at line 422 of file Particle.c.

423 {
424 if (!GetGame().IsServer() || !GetGame().IsMultiplayer())
425 {
427 if (fullPath == "")
428 {
429 ErrorEx("Could not play Particle as there is no valid particle id assigned.");
430 m_IsPlaying = false;
431 return;
432 }
433
434 if (m_ParticleEffect == null)
435 {
436 m_ParticleEffect = GetGame().CreateObjectEx("#particlesourceenf", vector.Zero, ECE_LOCAL); // particle source must be lowercase!
437 }
438
440
442 m_ParticleEffect.SetObject(vobj, "");
444
447 }
448 }
Object GetObject()
bool m_IsPlaying
Whether the Effect is currently playing.
Definition Effect.c:37
bool m_IsRepeat
Whether this particle repeats.
Definition Particle.c:17
float GetMaxLifetime()
Returns the approx. max lifetime.
Definition Particle.c:369
float m_Lifetime
Approx. remaining lifetime of particle.
Definition Particle.c:15
int m_ParticleID
ID from ParticleList if assigned.
Definition Particle.c:13
bool IsRepeat()
Returns whether there is a repeating particle.
Definition Particle.c:345
static string GetParticleFullPath(int particle_id)
Returns particle's full path (with .ptc suffix) based on its ID.
static const vector Zero
Definition EnConvert.c:110
enum ShapeType ErrorEx
proto native void ReleaseObject(vobject object, int flag=0)

References AddChild(), ECE_LOCAL, ErrorEx, GetGame(), GetMaxLifetime(), GetObject(), ParticleList::GetParticleFullPath(), IsRepeat(), m_ForceOrientationRelativeToWorld, m_IsPlaying, m_IsRepeat, m_Lifetime, m_ParticleEffect, m_ParticleID, ReleaseObject(), and vector::Zero.

Referenced by UpdateState().

◆ DestroyParticleEffect()

void Particle::DestroyParticleEffect ( )
inlineprivate

Destroys ParticleEffect child, called from UpdateState.

Note
Does not destroy it immediately As it simply nulls the lifetime Then it will be cleaned up by EOnFrame eventually

Definition at line 456 of file Particle.c.

457 {
458 if (m_ParticleEffect && GetGame())
459 {
460 SetParameter(-1, EmitorParam.LIFETIME, 0);
461 SetParameter(-1, EmitorParam.LIFETIME_RND, 0);
462 SetParameter(-1, EmitorParam.REPEAT, 0);
463
464 m_IsRepeat = false;
465 }
466 }
void SetParameter(int emitter, int parameter, float value)
Set the value of a parameter of an emitor in the particle.
Definition Particle.c:603
EmitorParam
Definition EnVisual.c:114

References GetGame(), m_IsRepeat, m_ParticleEffect, and SetParameter().

Referenced by UpdateState().

◆ EOnFrame()

override void Particle::EOnFrame ( IEntity other,
float timeSlice )
inlineprivate

OnFrame update event decrementing the stored approx. lifetime and checking for deletion.

Definition at line 471 of file Particle.c.

472 {
475 }
void OnCheckAutoDelete()
Creates ParticleEffect child, called from UpdateState.
Definition Particle.c:480

References m_Lifetime, and OnCheckAutoDelete().

◆ GetDirectParticleEffect()

Object Particle::GetDirectParticleEffect ( )
inlineprotected

Returns direct particle effect entity which is usually handled by this class 'Particle' if there is one.

Note
Is a child of this Particle
Returns
Object The Object with the particle component or null

Definition at line 302 of file Particle.c.

303 {
304 return m_ParticleEffect;
305 }

References m_ParticleEffect.

Referenced by FlammableBase::UpdateLight().

◆ GetMaxLifetime()

float Particle::GetMaxLifetime ( )
inlineprotected

Returns the approx. max lifetime.

Returns
float The largest lifetime sum among the emitors

Definition at line 369 of file Particle.c.

370 {
371 float lifetime_return = 0;
372
374 {
375 float lifetime_min = 0;
376 float lifetime_random = 0;
377 float effect_time = 0;
378
379 float lifetime_sum = 0;
380
382
383 for (int i = 0; i < emitors; ++i)
384 {
388
390
393 }
394 }
395
396 return lifetime_return;
397 }
proto int GetParticleEmitorCount(notnull IEntity ent)
proto void GetParticleParm(notnull IEntity ent, int emitor, EmitorParam parameter, out void value)

References GetParticleEmitorCount(), GetParticleParm(), and m_ParticleEffect.

Referenced by CreateParticleEffect(), and OnCheckAutoDelete().

◆ GetParameter()

void Particle::GetParameter ( int emitter,
int parameter,
out float value )
inlineprivate

Get the value of a parameter of an emitor in the particle.

Parameters
emitterint The emitor to get the value from
parameterint The parameter to get the value from (enum EmitorParam)
valuefloat The value

Definition at line 617 of file Particle.c.

618 {
619 if (!m_ParticleEffect)
620 return;
621
623 }

References GetParticleParm(), and m_ParticleEffect.

◆ GetParameterEx()

float Particle::GetParameterEx ( int emitter,
int parameter )
inlineprivate

Get the value of a parameter of an emitor in the particle.

Parameters
emitterint The emitor to get the value from
parameterint The parameter to get the value from (enum EmitorParam)
Returns
float The value

Definition at line 631 of file Particle.c.

632 {
633 if (!m_ParticleEffect)
634 return 0;
635
636 float value;
638 return value;
639 }

References GetParticleParm(), and m_ParticleEffect.

◆ GetParticleCount()

int Particle::GetParticleCount ( )
inlineprotected

Returns the total count of active particles in all emitors.

Note
Internally does a sum, HasActiveParticle is better for a quick check
Returns
int Total count of active particles

Definition at line 333 of file Particle.c.

334 {
337
338 return 0;
339 }
int ParticleGetCount(IEntity ent)
Definition EnVisual.c:205

References m_ParticleEffect, and ParticleGetCount().

Referenced by OnCheckAutoDelete().

◆ GetParticleID()

int Particle::GetParticleID ( )
inlineprotected

Gets particle id.

Note
This is not necessarily the CURRENT particle As one can use SetSource while the Particle is still playing But that will not change the particle before Particle is played again
Returns
int The last set Particle ID registered in ParticleList

Definition at line 292 of file Particle.c.

293 {
294 return m_ParticleID;
295 }

References m_ParticleID.

Referenced by FlammableBase::UpdateParticle().

◆ GetParticleParent()

Object Particle::GetParticleParent ( )
inlineprotected

Returns the parent of this Particle if there is one.

Returns
Object The registered parent or null

Definition at line 311 of file Particle.c.

312 {
313 return m_ParentObject;
314 }

References m_ParentObject.

◆ HasActiveParticle()

bool Particle::HasActiveParticle ( )
inlineprotected

Returns if there is any particle active.

Returns
bool Whether there is any particle active

Definition at line 320 of file Particle.c.

321 {
324
325 return false;
326 }
bool ParticleHasActive(IEntity ent)
Definition EnVisual.c:210

References m_ParticleEffect, and ParticleHasActive().

◆ IncrementParticleParam()

void Particle::IncrementParticleParam ( int parameter_id,
float value )
inlineprivate

Increments the value of the given parameter relatively from the CURRENT value.

Note
It's a simple sum, so negative value decrements
Parameters
parameter_idint The parameter to adjust (enum EmitorParam)
valuefloat The value to sum

Definition at line 705 of file Particle.c.

706 {
707 if (!m_ParticleEffect)
708 return;
709
711 for (int i = 0; i < emitors; ++i)
712 {
713 float param;
716 }
717 }
proto void SetParticleParm(notnull IEntity ent, int emitor, EmitorParam parameter, void value)

References GetParticleEmitorCount(), GetParticleParm(), m_ParticleEffect, and SetParticleParm().

◆ IncrementParticleParamFromOriginal()

void Particle::IncrementParticleParamFromOriginal ( int parameter_id,
float value )
inlineprivate

Increments the value of the given parameter relatively from the ORIGINAL value.

Note
It's a simple sum, so negative value decrements
Parameters
parameter_idint The parameter to adjust (enum EmitorParam)
valuefloat The value to sum

Definition at line 685 of file Particle.c.

686 {
687 if (!m_ParticleEffect)
688 return;
689
691 for (int i = 0; i < emitors; ++i)
692 {
693 float param;
696 }
697 }
proto void GetParticleParmOriginal(notnull IEntity ent, int emitor, EmitorParam parameter, out void value)

References GetParticleEmitorCount(), GetParticleParmOriginal(), m_ParticleEffect, and SetParticleParm().

◆ IsRepeat()

bool Particle::IsRepeat ( )
inlineprotected

Returns whether there is a repeating particle.

Returns
bool whether there is a repeating particle

Definition at line 345 of file Particle.c.

346 {
348 {
349 bool repeat = false;
350
352
353 for (int i = 0; i < emitors; ++i)
354 {
356
357 if (repeat)
358 return true;
359 }
360 }
361
362 return false;
363 }

References GetParticleEmitorCount(), GetParticleParm(), and m_ParticleEffect.

Referenced by CreateParticleEffect(), and OnCheckAutoDelete().

◆ IsWiggling()

bool Particle::IsWiggling ( )
inlineprivate

Checks if particle is currently wiggling.

Definition at line 730 of file Particle.c.

731 {
732 return m_RandomizeOri && m_RandomizeOri.IsRunning();
733 }
ref Timer m_RandomizeOri
Used for Wiggle API, calls the Wiggle functionality.
Definition Particle.c:44

References m_RandomizeOri.

Referenced by ParticleSource::OnParticleStop(), ParticleSource::OnParticleUnParented(), ParticleSource::SetWiggle(), and ParticleSource::StopWiggle().

◆ OnCheckAutoDelete()

void Particle::OnCheckAutoDelete ( )
inlineprivate

Creates ParticleEffect child, called from UpdateState.

Definition at line 480 of file Particle.c.

481 {
482 if (m_Lifetime <= 0)
483 {
485 {
486 m_IsRepeat = IsRepeat(); // It is possible that the REPEAT flag was changed during lifetime, so it needs to be checked again.
487
488 if (m_IsRepeat)
490 else
491 {
493
494 if (GetParticleCount() == 0)
495 {
496 m_MarkedForDeletion = true;
497 OnToDelete();
499 }
500 }
501 }
502 else
503 {
505 {
507 {
508 m_ParticleEffect.Delete();
510 }
511
512 Delete();
513 }
514 }
515 }
516 }
void OnParticleEnd()
Event when the particle ends.
void OnParticleStop()
Event when the particle stops.
bool m_MarkedForDeletion
Whether this particle is queued for deletion.
Definition Particle.c:19
int GetParticleCount()
Returns the total count of active particles in all emitors.
Definition Particle.c:333
void OnToDelete()
Called before deletion from OnCheckAutoDelete.
Definition Particle.c:521

References GetMaxLifetime(), GetParticleCount(), IsRepeat(), m_IsRepeat, m_Lifetime, m_MarkedForDeletion, m_ParticleEffect, OnParticleEnd(), OnParticleStop(), and OnToDelete().

Referenced by EOnFrame().

◆ OnToDelete()

void Particle::OnToDelete ( )
inlineprivate

Called before deletion from OnCheckAutoDelete.

Definition at line 521 of file Particle.c.

522 {
523
524 }

Referenced by OnCheckAutoDelete().

◆ ParticleInit()

void Particle::ParticleInit ( )
inlineprotected

Purely here so that it can be emptied in ParticleSource.

Definition at line 67 of file Particle.c.

68 {
69 SetFlags(EntityFlags.VISIBLE, true);
70 SetEventMask(EntityEvent.INIT);
71 SetEventMask(EntityEvent.FRAME);
72 }
proto native void SetFlags(ShapeFlags flags)
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44
EntityFlags
Entity flags.
Definition EnEntity.c:114

References SetFlags().

Referenced by Particle().

◆ Play() [1/3]

static Particle Particle::Play ( int particle_id,
Object parent_obj,
vector local_pos = "0 0 0",
vector local_ori = "0 0 0" )
inlinestaticprotected

Legacy function for backwards compatibility with 1.01 and below.

Definition at line 162 of file Particle.c.

163 {
165 }
static Particle PlayOnObject(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_world_rotation=false)
Creates a particle emitter, attaches it on the given object and activates it.
Definition Particle.c:151

References particle_id, and PlayOnObject().

◆ Play() [2/3]

static Particle Particle::Play ( int particle_id,
vector global_pos )
inlinestaticprotected

Legacy function for backwards compatibility with 1.01 and below.

Definition at line 184 of file Particle.c.

185 {
187 }
static Particle PlayInWorld(int particle_id, vector global_pos)
Creates a particle emitter on the given position and activates it.
Definition Particle.c:173

References particle_id, and PlayInWorld().

◆ Play() [3/3]

void Particle::Play ( int particle_id = -1)
inlineprotected

Legacy function for backwards compatibility with 1.01 and below.

Parameters
particle_idint Particle ID registered in ParticleList to start playing

Definition at line 229 of file Particle.c.

230 {
232 }
override void PlayParticle(int particle_id=-1)
Method to tell the particle to start playing.
Definition Particle.c:201

References particle_id, and PlayParticle().

◆ PlayInWorld()

static Particle Particle::PlayInWorld ( int particle_id,
vector global_pos )
inlinestaticprotected

Creates a particle emitter on the given position and activates it.

Parameters
particle_idint Particle ID registered in ParticleList
global_posVector Position where the particel will be created
Returns
Particle Created particle instance

Definition at line 173 of file Particle.c.

174 {
176 p.PlayParticle();
177
178 return p;
179 }

References CreateInWorld(), and particle_id.

Referenced by Play().

◆ PlayOnObject()

static Particle Particle::PlayOnObject ( int particle_id,
Object parent_obj,
vector local_pos = "0 0 0",
vector local_ori = "0 0 0",
bool force_world_rotation = false )
inlinestaticprotected

Creates a particle emitter, attaches it on the given object and activates it.

Parameters
particle_idint Particle ID registered in ParticleList
parent_objObject Instance on which this particle will be attached
local_posvector Attachment position local to the parent (Optional)
local_orivector Orientation local to the parent (Pitch, Yaw, Roll in degrees) (Optional)
force_world_rotationbool Forces particle's orientation to rotate relative to the world and not with the object (Optional)
Returns
Particle Created particle instance

Definition at line 151 of file Particle.c.

152 {
154 p.PlayParticle();
155
156 return p;
157 }

References CreateOnObject(), and particle_id.

Referenced by Play().

◆ PlayParticle()

override void Particle::PlayParticle ( int particle_id = -1)
inlineprotected

Method to tell the particle to start playing.

Parameters
particle_idint Particle ID registered in ParticleList to start playing

Definition at line 201 of file Particle.c.

202 {
204 }
override bool PlayParticleEx(int particle_id=-1, int flags=0)
Method to tell the particle to start playing.
Definition Particle.c:213

References particle_id, and PlayParticleEx().

Referenced by Play().

◆ PlayParticleEx()

override bool Particle::PlayParticleEx ( int particle_id = -1,
int flags = 0 )
inlineprotected

Method to tell the particle to start playing.

Note
The parameter to set the ID will only work when the particle is not already playing
Parameters
particle_idint Particle ID registered in ParticleList to start playing
flagsint Flags to pass to the playing (None on this level)
Returns
bool Whether the particle successfully started

Definition at line 213 of file Particle.c.

214 {
215 if (particle_id > -1)
217
219
220 UpdateState();
221
222 return true;
223 }
void OnParticleStart()
Event when the particle starts.
void SetSource(int particle_id)
Sets particle id.
Definition Particle.c:280
void UpdateState()
Creates/Destroys ParticleEffect child according to current state.
Definition Particle.c:411

References OnParticleStart(), particle_id, SetSource(), and UpdateState().

Referenced by PlayParticle().

◆ RandomizeOrientation()

void Particle::RandomizeOrientation ( )
inlineprivate

Randomizes a new orientation and applies it.

Definition at line 774 of file Particle.c.

775 {
776 m_WiggleProcessing = true;
777
778 if (m_ParentObject)
779 {
780 if (!m_RandomizeOri.IsRunning())
781 m_RandomizeOri.Run(Math.RandomFloat(0, m_MaxOriInterval), this, "RandomizeOrientation", NULL, false);
782
786 }
787
788 m_WiggleProcessing = false;
789 }
Definition EnMath.c:7
vector m_DefaultOri
Used for Wiggle API, to restore after unparenting.
Definition Particle.c:31
void AddAsChild(Object parent, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_to_world=false)
Attaches this particle onto some object. If null value is provided then the particle will be detached...
Definition Particle.c:542
bool m_WiggleProcessing
Used for Wiggle API, to signal that wiggle API is currently doing work.
Definition Particle.c:27
vector RandWiggleVector()
Helper to get a randomized wiggle vector.
Definition Particle.c:794
float m_MaxOriInterval
Used for Wiggle API, Interval for wiggling [0, m_MaxOriInterval[.
Definition Particle.c:42
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].

References AddAsChild(), m_DefaultOri, m_DefaultPos, m_MaxOriInterval, m_ParentObject, m_RandomizeOri, m_WiggleProcessing, Math::RandomFloat(), and RandWiggleVector().

◆ RandWiggleFloat()

float Particle::RandWiggleFloat ( )
inlineprotected

Helper to get a randomized wiggle float value.

Definition at line 802 of file Particle.c.

803 {
805 }
float m_MaxOriWiggle
Used for Wiggle API, Wiggle room [-m_MaxOriWiggle, m_MaxOriWiggle].
Definition Particle.c:40
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106

References m_MaxOriWiggle, and Math::RandomFloatInclusive().

Referenced by RandWiggleVector().

◆ RandWiggleVector()

vector Particle::RandWiggleVector ( )
inlineprotected

Helper to get a randomized wiggle vector.

Definition at line 794 of file Particle.c.

795 {
797 }
float RandWiggleFloat()
Helper to get a randomized wiggle float value.
Definition Particle.c:802

References RandWiggleFloat(), and Vector().

Referenced by RandomizeOrientation(), and ParticleSource::RandomizeOrientation().

◆ ScaleParticleParam()

void Particle::ScaleParticleParam ( int parameter_id,
float coef )
inlineprivate

Scales the given parameter on all emitors relatively to their CURRENT value.

Parameters
parameter_idint The parameter to adjust (enum EmitorParam)
coeffloat The multiplier to apply

Definition at line 665 of file Particle.c.

666 {
667 if (!m_ParticleEffect)
668 return;
669
671 for (int i = 0; i < emitors; ++i)
672 {
673 float value;
676 }
677 }

References GetParticleEmitorCount(), GetParticleParm(), m_ParticleEffect, and SetParticleParm().

◆ ScaleParticleParamFromOriginal()

void Particle::ScaleParticleParamFromOriginal ( int parameter_id,
float coef )
inlineprivate

Scales the given parameter on all emitors relatively to their ORIGINAL value.

Parameters
parameter_idint The parameter to adjust (enum EmitorParam)
coeffloat The multiplier to apply

Definition at line 646 of file Particle.c.

647 {
648 if (!m_ParticleEffect)
649 return;
650
652 for (int i = 0; i < emitors; ++i)
653 {
654 float value;
657 }
658 }

References GetParticleEmitorCount(), GetParticleParmOriginal(), m_ParticleEffect, and SetParticleParm().

Referenced by BroomBase::UpdateParticle(), and FlammableBase::UpdateParticle().

◆ SetParameter()

void Particle::SetParameter ( int emitter,
int parameter,
float value )
inlineprivate

Set the value of a parameter of an emitor in the particle.

Parameters
emitterint The emitter to apply the new value to, -1 for all emitter
parameterint The parameter to apply the new value to (enum EmitorParam)
valuefloat The value to apply

Definition at line 603 of file Particle.c.

604 {
605 if (!m_ParticleEffect)
606 return;
607
609 }

References m_ParticleEffect, and SetParticleParm().

Referenced by ManBase::ContaminatedParticleAdjustment(), CreateParticle(), DestroyParticleEffect(), ParticleNormalSmokeStart(), ParticleSmallSmokeStart(), PlayVFX(), ManBase::SetContaminatedEffectEx(), FlareSimulation::Simulate(), and FlareSimulation::TurnOffDistantLight().

◆ SetParticleParam()

void Particle::SetParticleParam ( int parameter_id,
float value )
inlineprivate

Set the value of a parameter of all emitors in the particle.

Parameters
parameterint The parameter to apply the new value to (enum EmitorParam)
valuefloat The value to apply

Definition at line 589 of file Particle.c.

590 {
591 if (!m_ParticleEffect)
592 return;
593
595 }

References m_ParticleEffect, and SetParticleParm().

◆ SetSource()

void Particle::SetSource ( int particle_id)
inlineprotected

Sets particle id.

Note
Does not work at runtime, particle object needs to be destroyed and then Particle needs to play again
Parameters
particle_idint Particle ID registered in ParticleList to start playing

Definition at line 280 of file Particle.c.

281 {
283 }

References m_ParticleID, and particle_id.

Referenced by PlayParticleEx().

◆ SetWiggle()

void Particle::SetWiggle ( float random_angle,
float random_interval )
inlineprivate

Makes the particle change direction by random_angle every random_interval seconds.

Note
This does not actually work on Particle with no parent, it should on ParticleSource
Calling SetWiggle(0,0) will effectively stop all wiggle functionality
Parameters
random_anglefloat Will be the range [-random_angle, random_angle[ to wiggle between
random_intervalfloat Will be the time range [0, random_interval] to wiggle next time

Definition at line 742 of file Particle.c.

743 {
744 if (random_angle != 0 || random_interval != 0)
745 {
748
749 if (!m_RandomizeOri)
751
752 if (!m_RandomizeOri.IsRunning()) // Makes sure the timer is NOT running already
753 m_RandomizeOri.Run(Math.RandomFloat(0, m_MaxOriInterval), this, "RandomizeOrientation", null, false);
754 }
755 else
756 StopWiggle();
757 }
void StopWiggle()
Stops randomized wiggle.
Definition Particle.c:762
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10

References CALL_CATEGORY_GAMEPLAY, m_MaxOriInterval, m_MaxOriWiggle, m_RandomizeOri, Math::RandomFloat(), and StopWiggle().

Referenced by FlareSimulation::OnActivation(), CupidsBoltSimulation::OnFire(), SmokeSimulation::OnFire(), Ammo_40mm_Smoke_ColorBase::OnVariablesSynchronized(), PlayVFX(), and Roadflare::UpdateActiveParticles().

◆ Stop()

◆ StopParticle()

override bool Particle::StopParticle ( int flags = 0)
inlineprotected

Method to tell the particle to stop playing.

Note
No flags available for Particle
Emitors are automatically removed later when its particle count is 0
Parameters
flagsint Flags to pass to the stopping (None on this level)
Returns
bool Whether the particle successfully stopped

Definition at line 241 of file Particle.c.

242 {
244
245 // Without the following we might get an error when a particle parent is despawned client-side.
246 Object parent = Object.Cast(GetParent());
247 if (parent && !ToDelete())
248 {
250 parent.RemoveChild(this);
252 }
253
254 UpdateState();
255
256 return true;
257 }
class JsonUndergroundAreaTriggerData GetPosition
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389

References GetParent(), GetPosition, OnParticleStop(), SetPosition(), and UpdateState().

Referenced by Stop().

◆ StopWiggle()

void Particle::StopWiggle ( )
inlineprivate

Stops randomized wiggle.

Definition at line 762 of file Particle.c.

763 {
764 if (m_RandomizeOri)
765 m_RandomizeOri.Stop();
766
767 m_MaxOriWiggle = 0;
769 }

References m_MaxOriInterval, m_MaxOriWiggle, and m_RandomizeOri.

Referenced by SetWiggle().

◆ UpdateState()

void Particle::UpdateState ( )
inlineprotected

Creates/Destroys ParticleEffect child according to current state.

Note
Is called from Play/Stop methods

Definition at line 411 of file Particle.c.

412 {
413 if (m_IsPlaying == false && m_ParticleEffect)
415 else if (m_IsPlaying == true && m_ParticleEffect == null)
417 }
void CreateParticleEffect()
Creates ParticleEffect child, called from UpdateState.
Definition Particle.c:422
void DestroyParticleEffect()
Destroys ParticleEffect child, called from UpdateState.
Definition Particle.c:456

References CreateParticleEffect(), DestroyParticleEffect(), m_IsPlaying, and m_ParticleEffect.

Referenced by PlayParticleEx(), and StopParticle().

Member Data Documentation

◆ m_DefaultOri

vector Particle::m_DefaultOri
private

Used for Wiggle API, to restore after unparenting.

Definition at line 31 of file Particle.c.

Referenced by ParticleSource::OnParticleUnParented(), RandomizeOrientation(), ParticleSource::RandomizeOrientation(), ParticleSource::SetWiggle(), and ParticleSource::StopWiggle().

◆ m_DefaultPos

vector Particle::m_DefaultPos
private

◆ m_DefaultWorldOri

vector Particle::m_DefaultWorldOri
private

Used for Wiggle API, to restore after unparenting.

Definition at line 35 of file Particle.c.

Referenced by ParticleSource::OnParticleUnParented(), and ParticleSource::SetWiggle().

◆ m_DefaultWorldPos

vector Particle::m_DefaultWorldPos
private

Used for Wiggle API, to restore after unparenting.

Definition at line 37 of file Particle.c.

Referenced by ParticleSource::OnParticleUnParented(), and ParticleSource::SetWiggle().

◆ m_ForceOrientationRelativeToWorld

bool Particle::m_ForceOrientationRelativeToWorld
private

Used for Wiggle API, to restore after unparenting.

Definition at line 29 of file Particle.c.

Referenced by AddAsChild(), CreateParticleEffect(), ParticleSource::RandomizeOrientation(), ParticleSource::SetWiggle(), and ParticleSource::StopWiggle().

◆ m_GlobalPosPreviousFrame

vector Particle::m_GlobalPosPreviousFrame
private

DEPRECATED.

Definition at line 55 of file Particle.c.

◆ m_IsRepeat

bool Particle::m_IsRepeat
protected

Whether this particle repeats.

Definition at line 17 of file Particle.c.

Referenced by CreateParticleEffect(), DestroyParticleEffect(), and OnCheckAutoDelete().

◆ m_Lifetime

float Particle::m_Lifetime
protected

Approx. remaining lifetime of particle.

Definition at line 15 of file Particle.c.

Referenced by CreateParticleEffect(), EOnFrame(), and OnCheckAutoDelete().

◆ m_MarkedForDeletion

bool Particle::m_MarkedForDeletion
private

Whether this particle is queued for deletion.

Definition at line 19 of file Particle.c.

Referenced by OnCheckAutoDelete().

◆ m_MaxOriInterval

float Particle::m_MaxOriInterval
private

Used for Wiggle API, Interval for wiggling [0, m_MaxOriInterval[.

Definition at line 42 of file Particle.c.

Referenced by ParticleSource::OnParticleUnParented(), RandomizeOrientation(), ParticleSource::RandomizeOrientation(), SetWiggle(), ParticleSource::SetWiggle(), and StopWiggle().

◆ m_MaxOriWiggle

float Particle::m_MaxOriWiggle
private

Used for Wiggle API, Wiggle room [-m_MaxOriWiggle, m_MaxOriWiggle].

Definition at line 40 of file Particle.c.

Referenced by ParticleSource::OnParticleUnParented(), RandWiggleFloat(), SetWiggle(), ParticleSource::SetWiggle(), and StopWiggle().

◆ m_ParentObject

Object Particle::m_ParentObject
protected

◆ m_ParticleEffect

◆ m_ParticleID

int Particle::m_ParticleID
protected

ID from ParticleList if assigned.

Definition at line 13 of file Particle.c.

Referenced by CreateParticleEffect(), GetParticleID(), and SetSource().

◆ m_PreviousFrame

int Particle::m_PreviousFrame
protected

DEPRECATED.

Definition at line 53 of file Particle.c.

◆ m_RandomizeOri

ref Timer Particle::m_RandomizeOri
private

Used for Wiggle API, calls the Wiggle functionality.

Definition at line 44 of file Particle.c.

Referenced by IsWiggling(), ParticleSource::OnParticleStop(), RandomizeOrientation(), ParticleSource::RandomizeOrientation(), SetWiggle(), and StopWiggle().

◆ m_WiggleProcessing

bool Particle::m_WiggleProcessing
private

Used for Wiggle API, to signal that wiggle API is currently doing work.

Definition at line 27 of file Particle.c.

Referenced by ParticleSource::OnParticleUnParented(), RandomizeOrientation(), and ParticleSource::RandomizeOrientation().

◆ MAX_EMITORS

const int Particle::MAX_EMITORS = 30
staticprivate

DEPRECATED.

Definition at line 57 of file Particle.c.


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