diff --git a/QSB/ModelShip/Messages/RespawnModelShipMessage.cs b/QSB/ModelShip/Messages/RespawnModelShipMessage.cs new file mode 100644 index 00000000..241e40a7 --- /dev/null +++ b/QSB/ModelShip/Messages/RespawnModelShipMessage.cs @@ -0,0 +1,13 @@ +using QSB.Messaging; +using QSB.Patches; +using QSB.WorldSync; + +namespace QSB.ModelShip.Messages; + +internal class RespawnModelShipMessage : QSBMessage +{ + public RespawnModelShipMessage(bool playEffects) : base(playEffects) { } + + public override void OnReceiveRemote() => + QSBPatch.RemoteCall(() => QSBWorldSync.GetUnityObject().RespawnModelShip(Data)); +} diff --git a/QSB/ModelShip/Messages/UseFlightConsole.cs b/QSB/ModelShip/Messages/UseFlightConsoleMessage.cs similarity index 88% rename from QSB/ModelShip/Messages/UseFlightConsole.cs rename to QSB/ModelShip/Messages/UseFlightConsoleMessage.cs index 6ef2df77..703d0c65 100644 --- a/QSB/ModelShip/Messages/UseFlightConsole.cs +++ b/QSB/ModelShip/Messages/UseFlightConsoleMessage.cs @@ -8,9 +8,9 @@ using QSB.WorldSync; namespace QSB.ModelShip.Messages; -internal class UseFlightConsole : QSBMessage +internal class UseFlightConsoleMessage : QSBMessage { - static UseFlightConsole() + static UseFlightConsoleMessage() { GlobalMessenger.AddListener(OWEvents.EnterRemoteFlightConsole, _ => Handler(true)); GlobalMessenger.AddListener(OWEvents.ExitRemoteFlightConsole, () => Handler(false)); @@ -20,11 +20,11 @@ internal class UseFlightConsole : QSBMessage { if (PlayerTransformSync.LocalInstance != null) { - new UseFlightConsole(active).Send(); + new UseFlightConsoleMessage(active).Send(); } } - private UseFlightConsole(bool active) : base(active) { } + private UseFlightConsoleMessage(bool active) : base(active) { } public override void OnReceiveLocal() { diff --git a/QSB/ModelShip/Patches/ModelShipPatches.cs b/QSB/ModelShip/Patches/ModelShipPatches.cs new file mode 100644 index 00000000..eebe6370 --- /dev/null +++ b/QSB/ModelShip/Patches/ModelShipPatches.cs @@ -0,0 +1,23 @@ +using HarmonyLib; +using QSB.Messaging; +using QSB.ModelShip.Messages; +using QSB.Patches; + +namespace QSB.ModelShip.Patches; + +public class ModelShipPatches : QSBPatch +{ + public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect; + + [HarmonyPrefix] + [HarmonyPatch(typeof(RemoteFlightConsole), nameof(RemoteFlightConsole.RespawnModelShip))] + private static void RemoteFlightConsole_RespawnModelShip(bool playEffects) + { + if (Remote) + { + return; + } + + new RespawnModelShipMessage(playEffects).Send(); + } +}