Repository navigation
Expand file tree
/
Copy pathSkillBasePatch.cs
More file actions
263 lines (226 loc) · 9.38 KB
/
Copy pathSkillBasePatch.cs
File metadata and controls
263 lines (226 loc) · 9.38 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
using HarmonyLib;
using MelonLoader;
using Il2CppScheduleOne;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Effects;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Levelling;
using Il2CppScheduleOne.ObjectScripts;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Property;
using Il2CppScheduleOne.UI.Shop;
using UnityEngine;
namespace SkillTree
{
/// <summary>
/// ADD POINTS AT LEVEL UP
/// </summary>
/*[HarmonyPatch(typeof(LevelManager), "IncreaseTier")]
public static class LevelUp_Patch
{
[HarmonyPostfix]
public static void Postfix()
{
if (Core.Instance != null)
Core.Instance.AttPoints(true);
}
}*/
/// <summary>
/// CHANGE THE RANK NECESSARY TO UNLOCK
/// </summary>
public static class ItemUnlocker
{
private static readonly Dictionary<string, FullRank> TargetRanks = new Dictionary<string, FullRank>
{
{ "moisturepreservingpot", new FullRank(ERank.Hoodlum, 5) },
{ "ledgrowlight", new FullRank(ERank.Hoodlum, 3) },
{ "plasticpot", new FullRank(ERank.Street_Rat, 5) },
{ "halogengrowlight", new FullRank(ERank.Street_Rat, 5) },
{ "suspensionrack", new FullRank(ERank.Street_Rat, 5) },
{ "airpot", new FullRank(ERank.Peddler, 2) },
{ "cauldron", new FullRank(ERank.Bagman, 3) },
{ "brickpress", new FullRank(ERank.Bagman, 5) },
{ "dryingrack", new FullRank(ERank.Street_Rat, 5) }
};
public static void UnlockSpecificItems()
{
var registry = Registry.Instance;
if (registry == null) return;
Il2CppSystem.Collections.Generic.List<ItemDefinition> allItems = registry.GetAllItems();
if (allItems == null) return;
int patchedCount = 0;
foreach (var def in allItems)
{
if (def == null || string.IsNullOrEmpty(def.ID)) continue;
string id = def.ID.ToLowerInvariant();
if (TargetRanks.TryGetValue(id, out FullRank rankAlvo))
{
var storable = def as StorableItemDefinition;
if (storable != null)
{
storable.RequiredRank = rankAlvo;
storable.RequiresLevelToPurchase = true;
patchedCount++;
MelonLogger.Msg($"[SkillTree Unlocker] Item {id} updated to Rank: {rankAlvo.Rank}, Tier: {rankAlvo.Tier}");
}
}
}
MelonLogger.Msg($"[SkillTree Unlocker] Total of {patchedCount} items successfully remapped.");
}
}
/// <summary>
/// ADD ITEMS TO HARDWARE STORES
/// </summary>
[HarmonyPatch(typeof(ShopInterface), "Awake")]
public static class ShopInjectionPatch
{
private static List<string> itemIdsToInject = new List<string>
{
"moisturepreservingpot",
"ledgrowlight",
"plasticpot",
"halogengrowlight",
"suspensionrack",
"airpot",
"dryingrack"
};
[HarmonyPostfix]
public static void Postfix(ShopInterface __instance)
{
if (__instance.ShopCode.ToLower().Contains("hardware") || __instance.ShopCode.ToLower().Contains("handy_hanks"))
{
StorableItemDefinition[] allItems = Resources.FindObjectsOfTypeAll<StorableItemDefinition>();
foreach (string id in itemIdsToInject)
{
bool alreadyExists = false;
foreach (var listing in __instance.Listings)
{
if (listing.Item != null && listing.Item.ID.ToLower() == id.ToLower())
{
alreadyExists = true;
break;
}
}
if (alreadyExists)
continue;
StorableItemDefinition targetItem = System.Array.Find(allItems, x => x.ID.ToLower() == id);
if (targetItem != null)
{
ShopListing newListing = new ShopListing();
newListing.Item = targetItem;
if (id == "moisturepreservingpot")
{
newListing.OverridePrice = true;
newListing.OverriddenPrice = 125f;
}
if (id == "ledgrowlight")
{
newListing.OverridePrice = true;
newListing.OverriddenPrice = 200f;
}
if (id == "plasticpot")
{
newListing.OverridePrice = true;
newListing.OverriddenPrice = 50f;
}
if (id == "halogengrowlight")
{
newListing.OverridePrice = true;
newListing.OverriddenPrice = 100f;
}
if (id == "suspensionrack")
{
newListing.OverridePrice = true;
newListing.OverriddenPrice = 100f;
}
if (id == "airpot")
{
newListing.OverridePrice = true;
newListing.OverriddenPrice = 300f;
}
if (id == "dryingrack")
{
newListing.OverridePrice = true;
newListing.OverriddenPrice = 400f;
}
Traverse trv = Traverse.Create(newListing);
if (newListing.IsUnlimitedStock)
trv.Field("isUnlimitedStock").SetValue(true);
else if (trv.Field("_isUnlimitedStock").FieldExists())
trv.Field("_isUnlimitedStock").SetValue(true);
__instance.Listings.Add(newListing);
newListing.Initialize(__instance);
__instance.CreateListingUI(newListing);
//Traverse.Create(__instance).Method("CreateListingUI", new object[] { newListing }).GetValue();
MelonLogger.Msg($"[SkillTree Shop] Item successfully injected: {targetItem.Name}");
}
}
}
}
/// <summary>
/// FIX MOVESPEED OF EFFECTS Athletic AND Energizing
/// </summary>
[HarmonyPatch]
public static class SpeedEffect_SkillHarmony_Patch
{
[HarmonyPatch(typeof(Athletic), "ApplyToPlayer")]
[HarmonyPostfix]
public static void Athletic_Apply_Postfix()
{
float baseWithSkill = SkillPatchStats.PlayerMovespeed.MovespeedBase;
PlayerSingleton<PlayerMovement>.Instance.MoveSpeedMultiplier = baseWithSkill + 0.3f;
}
[HarmonyPatch(typeof(Energizing), "ApplyToPlayer")]
[HarmonyPostfix]
public static void Energizing_Apply_Postfix()
{
float baseWithSkill = SkillPatchStats.PlayerMovespeed.MovespeedBase;
PlayerSingleton<PlayerMovement>.Instance.MoveSpeedMultiplier = baseWithSkill + 0.15f;
}
[HarmonyPatch(typeof(Athletic), "ClearFromPlayer")]
[HarmonyPostfix]
public static void Athletic_Clear_Postfix()
{
PlayerSingleton<PlayerMovement>.Instance.MoveSpeedMultiplier = SkillPatchStats.PlayerMovespeed.MovespeedBase;
}
[HarmonyPatch(typeof(Energizing), "ClearFromPlayer")]
[HarmonyPostfix]
public static void Energizing_Clear_Postfix()
{
PlayerSingleton<PlayerMovement>.Instance.MoveSpeedMultiplier = SkillPatchStats.PlayerMovespeed.MovespeedBase;
}
}
}
public static class QuickPackagers
{
public static bool Add = false;
}
[HarmonyPatch]
public static class RouteExpanderPatch
{
[HarmonyPatch(typeof(PackagingStation), "Awake")]
[HarmonyPostfix]
public static void Postfix_Speed(PackagingStation __instance)
{
if (QuickPackagers.Add)
__instance.PackagerEmployeeSpeedMultiplier = 2f;
}
}
public static class StackCache
{
public static Dictionary<string, int> ItemStack = new Dictionary<string, int>();
public static bool IsLoaded = false;
public static void FillCache(Il2CppSystem.Collections.Generic.List<ItemDefinition> business)
{
if (IsLoaded) return;
foreach (var c in business)
{
string key = c.name;
if (!ItemStack.ContainsKey(key))
ItemStack.Add(key, c.StackLimit);
}
IsLoaded = true;
MelonLogger.Msg("ItemStack Memory successfully stored!");
}
}
}