AlwaysBreakTemplateDeclarations
This commit is contained in:
parent
d89827046a
commit
336e5a5733
4 changed files with 28 additions and 14 deletions
|
@ -2,3 +2,4 @@ BasedOnStyle: LLVM
|
||||||
BreakBeforeBraces: Allman
|
BreakBeforeBraces: Allman
|
||||||
AccessModifierOffset: -4
|
AccessModifierOffset: -4
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
|
36
dinkyecs.hpp
36
dinkyecs.hpp
|
@ -58,28 +58,33 @@ struct World
|
||||||
$constants.push_back(entity);
|
$constants.push_back(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> EntityMap &entity_map_for()
|
template <typename Comp>
|
||||||
|
EntityMap &entity_map_for()
|
||||||
{
|
{
|
||||||
return $components[std::type_index(typeid(Comp))];
|
return $components[std::type_index(typeid(Comp))];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> EventQueue &queue_map_for()
|
template <typename Comp>
|
||||||
|
EventQueue &queue_map_for()
|
||||||
{
|
{
|
||||||
return $events[std::type_index(typeid(Comp))];
|
return $events[std::type_index(typeid(Comp))];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> void remove(Entity ent)
|
template <typename Comp>
|
||||||
|
void remove(Entity ent)
|
||||||
{
|
{
|
||||||
EntityMap &map = entity_map_for<Comp>();
|
EntityMap &map = entity_map_for<Comp>();
|
||||||
map.erase(ent);
|
map.erase(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> void set_the(Comp val)
|
template <typename Comp>
|
||||||
|
void set_the(Comp val)
|
||||||
{
|
{
|
||||||
$facts.insert_or_assign(std::type_index(typeid(Comp)), val);
|
$facts.insert_or_assign(std::type_index(typeid(Comp)), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> Comp &get_the()
|
template <typename Comp>
|
||||||
|
Comp &get_the()
|
||||||
{
|
{
|
||||||
auto comp_id = std::type_index(typeid(Comp));
|
auto comp_id = std::type_index(typeid(Comp));
|
||||||
dbc::check($facts.contains(comp_id),
|
dbc::check($facts.contains(comp_id),
|
||||||
|
@ -92,19 +97,22 @@ struct World
|
||||||
return std::any_cast<Comp &>(res);
|
return std::any_cast<Comp &>(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> bool has_the()
|
template <typename Comp>
|
||||||
|
bool has_the()
|
||||||
{
|
{
|
||||||
auto comp_id = std::type_index(typeid(Comp));
|
auto comp_id = std::type_index(typeid(Comp));
|
||||||
return $facts.contains(comp_id);
|
return $facts.contains(comp_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> void set(Entity ent, Comp val)
|
template <typename Comp>
|
||||||
|
void set(Entity ent, Comp val)
|
||||||
{
|
{
|
||||||
EntityMap &map = entity_map_for<Comp>();
|
EntityMap &map = entity_map_for<Comp>();
|
||||||
map.insert_or_assign(ent, val);
|
map.insert_or_assign(ent, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> Comp &get(Entity ent)
|
template <typename Comp>
|
||||||
|
Comp &get(Entity ent)
|
||||||
{
|
{
|
||||||
EntityMap &map = entity_map_for<Comp>();
|
EntityMap &map = entity_map_for<Comp>();
|
||||||
// use .at for bounds checking
|
// use .at for bounds checking
|
||||||
|
@ -112,7 +120,8 @@ struct World
|
||||||
return std::any_cast<Comp &>(res);
|
return std::any_cast<Comp &>(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> bool has(Entity ent)
|
template <typename Comp>
|
||||||
|
bool has(Entity ent)
|
||||||
{
|
{
|
||||||
EntityMap &map = entity_map_for<Comp>();
|
EntityMap &map = entity_map_for<Comp>();
|
||||||
return map.contains(ent);
|
return map.contains(ent);
|
||||||
|
@ -146,13 +155,15 @@ struct World
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> void send(Comp event, Entity entity, std::any data)
|
template <typename Comp>
|
||||||
|
void send(Comp event, Entity entity, std::any data)
|
||||||
{
|
{
|
||||||
EventQueue &queue = queue_map_for<Comp>();
|
EventQueue &queue = queue_map_for<Comp>();
|
||||||
queue.push({event, entity, data});
|
queue.push({event, entity, data});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> Event recv()
|
template <typename Comp>
|
||||||
|
Event recv()
|
||||||
{
|
{
|
||||||
EventQueue &queue = queue_map_for<Comp>();
|
EventQueue &queue = queue_map_for<Comp>();
|
||||||
Event evt = queue.front();
|
Event evt = queue.front();
|
||||||
|
@ -160,7 +171,8 @@ struct World
|
||||||
return evt;
|
return evt;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Comp> bool has_event()
|
template <typename Comp>
|
||||||
|
bool has_event()
|
||||||
{
|
{
|
||||||
EventQueue &queue = queue_map_for<Comp>();
|
EventQueue &queue = queue_map_for<Comp>();
|
||||||
return !queue.empty();
|
return !queue.empty();
|
||||||
|
|
|
@ -14,7 +14,8 @@ struct Point
|
||||||
|
|
||||||
typedef std::vector<Point> PointList;
|
typedef std::vector<Point> PointList;
|
||||||
|
|
||||||
template <> struct std::hash<Point>
|
template <>
|
||||||
|
struct std::hash<Point>
|
||||||
{
|
{
|
||||||
size_t operator()(const Point &p) const
|
size_t operator()(const Point &p) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue