17 #ifndef EMITTERLOGIC_H
18 #define EMITTERLOGIC_H
20 #include <Engine/Logic.h>
300 virtual void init()
override;
305 virtual void update()
override;
375 virtual void emitEntity(
const SpawnParameters& parameters);
378 void updateHasTimer();
380 int mRequestedMaxEntityCount = 500;
382 float mSpawnRate = 1.0f;
383 float mSpawnVelocity = 5.0f;
384 float mSpawnSpread = 0.0f;
385 float mSpawnSpray = 0.0f;
386 bool mSpawnRandom =
true;
387 bool mHasTimer =
false;
388 float mTimeOn = 1.0f;
389 float mTimeOff = 0.0f;
390 float mTransitionOnTime = 0.3f;
391 bool mHasTransitionOn =
true;
392 float mTransitionOffTime = 0.3f;
393 bool mHasTransitionOff =
true;
394 float mDecayTime = 3.33f;
395 float mDecayTimeRandomLength = 1.667f;
398 float mSpawnRateCounter = 0.0f;
399 float mCycleTimer = 0.0f;
400 bool mPaused =
false;
402 static const float SPAWN_OFFSETS[];
403 static const int SPAWN_OFFSET_COUNT;
404 static const float SPRAY_STRENGTH;
408 #endif // EMITTERLOGIC_H
void transitionOnTimeChanged()
Emitted when transitionOnTime changes.
void setSpawnRandom(bool value)
Sets spawnRandom.
void setSpawnSpread(float value)
Sets spawnSpread.
void timeOnChanged()
Emitted when timeOn changes.
int getRequestedMaxEntityCount() const
Returns requestedMaxEntityCount.
Definition: EmitterLogic.h:170
float spawnRate
Number of entities spawned per frame (i.e. each non-paused call to update()).
Definition: EmitterLogic.h:71
float timeOn
Number of seconds, in game time, the emitter will stay on in one cycle.
Definition: EmitterLogic.h:101
void setSpawnVelocity(float value)
Sets spawnVelocity.
int supportedMaxEntityCount
Class-defined maximum number of entities to spawn.
Definition: EmitterLogic.h:56
void setDecayTime(float value)
Sets decayTime.
int getMaxEntityCount() const
Returns maxEntityCount.
bool paused
Whether or not this emitter should spawn entities.
Definition: EmitterLogic.h:146
float getTransitionOnTime() const
Returns transitionOnTime.
Definition: EmitterLogic.h:254
void decayTimeChanged()
Emitted when decayTime changes.
float getSpawnSpray() const
Returns spawnSpray.
Definition: EmitterLogic.h:218
void setSpawnRate(float value)
Sets spawnRate.
void timeOffChanged()
Emitted when timeOff changes.
bool spawnRandom
true if SpawnParameters are pseudo randomized, or patterned if false.
Definition: EmitterLogic.h:97
float decayTimeRandomLength
Maximum time delta an entity can randomly stay alive if spawnRandom is true.
Definition: EmitterLogic.h:139
void setTransitionOnTime(float value)
Sets transitionOnTime.
Parameters to use for creating and initializing spawned entities.
Definition: EmitterLogic.h:152
float getTimeOff() const
Returns timeOff.
Definition: EmitterLogic.h:245
void spawnVelocityChanged()
Emitted when spawnVelocity changes.
float timeOff
Number of seconds, in game time, the emitter will stay off in one cycle.
Definition: EmitterLogic.h:105
void setTransitionOffTime(float value)
Sets transitionOffTime.
QPointF position
Position, in world space, at which to spawn the entity.
Definition: EmitterLogic.h:156
float getSpawnSpread() const
Returns spawnSpread.
Definition: EmitterLogic.h:209
void setTimeOn(float value)
Sets timeOn.
void decayTimeRandomLengthChanged()
Emitted when decayTimeRandomLength changes.
float spawnSpray
Divergence factor affecting the amount entities will stray from the direction of the emitter...
Definition: EmitterLogic.h:93
int requestedMaxEntityCount
User-defined maximum number of entities to spawn.
Definition: EmitterLogic.h:48
SpawnParameters getNextRandomSpawnParameters() const
Returns a randomized set of SpawnParameters according to EmitterLogic's parameters.
virtual void init() override
Checks that the EmitterLogic has an actor.
float getSpawnRate() const
Returns spawnRate.
Definition: EmitterLogic.h:191
float getSpawnVelocity() const
Returns spawnVelocity.
Definition: EmitterLogic.h:200
float getTransitionOffTime() const
Returns transitionOffTime.
Definition: EmitterLogic.h:263
float transitionOffTime
Number of seconds, in game time, the emitter takes to turn off.
Definition: EmitterLogic.h:121
void setRequestedMaxEntityCount(int value)
Sets requestedMaxEntityCount.
int maxEntityCount
Actual maximum number of entities to spawn, bounded by both requestedMaxEntityCount and supportedMaxE...
Definition: EmitterLogic.h:62
virtual int getSupportedMaxEntityCount() const
Returns supportedMaxEntityCount.
Definition: EmitterLogic.h:179
Non-visual entities in the QML item tree that define behavior for their parent Actor.
Definition: Logic.h:31
float getDecayTime() const
Returns decayTime.
Definition: EmitterLogic.h:272
float decayTime
Number of seconds, in game time, after which the entity should be destroyed.
Definition: EmitterLogic.h:164
void requestedMaxEntityCountChanged()
Emitted when requestedMaxEntityCount changes.
virtual void onPausedChanged()
Called when the emitter is moving to or from a paused state.
Definition: EmitterLogic.h:365
void setTimeOff(float value)
Sets timeOff.
void spawnRandomChanged()
Emitted when spawnRandom changes.
virtual void update() override
Updates the EmitterLogic cycle, calling emitEntity() for any entities that need to be spawned...
float getTimeOn() const
Returns timeOn.
Definition: EmitterLogic.h:236
void pausedChanged()
Emitted when paused changes.
float spawnSpread
Horizontal axis spread to apply to spawned entities.
Definition: EmitterLogic.h:85
Abstract base class to spawn generic entities into the Game based on configurable parameters...
Definition: EmitterLogic.h:35
float transitionOnTime
Number of seconds, in game time, the emitter takes to turn on.
Definition: EmitterLogic.h:113
void spawnSpreadChanged()
Emitted when spawnSpread changes.
void setPaused(bool value)
Sets paused.
bool isSpawnRandom() const
Returns spawnRandom.
Definition: EmitterLogic.h:227
void spawnRateChanged()
Emitted when spawnRate changes.
void transitionOffTimeChanged()
Emitted when transitionOffTime changes.
float spawnVelocity
Forward velocity for spawned entities.
Definition: EmitterLogic.h:78
virtual int getEntityCount() const
Returns entityCount.
Definition: EmitterLogic.h:187
bool isPaused() const
Returns paused.
Definition: EmitterLogic.h:290
virtual void emitEntity(const SpawnParameters ¶meters)
Performs the creation and initialization of a spawned entity with parameters.
void setSpawnSpray(float value)
Sets spawnSpray.
float decayTime
Number of seconds, in game time, before the entity is destroyed.
Definition: EmitterLogic.h:129
QPointF velocity
Initial velocity to give the spawned entity.
Definition: EmitterLogic.h:160
void spawnSprayChanged()
Emitted when spawnSpray changes.
int entityCount
Number of spawned entities still in existence.
Definition: EmitterLogic.h:67
float getDecayTimeRandomLength() const
Returns decayTimeRandomLength.
Definition: EmitterLogic.h:281
void setDecayTimeRandomLength(float value)
Sets decayTimeRandomLength.