-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cs
146 lines (129 loc) · 4.48 KB
/
Main.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
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
using AddedFeats.Feats;
using AddedFeats.NewSpells;
using BlueprintCore.Blueprints.Configurators.Root;
using BlueprintCore.Utils;
using HarmonyLib;
using Kingmaker.Blueprints.JsonSystem;
using System;
using UnityModManagerNet;
using static UnityModManagerNet.UnityModManager.ModEntry;
using AddedFeats.Utils;
using Kingmaker.PubSubSystem;
using AddedFeats.Homebrew;
namespace AddedFeats
{
public static class Main
{
public static bool Enabled;
private static readonly ModLogger Logger = Logging.GetLogger(nameof(Main));
// private static readonly LogWrapper Logger = LogWrapper.Get("AddedFeats");
public static bool Load(UnityModManager.ModEntry modEntry)
{
try
{
var harmony = new Harmony(modEntry.Info.Id);
harmony.PatchAll();
EventBus.Subscribe(new BlueprintCacheInitHandler());
Logger.Log("Finished patching.");
}
catch (Exception e)
{
Logger.LogException("Failed to patch", e);
}
return true;
}
class BlueprintCacheInitHandler : IBlueprintCacheInitHandler
{
private static bool Initialized = false;
private static bool InitializeDelayed = false;
public void AfterBlueprintCachePatches()
{
try
{
if (InitializeDelayed)
{
Logger.Log("Already initialized blueprints cache.");
return;
}
InitializeDelayed = true;
ConfigureFeatsDelayed();
RootConfigurator.ConfigureDelayedBlueprints();
}
catch (Exception e)
{
Logger.LogException("Delayed blueprint configuration failed.", e);
}
}
public void BeforeBlueprintCachePatches()
{
}
public void BeforeBlueprintCacheInit()
{
}
public void AfterBlueprintCacheInit()
{
try
{
if (Initialized)
{
Logger.Log("Already initialized blueprints cache.");
return;
}
Initialized = true;
// First strings
LocalizationTool.LoadEmbeddedLocalizationPacks(
"AddedFeats.Strings.Homebrew.json",
"AddedFeats.Strings.Features.json",
"AddedFeats.Strings.Settings.json",
"AddedFeats.Strings.Spells.json");
// Then settings
Settings.Init();
ConfigureHomebrew();
ConfigureFeats();
ConfigureSpells();
}
catch (Exception e)
{
Logger.LogException("Failed to initialize.", e);
}
}
private static void ConfigureHomebrew()
{
Logger.Log("Configuring homebrew.");
MythicAnimalFocus.Configure();
}
private static void ConfigureArchetypes()
{
Logger.Log("Configuring archetypes.");
}
private static void ConfigureClassFeats()
{
Logger.Log("Configuring class features.");
}
private static void ConfigureFeats()
{
Logger.Log("Configuring features.");
PlanarFocus.Configure();
FavoredAnimalFocusSelection.Configure();
ForcefulCharge.Configure();
ImprovedNaturalAttack.Configure();
ImprovedNaturalArmor.Configure();
EvolvedCompanion.Configure();
VampiricCompanion.Configure();
SpiritsGift.Configure();
ShareSpells.Configure();
}
private static void ConfigureSpells()
{
Logger.Log("Configuring spells.");
StrongJaw.Configure();
Atavism.Configure();
}
private static void ConfigureFeatsDelayed()
{
Logger.Log("Configuring delayed.");
TotemBeast.Configure();
}
}
}
}