Now using a simple collision map to track entities and then determine if they're near the player for attacking.
This commit is contained in:
parent
743f906bc7
commit
ec1ed23c52
6 changed files with 72 additions and 48 deletions
11
collider.hpp
11
collider.hpp
|
@ -12,21 +12,18 @@ struct PointHash {
|
|||
};
|
||||
|
||||
typedef std::vector<DinkyECS::Entity> FoundList;
|
||||
typedef std::unordered_map<Point, DinkyECS::Entity, PointHash> PointEntityMap;
|
||||
|
||||
class SpatialHashTable {
|
||||
public:
|
||||
SpatialHashTable() {}
|
||||
|
||||
// disable copying, I think?
|
||||
SpatialHashTable(SpatialHashTable &other) = delete;
|
||||
|
||||
void insert(Point pos, DinkyECS::Entity obj);
|
||||
void move(Point from, Point to, DinkyECS::Entity ent);
|
||||
void remove(Point pos);
|
||||
bool occupied(Point pos);
|
||||
|
||||
std::tuple<bool, FoundList> neighbors(Point position);
|
||||
bool occupied(Point pos) const;
|
||||
std::tuple<bool, FoundList> neighbors(Point position, bool diag=false) const;
|
||||
|
||||
private:
|
||||
std::unordered_map<Point, DinkyECS::Entity, PointHash> table;
|
||||
PointEntityMap table;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue