Files are now in a src directory and I'm using a src/meson.build and tests/meson.build to specify what to build.
This commit is contained in:
parent
4778677647
commit
1d4ae911b9
108 changed files with 94 additions and 83 deletions
|
|
@ -1,49 +0,0 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include "map.hpp"
|
||||
#include "dinkyecs.hpp"
|
||||
#include "point.hpp"
|
||||
|
||||
struct CollisionData {
|
||||
DinkyECS::Entity entity = DinkyECS::NONE;
|
||||
bool collision = false;
|
||||
};
|
||||
|
||||
struct EntityDistance {
|
||||
int dist_square=0;
|
||||
DinkyECS::Entity entity=DinkyECS::NONE;
|
||||
float wiggle=0.0f;
|
||||
};
|
||||
|
||||
// Point's has is in point.hpp
|
||||
using EntityList = std::vector<DinkyECS::Entity>;
|
||||
using PointEntityMap = std::unordered_multimap<Point, CollisionData>;
|
||||
using SortedEntities = std::vector<EntityDistance>;
|
||||
|
||||
struct FoundEntities {
|
||||
bool found;
|
||||
EntityList nearby;
|
||||
};
|
||||
|
||||
class SpatialMap {
|
||||
public:
|
||||
SpatialMap() {}
|
||||
PointEntityMap $collision;
|
||||
|
||||
void insert(Point pos, DinkyECS::Entity obj, bool has_collision);
|
||||
void move(Point from, Point to, DinkyECS::Entity ent);
|
||||
// return value is whether the removed thing has collision
|
||||
CollisionData remove(Point pos, DinkyECS::Entity entity);
|
||||
DinkyECS::Entity occupied_by(Point pos) const;
|
||||
bool occupied(Point pos) const;
|
||||
bool something_there(Point at) const;
|
||||
DinkyECS::Entity get(Point at) const;
|
||||
DinkyECS::Entity find(Point at, std::function<bool(CollisionData)> cb) const;
|
||||
void find_neighbor(EntityList &result, Point at, int dy, int dx) const;
|
||||
|
||||
FoundEntities neighbors(Point position, bool diag=false) const;
|
||||
|
||||
void distance_sorted(SortedEntities& sorted_sprites, Point from, int max_distance);
|
||||
size_t size() { return $collision.size(); }
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue