Enfusion Script API
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Particles Interface Reference

Script API to Particle Effect Component. More...

Inheritance diagram for Particles:
[legend]

Public Member Functions

proto external void Restart (bool invalidatePrevPos=false)
 Restarts the whole effect.
 
proto external void InvalidatePrevPos (vector parentVelocity=vector.Zero)
 Invalidates stored position of the owner (parent) entity from previous frame.
 
proto external void OverridePrevPos (vector pos)
 Manually sets a new value for the previous position of the owner (parent) entity.
 
proto external bool Simulate (float deltaTime)
 Schedules a simulation step (update) of the particle effect.
 
proto external bool SimulateMultiStep (float duration, float minFPS)
 Schedules simulation of the particle effect over given amount of time in multiple steps.
 
proto external int GetNumEmitters ()
 Gets the count of all emitters in the effect.
 
proto external int GetNumParticles ()
 Gets total active particle count (from all effect's emitters).
 
proto external void SetParam (int emitterIdx, EmitterParam param, void value)
 Sets a particle emitter parameter value.
 
proto external void GetParam (int emitterIdx, EmitterParam param, out void value)
 Gets the current value of a particle emitter parameter.
 
proto external void GetParamOrig (int emitterIdx, EmitterParam param, out void value)
 Gets a value of a particle emitter parameter from the effect definition (the default).
 
proto external void MultParam (int emitterIdx, EmitterParam param, float mul)
 Sets a given parameter of a given emitter to the multiple of its ORIGINAL value from the effect's definition.
 
proto external int GetEmitterNames (out array< string > names)
 Gets an array with the names of all emitters of the effect.
 
- Public Member Functions inherited from pointer
proto string ToString ()
 

Static Public Member Functions

static proto void SetVelocitySource (IEntity ent)
 Sets a physical velocity source (entity with a PhysicsComponent) for the particle effect.
 

Detailed Description

Script API to Particle Effect Component.

Please note that some emitters may not be present under some environments. E.g. the dedicated server will skip loading of most emitters as they are purely visual (on the other hand, L3 emitters with non-zero occlusion cannot be skipped as they can be used by AI). This also means some methods can take different arguments or give different results under different environments, e.g. GetNumEmitters, GetEmitterNames, GetNumParticles or anything working with an emitter index.

Member Function Documentation

◆ GetEmitterNames()

proto external int Particles.GetEmitterNames ( out array< string names)

Gets an array with the names of all emitters of the effect.

Parameters
namesInitialized array to which the names will be added. If the array is empty, the name of emitter with index = 0 will be at names[0], etc.
Returns
Number of emitters in the effect (how many items were added to the array).

◆ GetNumEmitters()

proto external int Particles.GetNumEmitters ( )

Gets the count of all emitters in the effect.

◆ GetNumParticles()

proto external int Particles.GetNumParticles ( )

Gets total active particle count (from all effect's emitters).

◆ GetParam()

proto external void Particles.GetParam ( int  emitterIdx,
EmitterParam  param,
out void  value 
)

Gets the current value of a particle emitter parameter.

Parameters
emitterIdxIndex of the emitter to get the value from
paramThe parameter to get the value of
valueOutput of the method - the value

◆ GetParamOrig()

proto external void Particles.GetParamOrig ( int  emitterIdx,
EmitterParam  param,
out void  value 
)

Gets a value of a particle emitter parameter from the effect definition (the default).

Parameters
emitterIdxIndex of the emitter to get the value from
paramThe parameter to get the default value of
valueOutput of the method - the value

◆ InvalidatePrevPos()

proto external void Particles.InvalidatePrevPos ( vector  parentVelocity = vector.Zero)

Invalidates stored position of the owner (parent) entity from previous frame.

The previous position is used for parent velocity computation (if there's no physical velocity source set), distributing newly emitted particles etc.

Should be used e.g. when owner entity is teleported or its transform is corrected by the networking code.

Parameters
parentVelocityOptional parent velocity vector to be used if there's no physical velocity source until the previous position is available again

◆ MultParam()

proto external void Particles.MultParam ( int  emitterIdx,
EmitterParam  param,
float  mul 
)

Sets a given parameter of a given emitter to the multiple of its ORIGINAL value from the effect's definition.

E.g. if the emitter #2 has birthrate = 100 in its definition then MultParam(2, EmitterParam.BIRTH_RATE, 0.50) will set it to 50 and a successive call of MultParam(2, EmitterParam.BIRTH_RATE, 0.75) will set it to 75.

Parameters
emitterIdxIndex of the emitter to set, -1 = "all emitters"
paramWhich parameter to set
mulThe multiplier of the original value

◆ OverridePrevPos()

proto external void Particles.OverridePrevPos ( vector  pos)

Manually sets a new value for the previous position of the owner (parent) entity.

The previous position is used for parent velocity computation (if there's no physical velocity source set), distributing newly emitted particles etc.

Normally, the position is set automatically by the particle system at the end of each frame. This allows to override the automatically stored position or it may be used after the position has been invalidated.

◆ Restart()

proto external void Particles.Restart ( bool  invalidatePrevPos = false)

Restarts the whole effect.

I.e. destroys all particles and resets emitting time to zero, etc.

Parameters
invalidatePrevPosIf true, the effect's previous position is invalidated and parent velocity set to zero. Useful e.g. for particle effect pooling where the effect is "teleported" and restarted. If false (the default), the previous position is kept so it is available right in the next frame. Useful when the parent entity's position is being continuously updated every frame even when the effect is not playing at the moment.

◆ SetParam()

proto external void Particles.SetParam ( int  emitterIdx,
EmitterParam  param,
void  value 
)

Sets a particle emitter parameter value.

Parameters
emitterIdxIndex of the emitter to set. -1 to set it for all emitters of the effect.
paramThe parameter to set
valueThe value to set the parameter to

◆ SetVelocitySource()

static proto void Particles.SetVelocitySource ( IEntity  ent)
static

Sets a physical velocity source (entity with a PhysicsComponent) for the particle effect.

If the physical velocity source is available, the effect will get parent velocity from that (which is preferred). Otherwise the effect calculates the velocity from current position, previous position and delta time.

Parameters
entEntity with a PhysicsComponent to use as a velocity source or null

◆ Simulate()

proto external bool Particles.Simulate ( float  deltaTime)

Schedules a simulation step (update) of the particle effect.

Expected to be called once per frame. The actual simulation will happen later in the same frame.

Parameters
deltaTimeduration since the last call
Returns
True iff the particle effect has finished (so it doesn't and won't have any more particles). Delayed by one frame due to the async nature of the operation.

◆ SimulateMultiStep()

proto external bool Particles.SimulateMultiStep ( float  duration,
float  minFPS 
)

Schedules simulation of the particle effect over given amount of time in multiple steps.

The actual simulation will happen later in this frame.

Approximates simulation result after multiple frames (i.e. after several calls to Simulate or Animate). Intended for "pre-warming" of the effect.

Parameters
durationTotal time in seconds to simulate
minFPSMinimum number of simulation steps per a second of the duration. Actual number of steps may be higher (e.g. due to minimum FPS specified in the effect) but it will never be lower.
Returns
True iff the particle effect has finished (so it doesn't and won't have any more particles). Delayed by one frame due to the async nature of the operation.

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