mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
Merge branch 'dev' into eote-ghost-lanterns
This commit is contained in:
commit
87e1878c23
@ -9,6 +9,8 @@ internal class MoveToCarryMessage : QSBWorldObjectMessage<IQSBItem>
|
||||
{
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
WorldObject.StoreLocation();
|
||||
|
||||
var player = QSBPlayerManager.GetPlayer(From);
|
||||
var itemType = WorldObject.GetItemType();
|
||||
|
||||
|
@ -44,6 +44,8 @@ internal class SocketItemMessage : QSBMessage<(SocketMessageType Type, int Socke
|
||||
return;
|
||||
}
|
||||
|
||||
qsbItem.StoreLocation();
|
||||
|
||||
var player = QSBPlayerManager.GetPlayer(From);
|
||||
player.HeldItem = qsbItem;
|
||||
|
||||
|
@ -9,4 +9,10 @@ public interface IQSBItem : IWorldObject
|
||||
void PickUpItem(Transform itemSocket);
|
||||
void DropItem(Vector3 position, Vector3 normal, Sector sector);
|
||||
void OnCompleteUnsocket();
|
||||
|
||||
/// <summary>
|
||||
/// store the last location when a remote player picks up/unsockets an item
|
||||
/// so we can drop/socket it if they leave while still holding it
|
||||
/// </summary>
|
||||
void StoreLocation();
|
||||
}
|
@ -29,11 +29,7 @@ public class QSBItem<T> : WorldObject<T>, IQSBItem
|
||||
|
||||
public override void OnRemoval() => QSBPlayerManager.OnRemovePlayer -= OnPlayerLeave;
|
||||
|
||||
/// <summary>
|
||||
/// store the last location when a remote player picks up an item
|
||||
/// so we can use it if they leave while still holding it
|
||||
/// </summary>
|
||||
private void StoreLocation()
|
||||
public void StoreLocation()
|
||||
{
|
||||
_lastParent = AttachedObject.transform.parent;
|
||||
_lastPosition = AttachedObject.transform.localPosition;
|
||||
@ -62,15 +58,16 @@ public class QSBItem<T> : WorldObject<T>, IQSBItem
|
||||
if (_lastSocket != null)
|
||||
{
|
||||
QSBPatch.RemoteCall(() => _lastSocket.PlaceIntoSocket(this));
|
||||
return;
|
||||
}
|
||||
|
||||
AttachedObject.transform.parent = _lastParent;
|
||||
AttachedObject.transform.localPosition = _lastPosition;
|
||||
AttachedObject.transform.localRotation = _lastRotation;
|
||||
AttachedObject.transform.localScale = Vector3.one;
|
||||
AttachedObject.SetSector(_lastSector?.AttachedObject);
|
||||
AttachedObject.SetColliderActivation(true);
|
||||
else
|
||||
{
|
||||
AttachedObject.transform.parent = _lastParent;
|
||||
AttachedObject.transform.localPosition = _lastPosition;
|
||||
AttachedObject.transform.localRotation = _lastRotation;
|
||||
AttachedObject.transform.localScale = Vector3.one;
|
||||
AttachedObject.SetSector(_lastSector?.AttachedObject);
|
||||
AttachedObject.SetColliderActivation(true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SendInitialState(uint to)
|
||||
@ -80,11 +77,8 @@ public class QSBItem<T> : WorldObject<T>, IQSBItem
|
||||
|
||||
public ItemType GetItemType() => AttachedObject.GetItemType();
|
||||
|
||||
public void PickUpItem(Transform holdTransform)
|
||||
{
|
||||
StoreLocation();
|
||||
public void PickUpItem(Transform holdTransform) =>
|
||||
QSBPatch.RemoteCall(() => AttachedObject.PickUpItem(holdTransform));
|
||||
}
|
||||
|
||||
public void DropItem(Vector3 position, Vector3 normal, Sector sector) =>
|
||||
QSBPatch.RemoteCall(() => AttachedObject.DropItem(position, normal, sector.transform, sector, null));
|
||||
|
Loading…
Reference in New Issue
Block a user