Skip to content

Commit 0883ad0

Browse files
committed
Update reg/enc to use patcher
1 parent 530525f commit 0883ad0

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

InscryptionAPI/Encounters/EncounterManager.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ internal static void SyncEncounterList()
2323

2424
static EncounterManager()
2525
{
26+
InscryptionAPIPlugin.ScriptableObjectLoaderLoad += static type =>
27+
{
28+
if (type == typeof(EncounterBlueprintData))
29+
{
30+
ScriptableObjectLoader<EncounterBlueprintData>.allData = AllEncountersCopy;
31+
}
32+
};
2633
NewEncounters.CollectionChanged += static (_, _) =>
2734
{
2835
SyncEncounterList();
@@ -44,12 +51,4 @@ public static EncounterBlueprintData New(string name, bool addToPool = true)
4451

4552
return retval;
4653
}
47-
48-
[HarmonyPrefix]
49-
[HarmonyPatch(typeof(ScriptableObjectLoader<UnityObject>), nameof(ScriptableObjectLoader<UnityObject>.LoadData))]
50-
[SuppressMessage("Member Access", "Publicizer001", Justification = "Need to set internal list of encounters")]
51-
private static void EncounterLoadPrefix()
52-
{
53-
ScriptableObjectLoader<EncounterBlueprintData>.allData = AllEncountersCopy;
54-
}
5554
}

InscryptionAPI/Regions/RegionManager.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ internal static void SyncRegionList()
2323

2424
static RegionManager()
2525
{
26+
InscryptionAPIPlugin.ScriptableObjectLoaderLoad += static type =>
27+
{
28+
if (type == typeof(RegionData))
29+
{
30+
ScriptableObjectLoader<RegionData>.allData = AllRegionsCopy;
31+
}
32+
};
2633
NewRegions.CollectionChanged += static (_, _) =>
2734
{
2835
SyncRegionList();
@@ -98,14 +105,6 @@ public static RegionData FromTierBasic(string name, int originalTier, bool addTo
98105
return FromTierBasic(name, originalTier, originalTier, addToPool);
99106
}
100107

101-
[HarmonyPrefix]
102-
[HarmonyPatch(typeof(ScriptableObjectLoader<UnityObject>), nameof(ScriptableObjectLoader<UnityObject>.LoadData))]
103-
[SuppressMessage("Member Access", "Publicizer001", Justification = "Need to set internal list of regions")]
104-
private static void RegionLoadPrefix()
105-
{
106-
ScriptableObjectLoader<RegionData>.allData = AllRegionsCopy;
107-
}
108-
109108
[HarmonyPrefix]
110109
[HarmonyPatch(typeof(RunState), "CurrentMapRegion", MethodType.Getter)]
111110
private static bool CurrentMapPrefix(RunState __instance, ref RegionData __result)

0 commit comments

Comments
 (0)