Code updates

This commit is contained in:
pan.codes 2025-06-08 21:39:23 +02:00
parent 34e0013ff4
commit b51696fb45
6 changed files with 203 additions and 76 deletions

View file

@ -0,0 +1,18 @@
using HarmonyLib;
using System.Collections.Generic;
using System.Linq;
namespace DisableShelves
{
public static partial class ShelfLabelPatch
{
[HarmonyPatch(typeof(DisplayManager), "GetLabeledEmptyDisplaySlots")]
public static class DisplayManager_GetLabeledEmptyDisplaySlots_Patch
{
public static void Postfix(ref List<DisplaySlot> __result)
{
__result = __result.Where(x => x.GetLabel().IsEnabled()).ToList();
}
}
}
}

View file

@ -0,0 +1,47 @@
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
namespace DisableShelves
{
public static partial class ShelfLabelPatch
{
[HarmonyPatch(typeof(Label), "SetProductIcon")]
public static class Label_SetProductIcon_Patch
{
public static void Prefix(Label __instance, int productID)
{
__instance.IsEnabled();
}
}
[HarmonyPatch(typeof(Label), "ClearLabel")]
[HarmonyPriority(10000)]
public static class Label_ClearLabel_Patch
{
public static bool Prefix(Label __instance)
{
Plugin.StaticLogger.LogInfo("Label: " + __instance.ToGUID());
Plugin.StaticLogger.LogInfo("Running prefix patcher");
var fi_m_DisplaySlot = typeof(Label).GetField("m_DisplaySlot", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var displaySlot = ((DisplaySlot)fi_m_DisplaySlot.GetValue(__instance));
if (displaySlot != null)
{
if (displaySlot.HasProduct)
{
bool all = Plugin.MultiModeShortcut.Value.IsPressed();
Plugin.StaticLogger.LogInfo("Multi Mode Shortcut pressed: " + all);
Plugin.StaticLogger.LogInfo("Label is shelf");
if (__instance.IsEnabled())
__instance.Disable(all);
else
__instance.Enable(all);
Plugin.StaticLogger.LogWarning("Returning false");
return false;
}
}
return true;
}
}
}
}

View file

@ -0,0 +1,17 @@
using HarmonyLib;
namespace DisableShelves
{
public static partial class ShelfLabelPatch
{
[HarmonyPatch(typeof(Restocker), "IsDisplaySlotAvailableToRestock")]
public static class Restocker_IsDisplaySlotAvailableToRestock_Patch
{
public static void Postfix(DisplaySlot displaySlot, ref bool __result)
{
if (!__result) return;
if (!displaySlot.GetLabel().IsEnabled()) __result = false;
}
}
}
}