Predict item drop animation client-side

This commit is contained in:
Kae 2023-08-18 16:54:47 +10:00
parent 50ec1a0406
commit aa0ef06ac6
2 changed files with 10 additions and 3 deletions

View File

@ -240,8 +240,13 @@ void ItemDrop::update(float dt, uint64_t) {
Root::singleton().itemDatabase()->loadItem(m_itemDescriptor.get(), m_item); Root::singleton().itemDatabase()->loadItem(m_itemDescriptor.get(), m_item);
m_netGroup.tickNetInterpolation(GlobalTimestep); m_netGroup.tickNetInterpolation(GlobalTimestep);
if (m_owningEntity.get() != NullEntityId) { if (m_owningEntity.get() != NullEntityId) {
updateTaken(false); m_dropAge.update(world()->epochTime());
m_movementController.tickMaster(dt); if (!isMaster() && m_dropAge.elapsedTime() > 1.0f)
m_owningEntity.set(NullEntityId);
else {
updateTaken(false);
m_movementController.tickMaster(dt);
}
} }
else { else {
m_movementController.tickSlave(dt); m_movementController.tickSlave(dt);

View File

@ -1125,8 +1125,10 @@ void WorldClient::update(float dt) {
// If the drop is within DropDist and not owned, request it. // If the drop is within DropDist and not owned, request it.
if (itemDrop->canTake() && !m_requestedDrops.contains(itemDrop->entityId()) && distSquared < square(DropDist)) { if (itemDrop->canTake() && !m_requestedDrops.contains(itemDrop->entityId()) && distSquared < square(DropDist)) {
m_requestedDrops.add(itemDrop->entityId()); 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<RequestDropPacket>(itemDrop->entityId())); m_outgoingPackets.append(make_shared<RequestDropPacket>(itemDrop->entityId()));
}
} }
} }
} else { } else {