-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpgradeItemMenu.cs
32 lines (29 loc) · 979 Bytes
/
UpgradeItemMenu.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using HarmonyLib;
using UnityEngine;
namespace DarkwoodCustomizer;
public static class UpgradeItemMenuPatch
{
public static Vector2 VanillaValue = new(0, 0);
public static Vector2 CraftingPos = new(0, 0);
[HarmonyPatch(typeof(UpgradeItemMenu), nameof(UpgradeItemMenu.open))]
[HarmonyPrefix]
public static void UpgradeMenuOpened(UpgradeItemMenu __instance, InvItemClass invItemClass)
{
if (!__instance.gameObject.TryGetComponent<PositionMe>(out var positionMe)) return;
if (VanillaValue is { x: 0, y: 0 })
{
VanillaValue.x = positionMe.offset.x;
VanillaValue.y = positionMe.offset.y;
}
if (Plugin.WorkbenchInventoryModification.Value)
{
var extraSlots = Plugin.CraftingRightSlots.Value - 5f;
var xPosition = 119f + 31f * extraSlots;
positionMe.offset = new Vector2(CraftingPos.x + xPosition, CraftingPos.y);
}
else
{
positionMe.offset = new Vector2(VanillaValue.x, VanillaValue.y);
}
}
}