-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
69 lines (57 loc) · 2.25 KB
/
Plugin.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
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
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using ProjectStar.Data;
using System.Collections.Generic;
using System.Linq;
namespace CatQuest3TrinketsTweak;
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
internal static new ManualLogSource Logger;
static HashSet<string> tweakedTrinkets = new();
private void Awake()
{
// Plugin startup logic
Logger = base.Logger;
new Harmony(MyPluginInfo.PLUGIN_GUID).PatchAll();
Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
}
static EquipmentItemData GetTrinket(string name) {
return AddressableSingletonScriptableObject<EquipmentDatabase>.Instance.contentTable.Values.FirstOrDefault(eq => eq.name == $"Equipment_Trinket_{name}");
}
public static void TweakTrinket(string trinketToTweak, params string[] trinketsToUse) {
if (IsTweaked(trinketToTweak))
return;
var trinket = GetTrinket(trinketToTweak);
var trinkets = trinketsToUse.Select(GetTrinket);
trinket.passiveAbilityDescription = trinkets.Join(t => t.passiveAbilityDescription, "\n");
var abilities = trinkets.SelectMany(t => t.abilities.abilityList).ToList();
trinket.abilities.abilityList = abilities;
tweakedTrinkets.Add($"Equipment_Trinket_{trinketToTweak}");
}
public static bool IsTweaked(string trinkedName) {
return tweakedTrinkets.Contains(trinkedName);
}
}
[HarmonyPatch(typeof(Prologue))]
class ProloguePatch {
[HarmonyPatch(nameof(Prologue.Start))]
[HarmonyPostfix]
static void StartPostfix() {
Plugin.Logger.LogInfo("Tweaking Lousy Boot");
Plugin.TweakTrinket("LousyBoot", "Warrior'sBraid", "OinkerNecklace", "BoarTusk", "MilkPawer");
}
}
[HarmonyPatch(typeof(EquipmentItemData))]
class EquipmentItemDataPatch {
[HarmonyPatch(nameof(EquipmentItemData.GetDescription))]
[HarmonyPrefix]
static bool GetDescriptionPrefix(EquipmentItemData __instance, ref (string, string) __result) {
if (Plugin.IsTweaked(__instance.name)) {
__result = ("", __instance.passiveAbilityDescription);
return false;
}
return true;
}
}