53 static const float SIN45 = 0.707106781F;
54 static const double PI = M_PI;
55 static const float PI2 = 2 * M_PI;
74 mChildMoveParticles(),
79 mInvDieDistance(-1.0F),
83 mDeathEffectConditions(0x00),
85 mAllowSizeAdjust(false),
112 int &cnt = (*it).second;
146 dist.
x * dist.
x + dist.
y * dist.
y + dist.
z * dist.
z);
155 invHypotenuse = 2.0F / (
static_cast<float>(fabs(dist.
x))
156 +
static_cast<float>(fabs(dist.
y))
157 +
static_cast<float>(fabs(dist.
z)));
161 invHypotenuse = 1.0F /
static_cast<float>(sqrt(
162 dist.
x * dist.
x + dist.
y * dist.
y + dist.
z * dist.
z));
166 if (invHypotenuse != 0.0F)
223 STD_VECTOR<Particle*> newParticles;
225 FOR_EACH (STD_VECTOR<Particle*>::const_iterator,
247 if (deathEffect !=
nullptr)
284 float rad =
static_cast<float>(atan2(
mVelocity.
x,
289 const float range =
static_cast<float>(
PI /
size);
298 const float range2 = 2 * range;
300 for (
int c = 1; c <
size; c++)
302 const float cRange =
static_cast<float>(c) *
304 if (cRange - range < rad &&
305 rad < cRange + range)
333 (*p)->moveBy(change);
402 (*p)->moveBy(change);
412 const int pixelX,
const int pixelY,
417 const size_t pos = particleEffectFile.find(
'|');
418 const std::string dyePalettes = (pos != std::string::npos)
419 ? particleEffectFile.substr(pos + 1) :
"";
425 XmlNodeConstPtrConst rootNode = doc->
rootNode();
427 if ((rootNode ==
nullptr) || !xmlNameEqual(rootNode,
"effect"))
429 logger->
log(
"Error loading particle: %s", particleEffectFile.c_str());
438 if (!xmlNameEqual(effectChildNode,
"particle"))
453 effectChildNode,
"rotation")) !=
nullptr)
460 "image")) !=
nullptr)
462 std::string imageSrc;
463 if (XmlHaveChildContent(node))
464 imageSrc = XmlChildContent(node);
465 if (!imageSrc.empty() && !dyePalettes.empty())
481 effectChildNode,
"position-x", 0);
483 effectChildNode,
"position-y", 0);
485 effectChildNode,
"position-z", 0);
486 const Vector position(
mPos.x +
static_cast<float>(pixelX) + offsetX,
487 mPos.y +
static_cast<float>(pixelY) + offsetY,
489 newParticle->
moveTo(position);
494 "size-adjustable",
"false");
501 if (xmlNameEqual(emitterNode,
"emitter"))
512 else if (xmlNameEqual(emitterNode,
"deatheffect"))
514 std::string deathEffect;
515 if ((node !=
nullptr) && XmlHaveChildContent(node))
516 deathEffect = XmlChildContent(emitterNode);
518 char deathEffectConditions = 0x00;
521 deathEffectConditions +=
CAST_S8(
526 deathEffectConditions +=
CAST_S8(
531 deathEffectConditions +=
CAST_S8(
536 deathEffectConditions +=
CAST_S8(
541 deathEffectConditions +=
CAST_S8(
545 deathEffect, deathEffectConditions);
549 mChildParticles.push_back(newParticle);
558 if (mAllowSizeAdjust)
561 (*e)->adjustSize(w, h);
570 if (particle ==
nullptr)
572 particle->prepareToDie();
573 if (particle->isAlive() &&
574 particle->mLifetimeLeft == -1 &&
575 particle->mAutoDelete)
ActorManager * actorManager
const BeingId BeingId_zero
ActorSprite * findActor(const BeingId id) const
void controlParticleDeleted(const Particle *const particle)
virtual void setMap(Map *const map)
static void instantiate(std::string &target, const std::string &palettes)
static StringIntMap imageParticleCountByName
void log(const char *const log_text,...)
static const float PARTICLE_SKY
Particle * addEffect(const std::string &particleEffectFile, const int pixelX, const int pixelY, const int rotation)
static ParticlePhysicsT fastPhysics
Particles mChildParticles
void adjustEmitterSize(const int w, const int h)
void setLifetime(const int lifetime)
SimpleAnimation * mAnimation
void moveBy(const Vector &change)
void setAllowSizeAdjust(const bool adjust)
signed char mDeathEffectConditions
Particles mChildMoveParticles
Particle * addEffect(const std::string &particleEffectFile, const int pixelX, const int pixelY, const int rotation)
virtual void setDeathEffect(const std::string &effectFile, const signed char conditions)
void addEmitter(ParticleEmitter *const emitter)
void moveTo(const Vector &pos)
void draw(Graphics *const graphics, const int offsetX, const int offsetY) const
bool update(const int timePassed)
Image * getCurrentImage() const
void delete_all(Container &c)
#define FOR_EACH(type, iter, array)
#define for_each_xml_child_node(var, parent)
float fastInvSqrt(float x)
XML::Document * getXml(const std::string &idPath, const UseVirtFs useResman, const SkipError skipError)
Image * getImage(const std::string &idPath)
float getFloatProperty(const xmlNodePtr node, const char *const name, float def)
bool getBoolProperty(const xmlNodePtr node, const char *const name, const bool def)
int getProperty(const xmlNodePtr node, const char *const name, int def)
xmlNodePtr findFirstChildByName(const xmlNode *const parent, const char *const name)
ParticleEngine * particleEngine
Particles::iterator ParticleIterator
Particles::const_iterator ParticleConstIterator
Emitters::const_iterator EmitterConstIterator
const bool SkipError_false
StringIntMap::iterator StringIntMapIter
const bool UseVirtFs_true