From aa0ef06ac64542183a6f66bbfcad7d4cb45e9fd9 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:54:47 +1000 Subject: [PATCH] Predict item drop animation client-side --- source/game/StarItemDrop.cpp | 9 +++++++-- source/game/StarWorldClient.cpp | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/game/StarItemDrop.cpp b/source/game/StarItemDrop.cpp index 289de55..4bf41e5 100644 --- a/source/game/StarItemDrop.cpp +++ b/source/game/StarItemDrop.cpp @@ -240,8 +240,13 @@ void ItemDrop::update(float dt, uint64_t) { Root::singleton().itemDatabase()->loadItem(m_itemDescriptor.get(), m_item); m_netGroup.tickNetInterpolation(GlobalTimestep); if (m_owningEntity.get() != NullEntityId) { - updateTaken(false); - m_movementController.tickMaster(dt); + m_dropAge.update(world()->epochTime()); + if (!isMaster() && m_dropAge.elapsedTime() > 1.0f) + m_owningEntity.set(NullEntityId); + else { + updateTaken(false); + m_movementController.tickMaster(dt); + } } else { m_movementController.tickSlave(dt); diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index 0b15afd..de324ad 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -1125,8 +1125,10 @@ void WorldClient::update(float dt) { // If the drop is within DropDist and not owned, request it. if (itemDrop->canTake() && !m_requestedDrops.contains(itemDrop->entityId()) && distSquared < square(DropDist)) { m_requestedDrops.add(itemDrop->entityId()); - if (m_mainPlayer->itemsCanHold(itemDrop->item()) != 0) + if (m_mainPlayer->itemsCanHold(itemDrop->item()) != 0) { + itemDrop->takeBy(m_mainPlayer->entityId()); m_outgoingPackets.append(make_shared(itemDrop->entityId())); + } } } } else {