From 79c5012033935b54d6ef94b2830aed12f92811c1 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 26 Jun 2023 02:03:50 +1000 Subject: [PATCH] fix Particles not being drawn with the new image member --- source/game/StarParticle.cpp | 18 +++++++++++------- source/game/StarParticle.hpp | 1 + source/rendering/StarWorldPainter.cpp | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/source/game/StarParticle.cpp b/source/game/StarParticle.cpp index ad0c168..82c63c6 100644 --- a/source/game/StarParticle.cpp +++ b/source/game/StarParticle.cpp @@ -42,6 +42,7 @@ Particle::Particle() { length = 0; destructionAction = DestructionAction::None; destructionTime = 0.0f; + destructionSet = false; trail = false; flippable = true; flip = false; @@ -224,13 +225,16 @@ void Particle::destructionUpdate() { } else if (destructionAction == DestructionAction::Fade) { color.setAlphaF(destructionFactor); } else if (destructionAction == DestructionAction::Image) { - size = 1.0f; - color = Color::White; - type = Particle::Type::Textured; - image = destructionImage; - angularVelocity = 0.0f; - length = 0.0f; - rotation = 0.0f; + if (!destructionSet) { + size = 1.0f; + color = Color::White; + type = Particle::Type::Textured; + image = destructionImage; + angularVelocity = 0.0f; + length = 0.0f; + rotation = 0.0f; + destructionSet = true; + } } } } diff --git a/source/game/StarParticle.hpp b/source/game/StarParticle.hpp index b35cb0a..a0945ac 100644 --- a/source/game/StarParticle.hpp +++ b/source/game/StarParticle.hpp @@ -100,6 +100,7 @@ struct Particle { DestructionAction destructionAction; AssetPath destructionImage; float destructionTime; + bool destructionSet; float timeToLive; Layer layer; diff --git a/source/rendering/StarWorldPainter.cpp b/source/rendering/StarWorldPainter.cpp index 4b2324d..ea63abe 100644 --- a/source/rendering/StarWorldPainter.cpp +++ b/source/rendering/StarWorldPainter.cpp @@ -182,7 +182,7 @@ void WorldPainter::renderParticles(WorldRenderData& renderData, Particle::Layer } else if (particle.type == Particle::Type::Textured || particle.type == Particle::Type::Animated) { Drawable drawable; 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 drawable = particle.animation->drawable(1.0f / TilePixels);