예제 #1
0
        internal static void Postfix(ZEventListener __instance)
        {
            if (!__instance.eventName_.StartsWith(CustomDataInfo.GetPrefix <MusicChoice>()))
            {
                return;
            }

            Mod.Instance.Variables.CachedMusicChoice.GetOrCreate(__instance, () => MusicChoice.FromObject(__instance));
        }
        public string GetMusicChoiceValue(GameObject obj, string key)
        {
            var listener = obj.GetComponent <ZEventListener>();

            if (listener?.eventName_.StartsWith(CustomDataInfo.GetPrefix <MusicChoice>()) != true)
            {
                return(null);
            }

            var choice = mod_.Variables.CachedMusicChoice.GetOrCreate(listener, () => MusicChoice.FromObject(listener));

            if (choice == null)
            {
                return(null);
            }

            choice.Choices.TryGetValue(key, out MusicChoiceEntry entry);

            if (entry == null)
            {
                return(null);
            }

            return(entry.Track);
        }