Code updates
This commit is contained in:
parent
34e0013ff4
commit
b51696fb45
6 changed files with 203 additions and 76 deletions
18
Patches/DisplayManager_GetLabeledEmptyDisplaySlots_Patch.cs
Normal file
18
Patches/DisplayManager_GetLabeledEmptyDisplaySlots_Patch.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Patches/Label_ClearLabel_Patch.cs
Normal file
47
Patches/Label_ClearLabel_Patch.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Patches/Restocker_IsDisplaySlotAvailableToRestock_Patch.cs
Normal file
17
Patches/Restocker_IsDisplaySlotAvailableToRestock_Patch.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue