store location before pick up item instead of after drop

This commit is contained in:
JohnCorby 2022-03-23 14:32:15 -07:00
parent e44b6aebdf
commit bfbfc6ffd9

View File

@ -22,14 +22,17 @@ internal class QSBItem<T> : WorldObject<T>, IQSBItem
{ {
await UniTask.WaitUntil(() => QSBWorldSync.AllObjectsAdded, cancellationToken: ct); await UniTask.WaitUntil(() => QSBWorldSync.AllObjectsAdded, cancellationToken: ct);
SetLastLocation(); StoreLocation();
QSBPlayerManager.OnRemovePlayer += OnPlayerLeave; QSBPlayerManager.OnRemovePlayer += OnPlayerLeave;
} }
public override void OnRemoval() => QSBPlayerManager.OnRemovePlayer -= OnPlayerLeave; public override void OnRemoval() => QSBPlayerManager.OnRemovePlayer -= OnPlayerLeave;
private void SetLastLocation() /// <summary>
/// store the last location so we can use it on player leave
/// </summary>
private void StoreLocation()
{ {
_lastParent = AttachedObject.transform.parent; _lastParent = AttachedObject.transform.parent;
_lastPosition = AttachedObject.transform.localPosition; _lastPosition = AttachedObject.transform.localPosition;
@ -77,17 +80,14 @@ internal class QSBItem<T> : WorldObject<T>, IQSBItem
public ItemType GetItemType() => AttachedObject.GetItemType(); public ItemType GetItemType() => AttachedObject.GetItemType();
public void PickUpItem(Transform holdTransform) public void PickUpItem(Transform holdTransform)
=> QSBPatch.RemoteCall(() => AttachedObject.PickUpItem(holdTransform));
public void DropItem(Vector3 position, Vector3 normal, Sector sector)
{ {
StoreLocation();
QSBPatch.RemoteCall(() => AttachedObject.PickUpItem(holdTransform));
}
public void DropItem(Vector3 position, Vector3 normal, Sector sector) =>
QSBPatch.RemoteCall(() => AttachedObject.DropItem(position, normal, sector.transform, sector, null)); QSBPatch.RemoteCall(() => AttachedObject.DropItem(position, normal, sector.transform, sector, null));
SetLastLocation();
}
public void OnCompleteUnsocket() public void OnCompleteUnsocket() =>
{
QSBPatch.RemoteCall(AttachedObject.OnCompleteUnsocket); QSBPatch.RemoteCall(AttachedObject.OnCompleteUnsocket);
SetLastLocation();
}
} }