RaftDock.OnPressInteract sync

This commit is contained in:
JohnCorby 2022-02-27 13:07:42 -08:00
parent 712398fb38
commit 75ff37dafc
4 changed files with 41 additions and 11 deletions

View File

@ -0,0 +1,10 @@
using QSB.EchoesOfTheEye.RaftSync.WorldObjects;
using QSB.Messaging;
namespace QSB.EchoesOfTheEye.RaftSync.Messages
{
public class RaftDockOnPressInteractMessage : QSBWorldObjectMessage<QSBRaftDock>
{
public override void OnReceiveRemote() => WorldObject.OnPressInteract();
}
}

View File

@ -1,10 +0,0 @@
using QSB.EchoesOfTheEye.RaftSync.WorldObjects;
using QSB.Messaging;
namespace QSB.EchoesOfTheEye.RaftSync.Messages
{
public class RaftUndockMessage : QSBWorldObjectMessage<QSBRaftDock>
{
public override void OnReceiveRemote() => WorldObject.UndockFromRaftDock();
}
}

View File

@ -1,6 +1,8 @@
using HarmonyLib;
using QSB.AuthoritySync;
using QSB.EchoesOfTheEye.RaftSync.Messages;
using QSB.EchoesOfTheEye.RaftSync.WorldObjects;
using QSB.Messaging;
using QSB.Patches;
using QSB.Utility;
using QSB.WorldSync;
@ -30,5 +32,33 @@ namespace QSB.EchoesOfTheEye.RaftSync.Patches
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(RaftDock), nameof(RaftDock.OnPressInteract))]
private static bool OnPressInteract(RaftDock __instance)
{
if (__instance._raft != null && __instance._state == RaftCarrier.DockState.Docked)
{
__instance._raftUndockCountDown = __instance._raft.dropDelay;
__instance._state = RaftCarrier.DockState.WaitForExit;
__instance._raft.SetRailingRaised(true);
if (__instance._gearInterface != null)
{
__instance._gearInterface.AddRotation(90f);
}
__instance.enabled = true;
__instance.GetWorldObject<QSBRaftDock>().SendMessage(new RaftDockOnPressInteractMessage());
return false;
}
if (__instance._gearInterface != null)
{
__instance._gearInterface.PlayFailure();
}
return false;
}
}
}

View File

@ -9,7 +9,7 @@ namespace QSB.EchoesOfTheEye.RaftSync.WorldObjects
// todo SendInitialState
}
public void UndockFromRaftDock()
public void OnPressInteract()
{
if (AttachedObject._raft != null && AttachedObject._state == RaftCarrier.DockState.Docked)
{