diff --git a/.clang-format b/.clang-format index 56e0e43..f62feeb 100644 --- a/.clang-format +++ b/.clang-format @@ -2,3 +2,4 @@ BasedOnStyle: LLVM BreakBeforeBraces: Allman AccessModifierOffset: -4 IndentWidth: 4 +AlwaysBreakTemplateDeclarations: Yes diff --git a/README.md b/README.md index 8bf9b4a..6a4ed64 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -[ZedAShaw's ecs library](https://git.learnjsthehardway.com/learn-code-the-hard-way/raycaster/src/branch/master/dinkyecs.hpp) \ No newline at end of file +[ZedAShaw's ecs library](https://git.learnjsthehardway.com/learn-code-the-hard-way/raycaster/src/branch/master/dinkyecs.hpp) diff --git a/dinkyecs.hpp b/dinkyecs.hpp index 946a0c0..1a73160 100644 --- a/dinkyecs.hpp +++ b/dinkyecs.hpp @@ -58,28 +58,33 @@ struct World $constants.push_back(entity); } - template EntityMap &entity_map_for() + template + EntityMap &entity_map_for() { return $components[std::type_index(typeid(Comp))]; } - template EventQueue &queue_map_for() + template + EventQueue &queue_map_for() { return $events[std::type_index(typeid(Comp))]; } - template void remove(Entity ent) + template + void remove(Entity ent) { EntityMap &map = entity_map_for(); map.erase(ent); } - template void set_the(Comp val) + template + void set_the(Comp val) { $facts.insert_or_assign(std::type_index(typeid(Comp)), val); } - template Comp &get_the() + template + Comp &get_the() { auto comp_id = std::type_index(typeid(Comp)); dbc::check($facts.contains(comp_id), @@ -92,19 +97,22 @@ struct World return std::any_cast(res); } - template bool has_the() + template + bool has_the() { auto comp_id = std::type_index(typeid(Comp)); return $facts.contains(comp_id); } - template void set(Entity ent, Comp val) + template + void set(Entity ent, Comp val) { EntityMap &map = entity_map_for(); map.insert_or_assign(ent, val); } - template Comp &get(Entity ent) + template + Comp &get(Entity ent) { EntityMap &map = entity_map_for(); // use .at for bounds checking @@ -112,7 +120,8 @@ struct World return std::any_cast(res); } - template bool has(Entity ent) + template + bool has(Entity ent) { EntityMap &map = entity_map_for(); return map.contains(ent); @@ -146,13 +155,15 @@ struct World } } - template void send(Comp event, Entity entity, std::any data) + template + void send(Comp event, Entity entity, std::any data) { EventQueue &queue = queue_map_for(); queue.push({event, entity, data}); } - template Event recv() + template + Event recv() { EventQueue &queue = queue_map_for(); Event evt = queue.front(); @@ -160,7 +171,8 @@ struct World return evt; } - template bool has_event() + template + bool has_event() { EventQueue &queue = queue_map_for(); return !queue.empty(); diff --git a/point.hpp b/point.hpp index 526dfe0..0cc4392 100644 --- a/point.hpp +++ b/point.hpp @@ -14,7 +14,8 @@ struct Point typedef std::vector PointList; -template <> struct std::hash +template <> +struct std::hash { size_t operator()(const Point &p) const {