X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsupertux%2Fsector.hpp;h=7016653b422b5a79675478376574d39f3adca04b;hb=ff8457f8f8516212e7a1749d88416806b54dae14;hp=80d5c267bf3dce0df62c2b313d90051da074bffe;hpb=13e56e5b8d9727128667bb42c3aa4850b4a8dd00;p=supertux.git diff --git a/src/supertux/sector.hpp b/src/supertux/sector.hpp index 80d5c267b..7016653b4 100644 --- a/src/supertux/sector.hpp +++ b/src/supertux/sector.hpp @@ -27,16 +27,18 @@ #include "util/writer_fwd.hpp" #include "util/currenton.hpp" #include "video/color.hpp" +#include "object/anchor_point.hpp" namespace collision { class Constraints; } class Vector; -class Rect; +class Rectf; class Sprite; class GameObject; class Player; +class PlayerStatus; class Camera; class TileMap; class Bullet; @@ -102,12 +104,12 @@ public: * tests if a given rectangle is inside the sector * (a rectangle that is on top of the sector is considered inside) */ - bool inside(const Rect& rectangle) const; + bool inside(const Rectf& rectangle) const; void play_music(MusicType musictype); MusicType get_music_type(); - bool add_bullet(const Vector& pos, float xm, Direction dir); + bool add_bullet(const Vector& pos, const PlayerStatus* player_status, float xm, Direction dir); bool add_smoke_cloud(const Vector& pos); /** get currently activated sector. */ @@ -128,27 +130,28 @@ public: } void collision_tilemap(collision::Constraints* constraints, - const Vector& movement, const Rect& dest) const; + const Vector& movement, const Rectf& dest, + MovingObject &object) const; /** * Checks if the specified rectangle is free of (solid) tiles. * Note that this does not include static objects, e.g. bonus blocks. */ - bool is_free_of_tiles(const Rect& rect, const bool ignoreUnisolid = false) const; + bool is_free_of_tiles(const Rectf& rect, const bool ignoreUnisolid = false) const; /** * Checks if the specified rectangle is free of both * 1.) solid tiles and * 2.) MovingObjects in COLGROUP_STATIC. * Note that this does not include badguys or players. */ - bool is_free_of_statics(const Rect& rect, const MovingObject* ignore_object = 0, const bool ignoreUnisolid = false) const; + bool is_free_of_statics(const Rectf& rect, const MovingObject* ignore_object = 0, const bool ignoreUnisolid = false) const; /** * Checks if the specified rectangle is free of both * 1.) solid tiles and * 2.) MovingObjects in COLGROUP_STATIC, COLGROUP_MOVINGSTATIC or COLGROUP_MOVING. * This includes badguys and players. */ - bool is_free_of_movingstatics(const Rect& rect, const MovingObject* ignore_object = 0) const; + bool is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object = 0) const; /** * returns a list of players currently in the sector @@ -156,8 +159,15 @@ public: std::vector get_players() { return std::vector(1, this->player); } + Player *get_nearest_player (const Vector& pos); + Player *get_nearest_player (const Rectf& pos) + { + return (get_nearest_player (get_anchor_pos (pos, ANCHOR_MIDDLE))); + } + + std::vector get_nearby_objects (const Vector& center, float max_distance); - Rect get_active_region(); + Rectf get_active_region(); /** * returns the width (in px) of a sector) @@ -195,7 +205,7 @@ public: float get_gravity() const; private: - uint32_t collision_tile_attributes(const Rect& dest) const; + uint32_t collision_tile_attributes(const Rectf& dest) const; void before_object_remove(GameObject* object); bool before_object_add(GameObject* object); @@ -226,7 +236,7 @@ private: * (because of ABORT_MOVE in the collision response or no collisions) */ void collision_static(collision::Constraints* constraints, - const Vector& movement, const Rect& dest, GameObject& object); + const Vector& movement, const Rectf& dest, MovingObject& object); void collision_static_constrains(MovingObject& object);