supertux
willowisp.hpp
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 HEADER_SUPERTUX_BADGUY_WILLOWISP_HPP
19 
20 #include "badguy/badguy.hpp"
21 #include "object/path_object.hpp"
22 
23 class SoundSource;
24 
31 class WillOWisp final : public BadGuy,
32  public PathObject
33 {
34 public:
35  static void register_class(ssq::VM& vm);
36 
37 public:
38  WillOWisp(const ReaderMapping& reader);
39 
40  virtual void finish_construction() override;
41  virtual void after_editor_set() override;
42 
43  virtual void activate() override;
44  virtual void deactivate() override;
45 
46  virtual void active_update(float dt_sec) override;
47  virtual bool is_flammable() const override { return false; }
48  virtual bool is_freezable() const override { return false; }
49  virtual bool is_hurtable() const override { return false; }
50  virtual void kill_fall() override { vanish(); }
51 
52  void goto_node(int node_idx);
53 
61  void set_state(const std::string& state);
62 
63  virtual void stop_looping_sounds() override;
64  virtual void play_looping_sounds() override;
65 
66  static std::string class_name() { return "willowisp"; }
67  virtual std::string get_class_name() const override { return class_name(); }
68  virtual std::string get_exposed_class_name() const override { return "WillOWisp"; }
69  static std::string display_name() { return _("Will o' Wisp"); }
70  virtual std::string get_display_name() const override { return display_name(); }
71  virtual GameObjectClasses get_class_types() const override { return BadGuy::get_class_types().add(typeid(PathObject)).add(typeid(WillOWisp)); }
72 
73  virtual ObjectSettings get_settings() override;
74  virtual void move_to(const Vector& pos) override;
75 
76  virtual void on_flip(float height) override;
77 
79  void vanish();
80 
81  Color get_color() const { return m_color; }
82 
83 protected:
84  virtual std::vector<Direction> get_allowed_directions() const override;
85 
86 private:
87  virtual bool collides(GameObject& other, const CollisionHit& hit) const override;
88  virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
89 
90 private:
91  enum MyState {
92  STATE_STOPPED, STATE_IDLE, STATE_TRACKING, STATE_VANISHING, STATE_WARPING,
93  STATE_PATHMOVING, STATE_PATHMOVING_TRACK
94  };
95 
96 private:
97  MyState m_mystate;
98 
99  std::string m_target_sector;
100  std::string m_target_spawnpoint;
101  std::string m_hit_script;
102 
103  std::unique_ptr<SoundSource> m_sound_source;
104  float m_flyspeed;
105  float m_track_range;
106  float m_vanish_range;
107 
108  Color m_color;
109 
110  int m_starting_node;
111 
112 private:
113  WillOWisp(const WillOWisp&) = delete;
114  WillOWisp& operator=(const WillOWisp&) = delete;
115 };
116 
117 #endif
118 
119 /* EOF */
virtual void deactivate() override
called when the badguy has been deactivated
Definition: willowisp.cpp:194
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: badguy.hpp:71
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: willowisp.hpp:71
virtual void kill_fall() override
Set the badguy to kill/falling state, which makes him falling of the screen (his sprite is turned ups...
Definition: willowisp.hpp:50
virtual void stop_looping_sounds() override
stops all looping sounds
Definition: willowisp.cpp:323
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: willowisp.hpp:70
void vanish()
make WillOWisp vanish
Definition: willowisp.cpp:215
virtual void finish_construction() override
Called after all objects have been added to the Sector and the Sector is fully constructed.
Definition: willowisp.cpp:92
Definition: object_settings.hpp:39
virtual void play_looping_sounds() override
continues all looping sounds
Definition: willowisp.cpp:330
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: willowisp.cpp:354
virtual std::vector< Direction > get_allowed_directions() const override
Returns a vector of directions the badguy can be set to.
Definition: willowisp.cpp:348
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
A sound source represents the source of audio output.
Definition: sound_source.hpp:25
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: willowisp.cpp:111
virtual bool is_hurtable() const override
Return true if this badguy can be hurt by tiles with the attribute "hurts".
Definition: willowisp.hpp:49
Definition: color.hpp:26
A base class for all objects that contain, or make use of a path.
Definition: path_object.hpp:36
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
A ""WillOWisp"" that was given a name can be controlled by scripts.
Definition: willowisp.hpp:31
Definition: reader_mapping.hpp:32
This module contains methods controlling the player.
Definition: player.hpp:47
virtual bool is_flammable() const override
Returns whether to call ignite() when a badguy gets hit by a fire bullet.
Definition: willowisp.hpp:47
virtual void activate() override
called when the badguy has been activated.
Definition: willowisp.cpp:180
void set_state(const std::string &state)
Sets the state of the WillOWisp.
Definition: willowisp.cpp:272
This class collects data about a collision.
Definition: collision_hit.hpp:44