ManaPlus
|
#include <particle.h>
Public Member Functions | |
Particle () | |
~Particle () | |
void | clear () |
bool | update () |
void | draw (Graphics *const graphics, const int offsetX, const int offsetY) const |
int | getPixelY () const |
int | getSortPixelY () const |
Particle * | addEffect (const std::string &particleEffectFile, const int pixelX, const int pixelY, const int rotation) |
void | addEmitter (ParticleEmitter *const emitter) |
void | moveTo (const Vector &pos) |
void | moveTo (const float x, const float y) |
void | moveBy (const Vector &change) |
void | setLifetime (const int lifetime) |
void | setFadeOut (const int fadeOut) |
void | setFadeIn (const int fadeIn) |
void | setVelocity (const float x, const float y, const float z) |
void | setGravity (const float gravity) |
void | setRandomness (const int r) |
void | setBounce (const float bouncieness) |
void | setFollow (const bool follow) |
bool | doesFollow () const |
void | setDestination (Particle *const target, const float accel, const float moment) |
void | setDieDistance (const float dist) |
void | adjustEmitterSize (const int w, const int h) |
void | setAllowSizeAdjust (const bool adjust) |
bool | isAlive () const |
void | prepareToDie () |
bool | isExtinct () const |
void | kill () |
void | disableAutoDelete () |
int | getNumberOfLayers () const |
float | getAlpha () const |
void | setAlpha (const float alpha) |
virtual void | setDeathEffect (const std::string &effectFile, const signed char conditions) |
void | setActor (const BeingId actor) |
Public Member Functions inherited from Actor | |
virtual | ~Actor () |
virtual int | getWidth () const |
virtual int | getHeight () const |
const Vector & | getPixelPositionF () const |
virtual void | setPixelPositionF (const Vector &pos) |
int | getPixelX () const |
virtual int | getTileX () const |
virtual int | getTileY () const |
virtual void | setMap (Map *const map) |
const Map * | getMap () const |
Protected Member Functions | |
void | updateSelf () |
Protected Member Functions inherited from Actor | |
Actor () | |
Protected Attributes | |
float | mAlpha |
int | mLifetimeLeft |
int | mLifetimePast |
int | mFadeOut |
int | mFadeIn |
Vector | mVelocity |
AliveStatusT | mAlive |
ParticleTypeT | mType |
SimpleAnimation * | mAnimation |
Image * | mImage |
BeingId | mActor |
Protected Attributes inherited from Actor | |
Map * | mMap |
Vector | mPos |
int | mYDiff |
Private Attributes | |
Emitters | mChildEmitters |
Particles | mChildParticles |
Particles | mChildMoveParticles |
std::string | mDeathEffect |
float | mGravity |
float | mBounce |
float | mAcceleration |
float | mInvDieDistance |
float | mMomentum |
Particle * | mTarget |
int | mRandomness |
signed char | mDeathEffectConditions |
bool | mAutoDelete |
bool | mAllowSizeAdjust |
bool | mFollow |
Friends | |
class | ParticleEngine |
Additional Inherited Members | |
Data Fields inherited from Actor | |
int | mPixelX |
int | mPixelY |
A particle spawned by a ParticleEmitter.
Definition at line 45 of file particle.h.
Particle::Particle | ( | ) |
Particle::~Particle | ( | ) |
Destructor.
Definition at line 91 of file particle.cpp.
References actorManager, BeingId_zero, clear(), ActorSprite::controlParticleDeleted(), delete2, ActorManager::findActor(), ParticleType::Image, ImageParticle::imageParticleCountByName, mActor, mAnimation, mImage, mType, ParticleEngine::particleCount, and restrict.
Particle * Particle::addEffect | ( | const std::string & | particleEffectFile, |
const int | pixelX, | ||
const int | pixelY, | ||
const int | rotation | ||
) |
Creates a child particle that hosts some emitters described in the particleEffectFile.
Definition at line 411 of file particle.cpp.
References addEmitter(), CAST_S8, AliveStatus::DEAD_FLOOR, AliveStatus::DEAD_IMPACT, AliveStatus::DEAD_OTHER, AliveStatus::DEAD_SKY, AliveStatus::DEAD_TIMEOUT, Resource::decRef(), XML::findFirstChildByName(), for_each_xml_child_node, XML::getBoolProperty(), XML::getFloatProperty(), Loader::getImage(), XML::getProperty(), Loader::getXml(), Dye::instantiate(), Logger::log(), logger, Ea::GameRecv::mMap, moveTo(), anonymous_namespace{mrand.cpp}::mPos, restrict, XML::Document::rootNode(), setAllowSizeAdjust(), setDeathEffect(), setLifetime(), Actor::setMap(), SkipError_false, and UseVirtFs_true.
|
inline |
Adds an emitter to the particle.
Definition at line 101 of file particle.h.
References mChildEmitters.
Referenced by addEffect(), ParticleEngine::addEffect(), and ParticleEmitter::createParticles().
void Particle::adjustEmitterSize | ( | const int | w, |
const int | h | ||
) |
Changes the size of the emitters so that the effect fills a rectangle of this size
Definition at line 556 of file particle.cpp.
References FOR_EACH.
Referenced by Map::initializeParticleEffects().
void Particle::clear | ( | ) |
Deletes all child particles and emitters.
Definition at line 582 of file particle.cpp.
References delete_all(), mChildEmitters, mChildMoveParticles, and mChildParticles.
Referenced by ~Particle().
|
inline |
After calling this function the particle will only request deletion when kill() is called
Definition at line 227 of file particle.h.
References mAutoDelete.
Referenced by ActorSprite::controlCustomParticle(), and ParticleVector::setLocally().
|
inline |
Gets the flag if the particle is supposed to be moved by its parent
Definition at line 176 of file particle.h.
References mFollow.
|
virtual |
Draws the particle image.
Implements Actor.
Reimplemented in TextParticle.
Definition at line 124 of file particle.cpp.
|
inlinevirtual |
Returns the current alpha value used to draw the actor.
Implements Actor.
Definition at line 234 of file particle.h.
|
inlinevirtual |
We consider particles (at least for now) to be one layer-sprites
Reimplemented from Actor.
Definition at line 231 of file particle.h.
|
inlinevirtual |
Necessary for sorting with the other sprites.
Reimplemented from Actor.
Reimplemented in TextParticle.
Definition at line 80 of file particle.h.
References CAST_S32, Actor::mPos, and Vector::y.
|
inlinevirtual |
Necessary for sorting with the other sprites for sorting only.
Reimplemented from Actor.
Reimplemented in TextParticle.
Definition at line 86 of file particle.h.
References CAST_S32, Actor::mPos, and Vector::y.
|
inline |
Definition at line 206 of file particle.h.
References AliveStatus::ALIVE, and mAlive.
Referenced by isExtinct().
|
inline |
Determines whether the particle and its children are all dead
Definition at line 214 of file particle.h.
References isAlive(), and mChildParticles.
Referenced by ParticleList::moveTo(), and ParticleVector::moveTo().
|
inline |
Manually marks the particle for deletion.
Definition at line 220 of file particle.h.
References AliveStatus::DEAD_OTHER, mAlive, and mAutoDelete.
Referenced by EffectManager::clear(), ParticleVector::delLocally(), EffectManager::logic(), ParticleList::moveTo(), ParticleVector::moveTo(), and ParticleList::removeLocally().
void Particle::moveBy | ( | const Vector & | change | ) |
Changes the particle position relative
Definition at line 397 of file particle.cpp.
References FOR_EACH, and anonymous_namespace{mrand.cpp}::mPos.
Referenced by moveTo(), and updateSelf().
void Particle::moveTo | ( | const float | x, |
const float | y | ||
) |
Sets the position in 2 dimensional space in pixels relative to map.
Definition at line 406 of file particle.cpp.
References anonymous_namespace{mrand.cpp}::mPos, x, and y.
|
inline |
Sets the position in 3 dimensional space in pixels relative to map.
Definition at line 107 of file particle.h.
References moveBy(), and Actor::mPos.
Referenced by addEffect(), ParticleEngine::addEffect(), ParticleEngine::addTextRiseFadeOutEffect(), ParticleEngine::addTextSplashEffect(), ParticleEmitter::createParticles(), ParticleList::moveTo(), and ParticleVector::moveTo().
void Particle::prepareToDie | ( | ) |
Definition at line 565 of file particle.cpp.
References FOR_EACH, mChildParticles, and restrict.
Referenced by ParticleList::removeLocally().
|
inline |
Definition at line 244 of file particle.h.
References mActor.
Referenced by ActorSprite::controlAutoParticle().
|
inline |
Definition at line 203 of file particle.h.
References mAllowSizeAdjust.
Referenced by addEffect(), and ParticleEngine::addEffect().
|
inlinevirtual |
Sets the alpha value used to draw the actor.
Implements Actor.
Definition at line 237 of file particle.h.
Referenced by ParticleEmitter::createParticles().
|
inline |
Sets the ammount of velocity particles retain after hitting the ground.
Definition at line 164 of file particle.h.
References mBounce.
Referenced by ParticleEngine::addTextSplashEffect(), and ParticleEmitter::createParticles().
|
inlinevirtual |
Definition at line 240 of file particle.h.
References mDeathEffect, and mDeathEffectConditions.
Referenced by addEffect(), ParticleEngine::addEffect(), and ParticleEmitter::createParticles().
|
inline |
Makes the particle move toward another particle with a given acceleration and momentum
Definition at line 183 of file particle.h.
References mAcceleration, mMomentum, and mTarget.
Referenced by ParticleEmitter::createParticles().
|
inline |
Sets the distance in pixel the particle can come near the target particle before it is destroyed. Does only make sense after a target particle has been set using setDestination.
Definition at line 194 of file particle.h.
References mInvDieDistance.
Referenced by ParticleEmitter::createParticles().
|
inline |
Sets the remaining particle lifetime where the particle starts to fade out.
Definition at line 137 of file particle.h.
References mFadeIn.
Referenced by ParticleEngine::addTextRiseFadeOutEffect(), and ParticleEmitter::createParticles().
|
inline |
Sets the age of the pixel in game ticks where the particle has faded in completely.
Definition at line 130 of file particle.h.
References mFadeOut.
Referenced by ParticleEngine::addTextRiseFadeOutEffect(), ParticleEngine::addTextSplashEffect(), and ParticleEmitter::createParticles().
|
inline |
Sets the flag if the particle is supposed to be moved by its parent
Definition at line 170 of file particle.h.
References Actions::follow(), and mFollow.
Referenced by ParticleEmitter::createParticles().
|
inline |
Sets the downward acceleration.
Definition at line 151 of file particle.h.
References mGravity.
Referenced by ParticleEngine::addTextRiseFadeOutEffect(), ParticleEngine::addTextSplashEffect(), and ParticleEmitter::createParticles().
|
inline |
Sets the time in game ticks until the particle is destroyed.
Definition at line 123 of file particle.h.
References mLifetimeLeft, and mLifetimePast.
Referenced by addEffect(), ParticleEngine::addEffect(), ParticleEngine::addTextRiseFadeOutEffect(), ParticleEngine::addTextSplashEffect(), and ParticleEmitter::createParticles().
|
inline |
Sets the ammount of random vector changes
Definition at line 157 of file particle.h.
References mRandomness.
Referenced by ParticleEmitter::createParticles().
|
inline |
Sets the current velocity in 3 dimensional space.
Definition at line 143 of file particle.h.
References mVelocity, x, Vector::x, y, Vector::y, and Vector::z.
Referenced by ParticleEngine::addTextRiseFadeOutEffect(), ParticleEngine::addTextSplashEffect(), and ParticleEmitter::createParticles().
bool Particle::update | ( | ) |
Updates particle position, returns false when the particle should be deleted.
Definition at line 254 of file particle.cpp.
References A_LIKELY, A_UNLIKELY, AliveStatus::ALIVE, ParticleType::Animation, AliveStatus::DEAD_TIMEOUT, SimpleAnimation::getCurrentImage(), SimpleAnimation::getLength(), mAlive, mAnimation, mAutoDelete, mChildMoveParticles, mChildParticles, mImage, mLifetimeLeft, Actor::mPos, mType, mVelocity, PI, PI2, restrict, SimpleAnimation::setFrame(), EmoteDB::size(), SimpleAnimation::update(), updateSelf(), Vector::x, and Vector::y.
|
protected |
Definition at line 130 of file particle.cpp.
References A_LIKELY, A_UNLIKELY, ParticleEngine::addEffect(), AliveStatus::ALIVE, ParticlePhysics::Best, CAST_U32, AliveStatus::DEAD_FLOOR, AliveStatus::DEAD_IMPACT, AliveStatus::DEAD_LONG_AGO, AliveStatus::DEAD_SKY, ParticleEngine::emitterSkip, ParticlePhysics::Fast, fastInvSqrt(), ParticleEngine::fastPhysics, FOR_EACH, mAcceleration, mAlive, mBounce, mChildEmitters, mChildMoveParticles, mChildParticles, mDeathEffect, mDeathEffectConditions, mFollow, mGravity, mInvDieDistance, mLifetimeLeft, mLifetimePast, mMomentum, moveBy(), Actor::mPos, mrand(), mRandomness, mTarget, mVelocity, ParticlePhysics::Normal, ParticleEngine::PARTICLE_SKY, particleEngine, restrict, SIN45, Vector::x, Vector::y, and Vector::z.
Referenced by update().
|
friend |
Definition at line 48 of file particle.h.
|
private |
Definition at line 301 of file particle.h.
Referenced by setDestination(), and updateSelf().
|
protected |
Definition at line 279 of file particle.h.
Referenced by setActor(), and ~Particle().
|
protected |
Definition at line 269 of file particle.h.
Referenced by isAlive(), kill(), update(), and updateSelf().
|
private |
Definition at line 324 of file particle.h.
Referenced by setAllowSizeAdjust().
|
protected |
Definition at line 251 of file particle.h.
Referenced by ImageParticle::setAlpha().
|
protected |
The image used for this particle.
Definition at line 274 of file particle.h.
Referenced by AnimationParticle::AnimationParticle(), RotationalParticle::RotationalParticle(), update(), and ~Particle().
|
private |
Definition at line 321 of file particle.h.
Referenced by disableAutoDelete(), kill(), and update().
|
private |
Definition at line 298 of file particle.h.
Referenced by setBounce(), and updateSelf().
|
private |
Definition at line 283 of file particle.h.
Referenced by addEmitter(), clear(), and updateSelf().
|
private |
Definition at line 288 of file particle.h.
Referenced by clear(), update(), and updateSelf().
|
private |
Definition at line 286 of file particle.h.
Referenced by clear(), isExtinct(), prepareToDie(), update(), and updateSelf().
|
private |
Definition at line 291 of file particle.h.
Referenced by setDeathEffect(), and updateSelf().
|
private |
Definition at line 318 of file particle.h.
Referenced by setDeathEffect(), and updateSelf().
|
protected |
Definition at line 263 of file particle.h.
Referenced by setFadeIn().
|
protected |
Definition at line 260 of file particle.h.
Referenced by setFadeOut().
|
private |
Definition at line 327 of file particle.h.
Referenced by doesFollow(), setFollow(), and updateSelf().
|
private |
Definition at line 295 of file particle.h.
Referenced by setGravity(), and updateSelf().
|
protected |
Definition at line 277 of file particle.h.
Referenced by ImageParticle::ImageParticle(), update(), and ~Particle().
|
private |
Definition at line 305 of file particle.h.
Referenced by setDieDistance(), and updateSelf().
|
protected |
Definition at line 254 of file particle.h.
Referenced by setLifetime(), update(), and updateSelf().
|
protected |
Definition at line 257 of file particle.h.
Referenced by setLifetime(), and updateSelf().
|
private |
Definition at line 308 of file particle.h.
Referenced by setDestination(), and updateSelf().
|
private |
Definition at line 314 of file particle.h.
Referenced by setRandomness(), and updateSelf().
|
private |
Definition at line 311 of file particle.h.
Referenced by setDestination(), and updateSelf().
|
protected |
Used animation for this particle
Definition at line 271 of file particle.h.
Referenced by AnimationParticle::AnimationParticle(), ImageParticle::ImageParticle(), RotationalParticle::RotationalParticle(), TextParticle::TextParticle(), update(), and ~Particle().
|
protected |
Definition at line 266 of file particle.h.
Referenced by setVelocity(), update(), and updateSelf().