using System.Collections.Generic; using System.Collections.Immutable; using VRC.SDK3.Avatars.ScriptableObjects; namespace nadena.dev.modular_avatar.core.editor { internal static class ClonedMenuMappings { /// /// Map to link the cloned menu from the clone source. /// If one menu is specified for multiple installers, they are replicated separately, so there is a one-to-many relationship. /// private static readonly Dictionary> ClonedMappings = new Dictionary>(); /// /// Map to link the clone source from the cloned menu. /// Map is the opposite of ClonedMappings. /// private static readonly Dictionary OriginalMapping = new Dictionary(); public static void Clear() { ClonedMappings.Clear(); OriginalMapping.Clear(); } public static void Add(VRCExpressionsMenu original, VRCExpressionsMenu clonedMenu) { if (!ClonedMappings.TryGetValue(original, out ImmutableList clonedMenus)) { clonedMenus = ImmutableList.Empty; } ClonedMappings[original] = clonedMenus.Add(clonedMenu); OriginalMapping[clonedMenu] = original; } public static bool TryGetClonedMenus(VRCExpressionsMenu original, out ImmutableList clonedMenus) { return ClonedMappings.TryGetValue(original, out clonedMenus); } public static VRCExpressionsMenu GetOriginal(VRCExpressionsMenu cloned) { return OriginalMapping.TryGetValue(cloned, out VRCExpressionsMenu original) ? original : null; } } }