Files
BoneSync/BoneSync/Patching/GripPatches.cs
2025-03-13 20:07:19 +02:00

43 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BoneSync.Data;
using BoneSync.Sync;
using BoneSync.Sync.Components;
using HarmonyLib;
using MelonLoader;
using StressLevelZero.Interaction;
namespace BoneSync.Patching
{
// Credit: Entanglement, this patch is based on the one from Entanglement
[HarmonyPatch(typeof(ForcePullGrip), nameof(ForcePullGrip.OnFarHandHoverUpdate))]
public class ForcePullPatch
{
public static void Prefix(ForcePullGrip __instance, ref bool __state, Hand hand)
{
__state = __instance.pullCoroutine != null;
}
public static void Postfix(ForcePullGrip __instance, ref bool __state, Hand hand)
{
if (!(__instance.pullCoroutine != null && !__state))
return;
SyncLogger.Msg("ForcePullGrip.OnFarHandHoverUpdate: " + __instance.name + " Hand: " + hand.name);
InteractableHost interactableHost = __instance?.grip?.host;
if (interactableHost == null)
{
SyncLogger.Error("InteractableHost is null for " + __instance.name);
return;
}
Syncable syncable = ObjectSync.MakeOrGetSyncable(interactableHost);
syncable?.RegisterSyncable();
}
}
}