Fix up the spatialmap to have an occupied_by method which checks if a square is occupied and returns what is there.

This commit is contained in:
Zed A. Shaw 2025-09-02 12:46:05 -04:00
parent 759f93cae0
commit a11e7de14e
7 changed files with 24 additions and 43 deletions

View file

@ -303,11 +303,10 @@ bool Autowalker::found_enemy() {
for(matrix::compass it{level.map->$walls, player.location.x, player.location.y}; it.next();) {
Point aim{it.x, it.y};
if(aim != player.aiming_at ||
!level.collision->occupied(player.aiming_at)) continue;
auto aimed_ent = level.collision->occupied_by(player.aiming_at);
if(aim != player.aiming_at || aimed_ent == DinkyECS::NONE) continue;
auto ent = level.collision->get(player.aiming_at);
if(level.world->has<components::Combat>(ent)) return true;
if(level.world->has<components::Combat>(aimed_ent)) return true;
}
return false;