Now items drop where you aim, and won't let you drop on a floor. But maybe one more change.

This commit is contained in:
Zed A. Shaw 2025-08-02 23:11:59 -04:00
parent 23ead1f0ca
commit 1788b8fb28
3 changed files with 21 additions and 41 deletions

View file

@ -444,30 +444,22 @@ bool System::drop_item(GameLevel& level, Entity item) {
auto& map = *level.map;
auto& collision = *level.collision;
auto player = world.get_the<Player>();
auto player_pos = world.get<Position>(player.entity);
auto& player_inv = world.get<inventory::Model>(player.entity);
auto player_pos = world.get<Position>(level.player);
// doesn't compass already avoid walls?
for(matrix::box it{map.walls(), player_pos.location.x, player_pos.location.y, 1}; it.next();)
{
Position pos{it.x, it.y};
Position pos{player_pos.aiming_at.x, player_pos.aiming_at.y};
if(map.can_move(pos.location) && !collision.occupied(pos.location)) {
world.set<Position>(item, pos);
collision.insert(pos.location, item, false);
// BUG: really there should be another system that handles loot->inv moves
if(player_inv.has(item)) player_inv.remove(item);
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, item, {});
level.world->not_constant(item);
return true;
}
if(map.can_move(pos.location)) {
world.set<Position>(item, pos);
collision.insert(pos.location, item, false);
level.world->not_constant(item);
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, item, {});
return true;
} else {
return false;
}
return false;
}
// NOTE: I tink pickup and this need to be different
// NOTE: I think pickup and this need to be different
bool System::place_in_container(World& world, Entity cont_id, const std::string& name, Entity world_entity) {
auto& container = world.get<inventory::Model>(cont_id);