|
|
|
@ -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
|
|
|
|
|