mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-16 16:15:24 +00:00
59 lines
1.1 KiB
C#
59 lines
1.1 KiB
C#
using HarmonyLib;
|
|
using QSB.Messaging;
|
|
using QSB.Patches;
|
|
using QSB.ShipSync.Messages;
|
|
using QSB.ShipSync.WorldObjects;
|
|
using QSB.WorldSync;
|
|
|
|
namespace QSB.ShipSync.Patches;
|
|
|
|
[HarmonyPatch(typeof(ShipDetachableModule))]
|
|
internal class ShipDetachableModulePatches : QSBPatch
|
|
{
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(nameof(ShipDetachableModule.Detach))]
|
|
public static void Detach(ShipDetachableModule __instance)
|
|
{
|
|
if (Remote)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (__instance.isDetached)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
{
|
|
return;
|
|
}
|
|
|
|
__instance.GetWorldObject<QSBShipDetachableModule>().SendMessage(new ModuleDetachMessage());
|
|
}
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(nameof(ShipDetachableLeg.Detach))]
|
|
public static void Detach(ShipDetachableLeg __instance)
|
|
{
|
|
if (Remote)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (__instance.isDetached)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
{
|
|
return;
|
|
}
|
|
|
|
__instance.GetWorldObject<QSBShipDetachableLeg>().SendMessage(new LegDetachMessage());
|
|
}
|
|
}
|