Skip to content

Commit

Permalink
Fix missing clothing in style menu
Browse files Browse the repository at this point in the history
Closes #34
  • Loading branch information
joeyparrish committed Jul 24, 2022
1 parent 1754f73 commit 6af92de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Pokeheim/DressUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ public Option(string name, string prefabName) {
public static void RegisterAllClothing() {
// Seek out all clothing and build the menus dynamically.
foreach (var prefab in ZNetScene.instance.m_prefabs) {
RegisterIfClothing(prefab);
try {
RegisterIfClothing(prefab);
} catch (Exception ex) {
Logger.LogError($"Exception registering possible clothing {prefab}: {ex}");
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions Pokeheim/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static class Utils {
public static Hook OnRPCsReady =
new Hook("OnRPCsReady", oneShot: false);
public static Hook OnDLCManAwake =
new Hook("OnDLCManAwake");
new Hook("OnDLCManAwake", oneShot: false);

[HarmonyPatch]
private static class HookPatches {
Expand All @@ -66,7 +66,10 @@ private static class HookPatches {
private static void RPCsReady() => OnRPCsReady.Trigger();

[HarmonyPatch(typeof(DLCMan), nameof(DLCMan.Awake)), HarmonyPostfix]
private static void DLC() => OnDLCManAwake.Trigger();
private static void DLCAwake() => OnDLCManAwake.Trigger();

[HarmonyPatch(typeof(DLCMan), nameof(DLCMan.OnDestroy)), HarmonyPostfix]
private static void DLCDead() => OnDLCManAwake.Untrigger();
}

public class Hook {
Expand Down Expand Up @@ -110,6 +113,11 @@ internal void Trigger() {
}
}

internal void Untrigger() {
triggered = false;
Logger.LogDebug($"Untriggering hook {name}");
}

private void SafeInvoke(Action callback) {
try {
callback();
Expand Down

0 comments on commit 6af92de

Please sign in to comment.