mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 00:32:43 +00:00
rafts: the beginning of initial state
This commit is contained in:
parent
21050a3f09
commit
cd42606d3b
14
QSB/EchoesOfTheEye/RaftSync/Messages/RaftSetDockMessage.cs
Normal file
14
QSB/EchoesOfTheEye/RaftSync/Messages/RaftSetDockMessage.cs
Normal 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);
|
||||
}
|
@ -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());
|
||||
}
|
||||
|
@ -22,4 +22,4 @@ public class RaftManager : WorldObjectManager
|
||||
QSBWorldSync.Init<QSBRaftDock, RaftDock>();
|
||||
QSBWorldSync.Init<QSBDamRaftLift, DamRaftLift>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects;
|
||||
|
||||
public interface IQSBRaftCarrier : IWorldObject { }
|
@ -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> { }
|
||||
|
@ -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}");
|
||||
}
|
||||
}
|
||||
|
13
QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftCarrier.cs
Normal file
13
QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftCarrier.cs
Normal 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 { }
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user