Small error in how mouse events are processed. I need to do them _outside_ of the guecs::UI so that the event is checked once and then confirmed in all grids. Then created a tombstone device to be used as a dead enemy marker that will later allow looting.

This commit is contained in:
Zed A. Shaw 2025-02-19 08:33:18 -05:00
parent 6447f86954
commit e04c03b381
8 changed files with 37 additions and 17 deletions

View file

@ -91,18 +91,15 @@ namespace guecs {
});
}
void UI::mouse(sf::RenderWindow &window) {
if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) {
sf::Vector2f pos = window.mapPixelToCoords(sf::Mouse::getPosition(window));
$world.query<lel::Cell, Clickable>([&](auto ent, auto& cell, auto &clicked) {
if((pos.x >= cell.x && pos.x <= cell.x + cell.w) &&
(pos.y >= cell.y && pos.y <= cell.y + cell.h))
{
auto& cn = $world.get<CellName>(ent);
clicked.action(ent, cn.name);
}
});
}
void UI::mouse(float x, float y) {
$world.query<lel::Cell, Clickable>([&](auto ent, auto& cell, auto &clicked) {
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);
}
});
}
Clickable make_action(DinkyECS::World& target, Events::GUI event) {