generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add non-component-based hook execution deduplication
This is in preparation for coordination with VRCF: https://discord.com/channels/1001423276553285653/1001424777401077830/1201398914574712842
- Loading branch information
1 parent
8030a1f
commit 990af42
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#if NDMF_VRCSDK3_AVATARS | ||
|
||
using System.Runtime.CompilerServices; | ||
using UnityEngine; | ||
|
||
namespace nadena.dev.ndmf.VRChat | ||
{ | ||
/// <summary> | ||
/// Ensures that we don't run hooks more than once. This is in preparation for coordinating with VRCFury to have all | ||
/// nondestructive utilities independently execute hooks as part of Apply on Play, while deduplicating to ensure that | ||
/// we don't rerun hooks on the same avatar. | ||
/// </summary> | ||
internal static class HookDedup | ||
{ | ||
internal class State | ||
{ | ||
internal bool ranEarlyHook; | ||
internal bool ranOptimization; | ||
} | ||
|
||
private static ConditionalWeakTable<GameObject, State> _avatars = new ConditionalWeakTable<GameObject, State>(); | ||
|
||
public static State RecordAvatar(GameObject root) | ||
{ | ||
if (_avatars.TryGetValue(root, out var state)) | ||
{ | ||
return state; | ||
} | ||
|
||
state = new State(); | ||
_avatars.Add(root, state); | ||
|
||
return state; | ||
} | ||
|
||
public static bool HasAvatar(GameObject root) | ||
{ | ||
return _avatars.TryGetValue(root, out _); | ||
} | ||
} | ||
} | ||
|
||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.