Now have a do_if on GUECS for many of the 'if this exists do this' patterns.
This commit is contained in:
parent
2ecef8d9f9
commit
57e042e786
5 changed files with 17 additions and 14 deletions
|
@ -99,7 +99,6 @@ namespace guecs {
|
|||
|
||||
struct Sound {
|
||||
std::string on_click{""};
|
||||
std::string on_hover{""};
|
||||
|
||||
void play(bool hover);
|
||||
};
|
||||
|
@ -166,6 +165,13 @@ namespace guecs {
|
|||
$world.set<Comp>(ent, val);
|
||||
}
|
||||
|
||||
template <typename Comp>
|
||||
void do_if(DinkyECS::Entity ent, std::function<void(Comp &)> cb) {
|
||||
if($world.has<Comp>(ent)) {
|
||||
cb($world.get<Comp>(ent));
|
||||
}
|
||||
}
|
||||
|
||||
lel::Cell& cell_for(DinkyECS::Entity ent) {
|
||||
return $world.get<lel::Cell>(ent);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue