fix Particles not being drawn with the new image member

This commit is contained in:
Kae 2023-06-26 02:03:50 +10:00
parent 500e81329a
commit 79c5012033
3 changed files with 13 additions and 8 deletions

View File

@ -42,6 +42,7 @@ Particle::Particle() {
length = 0; length = 0;
destructionAction = DestructionAction::None; destructionAction = DestructionAction::None;
destructionTime = 0.0f; destructionTime = 0.0f;
destructionSet = false;
trail = false; trail = false;
flippable = true; flippable = true;
flip = false; flip = false;
@ -224,6 +225,7 @@ void Particle::destructionUpdate() {
} else if (destructionAction == DestructionAction::Fade) { } else if (destructionAction == DestructionAction::Fade) {
color.setAlphaF(destructionFactor); color.setAlphaF(destructionFactor);
} else if (destructionAction == DestructionAction::Image) { } else if (destructionAction == DestructionAction::Image) {
if (!destructionSet) {
size = 1.0f; size = 1.0f;
color = Color::White; color = Color::White;
type = Particle::Type::Textured; type = Particle::Type::Textured;
@ -231,6 +233,8 @@ void Particle::destructionUpdate() {
angularVelocity = 0.0f; angularVelocity = 0.0f;
length = 0.0f; length = 0.0f;
rotation = 0.0f; rotation = 0.0f;
destructionSet = true;
}
} }
} }
} }

View File

@ -100,6 +100,7 @@ struct Particle {
DestructionAction destructionAction; DestructionAction destructionAction;
AssetPath destructionImage; AssetPath destructionImage;
float destructionTime; float destructionTime;
bool destructionSet;
float timeToLive; float timeToLive;
Layer layer; Layer layer;

View File

@ -182,7 +182,7 @@ void WorldPainter::renderParticles(WorldRenderData& renderData, Particle::Layer
} else if (particle.type == Particle::Type::Textured || particle.type == Particle::Type::Animated) { } else if (particle.type == Particle::Type::Textured || particle.type == Particle::Type::Animated) {
Drawable drawable; Drawable drawable;
if (particle.type == Particle::Type::Textured) if (particle.type == Particle::Type::Textured)
drawable = Drawable::makeImage(particle.string, 1.0f / TilePixels, true, Vec2F(0, 0)); drawable = Drawable::makeImage(particle.image, 1.0f / TilePixels, true, Vec2F(0, 0));
else else
drawable = particle.animation->drawable(1.0f / TilePixels); drawable = particle.animation->drawable(1.0f / TilePixels);