-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathPatchInventoryGrid.cs
More file actions
83 lines (82 loc) · 3.09 KB
/
PatchInventoryGrid.cs
File metadata and controls
83 lines (82 loc) · 3.09 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace QuickerStack
{
[HarmonyPatch(typeof(InventoryGrid))]
internal static class PatchInventoryGrid
{
[HarmonyPatch("UpdateGui")]
[HarmonyPostfix]
internal static void UpdateGui(InventoryGrid __instance, Player player, ItemDrop.ItemData dragItem, Inventory ___m_inventory, List<Element> ___m_elements)
{
if (player == null || player.GetInventory() != ___m_inventory)
{
return;
}
int width = ___m_inventory.GetWidth();
UserConfig playerConfig = QuickerStackPlugin.GetPlayerConfig(player.GetPlayerID());
foreach (ItemDrop.ItemData itemData in ___m_inventory.GetAllItems())
{
if (playerConfig.IsMarked(itemData.m_gridPos))
{
int index = itemData.m_gridPos.y * width + itemData.m_gridPos.x;
___m_elements[index].m_queued.enabled = true;
}
}
}
[HarmonyPatch("OnRightClick")]
[HarmonyPrefix]
internal static bool OnRightClick(InventoryGrid __instance, UIInputHandler element)
{
Player localPlayer = Player.m_localPlayer;
if (localPlayer.IsTeleporting())
{
return true;
}
if (InventoryGui.instance.GetDragGo())
{
return true;
}
if (!Input.GetKey(QuickerStackPlugin.ExclusionKey) && !Input.GetKey(QuickerStackPlugin.ExclusionKey2))
{
return true;
}
GameObject gameObject = element.gameObject;
Vector2i buttonPos = __instance.GetButtonPos(gameObject);
ItemDrop.ItemData itemAt = __instance.GetInventory().GetItemAt(buttonPos.x, buttonPos.y);
QuickerStackPlugin.GetPlayerConfig(localPlayer.GetPlayerID()).Toggle(itemAt.m_shared);
return false;
}
[HarmonyPatch("OnLeftClick")]
[HarmonyPrefix]
internal static bool OnLeftClick(InventoryGrid __instance, UIInputHandler clickHandler)
{
if (InventoryGui.instance.GetPlayerGrid() != __instance)
{
return true;
}
Player localPlayer = Player.m_localPlayer;
if (localPlayer.IsTeleporting())
{
return true;
}
if (InventoryGui.instance.GetDragGo())
{
return true;
}
if (!Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt))
{
return true;
}
GameObject gameObject = clickHandler.gameObject;
Vector2i buttonPos = __instance.GetButtonPos(gameObject);
QuickerStackPlugin.GetPlayerConfig(localPlayer.GetPlayerID()).Toggle(buttonPos);
return false;
}
}
}