From 75ff37dafcfad6698cbaede54c409f6111b47c88 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sun, 27 Feb 2022 13:07:42 -0800 Subject: [PATCH] RaftDock.OnPressInteract sync --- .../RaftDockOnPressInteractMessage.cs | 10 +++++++ .../RaftSync/Messages/RaftUndockMessage.cs | 10 ------- .../RaftSync/Patches/RaftPatches.cs | 30 +++++++++++++++++++ .../RaftSync/WorldObjects/QSBRaftDock.cs | 2 +- 4 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 QSB/EchoesOfTheEye/RaftSync/Messages/RaftDockOnPressInteractMessage.cs delete mode 100644 QSB/EchoesOfTheEye/RaftSync/Messages/RaftUndockMessage.cs diff --git a/QSB/EchoesOfTheEye/RaftSync/Messages/RaftDockOnPressInteractMessage.cs b/QSB/EchoesOfTheEye/RaftSync/Messages/RaftDockOnPressInteractMessage.cs new file mode 100644 index 00000000..b867ad67 --- /dev/null +++ b/QSB/EchoesOfTheEye/RaftSync/Messages/RaftDockOnPressInteractMessage.cs @@ -0,0 +1,10 @@ +using QSB.EchoesOfTheEye.RaftSync.WorldObjects; +using QSB.Messaging; + +namespace QSB.EchoesOfTheEye.RaftSync.Messages +{ + public class RaftDockOnPressInteractMessage : QSBWorldObjectMessage + { + public override void OnReceiveRemote() => WorldObject.OnPressInteract(); + } +} diff --git a/QSB/EchoesOfTheEye/RaftSync/Messages/RaftUndockMessage.cs b/QSB/EchoesOfTheEye/RaftSync/Messages/RaftUndockMessage.cs deleted file mode 100644 index 3f424cfa..00000000 --- a/QSB/EchoesOfTheEye/RaftSync/Messages/RaftUndockMessage.cs +++ /dev/null @@ -1,10 +0,0 @@ -using QSB.EchoesOfTheEye.RaftSync.WorldObjects; -using QSB.Messaging; - -namespace QSB.EchoesOfTheEye.RaftSync.Messages -{ - public class RaftUndockMessage : QSBWorldObjectMessage - { - public override void OnReceiveRemote() => WorldObject.UndockFromRaftDock(); - } -} diff --git a/QSB/EchoesOfTheEye/RaftSync/Patches/RaftPatches.cs b/QSB/EchoesOfTheEye/RaftSync/Patches/RaftPatches.cs index 5390b7c8..7f778633 100644 --- a/QSB/EchoesOfTheEye/RaftSync/Patches/RaftPatches.cs +++ b/QSB/EchoesOfTheEye/RaftSync/Patches/RaftPatches.cs @@ -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().SendMessage(new RaftDockOnPressInteractMessage()); + return false; + } + + if (__instance._gearInterface != null) + { + __instance._gearInterface.PlayFailure(); + } + + return false; + } } } diff --git a/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftDock.cs b/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftDock.cs index 088bcd2e..35a43cf0 100644 --- a/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftDock.cs +++ b/QSB/EchoesOfTheEye/RaftSync/WorldObjects/QSBRaftDock.cs @@ -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) {