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);
674 for (
int i = 0; i < emitors; ++i)
693 for (
int i = 0; i < emitors; ++i)
713 for (
int i = 0; i < emitors; ++i)
733 for (
int i = 0; i < emitors; ++i)
765 void SetWiggle(
float random_angle,
float random_interval)
767 if ( random_angle != 0 || random_interval != 0 )
protected bool m_IsPlaying
Whether the Effect is currently playing.
protected void OnParticleEnd()
Event when the particle ends.
protected void OnParticleStop()
Event when the particle stops.
protected void OnParticleStart()
Event when the particle starts.
class JsonUndergroundAreaTriggerData GetPosition
proto native Object CreateObjectEx(string type, vector pos, int iFlags, int iRotation=RF_DEFAULT)
Creates object of certain type.
Legacy way of using particles in the game.
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.
private void DestroyParticleEffect()
Destroys ParticleEffect child, called from UpdateState.
protected int m_ParticleID
ID from ParticleList if assigned.
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.
protected float m_Lifetime
Approx. remaining lifetime of particle.
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.
protected bool m_IsRepeat
Whether this particle repeats.
private bool m_MarkedForDeletion
Whether this particle is queued for deletion.
vector m_DefaultOri
Used for Wiggle API, to restore after unparenting.
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.
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.
static private const int MAX_EMITORS
DEPRECATED
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.
protected float RandWiggleFloat()
Helper to get a randomized wiggle float value.
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.
bool m_WiggleProcessing
Used for Wiggle API, to signal that wiggle API is currently doing work.
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...
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[.
protected Object m_ParticleEffect
The child object which contains the actual particle.
protected vector RandWiggleVector()
Helper to get a randomized wiggle vector.
bool HasActiveParticle()
Returns if there is any particle active.
protected void UpdateState()
Creates/Destroys ParticleEffect child according to current state.
protected Object m_ParentObject
Parent Object the Particle is child of.
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.
protected void ParticleInit()
Purely here so that it can be emptied in ParticleSource.
private vector m_GlobalPosPreviousFrame
DEPRECATED.
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.
private void OnToDelete()
Called before deletion from OnCheckAutoDelete.
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.
protected int m_PreviousFrame
DEPRECATED.
float GetMaxLifetime()
Returns the approx. max lifetime.
private void CreateParticleEffect()
Creates ParticleEffect child, called from UpdateState.
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.
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. lifetime and checking for deletion.
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.
static string GetParticleFullPath(int particle_id)
Returns particle's full path (with .ptc suffix) based on its ID.
proto native CGame GetGame()
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)
proto void GetParticleParmOriginal(notnull IEntity ent, int emitor, EmitorParam parameter, out void value)
proto int GetParticleEmitorCount(notnull IEntity ent)
proto void GetParticleParm(notnull IEntity ent, int emitor, EmitorParam parameter, out void value)
proto native void ReleaseObject(vobject object, int flag=0)