Legacy way of using particles in the game. More...
Private 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. | |
Misc Particle specific helpers | |
Functionality specific for Particle | |
protected void | UpdateState () |
Creates/Destroys ParticleEffect child according to current state. | |
private void | CreateParticleEffect () |
Creates ParticleEffect child, called from UpdateState. | |
private 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. | |
private void | OnToDelete () |
Called before deletion from OnCheckAutoDelete. | |
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. | |
float | GetParameterOriginal (int emitter, int parameter) |
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. | |
Static Private 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 Attributes | |
Generic data | |
Generic data for the Particle | |
protected int | m_ParticleID |
ID from ParticleList if assigned. | |
protected float | m_Lifetime |
Approx. remaining lifetime of particle. | |
protected bool | m_IsRepeat |
Whether this particle repeats. | |
private bool | m_MarkedForDeletion |
Whether this particle is queued for deletion. | |
Wiggle API | |
Settings to make the Particle wiggle | |
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. | |
protected Object | m_ParentObject |
Parent Object the Particle is child of. | |
protected Object | m_ParticleEffect |
The child object which contains the actual particle. | |
protected int | m_PreviousFrame |
DEPRECATED. | |
private vector | m_GlobalPosPreviousFrame |
DEPRECATED. | |
static private const int | MAX_EMITORS = 30 |
DEPRECATED | |
void | Particle () |
ctor | |
protected void | ParticleInit () |
Purely here so that it can be emptied in ParticleSource. | |
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. | |
protected vector | RandWiggleVector () |
Helper to get a randomized wiggle vector. | |
protected float | RandWiggleFloat () |
Helper to get a randomized wiggle float value. | |
Legacy way of using particles in the game.
|
inlineprivate |
ctor
References ParticleInit().
|
inlineprivate |
Attaches this particle onto some object. If null value is provided then the particle will be detached from the current parent.
parent | Object Parent onto which this particle will be attached |
local_pos | vector Attachment position local to the parent (optional) |
local_ori | vector Orientation local to the parent (Pitch, Yawn, Roll in degrees) (Optional) |
force_rotation_to_world | bool Force rotation to be in WS (Optional) |
References AddChild(), m_DefaultPos, m_ForceOrientationRelativeToWorld, m_ParentObject, m_ParticleEffect, and SetPosition().
Referenced by EffectParticle::AddAsChild(), CreateOnObject(), and RandomizeOrientation().
|
inlinestaticprivate |
Legacy function for backwards compatibility.
References CreateOnObject(), and particle_id.
|
inlinestaticprivate |
Legacy function for backwards compatibility with 1.01 and below.
References CreateInWorld(), and particle_id.
|
inlinestaticprivate |
Creates a particle emitter on the given position.
particle_id | int Particle ID registered in ParticleList |
global_pos | Vector Position where the particel will be created |
global_ori | vector Orientation (Pitch, Yawn, Roll in degrees) (Optional) |
force_world_rotation | bool Forces particle's orientation to rotate relative to the world and not with the object (Optional) |
Particle
Created particle instance References ECE_LOCAL, GetGame(), m_ForceOrientationRelativeToWorld, particle_id, and SetSource().
Referenced by Create(), CreateOnObject(), and PlayInWorld().
|
inlinestaticprivate |
Creates a particle emitter and attaches it on the given object.
particle_id | int Particle ID registered in ParticleList |
parent_obj | Object Instance on which this particle will be attached |
local_pos | vector Attachment position local to the parent (Optional) |
local_ori | vector Orientation local to the parent (Pitch, Yawn, Roll in degrees) (Optional) |
force_world_rotation | bool Forces particle's orientation to rotate relative to the world and not with the object (Optional) |
Particle
Created particle instance References AddAsChild(), CreateInWorld(), Error(), m_DefaultOri, particle_id, and Vector().
Referenced by Create(), and PlayOnObject().
|
inlineprivate |
Creates ParticleEffect child, called from UpdateState.
References AddChild(), CGame::CreateObjectEx(), 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().
|
inlineprivate |
Destroys ParticleEffect child, called from UpdateState.
References GetGame(), m_IsRepeat, m_ParticleEffect, and SetParameter().
Referenced by UpdateState().
OnFrame update event decrementing the stored approx. lifetime and checking for deletion.
References m_Lifetime, and OnCheckAutoDelete().
|
inlineprivate |
Returns direct particle effect entity which is usually handled by this class 'Particle' if there is one.
References m_ParticleEffect.
Referenced by FlammableBase::UpdateLight().
|
inlineprivate |
Returns the approx. max lifetime.
float
The largest lifetime sum among the emitors References GetParticleEmitorCount(), GetParticleParm(), and m_ParticleEffect.
Referenced by CreateParticleEffect(), and OnCheckAutoDelete().
Get the value of a parameter of an emitor in the particle.
emitter | int The emitor to get the value from |
parameter | int The parameter to get the value from (enum EmitorParam) |
value | float The value |
References GetParticleParm(), and m_ParticleEffect.
Get the value of a parameter of an emitor in the particle.
emitter | int The emitor to get the value from |
parameter | int The parameter to get the value from (enum EmitorParam) |
float
The value References GetParticleParm(), and m_ParticleEffect.
References GetParticleParmOriginal(), and m_ParticleEffect.
Referenced by EffectBoatWaterBase::EnableEmitor(), Update(), and EffectBoatWaterBack::Update().
|
inlineprivate |
Returns the total count of active particles in all emitors.
int
Total count of active particles References m_ParticleEffect, and ParticleGetCount().
Referenced by OnCheckAutoDelete().
|
inlineprivate |
Gets particle id.
int
The last set Particle ID registered in ParticleList References m_ParticleID.
Referenced by EffEngineSmoke::Event_OnFrameUpdate(), EffectParticle::GetCurrentParticleID(), and FlammableBase::UpdateParticle().
|
inlineprivate |
Returns the parent of this Particle if there is one.
Object
The registered parent or null References m_ParentObject.
|
inlineprivate |
Returns if there is any particle active.
bool
Whether there is any particle active References m_ParticleEffect, and ParticleHasActive().
Increments the value of the given parameter relatively from the CURRENT value.
parameter_id | int The parameter to adjust (enum EmitorParam) |
value | float The value to sum |
References GetParticleEmitorCount(), GetParticleParm(), m_ParticleEffect, and SetParticleParm().
Increments the value of the given parameter relatively from the ORIGINAL value.
parameter_id | int The parameter to adjust (enum EmitorParam) |
value | float The value to sum |
References GetParticleEmitorCount(), GetParticleParmOriginal(), m_ParticleEffect, and SetParticleParm().
|
inlineprivate |
Returns whether there is a repeating particle.
bool
whether there is a repeating particle References GetParticleEmitorCount(), GetParticleParm(), and m_ParticleEffect.
Referenced by CreateParticleEffect(), and OnCheckAutoDelete().
|
inlineprivate |
Checks if particle is currently wiggling.
References m_RandomizeOri.
Referenced by ParticleSource::OnParticleStop(), ParticleSource::OnParticleUnParented(), ParticleSource::SetWiggle(), and ParticleSource::StopWiggle().
|
inlineprivate |
Creates ParticleEffect child, called from UpdateState.
References GetMaxLifetime(), GetParticleCount(), IsRepeat(), m_IsRepeat, m_Lifetime, m_MarkedForDeletion, m_ParticleEffect, OnParticleEnd(), OnParticleStop(), and OnToDelete().
Referenced by EOnFrame().
|
inlineprivate |
Called before deletion from OnCheckAutoDelete.
Referenced by OnCheckAutoDelete().
|
inlineprivate |
Purely here so that it can be emptied in ParticleSource.
References SetFlags().
Referenced by Particle().
|
inlinestaticprivate |
Legacy function for backwards compatibility with 1.01 and below.
References particle_id, and PlayOnObject().
Legacy function for backwards compatibility with 1.01 and below.
References particle_id, and PlayInWorld().
|
inlineprivate |
Legacy function for backwards compatibility with 1.01 and below.
particle_id | int Particle ID registered in ParticleList to start playing |
References particle_id, and PlayParticle().
Creates a particle emitter on the given position and activates it.
particle_id | int Particle ID registered in ParticleList |
global_pos | Vector Position where the particel will be created |
Particle
Created particle instance References CreateInWorld(), particle_id, and PlayParticle().
Referenced by EffBulletImpactBase::Event_OnStarted(), and Play().
|
inlinestaticprivate |
Creates a particle emitter, attaches it on the given object and activates it.
particle_id | int Particle ID registered in ParticleList |
parent_obj | Object Instance on which this particle will be attached |
local_pos | vector Attachment position local to the parent (Optional) |
local_ori | vector Orientation local to the parent (Pitch, Yaw, Roll in degrees) (Optional) |
force_world_rotation | bool Forces particle's orientation to rotate relative to the world and not with the object (Optional) |
Particle
Created particle instance References CreateOnObject(), particle_id, and PlayParticle().
Referenced by Play().
|
inlineprivate |
Method to tell the particle to start playing.
particle_id | int Particle ID registered in ParticleList to start playing |
References particle_id, and PlayParticleEx().
Referenced by PMTPlayback::CheckStop(), Play(), PlayInWorld(), and PlayOnObject().
Method to tell the particle to start playing.
particle_id | int Particle ID registered in ParticleList to start playing |
flags | int Flags to pass to the playing (None on this level) |
bool
Whether the particle successfully started References OnParticleStart(), particle_id, SetSource(), and UpdateState().
Referenced by PlayParticle().
|
inlineprivate |
Randomizes a new orientation and applies it.
References AddAsChild(), m_DefaultOri, m_DefaultPos, m_MaxOriInterval, m_ParentObject, m_RandomizeOri, m_WiggleProcessing, Math::RandomFloat(), and RandWiggleVector().
|
inlineprivate |
Helper to get a randomized wiggle float value.
References m_MaxOriWiggle, and Math::RandomFloatInclusive().
Referenced by RandWiggleVector().
|
inlineprivate |
Helper to get a randomized wiggle vector.
References RandWiggleFloat(), and Vector().
Referenced by RandomizeOrientation(), and ParticleSource::RandomizeOrientation().
Scales the given parameter on all emitors relatively to their CURRENT value.
parameter_id | int The parameter to adjust (enum EmitorParam) |
coef | float The multiplier to apply |
References GetParticleEmitorCount(), GetParticleParm(), m_ParticleEffect, and SetParticleParm().
Referenced by Hit_MeatBones::BloodSplatGround(), EffBulletImpactBase::Event_OnStarted(), EffBulletImpactBase::OnEnterAngledCalculations(), EffBulletImpactBase::OnEnterCalculations(), Hit_MeatBones::OnEnterCalculations(), Hit_Wood::OnEnterCalculations(), EffBulletImpactBase::OnExitCalculations(), Hit_MeatBones::OnExitCalculations(), Hit_Wood::OnExitCalculations(), and EffBulletImpactBase::OnRicochetCalculations().
Scales the given parameter on all emitors relatively to their ORIGINAL value.
parameter_id | int The parameter to adjust (enum EmitorParam) |
coef | float The multiplier to apply |
References GetParticleEmitorCount(), GetParticleParmOriginal(), m_ParticleEffect, and SetParticleParm().
Referenced by EffEngineSmoke::Event_OnFrameUpdate(), EffExhaustSmoke::SetParticleStateLight(), EffCoolantSteam::UpdateParticle(), BroomBase::UpdateParticle(), and FlammableBase::UpdateParticle().
Set the value of a parameter of an emitor in the particle.
emitter | int The emitter to apply the new value to, -1 for all emitter |
parameter | int The parameter to apply the new value to (enum EmitorParam) |
value | float The value to apply |
References m_ParticleEffect, and SetParticleParm().
Referenced by ManBase::ContaminatedParticleAdjustment(), CreateParticle(), DestroyParticleEffect(), EffectBoatWaterBase::EnableEmitor(), ParticleNormalSmokeStart(), ParticleSmallSmokeStart(), PlayVFX(), ManBase::SetContaminatedEffectEx(), FlareSimulation::Simulate(), FlareSimulation::TurnOffDistantLight(), Update(), and EffectBoatWaterBack::Update().
Set the value of a parameter of all emitors in the particle.
parameter | int The parameter to apply the new value to (enum EmitorParam) |
value | float The value to apply |
References m_ParticleEffect, and SetParticleParm().
Referenced by BoatScript::ClearWaterEffects(), EntityLightSource::HandleDancingShadows(), Update(), EffectBoatWaterBack::Update(), and EffCoolantSteam::UpdateParticle().
|
inlineprivate |
Sets particle id.
particle_id | int Particle ID registered in ParticleList to start playing |
References m_ParticleID, and particle_id.
Referenced by CreateInWorld(), PlayParticleEx(), and EffectParticle::SetCurrentParticleID().
Makes the particle change direction by random_angle every random_interval seconds.
random_angle | float Will be the range [-random_angle, random_angle[ to wiggle between |
random_interval | float Will be the time range [0, random_interval] to wiggle next time |
References CALL_CATEGORY_GAMEPLAY, m_MaxOriInterval, m_MaxOriWiggle, m_RandomizeOri, Math::RandomFloat(), and StopWiggle().
Referenced by Roadflare::DestroyParticle(), CupidsBoltSimulation::OnFire(), SmokeSimulation::OnFire(), Ammo_40mm_Smoke_ColorBase::OnVariablesSynchronized(), PlayVFX(), and Roadflare::UpdateActiveParticles().
|
inlineprivate |
Legacy function for backwards compatibility with 1.14 and below.
References StopParticle().
Referenced by DestroyParticle(), Roadflare::DestroyParticle(), DynamicArea_Flare::EEDelete(), House::EEDelete(), BuildingSuper::EEDelete(), Misc_TirePile_Burning_DE::EEDelete(), Edible_Base::EEDelete(), Ammo_40mm_Smoke_ColorBase::EEDelete(), ItemBase::EEDelete(), HotSpringTrigger::EEDelete(), VolcanicTrigger::EEDelete(), InventoryItem::KillAllOverheatingParticles(), FlareSimulation::OnActivation(), FireworksLauncherClientEvent::OnExplode(), CupidsBoltSimulation::OnFire(), OnInventoryEnter(), FlammableBase::OnWorkStop(), FryingPan::ParticleCookingStop(), ManBase::SetContaminatedEffectEx(), EffectParticle::Stop(), FlammableBase::StopAllParticles(), InventoryItem::UpdateAllOverheatingParticles(), FlammableBase::UpdateParticle(), Edible_Base::UpdateVaporParticle(), CupidsBoltSimulation::~CupidsBoltSimulation(), DestructionEffectBase::~DestructionEffectBase(), ~EasterEgg(), FlareSimulation::~FlareSimulation(), and SmokeSimulation::~SmokeSimulation().
Method to tell the particle to stop playing.
flags | int Flags to pass to the stopping (None on this level) |
bool
Whether the particle successfully stopped References GetParent(), GetPosition, OnParticleStop(), SetPosition(), and UpdateState().
Referenced by Stop().
|
inlineprivate |
Stops randomized wiggle.
References m_MaxOriInterval, m_MaxOriWiggle, m_RandomizeOri, and Timer::Stop().
Referenced by SetWiggle().
|
inlineprivate |
Creates/Destroys ParticleEffect child according to current state.
References CreateParticleEffect(), DestroyParticleEffect(), m_IsPlaying, and m_ParticleEffect.
Referenced by PlayParticleEx(), and StopParticle().
|
private |
Used for Wiggle API, to restore after unparenting.
Referenced by CreateOnObject(), ParticleSource::OnParticleUnParented(), RandomizeOrientation(), ParticleSource::RandomizeOrientation(), ParticleSource::SetWiggle(), and ParticleSource::StopWiggle().
|
private |
Used for Wiggle API, to restore after unparenting.
Referenced by AddAsChild(), ParticleSource::OnParticleUnParented(), RandomizeOrientation(), ParticleSource::RandomizeOrientation(), ParticleSource::SetWiggle(), and ParticleSource::StopWiggle().
|
private |
Used for Wiggle API, to restore after unparenting.
Referenced by ParticleSource::OnParticleUnParented(), and ParticleSource::SetWiggle().
|
private |
Used for Wiggle API, to restore after unparenting.
Referenced by ParticleSource::OnParticleUnParented(), and ParticleSource::SetWiggle().
|
private |
Used for Wiggle API, to restore after unparenting.
Referenced by AddAsChild(), CreateInWorld(), CreateParticleEffect(), ParticleSource::RandomizeOrientation(), ParticleSource::SetWiggle(), and ParticleSource::StopWiggle().
|
private |
DEPRECATED.
|
private |
Whether this particle repeats.
Referenced by CreateParticleEffect(), DestroyParticleEffect(), and OnCheckAutoDelete().
|
private |
Approx. remaining lifetime of particle.
Referenced by CreateParticleEffect(), EOnFrame(), and OnCheckAutoDelete().
|
private |
Whether this particle is queued for deletion.
Referenced by OnCheckAutoDelete().
|
private |
Used for Wiggle API, Interval for wiggling [0, m_MaxOriInterval[.
Referenced by ParticleSource::OnParticleUnParented(), RandomizeOrientation(), ParticleSource::RandomizeOrientation(), SetWiggle(), ParticleSource::SetWiggle(), and StopWiggle().
|
private |
Used for Wiggle API, Wiggle room [-m_MaxOriWiggle, m_MaxOriWiggle].
Referenced by ParticleSource::OnParticleUnParented(), RandWiggleFloat(), SetWiggle(), ParticleSource::SetWiggle(), and StopWiggle().
|
private |
Parent Object the Particle is child of.
Referenced by AddAsChild(), GetParticleParent(), ParticleSource::OnParticleParented(), ParticleSource::OnParticleUnParented(), and RandomizeOrientation().
|
private |
The child object which contains the actual particle.
Referenced by AddAsChild(), CreateParticleEffect(), DestroyParticleEffect(), GetDirectParticleEffect(), GetMaxLifetime(), GetParameter(), GetParameterEx(), GetParameterOriginal(), GetParticleCount(), HasActiveParticle(), IncrementParticleParam(), IncrementParticleParamFromOriginal(), IsRepeat(), OnCheckAutoDelete(), ParticleSource::ParticleSource(), ScaleParticleParam(), ScaleParticleParamFromOriginal(), SetParameter(), SetParticleParam(), and UpdateState().
|
private |
ID from ParticleList if assigned.
Referenced by CreateParticleEffect(), GetParticleID(), and SetSource().
|
private |
DEPRECATED.
|
private |
Used for Wiggle API, calls the Wiggle functionality.
Referenced by IsWiggling(), ParticleSource::OnParticleStop(), RandomizeOrientation(), ParticleSource::RandomizeOrientation(), SetWiggle(), and StopWiggle().
|
private |
Used for Wiggle API, to signal that wiggle API is currently doing work.
Referenced by ParticleSource::OnParticleUnParented(), RandomizeOrientation(), and ParticleSource::RandomizeOrientation().
|
staticprivate |
DEPRECATED