diff --git a/collider.cpp b/collider.cpp index c7f7f2a..262dfd2 100644 --- a/collider.cpp +++ b/collider.cpp @@ -41,7 +41,7 @@ inline void find_neighbor(const PointEntityMap &table, EntityList &result, Point } } -std::tuple spatial_map::neighbors(Point cell, bool diag) const { +FoundEntities spatial_map::neighbors(Point cell, bool diag) const { EntityList result; // just unroll the loop since we only check four directions @@ -58,5 +58,5 @@ std::tuple spatial_map::neighbors(Point cell, bool diag) const find_neighbor(table, result, cell, -1, 1); // north west } - return std::tuple(!result.empty(), result); + return {!result.empty(), result}; } diff --git a/collider.hpp b/collider.hpp index 2a4f502..bbc5dee 100644 --- a/collider.hpp +++ b/collider.hpp @@ -4,12 +4,16 @@ #include "map.hpp" #include "dinkyecs.hpp" #include "point.hpp" -#include typedef std::vector EntityList; typedef std::unordered_map PointEntityMap; +struct FoundEntities { + bool found; + EntityList nearby; +}; + class spatial_map { public: spatial_map() {} @@ -18,7 +22,7 @@ class spatial_map { void move(Point from, Point to, DinkyECS::Entity ent); void remove(Point pos); bool occupied(Point pos) const; - std::tuple neighbors(Point position, bool diag=false) const; + FoundEntities neighbors(Point position, bool diag=false) const; private: PointEntityMap table;