using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LLGUI;
using LLScreen;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("com.github.daioutzu.cursorspeed")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7c7a5eb9c96c6f074b4b1580a405736da7c9db2f")]
[assembly: AssemblyProduct("CursorSpeed")]
[assembly: AssemblyTitle("com.github.daioutzu.cursorspeed")]
[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 CursorSpeed
{
[BepInPlugin("com.github.daioutzu.cursorspeed", "CursorSpeed", "1.0.0")]
public class CursorSpeedMain : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private Harmony harmony = new Harmony("com.github.daioutzu.cursorspeed");
internal ConfigEntry<float> configCursorSpeed;
internal static CursorSpeedMain Instance { get; private set; }
private void Awake()
{
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
SetUpConfig();
harmony.PatchAll(typeof(MultiCursorSpeedPatch));
harmony.PatchAll(typeof(SingleCursorSpeedPatch));
harmony.PatchAll(typeof(GameOptionsPatch));
Logger.LogInfo((object)"Plugin com.github.daioutzu.cursorspeed is loaded!");
((Behaviour)this).enabled = false;
}
private void SetUpConfig()
{
configCursorSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Cursor Speed Percentage", 1f, "Adjusts the speed of the cursor for controllers: 1 = 100%, 0.5 = 50%, ect");
}
}
internal class GameOptionsPatch
{
private static OptionsBar cursorSpeedOptionsBar;
[HarmonyPatch(typeof(HGFCCNMEEEF), "PNCAOJENGPB")]
[HarmonyTranspiler]
[HarmonyDebug]
private static IEnumerable<CodeInstruction> AddSaxOptionsBarBeforeDefault(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.SearchForward((Func<CodeInstruction, bool>)((CodeInstruction il) => il.opcode == OpCodes.Ldstr && il.operand as string == "BT_USE_DEFAULTS")).ThrowIfNotMatch("Didn't find default button", (CodeMatch[])(object)new CodeMatch[0]).Advance(-6);
FieldInfo fieldInfo = val.Operand as FieldInfo;
val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo),
Transpilers.EmitDelegate<Action<ScreenOptions>>((Action<ScreenOptions>)AddCursorSpeedOptionsBar),
new CodeInstruction(OpCodes.Ldarg_0, (object)null)
});
return val.InstructionEnumeration();
}
private static void AddCursorSpeedOptionsBar(ScreenOptions screenOptions)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
OptionsBar obj = screenOptions.AddBar((OptionsBarType)3, "Cursor Speed", (HNEDEAGADKO)0, (List<string>)null);
obj.onChange = new BarDelegate(GetOnCursorSpeedChange);
obj.curValue = (int)(CursorSpeedMain.Instance.configCursorSpeed.Value * 100f);
obj.curValueSlider = obj.curValue;
obj.UpdateLooks();
cursorSpeedOptionsBar = obj;
}
private static void GetOnCursorSpeedChange(int value)
{
CursorSpeedMain.Instance.configCursorSpeed.Value = (float)value * 0.01f;
}
[HarmonyPatch(typeof(OptionsBar), "ResetToDefault")]
[HarmonyPrefix]
private static void ResetCursorSpeedOptions(OptionsBar __instance)
{
if (!((Object)(object)cursorSpeedOptionsBar == (Object)null) && !((Object)(object)__instance != (Object)(object)cursorSpeedOptionsBar))
{
cursorSpeedOptionsBar.curValue = (int)(float)((ConfigEntryBase)CursorSpeedMain.Instance.configCursorSpeed).DefaultValue * 100;
cursorSpeedOptionsBar.curValueSlider = cursorSpeedOptionsBar.curValue;
if (cursorSpeedOptionsBar.onChange != null)
{
cursorSpeedOptionsBar.onChange.Invoke(cursorSpeedOptionsBar.curValue);
}
cursorSpeedOptionsBar.UpdateLooks();
}
}
}
[HarmonyPatch]
internal class MultiCursorSpeedPatch
{
[HarmonyTargetMethod]
private static MethodInfo TargetMethod()
{
return AccessTools.Method(AccessTools.FirstInner(typeof(UIInput), (Func<Type, bool>)((Type t) => t.Name == "<HandleCursors>c__AnonStorey0")), "<>m__0", (Type[])null, (Type[])null);
}
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> CursorSpeedRelativeToResolution(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
int num = -1;
int num2 = -1;
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Call && ((MethodInfo)i.operand).Name == "get_deltaTime"), (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld && ((FieldInfo)i.operand).Name == "move"), (string)null)
}).Advance(-1);
num2 = val.Pos;
val.MatchBack(true, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "move"), (string)null)
}).Advance(1);
num = val.Pos;
val.RemoveInstructionsInRange(num, num2).Insert((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Ldloc_0, (object)null),
Transpilers.EmitDelegate<Func<Vector2, LLCursor, Vector2>>((Func<Vector2, LLCursor, Vector2>)((Vector2 move, LLCursor cursor) => move * UIInput.cursorSpeed * cursor.GetHoverSlow() * CursorSpeedMain.Instance.configCursorSpeed.Value * Time.deltaTime * (float)Screen.width / 1280f))
});
return val.InstructionEnumeration();
}
}
[HarmonyPatch]
internal class SingleCursorSpeedPatch
{
[HarmonyPatch(typeof(UIInput), "HandleCursors")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> CursorSpeedRelativeToResolution(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
int num = -1;
int num2 = -1;
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Call && ((MethodInfo)i.operand).Name == "get_deltaTime"), (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld && ((FieldInfo)i.operand).Name == "move"), (string)null)
}).Advance(-1);
num2 = val.Pos;
val.MatchBack(true, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "move"), (string)null)
}).Advance(1);
num = val.Pos;
val.RemoveInstructionsInRange(num, num2).Insert((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<Vector2, Vector2>>((Func<Vector2, Vector2>)((Vector2 move) => move * UIInput.cursorSpeed * UIInput.mainCursor.GetHoverSlow() * CursorSpeedMain.Instance.configCursorSpeed.Value * Time.deltaTime * ((float)Screen.width / 1280f))) });
return val.InstructionEnumeration();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.github.daioutzu.cursorspeed";
public const string PLUGIN_NAME = "CursorSpeed";
public const string PLUGIN_VERSION = "1.0.0";
}
}