using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using IL;
using Logger;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("Onyx_QOL")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Onyx_QOL")]
[assembly: AssemblyTitle("Onyx_QOL")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Onyx_QOL
{
[BepInPlugin("com.Onyx.Onyx_QOL", "Onyx_QOL", "1.0.0")]
[BepInProcess("Magicite.exe")]
public class Onyx_QOL : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static hook_Update <0>__PlayerControllerN_Update;
public static Manipulator <1>__MuteLog;
}
public const string PluginGUID = "com.Onyx.Onyx_QOL";
public const string PluginAuthor = "Onyx";
public const string PluginName = "Onyx_QOL";
public const string PluginVersion = "1.0.0";
public static BaseUnityPlugin Instance;
public void Awake()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
Instance = (BaseUnityPlugin)(object)this;
Options.Init();
object obj = <>O.<0>__PlayerControllerN_Update;
if (obj == null)
{
hook_Update val = PlayerControllerN_Update;
<>O.<0>__PlayerControllerN_Update = val;
obj = (object)val;
}
PlayerControllerN.Update += (hook_Update)obj;
object obj2 = <>O.<1>__MuteLog;
if (obj2 == null)
{
Manipulator val2 = MuteLog;
<>O.<1>__MuteLog = val2;
obj2 = (object)val2;
}
PlayerControllerN.Update += (Manipulator)obj2;
GameScript.AddItem += new hook_AddItem(GameScript_AddItem);
CameraScript.GetAvgX += new hook_GetAvgX(CameraScript_GetAvgX);
CameraScript.GetAvgY += new hook_GetAvgY(CameraScript_GetAvgY);
}
private float CameraScript_GetAvgY(orig_GetAvgY orig, CameraScript self)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
float num = Input.mousePosition.y / (float)Screen.height;
return self.player.position.y + (num - 0.5f) * 30f * Options.panStrength.Value;
}
private float CameraScript_GetAvgX(orig_GetAvgX orig, CameraScript self)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
float num = Input.mousePosition.x / (float)Screen.width;
return self.player.position.x + (num - 0.5f) * 30f * Options.panStrength.Value;
}
private int GameScript_AddItem(orig_AddItem orig, GameScript self, Item item)
{
int result = orig.Invoke(self, item);
Log.Info("----------");
Log.Info(item.id);
Log.Info(item.d);
Log.Info(item.e);
Log.Info(item.q);
Log.Info(item.tier);
Log.Info("array:");
int[] e = item.e;
foreach (int num in e)
{
Log.Info(num);
}
return result;
}
private static void PlayerControllerN_Update(orig_Update orig, PlayerControllerN self)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (Input.GetKeyDown(Options.dashBind.Value) && !self.inDoor)
{
if (Input.GetButton("Left"))
{
((MonoBehaviour)self).StartCoroutine_Auto(self.Dash(0));
}
if (Input.GetButton("Right"))
{
((MonoBehaviour)self).StartCoroutine_Auto(self.Dash(1));
}
}
}
private static void MuteLog(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "GameScript.isTown: ")
}))
{
Log.Error("failed to find patch location: " + (object)il.Method);
return;
}
ILLabel val2 = val.MarkLabel();
if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(MonoBehaviour), "print")
}))
{
Log.Error("failed to find patch location: " + (object)il.Method);
return;
}
ILLabel val3 = val.MarkLabel();
val.GotoLabel(val2, (MoveType)1, false);
val.Emit(OpCodes.Br, (object)val3);
}
}
public static class Reflection
{
private const BindingFlags AllFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
public static MethodInfo GetPropertyGetter(this Type type, string propName)
{
return type.GetProperty(propName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetGetMethod(nonPublic: true);
}
public static MethodInfo GetPropertySetter(this Type type, string propName)
{
return type.GetProperty(propName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetSetMethod(nonPublic: true);
}
}
internal static class Options
{
public static ConfigEntry<KeyCode> dashBind { get; set; }
public static ConfigEntry<float> panStrength { get; set; }
public static void Init()
{
BaseUnityPlugin instance = Onyx_QOL.Instance;
dashBind = instance.Config.Bind<KeyCode>("Keybinds", "Undirectional Dash", (KeyCode)304, "Dash in your movement direction");
panStrength = instance.Config.Bind<float>("Settings", "Camera Pan Strenght", 1f, "Controls how far the camera pans based on your mouse position (Vanilla: 1)");
}
}
}
namespace Logger
{
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void message(object data)
{
_logSource.LogMessage(data);
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
StackFrame stackFrame = new StackFrame(1);
MethodBase method = stackFrame.GetMethod();
_logSource.LogInfo((object)("[" + method.Name + "]: " + data));
}
internal static void Message(object data)
{
message(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
}