rafts: the beginning of initial state

This commit is contained in:
JohnCorby 2022-03-11 06:40:00 -08:00
parent 21050a3f09
commit cd42606d3b
8 changed files with 42 additions and 34 deletions

View File

@ -0,0 +1,14 @@
using QSB.EchoesOfTheEye.RaftSync.WorldObjects;
using QSB.Messaging;
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.RaftSync.Messages;
public class RaftSetDockMessage : QSBWorldObjectMessage<QSBRaft, int>
{
public RaftSetDockMessage(RaftCarrier raftCarrier) :
base(raftCarrier != null ? raftCarrier.GetWorldObject<IQSBRaftCarrier>().ObjectId : -1) { }
public override void OnReceiveRemote() =>
WorldObject.SetDock(Data != -1 ? Data.GetWorldObject<IQSBRaftCarrier>() : null);
}

View File

@ -16,7 +16,7 @@ public class RaftPatches : QSBPatch
[HarmonyPrefix]
[HarmonyPatch(typeof(RaftController), nameof(RaftController.OnPressInteract))]
private static bool OnPressInteract(RaftController __instance)
private static bool RaftController_OnPressInteract(RaftController __instance)
{
__instance._interactReceiver.SetInteractionEnabled(false);
@ -35,6 +35,6 @@ public class RaftPatches : QSBPatch
[HarmonyPostfix]
[HarmonyPatch(typeof(RaftDock), nameof(RaftDock.OnPressInteract))]
private static void OnPressInteract(RaftDock __instance) =>
private static void RaftDock_OnPressInteract(RaftDock __instance) =>
__instance.GetWorldObject<QSBRaftDock>().SendMessage(new RaftDockOnPressInteractMessage());
}

View File

@ -22,4 +22,4 @@ public class RaftManager : WorldObjectManager
QSBWorldSync.Init<QSBRaftDock, RaftDock>();
QSBWorldSync.Init<QSBDamRaftLift, DamRaftLift>();
}
}
}

View File

@ -1,5 +0,0 @@
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects;
public interface IQSBRaftCarrier : IWorldObject { }

View File

@ -1,11 +1,3 @@
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects;
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects;
public class QSBDamRaftLift : WorldObject<DamRaftLift>, IQSBRaftCarrier
{
public override void SendInitialState(uint to)
{
// todo SendInitialState
}
}
public class QSBDamRaftLift : QSBRaftCarrier<DamRaftLift> { }

View File

@ -2,7 +2,10 @@
using Mirror;
using QSB.AuthoritySync;
using QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
using QSB.EchoesOfTheEye.RaftSync.Messages;
using QSB.EchoesOfTheEye.RaftSync.TransformSync;
using QSB.Messaging;
using QSB.Utility;
using QSB.WorldSync;
using System.Linq;
using System.Threading;
@ -57,13 +60,11 @@ public class QSBRaft : WorldObject<RaftController>
}
}
public override void SendInitialState(uint to)
{
// todo?? SendInitialState
public override void SendInitialState(uint to) =>
this.SendMessage(new RaftSetDockMessage(AttachedObject._dock));
if (AttachedObject._dock != null)
{
var qsbRaftCarrier = AttachedObject._dock.GetWorldObject<IQSBRaftCarrier>();
}
public void SetDock(IQSBRaftCarrier qsbRaftCarrier)
{
DebugLog.DebugWrite($"TODO: {this} dock = {qsbRaftCarrier}");
}
}

View File

@ -0,0 +1,13 @@
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects;
public abstract class QSBRaftCarrier<T> : WorldObject<T>, IQSBRaftCarrier where T : RaftCarrier
{
public override void SendInitialState(uint to)
{
// todo SendInitialState
}
}
public interface IQSBRaftCarrier : IWorldObject { }

View File

@ -1,14 +1,7 @@
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects;
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects;
public class QSBRaftDock : WorldObject<RaftDock>, IQSBRaftCarrier
public class QSBRaftDock : QSBRaftCarrier<RaftDock>
{
public override void SendInitialState(uint to)
{
// todo SendInitialState
}
public void OnPressInteract()
{
if (AttachedObject._raft != null && AttachedObject._state == RaftCarrier.DockState.Docked)