using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("NoEquipAnimation")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Disables weapon and arm equip animations in ULTRAKILL.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+46a6d4c135adb86f9ee09f51c66bddc8a53e53d3")]
[assembly: AssemblyProduct("NoEquipAnimation")]
[assembly: AssemblyTitle("NoEquipAnimation")]
[assembly: AssemblyVersion("1.0.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 NoEquipAnimation
{
public class FastDrawComponent : MonoBehaviour
{
private Animator animator;
private float originalSpeed = 1f;
private int framesToFast;
private bool isArm;
public void Initialize(bool isArmComponent)
{
isArm = isArmComponent;
}
private void Awake()
{
animator = ((Component)this).GetComponentInChildren<Animator>();
}
private void OnEnable()
{
if ((Object)(object)animator == (Object)null)
{
animator = ((Component)this).GetComponentInChildren<Animator>();
}
if ((Object)(object)animator != (Object)null)
{
originalSpeed = animator.speed;
if (isArm ? ModConfig.DisableArmEquipAnimation.Value : ModConfig.DisableWeaponEquipAnimation.Value)
{
animator.speed = 1000f;
framesToFast = 2;
}
}
}
private void Update()
{
if ((Object)(object)animator != (Object)null && framesToFast > 0)
{
framesToFast--;
if (framesToFast == 0)
{
animator.speed = originalSpeed;
}
}
}
}
public static class ModConfig
{
public static ConfigEntry<bool> DisableWeaponEquipAnimation;
public static ConfigEntry<bool> DisableArmEquipAnimation;
public static ConfigEntry<KeyCode> ToggleKey;
public static void Initialize(ConfigFile config)
{
DisableWeaponEquipAnimation = config.Bind<bool>("General", "DisableWeaponEquipAnimation", true, "Disable drawing/equip animations for weapons (guns).");
DisableArmEquipAnimation = config.Bind<bool>("General", "DisableArmEquipAnimation", true, "Disable drawing/equip animations for arms/fists.");
ToggleKey = config.Bind<KeyCode>("Controls", "ToggleKey", (KeyCode)104, "Key to toggle disabling equip animations in-game.");
}
}
public static class Patches
{
public static void WeaponOnEnablePostfix(MonoBehaviour __instance)
{
EnsureFastDraw(((Component)__instance).gameObject, isArm: false);
}
public static void ArmOnEnablePostfix(MonoBehaviour __instance)
{
EnsureFastDraw(((Component)__instance).gameObject, isArm: true);
}
private static void EnsureFastDraw(GameObject go, bool isArm)
{
if (!((Object)(object)go == (Object)null) && (Object)(object)go.GetComponent<FastDrawComponent>() == (Object)null)
{
go.AddComponent<FastDrawComponent>().Initialize(isArm);
Debug.Log((object)$"[NoEquipAnimation] FastDrawComponent eklendi: {((Object)go).name} (kol: {isArm})");
}
}
}
[BepInPlugin("com.antigravity.noequipanimation", "No Equip Animations", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private Harmony harmony;
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Initializing ULTRAKILL No Equip Animations mod...");
ModConfig.Initialize(((BaseUnityPlugin)this).Config);
harmony = new Harmony("com.antigravity.noequipanimation");
ApplyPatchesSafely();
((BaseUnityPlugin)this).Logger.LogInfo((object)"ULTRAKILL No Equip Animations mod initialized!");
}
private void ApplyPatchesSafely()
{
TryPatch(typeof(Revolver), "OnEnable", "WeaponOnEnablePostfix", isArm: false);
TryPatch(typeof(Shotgun), "OnEnable", "WeaponOnEnablePostfix", isArm: false);
TryPatch(typeof(Nailgun), "OnEnable", "WeaponOnEnablePostfix", isArm: false);
TryPatch(typeof(Railcannon), "OnEnable", "WeaponOnEnablePostfix", isArm: false);
TryPatch(typeof(RocketLauncher), "OnEnable", "WeaponOnEnablePostfix", isArm: false);
TryPatch(typeof(Punch), "OnEnable", "ArmOnEnablePostfix", isArm: true);
}
private void TryPatch(Type targetType, string methodName, string postfixName, bool isArm)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
try
{
MethodInfo methodInfo = AccessTools.Method(targetType, methodName, (Type[])null, (Type[])null);
if (methodInfo == null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("[NoEquipAnimation] " + targetType.Name + "." + methodName + " bulunamadı, atlanıyor."));
}
else
{
HarmonyMethod val = (isArm ? new HarmonyMethod(typeof(Patches), "ArmOnEnablePostfix", (Type[])null) : new HarmonyMethod(typeof(Patches), "WeaponOnEnablePostfix", (Type[])null));
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)("[NoEquipAnimation] " + targetType.Name + "." + methodName + " patch edildi."));
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("[NoEquipAnimation] " + targetType.Name + "." + methodName + " patch başarısız: " + ex.Message));
}
}
private void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (!Input.GetKeyDown(ModConfig.ToggleKey.Value))
{
return;
}
bool flag = !ModConfig.DisableWeaponEquipAnimation.Value;
ModConfig.DisableWeaponEquipAnimation.Value = flag;
ModConfig.DisableArmEquipAnimation.Value = flag;
((BaseUnityPlugin)this).Config.Save();
string text = (flag ? "CLOSED" : "OPEN");
((BaseUnityPlugin)this).Logger.LogInfo((object)("Equip animations: " + (flag ? "CLOSED" : "OPEN")));
try
{
if ((Object)(object)MonoSingleton<HudMessageReceiver>.Instance != (Object)null)
{
MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("Equip Animation: " + text, "", "", 0, false, false, true);
}
}
catch
{
}
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
}
}