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 VogueHeads v0.1.0
com.github.gramwhorye.vogueheads.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = ".NET Framework 4.7")] [assembly: AssemblyCompany("com.github.gramwhorye.vogueheads")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Asset replacement for Coilheads to turn their bland static poses into dramatic vogues.")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+2f9fb2157db864a7153fcbe25dce007454bd748b")] [assembly: AssemblyProduct("VogueHeads")] [assembly: AssemblyTitle("com.github.gramwhorye.vogueheads")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 VogueHeads { [BepInPlugin("com.github.gramwhorye.vogueheads", "VogueHeads", "0.1.0")] public class Plugin : BaseUnityPlugin { private static AssetBundle animationBundle; private const string bundleName = "voguebundle"; private void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) LoadAssets(); if ((Object)(object)animationBundle != (Object)null) { SpringManAIPatch.Init(((BaseUnityPlugin)this).Logger, animationBundle); new Harmony("com.github.gramwhorye.vogueheads").PatchAll(typeof(SpringManAIPatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin VogueHeads (0.1.0) is loaded!"); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Failed to load assets, skipping."); } } private void LoadAssets() { string location = ((BaseUnityPlugin)this).Info.Location; try { animationBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(location), "voguebundle")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Couldn't load asset bundle: " + ex.Message)); } } } [HarmonyPatch(typeof(SpringManAI))] internal class SpringManAIPatch : MonoBehaviour { internal struct State { internal bool HasStopped; } private const string assetName = "assets/animatorcontroller/animcontainer_14.controller"; private static string[] calloutNames = new string[5] { "assets/audioclip/fierce.mp3", "assets/audioclip/fierce1.mp3", "assets/audioclip/slay.mp3", "assets/audioclip/work.mp3", "assets/audioclip/work2.mp3" }; private static string[] animatorTriggerPrefix = new string[5] { "vogue-tilted", "vogue-trade", "vogue-duck", "vogue-serve", "dab" }; private static string[] stopPositionSuffix = new string[2] { "-left", "-right" }; public static AssetBundle bundle; public static RuntimeAnimatorController voguePoses; public static AudioClip[] callouts; private static FieldRef<SpringManAI, Animator> creatureAnimatorRef = AccessTools.FieldRefAccess<SpringManAI, Animator>("creatureAnimator"); private static FieldRef<SpringManAI, bool> hasStoppedRef = AccessTools.FieldRefAccess<SpringManAI, bool>("hasStopped"); private static FieldRef<SpringManAI, AnimationStopPoints> animStopPointsRef = AccessTools.FieldRefAccess<SpringManAI, AnimationStopPoints>("animStopPoints"); private static FieldRef<SpringManAI, AudioSource> creatureSFXRef = AccessTools.FieldRefAccess<SpringManAI, AudioSource>("creatureSFX"); private static ManualLogSource logger { get; set; } public static void Init(ManualLogSource logger, AssetBundle bundle) { SpringManAIPatch.logger = logger; SpringManAIPatch.bundle = bundle; try { voguePoses = bundle.LoadAsset<RuntimeAnimatorController>("assets/animatorcontroller/animcontainer_14.controller"); if ((Object)(object)voguePoses != (Object)null) { logger.LogInfo((object)"Loaded poses"); } else { logger.LogWarning((object)"Failed to load poses: assets/animatorcontroller/animcontainer_14.controller"); } } catch (Exception ex) { logger.LogError((object)("Couldn't load animator: " + ex.Message)); } if (callouts == null) { callouts = (AudioClip[])(object)new AudioClip[calloutNames.Length]; } int num = 0; string[] array = calloutNames; foreach (string text in array) { try { AudioClip val = bundle.LoadAsset<AudioClip>(text); if ((Object)(object)val != (Object)null) { callouts[num] = val; num++; } else { logger.LogWarning((object)("Couldn't load $" + text + ". Is it an Audio Clip?")); } } catch (Exception ex2) { logger.LogError((object)("Couldn't load audio clip: " + ex2.Message)); } } logger.LogInfo((object)$"Loaded {callouts.Length} audio clips"); } [HarmonyPostfix] [HarmonyPatch("__initializeVariables")] public static void patchAnimator(SpringManAI __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)voguePoses != (Object)null) { Animator component = ((Component)((Component)__instance).transform.Find("SpringManModel").Find("AnimContainer")).gameObject.GetComponent<Animator>(); if ((Object)(object)component != (Object)null) { component.runtimeAnimatorController = voguePoses; logger.LogInfo((object)"Replaced animator on coilhead"); } else { logger.LogWarning((object)"Couldn't find animator"); } } else { logger.LogWarning((object)"Vogue poses were not found. Cannot replace animator."); } } [HarmonyPatch(typeof(SpringManAI), "Update")] [HarmonyPrefix] public static void PreUpdate(SpringManAI __instance, ref State __state) { __state.HasStopped = hasStoppedRef.Invoke(__instance); } [HarmonyPatch(typeof(SpringManAI), "Update")] [HarmonyPostfix] public static void PostUpdate(SpringManAI __instance, ref State __state) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown bool flag = hasStoppedRef.Invoke(__instance); if (!(__state.HasStopped != flag && flag)) { return; } try { string text = stopPositionSuffix[animStopPointsRef.Invoke(__instance).animationPosition % 2]; int num = Random.Range(0, animatorTriggerPrefix.Length); string text2 = animatorTriggerPrefix[num]; creatureAnimatorRef.Invoke(__instance).SetTrigger(text2 + text); } catch (Exception ex) { logger.LogWarning((object)("Failed to set pose: " + ex.Message)); } if (callouts.Length != 0) { try { AudioSource val = creatureSFXRef.Invoke(__instance); if ((Object)(object)val != (Object)null) { ? val2 = val; object[] array = callouts; RoundManager.PlayRandomClip((AudioSource)val2, (AudioClip[])array, false, 1f, 0); } else { logger.LogWarning((object)"Couldn't find sound effect source"); } return; } catch (Exception ex2) { logger.LogWarning((object)("Failed to play audio clip: " + ex2.Message)); return; } } logger.LogWarning((object)"There are no callout audio clips available"); } } public static class PluginInfo { public const string PLUGIN_GUID = "com.github.gramwhorye.vogueheads"; public const string PLUGIN_NAME = "VogueHeads"; public const string PLUGIN_VERSION = "0.1.0"; } }