diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-08-18 20:03:06 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-08-18 20:03:06 +1000 |
commit | b51e174bdc158187fc110dc4a947946d3dc329c1 (patch) | |
tree | c1a61ba9edaa5ff0628f4275d16392ca12ddd4dd /source/game/StarPlayer.cpp | |
parent | ab03c224dd154a4cce9cf60e20bb166e57f33d01 (diff) |
Item drops inherit player velocity, other stuff
Diffstat (limited to 'source/game/StarPlayer.cpp')
-rw-r--r-- | source/game/StarPlayer.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source/game/StarPlayer.cpp b/source/game/StarPlayer.cpp index a78d300..a711f4d 100644 --- a/source/game/StarPlayer.cpp +++ b/source/game/StarPlayer.cpp @@ -717,10 +717,11 @@ void Player::dropItem() { if (!canUseTool()) return; - for (auto throwSlot : {m_inventory->primaryHeldSlot(), m_inventory->secondaryHeldSlot()}) { + Vec2F throwDirection = world()->geometry().diff(aimPosition(), position()); + for (auto& throwSlot : {m_inventory->primaryHeldSlot(), m_inventory->secondaryHeldSlot()}) { if (throwSlot) { if (auto drop = m_inventory->takeSlot(*throwSlot)) { - world()->addEntity(ItemDrop::throwDrop(drop, position(), world()->geometry().diff(aimPosition(), position()))); + world()->addEntity(ItemDrop::throwDrop(drop, position(), velocity(), throwDirection)); break; } } @@ -979,17 +980,20 @@ void Player::update(float dt, uint64_t) { m_humanoid->setMovingBackwards(false); m_humanoid->setRotation(m_movementController->rotation()); + bool suppressedItems = !canUseTool(); + auto loungeAnchor = as<LoungeAnchor>(m_movementController->entityAnchor()); if (loungeAnchor && loungeAnchor->dance) m_humanoid->setDance(*loungeAnchor->dance); - else + else if ((!suppressedItems && (m_tools->primaryHandItem() || m_tools->altHandItem())) + || m_humanoid->danceCyclicOrEnded() || m_movementController->running()) m_humanoid->setDance({}); bool isClient = world()->isClient(); if (isClient) m_armor->setupHumanoidClothingDrawables(*m_humanoid, forceNude()); - m_tools->suppressItems(!canUseTool()); + m_tools->suppressItems(suppressedItems); m_tools->tick(dt, m_shifting, m_pendingMoves); if (auto overrideFacingDirection = m_tools->setupHumanoidHandItems(*m_humanoid, position(), aimPosition())) @@ -2348,7 +2352,7 @@ void Player::dropSelectedItems(function<bool(ItemPtr)> filter) { m_inventory->forEveryItem([&](InventorySlot const&, ItemPtr& item) { if (item && (!filter || filter(item))) - world()->addEntity(ItemDrop::throwDrop(take(item), position(), Vec2F::withAngle(Random::randf(-Constants::pi, Constants::pi)), true)); + world()->addEntity(ItemDrop::throwDrop(take(item), position(), velocity(), Vec2F::withAngle(Random::randf(-Constants::pi, Constants::pi)), true)); }); } |