| 747 | } |
| 748 | |
| 749 | void Player::dropItem() { |
| 750 | if (!world()) |
| 751 | return; |
| 752 | if (!canUseTool()) |
| 753 | return; |
| 754 | |
| 755 | Vec2F throwDirection = world()->geometry().diff(aimPosition(), position()); |
| 756 | for (auto& throwSlot : {m_inventory->primaryHeldSlot(), m_inventory->secondaryHeldSlot()}) { |
| 757 | if (throwSlot) { |
| 758 | if (auto drop = m_inventory->takeSlot(*throwSlot)) { |
| 759 | world()->addEntity(ItemDrop::throwDrop(drop, position(), velocity(), throwDirection)); |
| 760 | break; |
| 761 | } |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | Maybe<Json> Player::receiveMessage(ConnectionId fromConnection, String const& message, JsonArray const& args) { |
| 767 | bool localMessage = fromConnection == world()->connection(); |
no test coverage detected