diff --git a/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaft.cs b/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaft.cs index e46a8d98..ff82c68d 100644 --- a/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaft.cs +++ b/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaft.cs @@ -2,6 +2,7 @@ using QSB.AuthoritySync; using QSB.EchoesOfTheEye.LightSensorSync.WorldObjects; using QSB.EchoesOfTheEye.RaftSync.TransformSync; +using QSB.ItemSync.WorldObjects; using QSB.Utility.LinkedWorldObject; using QSB.WorldSync; using System.Linq; @@ -10,8 +11,10 @@ using UnityEngine; namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects; -public class QSBRaft : LinkedWorldObject +public class QSBRaft : LinkedWorldObject, IQSBDropTarget { + IItemDropTarget IQSBDropTarget.AttachedObject => AttachedObject; + public override bool ShouldDisplayDebug() => false; protected override GameObject NetworkObjectPrefab => QSBNetworkManager.singleton.RaftPrefab; diff --git a/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftDock.cs b/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftDock.cs index 679466a0..cc8eba4c 100644 --- a/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftDock.cs +++ b/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftDock.cs @@ -1,10 +1,13 @@ -using QSB.Patches; +using QSB.ItemSync.WorldObjects; +using QSB.Patches; using QSB.WorldSync; namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects; -public class QSBRaftDock : WorldObject +public class QSBRaftDock : WorldObject, IQSBDropTarget { + IItemDropTarget IQSBDropTarget.AttachedObject => AttachedObject; + public override void SendInitialState(uint to) { } public void OnPressInteract() => diff --git a/QSB/ItemSync/ItemManager.cs b/QSB/ItemSync/ItemManager.cs index 1f1b6369..0c8ecda1 100644 --- a/QSB/ItemSync/ItemManager.cs +++ b/QSB/ItemSync/ItemManager.cs @@ -33,10 +33,10 @@ internal class ItemManager : WorldObjectManager // Sockets QSBWorldSync.Init(); - // drop targets + // other drop targets that don't already have world objects var listToInitFrom = QSBWorldSync.GetUnityObjects() .Where(x => x is IItemDropTarget and not (RaftDock or RaftController)) .SortDeterministic(); - QSBWorldSync.Init(listToInitFrom); + QSBWorldSync.Init(listToInitFrom); } } diff --git a/QSB/ItemSync/Messages/DropItemMessage.cs b/QSB/ItemSync/Messages/DropItemMessage.cs index 9cd4aea0..ba84b944 100644 --- a/QSB/ItemSync/Messages/DropItemMessage.cs +++ b/QSB/ItemSync/Messages/DropItemMessage.cs @@ -32,7 +32,7 @@ internal class DropItemMessage : QSBWorldObjectMessage().ObjectId; + tuple.dropTargetId = ((MonoBehaviour)customDropTarget).GetWorldObject().ObjectId; } tuple.sectorId = sector.GetWorldObject().ObjectId; @@ -46,7 +46,7 @@ internal class DropItemMessage : QSBWorldObjectMessage().AttachedObject; + : Data.dropTargetId.GetWorldObject().AttachedObject; var parent = customDropTarget == null ? Data.rigidBodyId.GetWorldObject().AttachedObject.transform diff --git a/QSB/ItemSync/WorldObjects/IQSBDropTarget.cs b/QSB/ItemSync/WorldObjects/IQSBDropTarget.cs new file mode 100644 index 00000000..454a64e2 --- /dev/null +++ b/QSB/ItemSync/WorldObjects/IQSBDropTarget.cs @@ -0,0 +1,8 @@ +using QSB.WorldSync; + +namespace QSB.ItemSync.WorldObjects; + +public interface IQSBDropTarget : IWorldObject +{ + new IItemDropTarget AttachedObject { get; } +} diff --git a/QSB/ItemSync/WorldObjects/QSBDropTarget.cs b/QSB/ItemSync/WorldObjects/QSBOtherDropTarget.cs similarity index 64% rename from QSB/ItemSync/WorldObjects/QSBDropTarget.cs rename to QSB/ItemSync/WorldObjects/QSBOtherDropTarget.cs index d569c69e..09c03ff6 100644 --- a/QSB/ItemSync/WorldObjects/QSBDropTarget.cs +++ b/QSB/ItemSync/WorldObjects/QSBOtherDropTarget.cs @@ -6,13 +6,13 @@ using UnityEngine; namespace QSB.ItemSync.WorldObjects; -public class QSBDropTarget : WorldObject +public class QSBOtherDropTarget : WorldObject, IQSBDropTarget { - public new IItemDropTarget AttachedObject => (IItemDropTarget)base.AttachedObject; + IItemDropTarget IQSBDropTarget.AttachedObject => (IItemDropTarget)AttachedObject; public override async UniTask Init(CancellationToken ct) { - if (base.AttachedObject is not IItemDropTarget) + if (AttachedObject is not IItemDropTarget) { throw new ArgumentException("QSBDropTarget.AttachedObject is not an IItemDropTarget!"); }