Now floor drops always work by having a drop against a wall just drop at your feet. Closes #77.

This commit is contained in:
Zed A. Shaw 2025-08-02 23:26:42 -04:00
parent 1788b8fb28
commit 694ee210d6
8 changed files with 30 additions and 38 deletions

View file

@ -439,24 +439,24 @@ Entity System::spawn_item(World& world, const std::string& name) {
return item_id;
}
bool System::drop_item(GameLevel& level, Entity item) {
void System::drop_item(GameLevel& level, Entity item) {
auto& world = *level.world;
auto& map = *level.map;
auto& collision = *level.collision;
auto player_pos = world.get<Position>(level.player);
Position pos{player_pos.aiming_at.x, player_pos.aiming_at.y};
dbc::check(map.can_move(player_pos.location), "impossible, the player can't be in a wall");
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;
}
Position drop_spot = {player_pos.aiming_at.x, player_pos.aiming_at.y};
// if they're aiming at a wall then drop at their feet
if(!map.can_move(drop_spot.location)) drop_spot = player_pos;
world.set<Position>(item, drop_spot);
collision.insert(drop_spot.location, item, false);
level.world->not_constant(item);
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, item, {});
}
// NOTE: I think pickup and this need to be different