Brought over a bunch of code from the roguelike and now will use it to generate a random map.
This commit is contained in:
parent
8d3d3b4ec3
commit
2daa1c9bd5
59 changed files with 4303 additions and 411 deletions
31
spatialmap.hpp
Normal file
31
spatialmap.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include "map.hpp"
|
||||
#include "dinkyecs.hpp"
|
||||
#include "point.hpp"
|
||||
|
||||
typedef std::vector<DinkyECS::Entity> EntityList;
|
||||
|
||||
// Point's has is in point.hpp
|
||||
typedef std::unordered_map<Point, DinkyECS::Entity> 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