EffectManager

Allows interesting visual effects to be created and attached to entities.

About

This is a global object that can always be accessed.

When it’s time to put some fire in your brazier, or smoke in your chimney, it’s time for particle systems.

The EffectManager is based around Wong Chin Foo’s LinearParticle system.  Although the interface has been somewhat streamlined to match the rest of Novashell, you might want to check out his webpage at (http://galaxist.net/file/linear_p/latest_doc) to glean some info on its inner-workings.

How it works

The effect system is modular to allow more flexibility.  You plug and play different pieces together to get the effect you want.

ParticleA global template Particle that is shared between effects.
MotionControllerEvery Particle has a MotionController that can be accessed to setup special movement.
EffectBaseAll effect emitters are derived from EffectBase and contain its functions too.
EffectExplosionA type of particle emitter good for explosions.  Create an EffectExplosion, attach one or more particles, then assign it to an entity with <Entity:AddEffect>.
Summary
EffectManagerAllows interesting visual effects to be created and attached to entities.
Member Functions
CreateParticle
GetParticleByName
CreateEffectExplosion

Member Functions

CreateParticle

Particle CreateParticle(string name, string imageFileName, number lifeMS)

Allows you to create a particle template that can be referenced by name.  If you change any parameters later on this particle, all particle systems using it will be modified.

Usage

local particle = GetEffectManager:GetParticleByName("smoke_brazier");

if (not particle) then
//doesn't exist? We'll need to create it then.
particle = GetEffectManager:CreateParticle("smoke_brazier", "effects/media/explosion.png", 500);
end

//now we can use "particle" anywhere needed.

end

Parameters

nameA name that can be used to access this particle in the future.  It will give an error if the name already exists.
imageFileNameAn image to use for the particles visual.  Generally a 32 bit .png is used.
lifeMSHow long this type of particle ‘lives’ before disappearing.

Returns

A handle to a global Particle object created that can be used to make additional changes.

GetParticleByName

Particle GetParticleByName(string name)

Returns

The shared Particle previously created with the same name, or nil if it doesn’t exist yet.

CreateEffectExplosion

EffectExplosion CreateEffectExplosion(number periodMS, number minParticles, number maxParticles, number initialSpeed)

Creates a new EffectExplosion object.  You must use <Entity::AddEffect> to add it to an entity.  When its containing entity is destroyed it is destroyed also.  Trying to attach the same explosion to two or more entities will explode your computer, don’t do it.

Parameters

periodMSinterval between two emissions in milliseconds
minParticlesThe minimum number of particles to be emitted during a period
maxParticlesThe maximum number of particles to be emitted during a period
intialSpeedThe initial velocity that particles have when created

Returns

The new EffectExplosion object, ready to be attached to an entity with <Entity::AddEffect>.

Information about a certain particle type that is shared between effects.
All Particles have a motion controller that can be accessed for extra effects.
All effect emitters are based on this type and can use its functions.
Particle emitter based on EffectBase that is good for explosions.