Results of today's code review session.

This commit is contained in:
Zed A. Shaw 2025-01-05 15:07:30 -05:00
parent 14b3ea7676
commit f35b74f335
21 changed files with 64 additions and 59 deletions

30
spatialmap.hpp Normal file
View file

@ -0,0 +1,30 @@
#pragma once
#include <vector>
#include <unordered_map>
#include "map.hpp"
#include "dinkyecs.hpp"
#include "point.hpp"
typedef std::vector<DinkyECS::Entity> EntityList;
typedef std::unordered_map<Point, DinkyECS::Entity, PointHash> PointEntityMap;
struct FoundEntities {
bool found;
EntityList nearby;
};
class SpatialMap {
public:
SpatialMap() {}
void insert(Point pos, DinkyECS::Entity obj);
void move(Point from, Point to, DinkyECS::Entity ent);
void remove(Point pos);
bool occupied(Point pos) const;
DinkyECS::Entity get(Point at) const;
FoundEntities neighbors(Point position, bool diag=false) const;
private:
PointEntityMap table;
};