91 Error(
"ERROR when creating a particle! Parameter parent_obj is NULL!");
93 vector global_pos = parent_obj.GetPosition();
95 p.
AddAsChild(parent_obj, local_pos, local_ori, force_world_rotation);
121 p.SetOrientation(global_ori);
251 if ( parent && !ToDelete())
254 parent.RemoveChild(
this);
362 for (
int i = 0; i < emitors; ++i)
382 float lifetime_return = 0;
386 float lifetime_min = 0;
387 float lifetime_random = 0;
388 float effect_time = 0;
390 float lifetime_sum = 0;
394 for (
int i = 0; i < emitors; ++i)
400 lifetime_sum = lifetime_min + lifetime_random + effect_time;
402 if ( lifetime_sum > lifetime_return )
404 lifetime_return = lifetime_sum;
409 return lifetime_return;
447 ErrorEx(
"Could not play Particle as there is no valid particle id assigned.");
573 if (!parent.ToDelete())
576 SetOrientation(local_ori);
584 parent.AddChild(
this, -1,
false);
684 for (
int i = 0; i < emitors; ++i)
703 for (
int i = 0; i < emitors; ++i)
723 for (
int i = 0; i < emitors; ++i)
743 for (
int i = 0; i < emitors; ++i)
775 void SetWiggle(
float random_angle,
float random_interval)
777 if ( random_angle != 0 || random_interval != 0 )
Internal ancestor of all Entity implementations.
Object GetDirectParticleEffect()
Returns direct particle effect entity which is usually handled by this class 'Particle' if there is o...
void SetParameter(int emitter, int parameter, float value)
Set the value of a parameter of an emitor in the particle.
void DestroyParticleEffect()
Destroys ParticleEffect child, called from UpdateState.
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
void Play(int particle_id=-1)
Legacy function for backwards compatibility with 1.01 and below.
Object m_ParentObject
Parent Object the Particle is child of.
void ScaleParticleParam(int parameter_id, float coef)
Scales the given parameter on all emitors relatively to their CURRENT value.
float m_MaxOriWiggle
Used for Wiggle API, Wiggle room [-m_MaxOriWiggle, m_MaxOriWiggle].
bool IsWiggling()
Checks if particle is currently wiggling.
void GetParameter(int emitter, int parameter, out float value)
Get the value of a parameter of an emitor in the particle.
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.
bool m_MarkedForDeletion
Whether this particle is queued for deletion.
vector m_GlobalPosPreviousFrame
DEPRECATED.
vector m_DefaultOri
Used for Wiggle API, to restore after unparenting.
int m_ParticleID
ID from ParticleList if assigned.
override bool PlayParticleEx(int particle_id=-1, int flags=0)
Method to tell the particle to start playing.
bool IsRepeat()
Returns whether there is a repeating particle.
const int MAX_EMITORS
DEPRECATED.
static Particle Play(int particle_id, vector global_pos)
Legacy function for backwards compatibility with 1.01 and below.
vector m_DefaultPos
Used for Wiggle API, to restore after unparenting.
float RandWiggleFloat()
Helper to get a randomized wiggle float value.
Object GetParticleParent()
Returns the parent of this Particle if there is one.
override void PlayParticle(int particle_id=-1)
Method to tell the particle to start playing.
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.
void UpdateState()
Creates/Destroys ParticleEffect child according to current state.
bool m_WiggleProcessing
Used for Wiggle API, to signal that wiggle API is currently doing work.
void CreateParticleEffect()
Creates ParticleEffect child, called from UpdateState.
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.
void SetWiggle(float random_angle, float random_interval)
Makes the particle change direction by random_angle every random_interval seconds.
vector m_DefaultWorldPos
Used for Wiggle API, to restore after unparenting.
float m_MaxOriInterval
Used for Wiggle API, Interval for wiggling [0, m_MaxOriInterval[.
bool m_IsRepeat
Whether this particle repeats.
bool HasActiveParticle()
Returns if there is any particle active.
int m_PreviousFrame
DEPRECATED.
float GetParameterEx(int emitter, int parameter)
Get the value of a parameter of an emitor in the particle.
bool m_ForceOrientationRelativeToWorld
Used for Wiggle API, to restore after unparenting.
void ParticleInit()
Purely here so that it can be emptied in ParticleSource.
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.
void IncrementParticleParam(int parameter_id, float value)
Increments the value of the given parameter relatively from the CURRENT value.
void RandomizeOrientation()
Randomizes a new orientation and applies it.
float GetParameterOriginal(int emitter, int parameter)
static Particle PlayInWorld(int particle_id, vector global_pos)
Creates a particle emitter on the given position and activates it.
void SetParticleParam(int parameter_id, float value)
Set the value of a parameter of all emitors in the particle.
void SetSource(int particle_id)
Sets 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.
int GetParticleID()
Gets particle id.
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.
void StopWiggle()
Stops randomized wiggle.
void OnCheckAutoDelete()
Creates ParticleEffect child, called from UpdateState.
float GetMaxLifetime()
Returns the approx.
Object m_ParticleEffect
The child object which contains the actual particle.
void OnToDelete()
Called before deletion from OnCheckAutoDelete.
void IncrementParticleParamFromOriginal(int parameter_id, float value)
Increments the value of the given parameter relatively from the ORIGINAL value.
int GetParticleCount()
Returns the total count of active particles in all emitors.
vector RandWiggleVector()
Helper to get a randomized wiggle vector.
override bool StopParticle(int flags=0)
Method to tell the particle to stop playing.
vector m_DefaultWorldOri
Used for Wiggle API, to restore after unparenting.
override void EOnFrame(IEntity other, float timeSlice)
OnFrame update event decrementing the stored approx.
void ScaleParticleParamFromOriginal(int parameter_id, float coef)
Scales the given parameter on all emitors relatively to their ORIGINAL value.
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.
ref Timer m_RandomizeOri
Used for Wiggle API, calls the Wiggle functionality.
float m_Lifetime
Approx. remaining lifetime of particle.
static string GetParticleFullPath(int particle_id)
Returns particle's full path (with .ptc suffix) based on its ID.
bool m_IsPlaying
Whether the Effect is currently playing.
void Error(string err)
Messagebox with error message.
proto native void SetPosition(vector position)
Set the world position of the Effect.
proto native void SetFlags(ShapeFlags flags)
EntityEvent
Entity events for event-mask, or throwing event from code.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
proto void SetParticleParm(notnull IEntity ent, int emitor, EmitorParam parameter, void value)
bool ParticleHasActive(IEntity ent)
proto void GetParticleParmOriginal(notnull IEntity ent, int emitor, EmitorParam parameter, out void value)
int ParticleGetCount(IEntity ent)
proto int GetParticleEmitorCount(notnull IEntity ent)
proto void GetParticleParm(notnull IEntity ent, int emitor, EmitorParam parameter, out void value)
vector GetPosition()
Get the world position of the Effect.
proto native void ReleaseObject(vobject object, int flag=0)
Release object.
void OnParticleStart()
Event when the particle starts.
void OnParticleEnd()
Event when the particle ends.
void OnParticleStop()
Event when the particle stops.