diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 75d77c135d2..ac7e08356a6 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -64,13 +64,13 @@ BadGuy::BadGuy(const Vector& pos, Direction direction, const std::string& sprite m_melting_time(0), m_lightsprite(SpriteManager::current()->create(light_sprite_name)), m_glowing(false), + m_parent_dispenser(), m_state(STATE_INIT), m_is_active_flag(), m_state_timer(), m_on_ground_flag(false), m_floor_normal(), - m_colgroup_active(COLGROUP_MOVING), - m_parent_dispenser() + m_colgroup_active(COLGROUP_MOVING) { SoundManager::current()->preload("sounds/squish.wav"); SoundManager::current()->preload("sounds/fall.wav"); @@ -98,13 +98,13 @@ BadGuy::BadGuy(const ReaderMapping& reader, const std::string& sprite_name_, int m_melting_time(0), m_lightsprite(SpriteManager::current()->create(light_sprite_name)), m_glowing(false), + m_parent_dispenser(), m_state(STATE_INIT), m_is_active_flag(), m_state_timer(), m_on_ground_flag(false), m_floor_normal(), - m_colgroup_active(COLGROUP_MOVING), - m_parent_dispenser() + m_colgroup_active(COLGROUP_MOVING) { std::string dir_str = "auto"; reader.get("direction", dir_str); diff --git a/src/badguy/badguy.hpp b/src/badguy/badguy.hpp index f26e1ded765..065258f0405 100644 --- a/src/badguy/badguy.hpp +++ b/src/badguy/badguy.hpp @@ -258,6 +258,10 @@ class BadGuy : public MovingSprite, SpritePtr m_lightsprite; bool m_glowing; + /** If this badguy was dispensed from a dispenser, + save the dispenser here. */ + Dispenser* m_parent_dispenser; + private: State m_state; @@ -278,10 +282,6 @@ class BadGuy : public MovingSprite, /** CollisionGroup the badguy should be in while active */ CollisionGroup m_colgroup_active; - /** If this badguy was dispensed from a dispenser, - save the dispenser here. */ - Dispenser* m_parent_dispenser; - private: BadGuy(const BadGuy&) = delete; BadGuy& operator=(const BadGuy&) = delete; diff --git a/src/badguy/treewillowisp.cpp b/src/badguy/treewillowisp.cpp index 9ee3f5427be..e8387f82830 100644 --- a/src/badguy/treewillowisp.cpp +++ b/src/badguy/treewillowisp.cpp @@ -20,6 +20,7 @@ #include "audio/sound_manager.hpp" #include "audio/sound_source.hpp" +#include "badguy/dispenser.hpp" #include "badguy/ghosttree.hpp" #include "math/util.hpp" #include "object/lantern.hpp" @@ -67,6 +68,11 @@ TreeWillOWisp::vanish() mystate = STATE_VANISHING; m_sprite->set_action("vanishing", 1); set_colgroup_active(COLGROUP_DISABLED); + + if (m_parent_dispenser != nullptr) + { + m_parent_dispenser->notify_dead(); + } } void diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 36423fdd0d6..84e3623a25a 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -18,6 +18,7 @@ #include "audio/sound_manager.hpp" #include "audio/sound_source.hpp" +#include "badguy/dispenser.hpp" #include "editor/editor.hpp" #include "object/lantern.hpp" #include "object/player.hpp" @@ -44,7 +45,8 @@ WillOWisp::WillOWisp(const ReaderMapping& reader) : m_sound_source(), m_flyspeed(), m_track_range(), - m_vanish_range() + m_vanish_range(), + m_color(0, 1, 0) { if (Editor::is_active()) { reader.get("sector", m_target_sector); @@ -62,13 +64,22 @@ WillOWisp::WillOWisp(const ReaderMapping& reader) : bool running; if ( !reader.get("running", running)) running = false; + std::vector color; + if (reader.get("color", color)) + { + m_color = Color(color); + } + init_path(reader, running); m_countMe = false; SoundManager::current()->preload(SOUNDFILE); SoundManager::current()->preload("sounds/warp.wav"); - m_lightsprite->set_color(Color(0.0f, 0.2f, 0.0f)); + m_lightsprite->set_color(Color(m_color.red * 0.2f, + m_color.green * 0.2f, + m_color.blue * 0.2f)); + m_sprite->set_color(m_color); m_glowing = true; m_sprite->set_action("idle"); @@ -82,6 +93,15 @@ WillOWisp::finish_construction() } } +void +WillOWisp::after_editor_set() +{ + m_lightsprite->set_color(Color(m_color.red * 0.2f, + m_color.green * 0.2f, + m_color.blue * 0.2f)); + m_sprite->set_color(m_color); +} + void WillOWisp::active_update(float dt_sec) { @@ -192,6 +212,11 @@ WillOWisp::vanish() m_mystate = STATE_VANISHING; m_sprite->set_action("vanishing", 1); set_colgroup_active(COLGROUP_DISABLED); + + if (m_parent_dispenser != nullptr) + { + m_parent_dispenser->notify_dead(); + } } bool @@ -284,6 +309,7 @@ WillOWisp::get_settings() result.add_float(_("Vanish range"), &m_vanish_range, "vanish-range", VANISH_RANGE); result.add_float(_("Fly speed"), &m_flyspeed, "flyspeed", FLYSPEED); result.add_path_ref(_("Path"), get_path_ref(), "path-ref"); + result.add_color(_("Color"), &m_color, "color"); result.reorder({"sector", "spawnpoint", "flyspeed", "track-range", "hit-script", "vanish-range", "name", "path-ref", "region", "x", "y"}); diff --git a/src/badguy/willowisp.hpp b/src/badguy/willowisp.hpp index a98756a8837..dfb6d0d3845 100644 --- a/src/badguy/willowisp.hpp +++ b/src/badguy/willowisp.hpp @@ -33,6 +33,7 @@ class WillOWisp final : WillOWisp(const ReaderMapping& reader); virtual void finish_construction() override; + virtual void after_editor_set() override; virtual void activate() override; virtual void deactivate() override; @@ -70,6 +71,8 @@ class WillOWisp final : /** make WillOWisp vanish */ void vanish(); + Color get_color() const { return m_color; } + private: virtual bool collides(GameObject& other, const CollisionHit& hit) const override; virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override; @@ -92,6 +95,8 @@ class WillOWisp final : float m_track_range; float m_vanish_range; + Color m_color; + private: WillOWisp(const WillOWisp&) = delete; WillOWisp& operator=(const WillOWisp&) = delete; diff --git a/src/object/lantern.cpp b/src/object/lantern.cpp index fdab16bdad9..8491baebb7b 100644 --- a/src/object/lantern.cpp +++ b/src/object/lantern.cpp @@ -99,7 +99,7 @@ HitResponse Lantern::collision(GameObject& other, const CollisionHit& hit) { if (wow) { // collided with WillOWisp while grabbed and unlit SoundManager::current()->play("sounds/willocatch.wav"); - lightcolor = Color(0,1,0); + lightcolor = wow->get_color(); updateColor(); wow->vanish(); }