| 1 | // SuperTux - "Will-O-Wisp" Badguy |
| 2 | // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de> |
| 3 | // |
| 4 | // This program is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
| 17 | #ifndef HEADER_SUPERTUX_BADGUY_WILLOWISP_HPP |
| 18 | #define |
| 19 | |
| 20 | #include "badguy/badguy.hpp" |
| 21 | #include "object/path_object.hpp" |
| 22 | #include "squirrel/exposed_object.hpp" |
| 23 | #include "scripting/willowisp.hpp" |
| 24 | |
| 25 | class SoundSource; |
| 26 | |
| 27 | class WillOWisp final : |
| 28 | public BadGuy, |
| 29 | public ExposedObject<WillOWisp, scripting::WillOWisp>, |
| 30 | public PathObject |
| 31 | { |
| 32 | public: |
| 33 | WillOWisp(const ReaderMapping& reader); |
| 34 | |
| 35 | virtual void finish_construction() override; |
| 36 | |
| 37 | virtual void activate() override; |
| 38 | virtual void deactivate() override; |
| 39 | |
| 40 | virtual void active_update(float dt_sec) override; |
| 41 | virtual bool is_flammable() const override { return false; } |
| 42 | virtual bool is_freezable() const override { return false; } |
| 43 | virtual bool is_hurtable() const override { return false; } |
| 44 | virtual void kill_fall() override { vanish(); } |
| 45 | |
| 46 | virtual void goto_node(int node_no); |
| 47 | virtual void set_state(const std::string& state); |
| 48 | virtual void start_moving(); |
| 49 | virtual void stop_moving(); |
| 50 | |
| 51 | virtual void stop_looping_sounds() override; |
| 52 | virtual void play_looping_sounds() override; |
| 53 | |
| 54 | virtual std::string get_class() const override { return "willowisp" ; } |
| 55 | virtual std::string get_display_name() const override { return _("Will o' Wisp" ); } |
| 56 | |
| 57 | virtual ObjectSettings get_settings() override; |
| 58 | virtual void move_to(const Vector& pos) override; |
| 59 | |
| 60 | /** make WillOWisp vanish */ |
| 61 | void vanish(); |
| 62 | |
| 63 | private: |
| 64 | virtual bool collides(GameObject& other, const CollisionHit& hit) const override; |
| 65 | virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override; |
| 66 | |
| 67 | private: |
| 68 | enum MyState { |
| 69 | STATE_STOPPED, STATE_IDLE, STATE_TRACKING, STATE_VANISHING, STATE_WARPING, |
| 70 | STATE_PATHMOVING, STATE_PATHMOVING_TRACK |
| 71 | }; |
| 72 | |
| 73 | private: |
| 74 | MyState m_mystate; |
| 75 | |
| 76 | std::string m_target_sector; |
| 77 | std::string m_target_spawnpoint; |
| 78 | std::string m_hit_script; |
| 79 | |
| 80 | std::unique_ptr<SoundSource> m_sound_source; |
| 81 | float m_flyspeed; |
| 82 | float m_track_range; |
| 83 | float m_vanish_range; |
| 84 | |
| 85 | private: |
| 86 | WillOWisp(const WillOWisp&) = delete; |
| 87 | WillOWisp& operator=(const WillOWisp&) = delete; |
| 88 | }; |
| 89 | |
| 90 | #endif |
| 91 | |
| 92 | /* EOF */ |
| 93 | |