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:
Zed A. Shaw 2024-10-26 04:33:23 -04:00
parent 743f906bc7
commit ec1ed23c52
6 changed files with 72 additions and 48 deletions

View file

@ -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;
};