Decompiled source of DashRest v0.1.0

DashRest.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DashRest")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("DashRest")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DashRest")]
[assembly: AssemblyTitle("DashRest")]
[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.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]
	[Microsoft.CodeAnalysis.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]
	[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 DashRest
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("DashRest", "DashRest", "1.0.0")]
	public class DashRest : BaseUnityPlugin
	{
		private ConfigEntry<float> _dashCooldown;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			RCGLifeCycle.DontDestroyForever(((Component)this).gameObject);
			_harmony = new Harmony("DashRest");
			_harmony.PatchAll();
			_dashCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Dash Cooldown", 1f, "Cooldown time for dashing.");
			_dashCooldown.SettingChanged += delegate
			{
				SetDashCooldown(_dashCooldown.Value);
			};
			Log.Info("Plugin DashRest loaded successfully.");
			SetDashCooldown(_dashCooldown.Value);
		}

		private void SetDashCooldown(float cooldownTime)
		{
			if ((Object)(object)SingletonBehaviour<SaveManager>.Instance == (Object)null)
			{
				Log.Warning("SaveManager.Instance is null; cannot set dash cooldown.");
				return;
			}
			StatData stat = SingletonBehaviour<SaveManager>.Instance.allStatData.GetStat("RollCoolDown 閃避CD");
			if ((Object)(object)stat != (Object)null)
			{
				Traverse.Create((object)stat.Stat).Field("_value").SetValue((object)cooldownTime);
				Log.Info($"Dash cooldown set to {cooldownTime} seconds.");
			}
			else
			{
				Log.Warning("RollCoolDown 閃避CD stat not found; cannot set dash cooldown.");
			}
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Log.Info("Plugin unpatched and destroyed.");
		}
	}
	internal static class Log
	{
		private static ManualLogSource? logSource;

		internal static void Init(ManualLogSource logSource)
		{
			Log.logSource = logSource;
		}

		internal static void Debug(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogDebug(data);
			}
		}

		internal static void Error(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogError(data);
			}
		}

		internal static void Fatal(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogFatal(data);
			}
		}

		internal static void Info(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogInfo(data);
			}
		}

		internal static void Message(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogMessage(data);
			}
		}

		internal static void Warning(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogWarning(data);
			}
		}
	}
	[HarmonyPatch]
	public class Patches
	{
		[HarmonyPatch(typeof(Player), "ResetJumpAndDash")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = instructions.ToList();
			if (list.Count > 37)
			{
				list[35].opcode = OpCodes.Nop;
				list[36].opcode = OpCodes.Nop;
				list[37].opcode = OpCodes.Nop;
			}
			return list.AsEnumerable();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DashRest";

		public const string PLUGIN_NAME = "DashRest";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}