Inventory system basically works now but is in a alpha hack stage. Time to refactor.

This commit is contained in:
Zed A. Shaw 2025-02-23 22:57:27 -05:00
parent b7f49aa719
commit e0e7a1027c
11 changed files with 92 additions and 33 deletions

View file

@ -103,15 +103,19 @@ namespace guecs {
if((x >= cell.x && x <= cell.x + cell.w) &&
(y >= cell.y && y <= cell.y + cell.h))
{
auto& cn = $world.get<CellName>(ent);
clicked.action(ent, cn.name);
if(auto action_data = get_if<ActionData>(ent)) {
clicked.action(ent, action_data->data);
} else {
clicked.action(ent, {});
}
}
});
}
Clickable make_action(DinkyECS::World& target, Events::GUI event) {
return {[&, event](auto ent, auto&){
target.send<Events::GUI>(event, ent, {});
return {[&, event](auto ent, auto data){
// remember that ent is passed in from the UI::mouse handler
target.send<Events::GUI>(event, ent, data);
}};
}
}