using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("deathanimations")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("test")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("deathanimations")]
[assembly: AssemblyTitle("deathanimations")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[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 deathanimations
{
[BepInPlugin("com.chillosophia.deathanimations", "Death Animations", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "com.chillosophia.deathanimations";
public const string modName = "Death Animations";
public const string modVersion = "0.1.0";
private static Harmony _harmony = new Harmony("com.chillosophia.deathanimations");
internal static ManualLogSource mls;
internal static AssetBundle ModAssets;
public static Dictionary<string, RuntimeAnimatorController> Controllers = new Dictionary<string, RuntimeAnimatorController>();
private void Awake()
{
mls = Logger.CreateLogSource("com.chillosophia.deathanimations");
LoadAnims();
_harmony.PatchAll();
}
private void LoadAnims()
{
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
string text = Path.Combine(directoryName, "animdata");
ModAssets = AssetBundle.LoadFromFile(text);
LoadController("RadMech", "AnimContainer_17");
LoadController("Jester", "AnimContainer_13");
LoadController("ClaySurgeon", "AnimContainer_5");
LoadController("DressGirl", "AnimContainer_8");
LoadController("Blob", "Armature");
LoadController("SpringMan", "AnimContainer_19");
LoadController("Puffer", "AnimContainer_16");
}
private void LoadController(string key, string assetName)
{
RuntimeAnimatorController value = ModAssets.LoadAsset<RuntimeAnimatorController>(assetName);
Controllers.Add(key, value);
mls.LogInfo((object)("controller " + assetName + " mapped to key " + key));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "deathanimations";
public const string PLUGIN_NAME = "deathanimations";
public const string PLUGIN_VERSION = "0.1.0";
}
}
namespace deathanimations.Patches
{
[HarmonyPatch(typeof(EnemyAI))]
internal class EnemyPatches
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void SwappingPostfix(EnemyAI __instance)
{
string key = ((object)__instance).GetType().Name.Replace("AI", "");
if (Plugin.Controllers.TryGetValue(key, out var value) && (Object)(object)__instance.creatureAnimator != (Object)null)
{
__instance.creatureAnimator.runtimeAnimatorController = value;
}
}
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void CleanupOnDeath(EnemyAI __instance)
{
__instance.isEnemyDead = true;
AudioSource creatureVoice = __instance.creatureVoice;
if (creatureVoice != null)
{
creatureVoice.Stop();
}
AudioSource creatureSFX = __instance.creatureSFX;
if (creatureSFX != null)
{
creatureSFX.Stop();
}
JesterAI val = (JesterAI)(object)((__instance is JesterAI) ? __instance : null);
if (val == null)
{
RadMechAI val2 = (RadMechAI)(object)((__instance is RadMechAI) ? __instance : null);
if (val2 == null)
{
DressGirlAI val3 = (DressGirlAI)(object)((__instance is DressGirlAI) ? __instance : null);
if (val3 != null)
{
val3.SFXVolumeLerpTo = 0f;
((EnemyAI)val3).creatureSFX.volume = 0f;
AudioSource heartbeatMusic = val3.heartbeatMusic;
if (heartbeatMusic != null)
{
heartbeatMusic.Stop();
}
}
return;
}
AudioSource localLRADAudio = val2.LocalLRADAudio;
if (localLRADAudio != null)
{
localLRADAudio.Stop();
}
AudioSource localLRADAudio2 = val2.LocalLRADAudio2;
if (localLRADAudio2 != null)
{
localLRADAudio2.Stop();
}
AudioSource engineSFX = val2.engineSFX;
if (engineSFX != null)
{
engineSFX.Stop();
}
}
else
{
AudioSource farAudio = val.farAudio;
if (farAudio != null)
{
farAudio.Stop();
}
}
}
}
}