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
18
guecs.cpp
18
guecs.cpp
|
@ -60,10 +60,7 @@ namespace guecs {
|
|||
}
|
||||
|
||||
void Sound::play(bool hover) {
|
||||
if(hover) {
|
||||
// BUG: need to sort out how to make hover a one shot thing
|
||||
// sound::play(on_hover);
|
||||
} else {
|
||||
if(!hover) {
|
||||
sound::play(on_click);
|
||||
}
|
||||
}
|
||||
|
@ -235,17 +232,14 @@ namespace guecs {
|
|||
if((x >= cell.x && x <= cell.x + cell.w) &&
|
||||
(y >= cell.y && y <= cell.y + cell.h))
|
||||
{
|
||||
if($world.has<Effect>(ent)) {
|
||||
auto& effect = $world.get<Effect>(ent);
|
||||
do_if<Effect>(ent, [hover](auto& effect) {
|
||||
effect.$shader->setUniform("hover", hover);
|
||||
effect.run();
|
||||
}
|
||||
|
||||
if($world.has<Sound>(ent)) {
|
||||
auto& sound = $world.get<Sound>(ent);
|
||||
sound.play(hover);
|
||||
}
|
||||
});
|
||||
|
||||
do_if<Sound>(ent, [hover](auto& sound) {
|
||||
sound.play(hover);
|
||||
});
|
||||
|
||||
if(hover) return; // kinda gross
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue