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 #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 
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 */
virtual void deactivate() override
called when the badguy has been deactivated
Definition: willowisp.cpp:169
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:31
Simple two dimensional vector.
Definition: vector.hpp:24
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:44
This class binds a certain GameObject class to a scripting class.
Definition: exposed_object.hpp:45
virtual void stop_looping_sounds() override
stops all looping sounds
Definition: willowisp.cpp:293
void vanish()
make WillOWisp vanish
Definition: willowisp.cpp:190
virtual void finish_construction() override
Called after all objects have been added to the Sector and the Sector is fully constructed.
Definition: willowisp.cpp:78
Definition: object_settings.hpp:35
virtual void play_looping_sounds() override
continues all looping sounds
Definition: willowisp.cpp:300
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
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:86
virtual bool is_hurtable() const override
Return true if this badguy can be hurt by tiles with the attribute "hurts".
Definition: willowisp.hpp:43
A class for all objects that contain / make use of a path.
Definition: path_object.hpp:28
Definition: willowisp.hpp:27
Definition: reader_mapping.hpp:31
Definition: player.hpp:39
virtual bool is_flammable() const override
Returns whether to call ignite() when a badguy gets hit by a fire bullet.
Definition: willowisp.hpp:41
virtual void activate() override
called when the badguy has been activated.
Definition: willowisp.cpp:155
This class collects data about a collision.
Definition: collision_hit.hpp:44