| CRM64Pro GDK v0.19.0 A free cross-platform game development kit built on top of SDL 3.0

Loading...
Searching...
No Matches
CRM64Pro::ParticleMgr
Graphics modules » Particle Effects

Particle manager class. More...

## Detailed Description

Particle manager class.

Creates, loads, updates, renders and destroys ParticleEmitter objects. Access this manager through Main::particleMgr().

## Public Member Functions
bool | info (Sint32 iMode=0) override
| Request Particle Manager information.
Sint32 | create (const string &sName, Uint32 iVersion=10) override
| Create a new ParticleEmitter.
Sint32 | playOneShot (eParticleEffectPreset ePreset, float fX, float fY)
| Create and play a temporary one-shot preset emitter.
Sint32 | closeOneShots ()
| Close all temporary one-shot emitters.
Sint32 | getPresetCount () const
| Get the number of built-in particle presets.
const ParticlePresetDesc * | getPresetDesc (Sint32 iIndex) const
| Get a built-in particle preset descriptor by index.
const ParticlePresetDesc * | getPresetDesc (eParticleEffectPreset ePreset) const
| Get a built-in particle preset descriptor by preset identifier.
Sint32 | close (Sint32 idParticle) override
| Close and destroy a ParticleEmitter.
Sint32 | getCount () const override
| Get number of loaded ParticleEmitter objects.
Sint32 | setName (Sint32 idParticle, const string &sName) override
| Change the ParticleEmitter name.
ParticleEmitter * | get (Sint32 idParticle)
| Get a ParticleEmitter pointer.
Sint32 | load (const string &sCDCFile, const string &sName)
| Load a ParticleEmitter from a CDC file.
Sint32 | load (Sint32 idCDC, const string &sName)
| Load a ParticleEmitter from an opened CDC archive.
Sint32 | remove (Sint32 idCDC, const string &sName)
| Remove a ParticleEmitter resource from an opened CDC archive.
bool | exists (Sint32 idCDC, const string &sName) const
| Check if a ParticleEmitter resource exists in an opened CDC archive.
bool | exists (const string &sCDCFile, const string &sName) const
| Check if a ParticleEmitter resource exists in a CDC file.
bool | update (float fDeltaTime)
| Advance all loaded ParticleEmitter objects.
Sint32 | render (Sint32 idRes=0)
| Render all loaded ParticleEmitter objects.

## Member Function Documentation

## ◆ info()

bool CRM64Pro::ParticleMgr::info | ( | Sint32 | iMode = 0 | ) |
| override

Request Particle Manager information.

Writes information to the default log.

Parameters

  iMode | Reserved for future use. Pass 0.

Returns
  true on success, or false on failure.

## ◆ create()

Sint32 CRM64Pro::ParticleMgr::create | ( | const string & | sName,
|  | Uint32 | iVersion = 10 )
| override

Create a new ParticleEmitter.

Parameters

  sName | Name of the new emitter. Must be unique.
  iVersion | Particle resource version. Default is 10.

Returns
  New ParticleEmitter id on success, or a negative error code on failure.

## ◆ playOneShot()

Sint32 CRM64Pro::ParticleMgr::playOneShot | ( | eParticleEffectPreset | ePreset,
|  | float | fX,
|  | float | fY )

Create and play a temporary one-shot preset emitter.

Parameters

  ePreset | Built-in preset to apply. The preset must have a finite duration.
  fX | Horizontal emitter position in pixels.
  fY | Vertical emitter position in pixels.

Returns
  Temporary ParticleEmitter id on success, or a negative error code on failure.

Note
  The emitter is automatically closed by ParticleMgr::update() after it reaches ::GS_END.

## ◆ closeOneShots()

Sint32 CRM64Pro::ParticleMgr::closeOneShots | ( |  | ) |

Close all temporary one-shot emitters.

Returns
  0 on success, or a negative error code on failure.

Note
  Regular loaded emitters are not affected.

## ◆ getPresetCount()

Sint32 CRM64Pro::ParticleMgr::getPresetCount | ( |  | ) | const

Get the number of built-in particle presets.

Returns
  Number of preset descriptors available through getPresetDesc().

## ◆ getPresetDesc() [1/2]

const ParticlePresetDesc * CRM64Pro::ParticleMgr::getPresetDesc | ( | Sint32 | iIndex | ) | const

Get a built-in particle preset descriptor by index.

Parameters

  iIndex | Preset descriptor index in the range [0, getPresetCount()).

Returns
  Borrowed pointer to a static preset descriptor, or nullptr when iIndex is invalid.

Note
  The returned pointer must not be deleted or stored long-term. It remains valid until the application terminates.

## ◆ getPresetDesc() [2/2]

const ParticlePresetDesc * CRM64Pro::ParticleMgr::getPresetDesc | ( | eParticleEffectPreset | ePreset | ) | const

Get a built-in particle preset descriptor by preset identifier.

Parameters

  ePreset | Preset identifier.

Returns
  Borrowed pointer to a static preset descriptor, or nullptr when ePreset is invalid.

Note
  The returned pointer must not be deleted or stored long-term. It remains valid until the application terminates.

## ◆ close()

Sint32 CRM64Pro::ParticleMgr::close | ( | Sint32 | idParticle | ) |
| override

Close and destroy a ParticleEmitter.

Parameters

  idParticle | ParticleEmitter id.

Returns
  0 on success, or a negative error code on failure.

## ◆ getCount()

Sint32 CRM64Pro::ParticleMgr::getCount | ( |  | ) | const
| override

Get number of loaded ParticleEmitter objects.

Returns
  Number of emitters currently managed by ParticleMgr.

## ◆ setName()

Sint32 CRM64Pro::ParticleMgr::setName | ( | Sint32 | idParticle,
|  | const string & | sName )
| override

Change the ParticleEmitter name.

Parameters

  idParticle | ParticleEmitter id.
  sName | New emitter name. Must be unique.

Returns
  0 on success, or a negative error code on failure.

## ◆ get()

ParticleEmitter * CRM64Pro::ParticleMgr::get | ( | Sint32 | idParticle | ) |

Get a ParticleEmitter pointer.

Parameters

  idParticle | ParticleEmitter id.

Returns
  Pointer to the ParticleEmitter on success, or nullptr on failure.

Note
  The returned pointer is owned by ParticleMgr and must not be deleted by the caller.

## ◆ load() [1/2]

Sint32 CRM64Pro::ParticleMgr::load | ( | const string & | sCDCFile,
|  | const string & | sName )

Load a ParticleEmitter from a CDC file.

Parameters

  sCDCFile | string containing the [directory]+filename.
  sName | Resource name inside the CDC archive.

Returns
  ParticleEmitter id on success, or a negative error code on failure.

## ◆ load() [2/2]

Sint32 CRM64Pro::ParticleMgr::load | ( | Sint32 | idCDC,
|  | const string & | sName )

Load a ParticleEmitter from an opened CDC archive.

Parameters

  idCDC | CDC id.
  sName | Resource name inside the CDC archive.

Returns
  ParticleEmitter id on success, or a negative error code on failure.

## ◆ remove()

Sint32 CRM64Pro::ParticleMgr::remove | ( | Sint32 | idCDC,
|  | const string & | sName )

Remove a ParticleEmitter resource from an opened CDC archive.

Parameters

  idCDC | CDC id.
  sName | Resource name inside the CDC archive.

Returns
  0 on success, or a negative error code on failure.

## ◆ exists() [1/2]

bool CRM64Pro::ParticleMgr::exists | ( | Sint32 | idCDC,
|  | const string & | sName ) const

Check if a ParticleEmitter resource exists in an opened CDC archive.

Parameters

  idCDC | CDC id.
  sName | Resource name inside the CDC archive.

Returns
  true if the resource exists, or false otherwise.

## ◆ exists() [2/2]

bool CRM64Pro::ParticleMgr::exists | ( | const string & | sCDCFile,
|  | const string & | sName ) const

Check if a ParticleEmitter resource exists in a CDC file.

Parameters

  sCDCFile | string containing the [directory]+filename.
  sName | Resource name inside the CDC archive.

Returns
  true if the resource exists, or false otherwise.

## ◆ update()

bool CRM64Pro::ParticleMgr::update | ( | float | fDeltaTime | ) |

Advance all loaded ParticleEmitter objects.

Parameters

  fDeltaTime | Elapsed time in seconds in the range [0, 1]. Each emitter's scaled delta must also be no greater than 1.

Returns
  true on success, or false on failure.

Note
  Use Main::getLogicDeltaTime() for fixed-step simulation. Temporary emitters created by ParticleMgr::playOneShot() are closed here after they reach ::GS_END.
  Returns false when any emitter exceeds 8192 emission timestamps in one update.

## ◆ render()

Sint32 CRM64Pro::ParticleMgr::render | ( | Sint32 | idRes = 0 | ) |

Render all loaded ParticleEmitter objects.

Parameters

  idRes | Render target id. Use 0 for the default screen target.

Returns
  0 on success, or a negative error code on failure.