Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ValikTooManyEmotes v1.0.2
BepInEx/plugins/ValikTooManyEmotes/ValikTooManyEmotes.dll
Decompiled 2 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using TooManyEmotes; using TooManyEmotes.Audio; using TooManyEmotes.UI; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("exeryze")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Imports ValikEmotes animations and music natively into TooManyEmotes.")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("ValikTooManyEmotes")] [assembly: AssemblyTitle("ValikTooManyEmotes")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ValikTooManyEmotes { [BepInPlugin("ValikTooManyEmotes", "ValikTooManyEmotes", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "ValikTooManyEmotes"; public const string PluginName = "ValikTooManyEmotes"; public const string PluginVersion = "1.0.2"; private Harmony? _harmony; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown PluginConfig.Bind(((BaseUnityPlugin)this).Config); _harmony = new Harmony("ValikTooManyEmotes"); _harmony.PatchAll(typeof(TooManyEmotesPatches)); ValikEmoteLoader.Initialize(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? Paths.PluginPath, ((BaseUnityPlugin)this).Logger); } } internal static class PluginConfig { internal static ConfigEntry<bool> UnlockAllByDefault { get; private set; } internal static ConfigEntry<bool> PlayAudioWithoutBoombox { get; private set; } internal static ConfigEntry<bool> IncludeDuplicateTitles { get; private set; } internal static ConfigEntry<bool> EnableTraversalEmotes { get; private set; } internal static ConfigEntry<bool> AddCustomCategoryTab { get; private set; } internal static void Bind(ConfigFile config) { UnlockAllByDefault = config.Bind<bool>("General", "UnlockAllByDefault", true, "When true, all ValikTooManyEmotes dances are placed in TooManyEmotes' Complementary category and unlocked immediately by default."); PlayAudioWithoutBoombox = config.Bind<bool>("Audio", "PlayAudioWithoutBoombox", true, "When true, ValikTooManyEmotes dances play their audio directly without requiring a Boombox."); IncludeDuplicateTitles = config.Bind<bool>("Emotes", "IncludeDuplicateTitles", true, "When true, includes dances whose names already exist in TooManyEmotes or other packs, labeled with ' (Valik)'."); EnableTraversalEmotes = config.Bind<bool>("Emotes", "EnableTraversalEmotes", true, "When true, allows moving while performing traversal emotes such as Dr Livsey, Naruto Run, Starman, and Stairs."); AddCustomCategoryTab = config.Bind<bool>("UI", "AddCustomCategoryTab", true, "When true, adds a dedicated 'Valik' category tab to TooManyEmotes' emote wheel."); } } internal readonly record struct ValikEmoteDef(string Key, string DisplayName, string PrimaryAnimPath, string? LoopAnimPath, string PrimaryAudioPath, string? LoopAudioPath, bool CanMove, bool IsDuplicateTitle); internal static class ValikEmoteCatalog { internal static readonly ValikEmoteDef[] All = new ValikEmoteDef[53] { new ValikEmoteDef("monetochka", "Monetochka", "assets/monetochka.anim", null, "assets/kazdij_raz.ogg", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("raspiat", "Raspiat", "assets/raspiat.anim", null, "assets/raspiat.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("livsey", "Dr Livsey", "assets/livsey.anim", null, "assets/livsey.mp3", null, CanMove: true, IsDuplicateTitle: false), new ValikEmoteDef("rat_dance", "Rat Dance (Valik)", "assets/rat_dance.anim", null, "assets/rat_dance.mp3", null, CanMove: false, IsDuplicateTitle: true), new ValikEmoteDef("t_rex", "T-Rex (Valik)", "assets/t_rex.anim", null, "assets/t_rex.mp3", null, CanMove: false, IsDuplicateTitle: true), new ValikEmoteDef("gaston", "Gaston, Ti Wizil!", "assets/gaston.anim", null, "assets/gaston.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("headlock", "Headlock", "assets/headlock.anim", null, "assets/headlock.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("laugh", "Laugh", "assets/laugh.anim", null, "assets/laugh.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("number", "Number", "assets/number.anim", null, "assets/number.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("bolnownoge", "Bolno W Noge", "assets/bolnownoge.anim", null, "assets/bolnownoge.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("fast_run", "Fast Run", "assets/fast_run.anim", null, "assets/fast_run.mp3", null, CanMove: true, IsDuplicateTitle: false), new ValikEmoteDef("fnaf_run", "Fnaf Run", "assets/fnaf_run.anim", null, "assets/fnaf_run.mp3", null, CanMove: true, IsDuplicateTitle: false), new ValikEmoteDef("naruto_run", "Naruto Run", "assets/naruto_run.anim", null, "assets/naruto_run.mp3", null, CanMove: true, IsDuplicateTitle: false), new ValikEmoteDef("weird_run", "Weird Run", "assets/weird_run.anim", null, "assets/weird_run.mp3", null, CanMove: true, IsDuplicateTitle: false), new ValikEmoteDef("poshel", "Poshel", "assets/poshel.anim", null, "assets/poshel.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("starman", "Starman", "assets/starman.anim", null, "assets/starman.mp3", null, CanMove: true, IsDuplicateTitle: false), new ValikEmoteDef("vmeste_my", "Vmeste My", "assets/vmeste_my.anim", null, "assets/vmeste_my.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("brooklin_blood", "Brooklin Blood", "assets/brooklin_blood.anim", null, "assets/brooklin_blood.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("internet_yamero", "Internet Yamero", "assets/internet_yamero.anim", "assets/internet_yameroloop.anim", "assets/internet_yamero.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("oiiaa", "Oiiaa Cat", "assets/oiiaa.anim", null, "assets/oiiaa.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("oiiaa_moving", "Oiiaa Cat Moving", "assets/oiiaa_moving.anim", null, "assets/oiiaa_moving.ogg", null, CanMove: true, IsDuplicateTitle: false), new ValikEmoteDef("silly_dance", "Silly Dance", "assets/silly_dance.anim", null, "assets/silly_dance.ogg", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("bara_bere", "Bara Bere", "assets/bara_bere.anim", null, "assets/bara_bere.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("gospodi", "Gospodi Pomiluj", "assets/gospodi_start.anim", "assets/gospodi_loop.anim", "assets/gospodi_pomiluj.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("laggy_bear", "Laggy Bear", "assets/laggy_bear.anim", null, "assets/laggy_bear.ogg", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("lifecouldbe_dream", "Life Could Be Dream", "assets/lifecouldbe_dream.anim", null, "assets/lifecouldbe_dream.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("phone_call", "Phone Call", "assets/phone_call.anim", null, "assets/phone_call.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("piano_playing", "Piano Playing", "assets/piano_playing.anim", null, "assets/piano_playing.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("stairs", "Stairs", "assets/stairs.anim", null, "assets/stairs.mp3", null, CanMove: true, IsDuplicateTitle: false), new ValikEmoteDef("thank_you", "Thank You", "assets/thank_you.anim", null, "assets/thank_you.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("zagorami", "Za Lesami", "assets/zagorami.anim", null, "assets/zagorami_start.mp3", "assets/zagorami_loop.mp3", CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("kchertu_lubov", "K Chertu Lubov", "assets/kchertu_lubov.anim", null, "assets/kchertu_lubov.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("psl", "PSL", "assets/psl.anim", null, "assets/psl_start.ogg", "assets/psl_loop.ogg", CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("domino", "Dancin Domino (Valik)", "assets/domino_start.anim", "assets/domino_loop.anim", "assets/domino_start.wav", "assets/domino_loop.wav", CanMove: false, IsDuplicateTitle: true), new ValikEmoteDef("dare", "Dare", "assets/dare.anim", null, "assets/dare.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("blue_shirtguy", "Blue Shirt Guy", "assets/blue_shirtguy.anim", null, "assets/blue_shirtguy.wav", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("back_on74", "Back On 74", "assets/back_on74.anim", null, "assets/back_on74.wav", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("get_lucky", "Get Lucky", "assets/get_lucky.anim", null, "assets/get_lucky.wav", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("moonlight", "Moonlight", "assets/moonlight.anim", null, "assets/moonlight.wav", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("whachu_want", "What You Want (Valik)", "assets/whachu_want.anim", null, "assets/whachu_want.wav", null, CanMove: false, IsDuplicateTitle: true), new ValikEmoteDef("firework", "Firework (Valik)", "assets/firework.anim", null, "assets/firework.ogg", null, CanMove: false, IsDuplicateTitle: true), new ValikEmoteDef("kehlani", "Kehlani (Valik)", "assets/kehlani.anim", null, "assets/kehlani.ogg", null, CanMove: false, IsDuplicateTitle: true), new ValikEmoteDef("shuffle", "Hardstyle Shuffle", "assets/shuffle.anim", null, "assets/shuffle.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("67", "67", "assets/67.anim", null, "assets/67.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("lucid", "Lucid Dreams (Valik)", "assets/lucid_start.anim", "assets/lucid_loop.anim", "assets/lucid_start.wav", "assets/lucid_loop.wav", CanMove: false, IsDuplicateTitle: true), new ValikEmoteDef("nizmoo", "Nizmoo", "assets/nizmoo.anim", null, "assets/nizmoo.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("jajca", "Jajca", "assets/inthened_jajca.anim", null, "assets/intheend_jajca.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("invincible", "Invincible Edit", "assets/invincible.anim", null, "assets/invincible.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("get_away", "Get Away", "assets/get_away.anim", null, "assets/get_away.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("fruity20", "Fruity", "assets/fruity20.anim", null, "assets/fruity20.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("stakillaz", "Stakillaz", "assets/stakillaz.anim", null, "assets/stakillaz.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("na_grani", "Na Grani", "assets/na_grani.anim", null, "assets/na_grani.mp3", null, CanMove: false, IsDuplicateTitle: false), new ValikEmoteDef("xonada", "Montagem Xonada", "assets/xonada.anim", null, "assets/xonada.mp3", null, CanMove: false, IsDuplicateTitle: false) }; } internal static class ValikEmoteLoader { private readonly record struct RegisteredEmoteMeta(ValikEmoteDef Def, string EmoteKey, string PrimaryAudioKey, string? LoopAudioKey); private const string TabDisplayName = "<color=#66CCFF>Valik</color>"; private static readonly Dictionary<string, AudioClip> AudioByKey = new Dictionary<string, AudioClip>(StringComparer.Ordinal); private static readonly List<RegisteredEmoteMeta> RegisteredEmotes = new List<RegisteredEmoteMeta>(); private static readonly List<UnlockableEmote> PackTabEmotes = new List<UnlockableEmote>(); private static FieldInfo? _loadedAudioClipsField; private static FieldInfo? _loadedAudioClipsDmcaFreeField; private static FieldInfo? _audioClipsDictDmcaField; private static FieldInfo? _audioClipsDictDmcaFreeField; private static FieldInfo? _complementaryEmotesDefaultField; private static AssetBundle? _animBundle; private static AssetBundle? _audioBundle; private static bool _isApplyingMetadata; private static ManualLogSource? _log; internal static void Initialize(string pluginDirectory, ManualLogSource log) { if ((Object)(object)_animBundle != (Object)null || (Object)(object)_audioBundle != (Object)null) { return; } _log = log; ResolveAudioManagerFields(); string text = Path.Combine(pluginDirectory, "assetbundles", "valikemotesanim"); string text2 = Path.Combine(pluginDirectory, "assetbundles", "valikemotesaudio"); if (!File.Exists(text) || !File.Exists(text2)) { _log.LogError((object)("Missing AssetBundles under '" + Path.Combine(pluginDirectory, "assetbundles") + "'. Expected valikemotesanim and valikemotesaudio.")); return; } AssetBundle val = AssetBundle.LoadFromFile(text); AssetBundle val2 = AssetBundle.LoadFromFile(text2); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { _log.LogError((object)"Failed to load ValikTooManyEmotes AssetBundles."); if (val != null) { val.Unload(false); } if (val2 != null) { val2.Unload(false); } return; } _animBundle = val; _audioBundle = val2; Dictionary<string, string> animLookup = BuildBundleAssetLookup(val); Dictionary<string, string> audioLookup = BuildBundleAssetLookup(val2); bool value = PluginConfig.UnlockAllByDefault.Value; bool value2 = PluginConfig.IncludeDuplicateTitles.Value; int num = 0; foreach (ValikEmoteDef item in ValikEmoteCatalog.All.OrderBy<ValikEmoteDef, string>((ValikEmoteDef d) => d.DisplayName, StringComparer.OrdinalIgnoreCase)) { if ((!item.IsDuplicateTitle || value2) && TryRegisterEmote(item, val, val2, animLookup, audioLookup, value)) { num++; } } RegisterAllAudioInManager(); _log.LogInfo((object)$"Registered {num} ValikEmotes animations/audio clips. Rebuilding TooManyEmotes list..."); EmotesManager.BuildEmotesList(); ApplyMetadataToEmotes(); AdditionalEmoteData.SetAdditionalEmoteData(); AdditionalEmoteData.SetAdditionalPropData(); AdditionalEmoteData.SetAdditionalMusicData(); _log.LogInfo((object)$"ValikTooManyEmotes ready with {RegisteredEmotes.Count} active emotes."); } internal static void ApplyMetadataToEmotes() { if (_isApplyingMetadata || RegisteredEmotes.Count == 0) { return; } _isApplyingMetadata = true; try { bool value = PluginConfig.EnableTraversalEmotes.Value; bool value2 = PluginConfig.PlayAudioWithoutBoombox.Value; bool value3 = PluginConfig.UnlockAllByDefault.Value; List<UnlockableEmote> list = _complementaryEmotesDefaultField?.GetValue(null) as List<UnlockableEmote>; foreach (RegisteredEmoteMeta registeredEmote in RegisteredEmotes) { if (!EmotesManager.allUnlockableEmotesDict.TryGetValue(registeredEmote.EmoteKey, out var value4) || value4 == null) { continue; } value4.displayName = registeredEmote.Def.DisplayName; value4.complementary = value3; value4.overrideAudioClipName = registeredEmote.PrimaryAudioKey; value4.overrideAudioLoopClipName = registeredEmote.LoopAudioKey ?? string.Empty; if (value3) { if (list != null && !list.Contains(value4)) { list.Add(value4); } if (EmotesManager.complementaryEmotes != null && !EmotesManager.complementaryEmotes.Contains(value4)) { EmotesManager.complementaryEmotes.Add(value4); } EmotesManager.allEmotesTier0?.Remove(value4); EmotesManager.allEmotesTier1?.Remove(value4); EmotesManager.allEmotesTier2?.Remove(value4); EmotesManager.allEmotesTier3?.Remove(value4); } if (registeredEmote.Def.CanMove && value) { value4.canMoveWhileEmoting = true; AdditionalEmoteData.SetCanMoveWhileEmoting(registeredEmote.EmoteKey); } if (value2) { value4.isBoomboxAudio = false; AdditionalEmoteData.SetEmoteDoesNotUseBoombox(registeredEmote.EmoteKey); } } RefreshPackTabEmotes(); } catch (Exception arg) { ManualLogSource? log = _log; if (log != null) { log.LogError((object)$"Error applying ValikTooManyEmotes metadata: {arg}"); } } finally { _isApplyingMetadata = false; } } internal static void RefreshPackTabEmotes() { PackTabEmotes.Clear(); if (EmotesManager.allUnlockableEmotesDict == null || RegisteredEmotes.Count == 0) { return; } bool value = PluginConfig.UnlockAllByDefault.Value; foreach (RegisteredEmoteMeta registeredEmote in RegisteredEmotes) { if (EmotesManager.allUnlockableEmotesDict.TryGetValue(registeredEmote.EmoteKey, out var value2) && value2 != null && (value || SessionManager.IsEmoteUnlocked(value2, ""))) { PackTabEmotes.Add(value2); } } } internal static void EnsureCustomLoadoutTabRegistered() { try { if (!PluginConfig.AddCustomCategoryTab.Value || PackTabEmotes.Count == 0 || (Object)(object)EmoteMenu.menuGameObject == (Object)null || EmoteMenu.emoteLoadoutUIElementsList == null || EmoteMenu.emoteLoadoutUIElementsList.Count == 0 || EmoteMenu.emoteLoadouts == null) { return; } if (EmoteMenu.emoteLoadoutUIElementsList.Count != EmoteMenu.emoteLoadouts.Count) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)string.Format("Skipping custom tab '{0}': EmoteMenu UI count ({1}) != loadout list count ({2}).", "<color=#66CCFF>Valik</color>", EmoteMenu.emoteLoadoutUIElementsList.Count, EmoteMenu.emoteLoadouts.Count)); } return; } for (int i = 0; i < EmoteMenu.emoteLoadoutUIElementsList.Count; i++) { EmoteLoadoutUIElement val = EmoteMenu.emoteLoadoutUIElementsList[i]; if ((Object)(object)val != (Object)null && string.Equals(val.loadoutName, "<color=#66CCFF>Valik</color>", StringComparison.Ordinal)) { return; } } EmoteLoadoutUIElement val2 = EmoteMenu.emoteLoadoutUIElementsList[0]; if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).transform.parent == (Object)null) { return; } Transform parent = ((Component)val2).transform.parent; int count = EmoteMenu.emoteLoadoutUIElementsList.Count; bool activeSelf = EmoteMenu.menuGameObject.activeSelf; EmoteLoadoutUIElement val3 = null; try { if (!activeSelf) { EmoteMenu.menuGameObject.SetActive(true); } EmoteLoadoutUIElement.uiCount = count; val3 = Object.Instantiate<EmoteLoadoutUIElement>(val2, parent); } finally { if (!activeSelf && (Object)(object)EmoteMenu.menuGameObject != (Object)null) { EmoteMenu.menuGameObject.SetActive(false); } } if (!((Object)(object)val3 == (Object)null)) { val3.id = count; ((Object)val3).name = $"EmoteLoadout_{count}"; val3.loadoutName = "<color=#66CCFF>Valik</color>"; EmoteLoadoutUIElement val4 = val3; if (val4.backgroundImage == null) { val4.backgroundImage = ((Component)val3).GetComponentInChildren<Image>(true); } val4 = val3; if (val4.textContainer == null) { val4.textContainer = ((Component)val3).GetComponentInChildren<TextMeshPro>(true); } if ((Object)(object)val3.textContainer != (Object)null) { ((TMP_Text)val3.textContainer).text = "<color=#66CCFF>Valik</color>"; } EmoteLoadoutUIElement.uiCount = count + 1; EmoteMenu.emoteLoadoutUIElementsList.Add(val3); EmoteMenu.emoteLoadouts.Add(PackTabEmotes); if ((Object)(object)val3.backgroundImage != (Object)null) { val3.OnHover(false); } AdjustLoadoutListLayout(parent); } } catch (Exception arg) { ManualLogSource? log2 = _log; if (log2 != null) { log2.LogError((object)string.Format("Error registering custom emote wheel tab '{0}': {1}", "<color=#66CCFF>Valik</color>", arg)); } } } private static void AdjustLoadoutListLayout(Transform loadoutsParent) { //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) int count = EmoteMenu.emoteLoadoutUIElementsList.Count; if (count <= 7) { return; } float num = Mathf.Clamp(7.5f / (float)count, 0.58f, 1f); Transform val = (((Object)(object)Plugin.radialMenuPrefab != (Object)null) ? Plugin.radialMenuPrefab.transform.Find("MenuUI/EmoteLoadouts") : null); VerticalLayoutGroup component = ((Component)loadoutsParent).GetComponent<VerticalLayoutGroup>(); VerticalLayoutGroup val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<VerticalLayoutGroup>() : null); if ((Object)(object)component != (Object)null && (Object)(object)val2 != (Object)null) { ((HorizontalOrVerticalLayoutGroup)component).spacing = ((HorizontalOrVerticalLayoutGroup)val2).spacing * num; } RectTransform val3 = (((Object)(object)val != (Object)null && val.childCount > 0) ? ((Component)val.GetChild(0)).GetComponent<RectTransform>() : null); LayoutElement val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<LayoutElement>() : null); TextMeshPro val5 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponentInChildren<TextMeshPro>(true) : null); for (int i = 0; i < EmoteMenu.emoteLoadoutUIElementsList.Count; i++) { EmoteLoadoutUIElement val6 = EmoteMenu.emoteLoadoutUIElementsList[i]; if ((Object)(object)val6 == (Object)null) { continue; } RectTransform component2 = ((Component)val6).GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null && (Object)(object)val3 != (Object)null) { component2.sizeDelta = new Vector2(val3.sizeDelta.x, val3.sizeDelta.y * num); LayoutElement component3 = ((Component)val6).GetComponent<LayoutElement>(); if ((Object)(object)component3 != (Object)null && (Object)(object)val4 != (Object)null) { if (val4.preferredHeight > 0f) { component3.preferredHeight = val4.preferredHeight * num; } if (val4.minHeight > 0f) { component3.minHeight = val4.minHeight * num; } } } TextMeshPro textContainer = val6.textContainer; if ((Object)(object)textContainer != (Object)null) { float num2 = (((Object)(object)val5 != (Object)null && ((TMP_Text)val5).enableAutoSizing && ((TMP_Text)val5).fontSizeMax > 0f) ? ((TMP_Text)val5).fontSizeMax : ((!((Object)(object)val5 != (Object)null) || !(((TMP_Text)val5).fontSize > 0f)) ? ((((TMP_Text)textContainer).fontSize > 0f) ? ((TMP_Text)textContainer).fontSize : 16f) : ((TMP_Text)val5).fontSize)); ((TMP_Text)textContainer).enableWordWrapping = false; ((TMP_Text)textContainer).overflowMode = (TextOverflowModes)1; ((TMP_Text)textContainer).enableAutoSizing = true; ((TMP_Text)textContainer).fontSizeMin = Mathf.Max(4f, num2 * 0.45f); ((TMP_Text)textContainer).fontSizeMax = num2 * Mathf.Lerp(1f, num, 0.65f); if ((Object)(object)val5 != (Object)null && Mathf.Approximately(((TMP_Text)val5).rectTransform.anchorMin.y, ((TMP_Text)val5).rectTransform.anchorMax.y)) { ((TMP_Text)textContainer).rectTransform.sizeDelta = new Vector2(((TMP_Text)val5).rectTransform.sizeDelta.x, ((TMP_Text)val5).rectTransform.sizeDelta.y * num); } } } if ((Object)(object)component == (Object)null && (Object)(object)val != (Object)null) { loadoutsParent.localScale = val.localScale * Mathf.Clamp(7.5f / (float)count, 0.72f, 1f); } RectTransform val7 = (RectTransform)(object)((loadoutsParent is RectTransform) ? loadoutsParent : null); if (val7 != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(val7); } } internal static void RegisterAllAudioInManager() { if (AudioByKey.Count == 0) { return; } HashSet<AudioClip> hashSet = _loadedAudioClipsField?.GetValue(null) as HashSet<AudioClip>; HashSet<AudioClip> hashSet2 = _loadedAudioClipsDmcaFreeField?.GetValue(null) as HashSet<AudioClip>; Dictionary<string, AudioClip> dictionary = _audioClipsDictDmcaField?.GetValue(null) as Dictionary<string, AudioClip>; Dictionary<string, AudioClip> dictionary2 = _audioClipsDictDmcaFreeField?.GetValue(null) as Dictionary<string, AudioClip>; foreach (var (key, val2) in AudioByKey) { if (!((Object)(object)val2 == (Object)null)) { hashSet?.Add(val2); hashSet2?.Add(val2); if (dictionary != null) { dictionary[key] = val2; } if (dictionary2 != null) { dictionary2[key] = val2; } } } } internal static bool TryGetAudioClip(string? clipName, out AudioClip? clip) { if (!string.IsNullOrEmpty(clipName) && AudioByKey.TryGetValue(clipName, out AudioClip value) && (Object)(object)value != (Object)null) { clip = value; return true; } clip = null; return false; } internal static bool HasAudioClip(string? clipName) { if (!string.IsNullOrEmpty(clipName)) { return AudioByKey.ContainsKey(clipName); } return false; } private static bool TryRegisterEmote(ValikEmoteDef def, AssetBundle animBundle, AssetBundle audioBundle, Dictionary<string, string> animLookup, Dictionary<string, string> audioLookup, bool unlockByDefault) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) AnimationClip val = LoadAssetCaseInsensitive<AnimationClip>(animBundle, animLookup, def.PrimaryAnimPath); if ((Object)(object)val == (Object)null) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)("Could not load primary animation '" + def.PrimaryAnimPath + "' for '" + def.DisplayName + "'.")); } return false; } AudioClip val2 = LoadAssetCaseInsensitive<AudioClip>(audioBundle, audioLookup, def.PrimaryAudioPath); if ((Object)(object)val2 == (Object)null) { ManualLogSource? log2 = _log; if (log2 != null) { log2.LogWarning((object)("Could not load primary audio '" + def.PrimaryAudioPath + "' for '" + def.DisplayName + "'.")); } return false; } if ((int)val2.loadState == 0) { val2.LoadAudioData(); } string text = "valik_" + def.Key; bool flag = def.LoopAnimPath != null || def.LoopAudioPath != null; AnimationClip val3 = null; if (def.LoopAnimPath != null) { val3 = LoadAssetCaseInsensitive<AnimationClip>(animBundle, animLookup, def.LoopAnimPath); if ((Object)(object)val3 == (Object)null) { ManualLogSource? log3 = _log; if (log3 != null) { log3.LogWarning((object)("Could not load loop animation '" + def.LoopAnimPath + "' for '" + def.DisplayName + "'. Falling back to cloned primary clip.")); } val3 = Object.Instantiate<AnimationClip>(val); } } else if (def.LoopAudioPath != null) { val3 = Object.Instantiate<AnimationClip>(val); } AudioClip val4 = null; if (def.LoopAudioPath != null) { val4 = LoadAssetCaseInsensitive<AudioClip>(audioBundle, audioLookup, def.LoopAudioPath); if ((Object)(object)val4 == (Object)null) { ManualLogSource? log4 = _log; if (log4 != null) { log4.LogWarning((object)("Could not load loop audio '" + def.LoopAudioPath + "' for '" + def.DisplayName + "'.")); } } else if ((int)val4.loadState == 0) { val4.LoadAudioData(); } } string text2 = (((Object)val).name = (flag ? (text + "_start") : text)); if (Plugin.customAnimationClips == null) { Plugin.customAnimationClips = new List<AnimationClip>(); } if (Plugin.customAnimationClipsHash == null) { Plugin.customAnimationClipsHash = new HashSet<AnimationClip>(); } if (Plugin.customAnimationClipsLoopDict == null) { Plugin.customAnimationClipsLoopDict = new Dictionary<string, AnimationClip>(); } if (Plugin.complementaryAnimationClips == null) { Plugin.complementaryAnimationClips = new List<AnimationClip>(); } if (!Plugin.customAnimationClipsHash.Contains(val)) { Plugin.customAnimationClips.Add(val); Plugin.customAnimationClipsHash.Add(val); } if (unlockByDefault && !Plugin.complementaryAnimationClips.Contains(val)) { Plugin.complementaryAnimationClips.Add(val); } if (flag && (Object)(object)val3 != (Object)null) { string key = (((Object)val3).name = text + "_loop"); Plugin.customAnimationClipsLoopDict[key] = val3; } ((Object)val2).name = text2; AudioByKey[text2] = val2; string text5 = null; if ((Object)(object)val4 != (Object)null) { text5 = (((Object)val4).name = text + "_loop"); AudioByKey[text5] = val4; } RegisteredEmotes.Add(new RegisteredEmoteMeta(def, text, text2, text5)); return true; } private static Dictionary<string, string> BuildBundleAssetLookup(AssetBundle bundle) { Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); string[] allAssetNames = bundle.GetAllAssetNames(); foreach (string text in allAssetNames) { dictionary[text] = text; } return dictionary; } private static T? LoadAssetCaseInsensitive<T>(AssetBundle bundle, Dictionary<string, string> lookup, string requestedPath) where T : Object { string value; string text = (lookup.TryGetValue(requestedPath, out value) ? value : requestedPath); return bundle.LoadAsset<T>(text); } private static void ResolveAudioManagerFields() { Type? typeFromHandle = typeof(AudioManager); _loadedAudioClipsField = AccessTools.Field(typeFromHandle, "loadedAudioClips"); _loadedAudioClipsDmcaFreeField = AccessTools.Field(typeFromHandle, "loadedAudioClipsDmcaFree"); _audioClipsDictDmcaField = AccessTools.Field(typeFromHandle, "audioClipsDictDmca"); _audioClipsDictDmcaFreeField = AccessTools.Field(typeFromHandle, "audioClipsDictDmcaFree"); _complementaryEmotesDefaultField = AccessTools.Field(typeof(EmotesManager), "complementaryEmotesDefault"); } } [HarmonyPatch] internal static class TooManyEmotesPatches { [HarmonyPatch(typeof(EmotesManager), "BuildEmotesList")] [HarmonyPostfix] private static void AfterBuildEmotesList() { ValikEmoteLoader.ApplyMetadataToEmotes(); } [HarmonyPatch(typeof(AudioManager), "ClearAudioClipCache")] [HarmonyPostfix] private static void AfterClearAudioClipCache() { ValikEmoteLoader.RegisterAllAudioInManager(); } [HarmonyPatch(typeof(AudioManager), "LoadAudioClip")] [HarmonyPrefix] private static bool PrefixLoadAudioClip(string clipName, ref AudioClip? __result) { if (!ValikEmoteLoader.TryGetAudioClip(clipName, out AudioClip clip) || (Object)(object)clip == (Object)null) { return true; } __result = clip; return false; } [HarmonyPatch(typeof(AudioManager), "AudioExists")] [HarmonyPrefix] private static bool PrefixAudioExists(string audioName, ref bool __result) { if (!ValikEmoteLoader.HasAudioClip(audioName)) { return true; } __result = true; return false; } [HarmonyPatch(typeof(EmoteMenu), "InitializeUI")] [HarmonyPostfix] private static void AfterInitializeUI() { ValikEmoteLoader.EnsureCustomLoadoutTabRegistered(); } [HarmonyPatch(typeof(EmoteMenu), "OpenEmoteMenu")] [HarmonyPrefix] private static void BeforeOpenEmoteMenu() { ValikEmoteLoader.EnsureCustomLoadoutTabRegistered(); ValikEmoteLoader.RefreshPackTabEmotes(); } } } namespace System.Runtime.CompilerServices { internal static class IsExternalInit { } }