VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Classes | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
EmitterLogic Class Reference

Abstract base class to spawn generic entities into the Game based on configurable parameters. More...

Inheritance diagram for EmitterLogic:
Logic QObject ActorEmitterLogic ParticleEmitterLogic WaterBodyLogic

Classes

struct  SpawnParameters
 Parameters to use for creating and initializing spawned entities. More...
 

Signals

void requestedMaxEntityCountChanged ()
 Emitted when requestedMaxEntityCount changes. More...
 
void spawnRateChanged ()
 Emitted when spawnRate changes. More...
 
void spawnVelocityChanged ()
 Emitted when spawnVelocity changes. More...
 
void spawnSpreadChanged ()
 Emitted when spawnSpread changes. More...
 
void spawnSprayChanged ()
 Emitted when spawnSpray changes. More...
 
void spawnRandomChanged ()
 Emitted when spawnRandom changes. More...
 
void timeOffChanged ()
 Emitted when timeOff changes. More...
 
void timeOnChanged ()
 Emitted when timeOn changes. More...
 
void transitionOnTimeChanged ()
 Emitted when transitionOnTime changes. More...
 
void transitionOffTimeChanged ()
 Emitted when transitionOffTime changes. More...
 
void decayTimeChanged ()
 Emitted when decayTime changes. More...
 
void decayTimeRandomLengthChanged ()
 Emitted when decayTimeRandomLength changes. More...
 
void pausedChanged ()
 Emitted when paused changes. More...
 
- Signals inherited from Logic
void activeChanged ()
 Emitted when active changes. More...
 

Public Member Functions

int getRequestedMaxEntityCount () const
 Returns requestedMaxEntityCount. More...
 
void setRequestedMaxEntityCount (int value)
 Sets requestedMaxEntityCount. More...
 
virtual int getSupportedMaxEntityCount () const
 Returns supportedMaxEntityCount. More...
 
int getMaxEntityCount () const
 Returns maxEntityCount. More...
 
virtual int getEntityCount () const
 Returns entityCount. More...
 
float getSpawnRate () const
 Returns spawnRate. More...
 
void setSpawnRate (float value)
 Sets spawnRate. More...
 
float getSpawnVelocity () const
 Returns spawnVelocity. More...
 
void setSpawnVelocity (float value)
 Sets spawnVelocity. More...
 
float getSpawnSpread () const
 Returns spawnSpread. More...
 
void setSpawnSpread (float value)
 Sets spawnSpread. More...
 
float getSpawnSpray () const
 Returns spawnSpray. More...
 
void setSpawnSpray (float value)
 Sets spawnSpray. More...
 
bool isSpawnRandom () const
 Returns spawnRandom. More...
 
void setSpawnRandom (bool value)
 Sets spawnRandom. More...
 
float getTimeOn () const
 Returns timeOn. More...
 
void setTimeOn (float value)
 Sets timeOn. More...
 
float getTimeOff () const
 Returns timeOff. More...
 
void setTimeOff (float value)
 Sets timeOff. More...
 
float getTransitionOnTime () const
 Returns transitionOnTime. More...
 
void setTransitionOnTime (float value)
 Sets transitionOnTime. More...
 
float getTransitionOffTime () const
 Returns transitionOffTime. More...
 
void setTransitionOffTime (float value)
 Sets transitionOffTime. More...
 
float getDecayTime () const
 Returns decayTime. More...
 
void setDecayTime (float value)
 Sets decayTime. More...
 
float getDecayTimeRandomLength () const
 Returns decayTimeRandomLength. More...
 
void setDecayTimeRandomLength (float value)
 Sets decayTimeRandomLength. More...
 
bool isPaused () const
 Returns paused. More...
 
void setPaused (bool value)
 Sets paused. More...
 
virtual void init () override
 Checks that the EmitterLogic has an actor. More...
 
virtual void update () override
 Updates the EmitterLogic cycle, calling emitEntity() for any entities that need to be spawned. More...
 
- Public Member Functions inherited from Logic
 Logic (QObject *parent=nullptr)
 Constructs a Logic. More...
 
ActorgetActor () const
 Returns actor. More...
 
bool isActive () const
 Returns active. More...
 
void setActive (bool value)
 Sets active. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegExp &regExp, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegularExpression &re, QFlags< Qt::FindChildOption > options) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 

Protected Member Functions

virtual void onPausedChanged ()
 Called when the emitter is moving to or from a paused state. More...
 
SpawnParameters getNextRandomSpawnParameters () const
 Returns a randomized set of SpawnParameters according to EmitterLogic's parameters. More...
 
virtual void emitEntity (const SpawnParameters &parameters)
 Performs the creation and initialization of a spawned entity with parameters. More...
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Properties

int requestedMaxEntityCount
 User-defined maximum number of entities to spawn. More...
 
int supportedMaxEntityCount
 Class-defined maximum number of entities to spawn. More...
 
int maxEntityCount
 Actual maximum number of entities to spawn, bounded by both requestedMaxEntityCount and supportedMaxEntityCount. More...
 
int entityCount
 Number of spawned entities still in existence. More...
 
float spawnRate
 Number of entities spawned per frame (i.e. each non-paused call to update()). More...
 
float spawnVelocity
 Forward velocity for spawned entities. More...
 
float spawnSpread
 Horizontal axis spread to apply to spawned entities. More...
 
float spawnSpray
 Divergence factor affecting the amount entities will stray from the direction of the emitter. More...
 
bool spawnRandom
 true if SpawnParameters are pseudo randomized, or patterned if false. More...
 
float timeOn
 Number of seconds, in game time, the emitter will stay on in one cycle. More...
 
float timeOff
 Number of seconds, in game time, the emitter will stay off in one cycle. More...
 
float transitionOnTime
 Number of seconds, in game time, the emitter takes to turn on. More...
 
float transitionOffTime
 Number of seconds, in game time, the emitter takes to turn off. More...
 
float decayTime
 Number of seconds, in game time, before the entity is destroyed. More...
 
float decayTimeRandomLength
 Maximum time delta an entity can randomly stay alive if spawnRandom is true. More...
 
bool paused
 Whether or not this emitter should spawn entities. More...
 
- Properties inherited from Logic
Actor actor
 Parent actor that is affected by this Logic's behavior. More...
 
bool active
 Whether or not Engine calls update() on this Logic during the Engine::LOGICS_PHASE. More...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Detailed Description

Abstract base class to spawn generic entities into the Game based on configurable parameters.

EmitterLogic handles the logic for determining if and how an entity needs to be spawned in update(). Subclasses define the actual entity emitted by implementing emitEntity(). The spawned entity's SpawnParameters::position and SpawnParameter::velocity are functions of the emitter location and direction (i.e. the actor's position and rotation in world space) and the EmitterLogic parameters.

Note
It is up to subclasses to correctly override update() to decay entities appropriately according to SpawnParameters::decayTime and to accurately track entity count by implementing getEntityCount().

Member Function Documentation

void EmitterLogic::decayTimeChanged ( )
signal

Emitted when decayTime changes.

void EmitterLogic::decayTimeRandomLengthChanged ( )
signal

Emitted when decayTimeRandomLength changes.

virtual void EmitterLogic::emitEntity ( const SpawnParameters parameters)
protectedvirtual

Performs the creation and initialization of a spawned entity with parameters.

Parameters
parametersParameters to configure the spawned entity with

Reimplemented in ParticleEmitterLogic, and ActorEmitterLogic.

float EmitterLogic::getDecayTime ( ) const
inline

Returns decayTime.

float EmitterLogic::getDecayTimeRandomLength ( ) const
inline
virtual int EmitterLogic::getEntityCount ( ) const
inlinevirtual

Returns entityCount.

Reimplemented in ParticleEmitterLogic, and ActorEmitterLogic.

int EmitterLogic::getMaxEntityCount ( ) const

Returns maxEntityCount.

SpawnParameters EmitterLogic::getNextRandomSpawnParameters ( ) const
protected

Returns a randomized set of SpawnParameters according to EmitterLogic's parameters.

int EmitterLogic::getRequestedMaxEntityCount ( ) const
inline
float EmitterLogic::getSpawnRate ( ) const
inline

Returns spawnRate.

float EmitterLogic::getSpawnSpray ( ) const
inline

Returns spawnSpray.

float EmitterLogic::getSpawnSpread ( ) const
inline

Returns spawnSpread.

float EmitterLogic::getSpawnVelocity ( ) const
inline

Returns spawnVelocity.

virtual int EmitterLogic::getSupportedMaxEntityCount ( ) const
inlinevirtual

Returns supportedMaxEntityCount.

Reimplemented in WaterBodyLogic.

float EmitterLogic::getTimeOff ( ) const
inline

Returns timeOff.

float EmitterLogic::getTimeOn ( ) const
inline

Returns timeOn.

float EmitterLogic::getTransitionOffTime ( ) const
inline
float EmitterLogic::getTransitionOnTime ( ) const
inline

Returns transitionOnTime.

virtual void EmitterLogic::init ( )
overridevirtual

Checks that the EmitterLogic has an actor.

Reimplemented from Logic.

Reimplemented in WaterBodyLogic.

bool EmitterLogic::isPaused ( ) const
inline

Returns paused.

bool EmitterLogic::isSpawnRandom ( ) const
inline

Returns spawnRandom.

virtual void EmitterLogic::onPausedChanged ( )
inlineprotectedvirtual

Called when the emitter is moving to or from a paused state.

Reimplemented in ParticleEmitterLogic, and WaterBodyLogic.

void EmitterLogic::pausedChanged ( )
signal

Emitted when paused changes.

void EmitterLogic::requestedMaxEntityCountChanged ( )
signal

Emitted when requestedMaxEntityCount changes.

void EmitterLogic::setDecayTime ( float  value)

Sets decayTime.

Parameters
valueFloat to set decayTime to
void EmitterLogic::setDecayTimeRandomLength ( float  value)

Sets decayTimeRandomLength.

Parameters
valueFloat to set decayTimeRandomLength to
void EmitterLogic::setPaused ( bool  value)

Sets paused.

Parameters
valueBoolean to set paused to
void EmitterLogic::setRequestedMaxEntityCount ( int  value)

Sets requestedMaxEntityCount.

Parameters
valueInteger to set requestedMaxEntityCount to
void EmitterLogic::setSpawnRandom ( bool  value)

Sets spawnRandom.

Parameters
valueBoolean to set spawnRandom to
void EmitterLogic::setSpawnRate ( float  value)

Sets spawnRate.

Parameters
valueFloat to set spawnRate to
void EmitterLogic::setSpawnSpray ( float  value)

Sets spawnSpray.

Parameters
valueFloat to set spawnSpray to
void EmitterLogic::setSpawnSpread ( float  value)

Sets spawnSpread.

Parameters
valueFloat to set spawnSpread to
void EmitterLogic::setSpawnVelocity ( float  value)

Sets spawnVelocity.

Parameters
valueFloat to set spawnVelocity to
void EmitterLogic::setTimeOff ( float  value)

Sets timeOff.

Parameters
valueFloat to set timeOff to
void EmitterLogic::setTimeOn ( float  value)

Sets timeOn.

Parameters
valueFloat to set timeOn to
void EmitterLogic::setTransitionOffTime ( float  value)

Sets transitionOffTime.

Parameters
valueFloat to set transitionOffTime to
void EmitterLogic::setTransitionOnTime ( float  value)

Sets transitionOnTime.

Parameters
valueFloat to set transitionOnTime to
void EmitterLogic::spawnRandomChanged ( )
signal

Emitted when spawnRandom changes.

void EmitterLogic::spawnRateChanged ( )
signal

Emitted when spawnRate changes.

void EmitterLogic::spawnSprayChanged ( )
signal

Emitted when spawnSpray changes.

void EmitterLogic::spawnSpreadChanged ( )
signal

Emitted when spawnSpread changes.

void EmitterLogic::spawnVelocityChanged ( )
signal

Emitted when spawnVelocity changes.

void EmitterLogic::timeOffChanged ( )
signal

Emitted when timeOff changes.

void EmitterLogic::timeOnChanged ( )
signal

Emitted when timeOn changes.

void EmitterLogic::transitionOffTimeChanged ( )
signal

Emitted when transitionOffTime changes.

void EmitterLogic::transitionOnTimeChanged ( )
signal

Emitted when transitionOnTime changes.

virtual void EmitterLogic::update ( )
overridevirtual

Updates the EmitterLogic cycle, calling emitEntity() for any entities that need to be spawned.

Reimplemented from Logic.

Reimplemented in ParticleEmitterLogic, ActorEmitterLogic, and WaterBodyLogic.

Property Documentation

float EmitterLogic::decayTime
readwrite

Number of seconds, in game time, before the entity is destroyed.

This value (randomized according to decayTimeRandomLength if spawnRandom is true) is used to initialize SpawnParameters::decayTime, but is not enforced by EmitterLogic. Instead, it is up to subclasses to correctly override update() to decay entities appropriately.

float EmitterLogic::decayTimeRandomLength
readwrite

Maximum time delta an entity can randomly stay alive if spawnRandom is true.

SpawnParameters::decayTime varies by [-decayTimeRandomLength, decayTimeRandomLength].

Note
If decayTimeRandomLength is greater than or equal to decayTime, SpawnParameters::decayTime could end up being negative, which means that the spawned entity should decay instantly.
int EmitterLogic::entityCount
read

Number of spawned entities still in existence.

Note
This property value is defined by subclasses according to their functionality.
int EmitterLogic::maxEntityCount
read

Actual maximum number of entities to spawn, bounded by both requestedMaxEntityCount and supportedMaxEntityCount.

See also
requestedMaxEntityCount, supportedMaxEntityCount
bool EmitterLogic::paused
readwrite

Whether or not this emitter should spawn entities.

Note
This differs from active in that the EmitterLogic will still continue cycling even when paused, simply opting not to emit entities. To stop the cycle completely, set active to false.
int EmitterLogic::requestedMaxEntityCount
readwrite

User-defined maximum number of entities to spawn.

Negative values are considered infinite.

Default Value:
500
Note
The default value can be changed through setRequestedMaxEntityCount() in subclasses, so the documentation for the classes should be checked before assuming this default.
See also
supportedMaxEntityCount, maxEntityCount
bool EmitterLogic::spawnRandom
readwrite

true if SpawnParameters are pseudo randomized, or patterned if false.

float EmitterLogic::spawnRate
readwrite

Number of entities spawned per frame (i.e. each non-paused call to update()).

float EmitterLogic::spawnSpray
readwrite

Divergence factor affecting the amount entities will stray from the direction of the emitter.

If spawnSpray is positive, emitted entities will have a divergent SpawnParameters::velocity, and if it is negative, emitted entities will have a convergent velocity.

float EmitterLogic::spawnSpread
readwrite

Horizontal axis spread to apply to spawned entities.

This value allows for the initial position of spawned entities to vary perpendicularly by up to spawnSpread units in order to prevent these entities from colliding immediately.

float EmitterLogic::spawnVelocity
readwrite

Forward velocity for spawned entities.

This value represents the y-component of the initial, local velocity vector.

int EmitterLogic::supportedMaxEntityCount
read

Class-defined maximum number of entities to spawn.

Negative values are considered infinite.

Note
This property value can be defined by subclasses according to their functionality.
See also
requestedMaxEntityCount, maxEntityCount
float EmitterLogic::timeOff
readwrite

Number of seconds, in game time, the emitter will stay off in one cycle.

float EmitterLogic::timeOn
readwrite

Number of seconds, in game time, the emitter will stay on in one cycle.

float EmitterLogic::transitionOffTime
readwrite

Number of seconds, in game time, the emitter takes to turn off.

The entity spawn rate is non-linearly (quadratically) interpolated from spawnRate to 0.0f over transitionOffTime seconds.

float EmitterLogic::transitionOnTime
readwrite

Number of seconds, in game time, the emitter takes to turn on.

The entity spawn rate is non-linearly (quadratically) interpolated from 0.0f to spawnRate over transitionOnTime seconds.