using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Zorro.Settings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.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 InputAPI
{
public abstract class BaseCWInput : KeyCodeSetting
{
internal InputKey inputKey;
protected bool _disabled;
public void HandleKeys(Player player)
{
if (!_disabled)
{
if (inputKey.GetKeyDown())
{
OnKeyDown(player);
}
else if (inputKey.GetKeyUp())
{
OnKeyUp(player);
}
else if (inputKey.GetKey())
{
OnHeld(player);
}
}
}
protected abstract void OnKeyDown(Player player);
protected abstract void OnKeyUp(Player player);
protected abstract void OnHeld(Player player);
public void Disable()
{
_disabled = true;
}
public void Enable()
{
_disabled = false;
}
public BaseCWInput()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
inputKey = new InputKey();
inputKey.SetKeybind((KeyCodeSetting)(object)this);
Plugin._inputs.Add(this);
_disabled = false;
}
}
[BepInPlugin("com.visualerror.inputapi", "InputAPI", "1.0.2")]
[ContentWarningPlugin("com.visualerror.inputapi", "InputAPI", true)]
public class Plugin : BaseUnityPlugin
{
internal static List<BaseCWInput> _inputs = new List<BaseCWInput>();
public static Plugin Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Patch();
Logger.LogInfo((object)"com.visualerror.inputapi v1.0.2 has loaded!");
}
internal static void Patch()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("com.visualerror.inputapi");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
}
namespace InputAPI.Patches
{
[HarmonyPatch(typeof(PlayerInput))]
internal class PlayerInputPatch
{
[HarmonyPatch("SampeInput")]
[HarmonyPostfix]
private static void SampeInput(Player player)
{
foreach (BaseCWInput input in Plugin._inputs)
{
input.HandleKeys(player);
}
}
}
[HarmonyPatch(typeof(SettingsHandler))]
internal static class SettingsHandlerPatch
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void AddCustomBinds(SettingsHandler __instance)
{
List<Setting> allSettingsNonAlloc = __instance.GetAllSettingsNonAlloc();
BaseCWInput[] array = Plugin._inputs.ToArray();
foreach (BaseCWInput input in array)
{
if (!allSettingsNonAlloc.Contains((Setting)(object)input))
{
if (allSettingsNonAlloc.Any((Setting s) => ((object)s).GetType() == ((object)input).GetType()))
{
Plugin._inputs.Remove(input);
Plugin.Logger.LogInfo((object)("Skipping duplicate modded keybind: " + ((object)input).GetType().Name));
}
else
{
Plugin.Logger.LogInfo((object)("Loading modded keybind: " + ((object)input).GetType().Name));
__instance.AddSetting((Setting)(object)input);
}
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}