-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatch.cs
More file actions
161 lines (144 loc) · 5.94 KB
/
Copy pathPatch.cs
File metadata and controls
161 lines (144 loc) · 5.94 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using System.Reflection.Emit;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System;
using System.IO;
using BepInEx.Logging;
using HarmonyLib;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using UnityEngine.Rendering;
using Steamworks;
using rail;
[module: UnverifiableCode]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
namespace DSPMultiplyStackSize
{
[HarmonyPatch]
internal class Patch
{
public static ItemProto selectedProto;
//アイテムをクリックしたら情報を表示
[HarmonyPrefix, HarmonyPatch(typeof(UIItemPicker), "OnBoxMouseDown")]
public static bool UIItemPicker_OnBoxMouseDowne_PrePatch(UIItemPicker __instance)
{
if (Main.stackSizeChangerMode)
{
if (__instance.hoveredIndex >= 0)
{
selectedProto = __instance.protoArray[__instance.hoveredIndex];
if (selectedProto != null)
{
//UI.selectedItem.SetActive(true);
UI.selectedItemName.GetComponent<Text>().text = selectedProto.name;
UI.selectedItemIcon.transform.Find("icon 1").gameObject.SetActive(true);
UI.selectedItemIcon.transform.Find("icon 1").GetComponent<Image>().sprite = selectedProto.iconSprite;
UI.selectedItemStackSizeInput.GetComponent<InputField>().text = selectedProto.StackSize.ToString();
return false;
}
}else
{
//UI.selectedItem.SetActive(false);
UI.selectedItemName.GetComponent<Text>().text = "";
UI.selectedItemIcon.transform.Find("icon 1").gameObject.SetActive(false);
UI.selectedItemStackSizeInput.GetComponent<InputField>().text = "";
}
}
return true;
}
//タブを切り替えたら選択アイテムをリセット
[HarmonyPostfix, HarmonyPatch(typeof(UIItemPicker), "OnTypeButtonClick")]
public static void UIItemPicker_OnTypeButtonClick_PostPatch(UIItemPicker __instance)
{
if (Main.stackSizeChangerMode)
{
//UI.selectedItem.SetActive(false);
UI.selectedItemName.GetComponent<Text>().text = "";
UI.selectedItemIcon.transform.Find("icon 1").gameObject.SetActive(false);
UI.selectedItemStackSizeInput.GetComponent<InputField>().text = "";
UI.refreshNumTexts();
}
}
//スタックサイズを表示
[HarmonyPostfix, HarmonyPatch(typeof(UIItemPicker), "_OnOpen")]
public static void UIItemPicker_OnUpdate_Patch(UIItemPicker __instance)
{
if (Main.stackSizeChangerMode)
{
UI.numTextsBase.SetActive(true);
UI.btnBox.SetActive(true);
UI.resetButton.SetActive(true);
UI.selectedItem.SetActive(true);
UI.selectedItemName.GetComponent<Text>().text = "";
UI.selectedItemIcon.transform.Find("icon 1").gameObject.SetActive(false);
UI.selectedItemStackSizeInput.GetComponent<InputField>().text = "";
UI.refreshNumTexts();
}
else
{
UI.selectedItem.SetActive(false);
UI.numTextsBase.SetActive(false);
UI.btnBox.SetActive(false);
UI.resetButton.SetActive(false);
}
}
//スタックサイズを表示
[HarmonyPostfix, HarmonyPatch(typeof(UIItemPicker), "_OnClose")]
public static void UIItemPicker_Close_Patch(UIItemPicker __instance)
{
Main.stackSizeChangerMode = false;
}
//起動後のスタックサイズ修正
[HarmonyPostfix,HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
[HarmonyPriority(1)]
public static void VFPreload_PreloadThread_Patch()
{
if (!Main.StackSizeUpdated)
{
LogManager.Logger.LogInfo("Apply Multiply Stack Size.");
foreach (var item in LDB.items.dataArray)
{
if (item != null)
{
int stacksize = item.StackSize * Main.configMultiplyStackSize.Value;
Main.stackSizeDictionaryOrigin.Add(item.ID, stacksize);
if (Main.stackSizeDictionary.ContainsKey(item.ID))
{
stacksize = Main.stackSizeDictionary[item.ID];
}
item.StackSize = stacksize;
StorageComponent.itemStackCount[item.ID] = stacksize;
}
}
Main.StackSizeUpdated = true;
}
}
//メカのワーパースロットのスタックサイズ修正1
[HarmonyPostfix,HarmonyPatch(typeof(Mecha), "Init")]
public static void Mecha_Init_Patch(Mecha __instance)
{
if (Main.editWarperSlotStackSize.Value)
{
__instance.warpStorage.SetFilter(0, 1210, LDB.items.Select(1210).StackSize);
}
}
//メカのワーパースロットのスタックサイズ修正2
[HarmonyPostfix,HarmonyPatch(typeof(Mecha), "SetForNewGame")]
public static void Mecha_SetForNewGame_Patch(Mecha __instance)
{
if (Main.editWarperSlotStackSize.Value)
{
__instance.warpStorage.SetFilter(0, 1210, LDB.items.Select(1210).StackSize);
}
}
}
}