X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fbadguy%2Fbadguy.hpp;h=092ff54c84099338cbf7d4bdc733e58d9e4d7732;hb=092556fd403b1464402c741f949c48f04f628ee8;hp=7555d837d0baad58029979b88d29f209d21ac2dc;hpb=08813a74da6ac1fd045a105e4e8105f1d7f716f0;p=supertux.git diff --git a/src/badguy/badguy.hpp b/src/badguy/badguy.hpp index 7555d837d..092ff54c8 100644 --- a/src/badguy/badguy.hpp +++ b/src/badguy/badguy.hpp @@ -53,7 +53,7 @@ public: /** Set the badguy to kill/falling state, which makes him falling of the screen (his sprite is turned upside-down) */ virtual void kill_fall(); - + /** Call this, if you use custom kill_fall() or kill_squashed(GameObject& object) */ virtual void run_dead_script(); @@ -68,15 +68,12 @@ public: { return start_position; } + void set_start_position(const Vector& vec) { start_position = vec; } - /** Count this badguy to the statistics? This value should not be - changed during runtime. */ - bool countMe; - /** Called when hit by a fire bullet, and is_flammable() returns true */ virtual void ignite(); @@ -99,6 +96,8 @@ public: bool is_frozen() const; + bool is_in_water() const; + protected: enum State { STATE_INIT, @@ -132,12 +131,9 @@ protected: /** called each frame when the badguy is not activated. */ virtual void inactive_update(float elapsed_time); - /** true if initialize() has already been called */ - bool is_initialized; - /** called immediately before the first call to initialize */ virtual void initialize(); - + /** called when the badguy has been activated. (As a side effect the dir variable might have been changed so that it faces towards the player. */ @@ -152,6 +148,10 @@ protected: State get_state() const { return state; } + bool check_state_timer() { + return state_timer.check(); + } + /** returns a pointer to the nearest player or 0 if no player is available */ Player* get_nearest_player(); @@ -163,14 +163,6 @@ protected: pixels. Minimum value for height is 1 pixel */ bool might_fall(int height = 1); - Vector start_position; - - /** The direction we currently face in */ - Direction dir; - - /** The direction we initially faced in */ - Direction start_dir; - /** Get Direction from String. */ Direction str2dir( std::string dir_str ); @@ -190,17 +182,12 @@ protected: from above. */ Vector get_floor_normal(); - bool frozen; - bool ignited; /**< true if this badguy is currently on fire */ - - std::string dead_script; /**< script to execute when badguy is killed */ - /** Returns true if we were in STATE_ACTIVE at the beginning of the last call to update() */ bool is_active(); /** changes colgroup_active. Also calls set_group when badguy is in STATE_ACTIVE */ - void set_colgroup_active(CollisionGroup group); + void set_colgroup_active(CollisionGroup group); private: void try_activate(); @@ -208,23 +195,46 @@ private: protected: Physic physic; +public: + /** Count this badguy to the statistics? This value should not be + changed during runtime. */ + bool countMe; + +protected: + /** true if initialize() has already been called */ + bool is_initialized; + + Vector start_position; + + /** The direction we currently face in */ + Direction dir; + + /** The direction we initially faced in */ + Direction start_dir; + + bool frozen; + bool ignited; /**< true if this badguy is currently on fire */ + bool in_water; /** < true if the badguy is currently in water */ + + std::string dead_script; /**< script to execute when badguy is killed */ + private: State state; /** true if state was STATE_ACTIVE at the beginning of the last call to update() */ - bool is_active_flag; + bool is_active_flag; Timer state_timer; /** true if we touched something solid from above and update_on_ground_flag was called last frame */ - bool on_ground_flag; + bool on_ground_flag; /** floor normal stored the last time when update_on_ground_flag was called and we touched something solid from above */ - Vector floor_normal; - + Vector floor_normal; + /** CollisionGroup the badguy should be in while active */ CollisionGroup colgroup_active;