33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using Global.Shared.Plugin;
|
|
using HarmonyLib;
|
|
using Sandbox.Game.Entities.Blocks;
|
|
|
|
namespace Global.Patches
|
|
{
|
|
[HarmonyPatch(typeof(MyMechanicalConnectionBlockBase))]
|
|
public class MyMechanicalConnectionBlockBasePatch
|
|
{
|
|
public static bool IsCreatingSubPart;
|
|
|
|
[HarmonyPatch("RaiseAttachedEntityChanged")]
|
|
[HarmonyPrefix]
|
|
public static void RaiseAttachedEntityChanged(MyMechanicalConnectionBlockBase __instance)
|
|
{
|
|
GlobalStatic.OcTreeHandler.GridTree.Get(__instance.CubeGrid.EntityId)?.RaiseAttachedEntityChanged();
|
|
}
|
|
|
|
[HarmonyPatch("CreateTopPartAndAttach")]
|
|
[HarmonyPrefix]
|
|
public static void CreateTopPrefix(long builtBy, bool smallToLarge, bool instantBuild)
|
|
{
|
|
IsCreatingSubPart = true;
|
|
}
|
|
|
|
[HarmonyPatch("CreateTopPartAndAttach")]
|
|
[HarmonyPostfix]
|
|
public static void CreateTopPostfix(long builtBy, bool smallToLarge, bool instantBuild)
|
|
{
|
|
IsCreatingSubPart = false;
|
|
}
|
|
}
|
|
} |