Results of today's code review session.
This commit is contained in:
parent
14b3ea7676
commit
f35b74f335
21 changed files with 64 additions and 59 deletions
30
spatialmap.hpp
Normal file
30
spatialmap.hpp
Normal 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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue