using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[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("ScrollInverter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Inverts the scroll wheel direction for the item bar.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ScrollInverter")]
[assembly: AssemblyTitle("ScrollInverter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 ScrollInverter
{
[BepInPlugin("ScrollInverter", "ScrollInverter", "1.0.0")]
public class ScrollInverter : BaseUnityPlugin
{
private bool _isPatched;
private Harmony Harmony { get; set; }
internal static ManualLogSource Logger { get; set; }
public static ScrollInverter Instance { get; private set; }
private void Awake()
{
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
PatchAll();
Logger.LogInfo((object)"Plugin ScrollInverter is loaded!");
}
public void PatchAll()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
if (_isPatched)
{
Logger.LogWarning((object)"Already patched!");
return;
}
Logger.LogDebug((object)"Patching...");
Harmony = new Harmony("ScrollInverter");
Harmony.PatchAll();
_isPatched = true;
Logger.LogDebug((object)"Patched!");
}
public void UnpatchAll()
{
if (!_isPatched)
{
Logger.LogWarning((object)"Already unpatched!");
return;
}
Logger.LogDebug((object)"Unpatching...");
Harmony.UnpatchSelf();
_isPatched = false;
Logger.LogDebug((object)"Unpatched!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ScrollInverter";
public const string PLUGIN_NAME = "ScrollInverter";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace ScrollInverter.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
public class PlayerControllerBPatches
{
[HarmonyPatch("SwitchItem_performed")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> InvertControlsSwitchItemPerformed(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
return new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)delegate(CodeInstruction instruction)
{
string? name = instruction.opcode.Name;
OpCode ble_Un = OpCodes.Ble_Un;
return name == ble_Un.Name;
}).ThrowIfInvalid("Could not find branch instruction").SetOpcodeAndAdvance(OpCodes.Bge_Un_S)
.InstructionEnumeration();
}
}
}