Files
fs2open.github.com/code/particle/effects/CompositeEffect.cpp
T
asarium c6e2f94d0b Use type-safe handles for particle effects
Nightmare discovered an off-by-one error when checking the validity of a
particle effect handle. Since the new ID system makes that much easier
and less error-prone I decided to go ahead and convert all handles to
an ID typedef which also fixes the reported bug.
2018-07-15 14:50:32 +02:00

43 lines
1.1 KiB
C++

#include "particle/particle.h"
#include "particle/ParticleEffect.h"
#include "particle/ParticleSource.h"
#include "particle/effects/CompositeEffect.h"
namespace particle {
namespace effects {
CompositeEffect::CompositeEffect(const SCP_string& name) : ParticleEffect(name) {}
bool CompositeEffect::processSource(const ParticleSource*) {
UNREACHABLE("Processing a composite source is not supported! This was caused by a coding error, get a coder!");
return false;
}
void CompositeEffect::parseValues(bool) {
while (optional_string("+Child effect:")) {
auto effectId = internal::parseEffectElement();
if (effectId.isValid()) {
ParticleEffectPtr effect = ParticleManager::get()->getEffect(effectId);
if (effect->getType() == EffectType::Composite) {
error_display(0,
"A composite effect cannot contain more composite effects! The effect as not been added.");
}
else {
addEffect(effect);
}
}
}
}
void CompositeEffect::pageIn() {
for (auto& effect : m_childEffects) {
effect->pageIn();
}
}
void CompositeEffect::addEffect(ParticleEffectPtr effect) {
m_childEffects.push_back(effect);
}
}
}