Decompiled source of PlayerEnergyRegen v1.0.0

build/PlayerEnergyRegen.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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("PlayerEnergyRegen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlayerEnergyRegen")]
[assembly: AssemblyTitle("PlayerEnergyRegen")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 BridgeGPT.PlayerEnergyRegen
{
	[BepInPlugin("com.bridgegpt.repo.playerenergyregen", "Player Energy Regen", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerController), "Update")]
		private static class PlayerEnergyUpdatePatch
		{
			private static void Prefix(PlayerController __instance)
			{
				if ((Object)(object)__instance == (Object)null || (Object)(object)__instance != (Object)(object)PlayerController.instance)
				{
					return;
				}
				try
				{
					if (Enabled == null || !Enabled.Value)
					{
						RechargeTimeField.SetValue(__instance, 1f);
						RechargeAmountField.SetValue(__instance, 2f);
					}
					else
					{
						RechargeTimeField.SetValue(__instance, RechargeDelay.Value);
						RechargeAmountField.SetValue(__instance, RechargeRate.Value);
					}
				}
				catch
				{
				}
			}
		}

		public const string PluginGuid = "com.bridgegpt.repo.playerenergyregen";

		public const string PluginName = "Player Energy Regen";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> RechargeRate;

		internal static ConfigEntry<float> RechargeDelay;

		internal static readonly FieldInfo RechargeTimeField = AccessTools.Field(typeof(PlayerController), "sprintRechargeTime");

		internal static readonly FieldInfo RechargeAmountField = AccessTools.Field(typeof(PlayerController), "sprintRechargeAmount");

		private Harmony _harmony;

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable configurable player energy regeneration.");
			RechargeRate = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RechargeRate", 8f, new ConfigDescription("Energy restored per second (vanilla: 2).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 50f), Array.Empty<object>()));
			RechargeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RechargeDelay", 0f, new ConfigDescription("Delay in seconds after sprinting before energy starts regenerating (vanilla: 1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			if (RechargeTimeField == null || RechargeAmountField == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find PlayerController stamina recharge fields. Plugin will not patch.");
				return;
			}
			_harmony = new Harmony("com.bridgegpt.repo.playerenergyregen");
			_harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Energy Regen loaded. Rate and delay are configurable.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}

package/PlayerEnergyRegen.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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("PlayerEnergyRegen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlayerEnergyRegen")]
[assembly: AssemblyTitle("PlayerEnergyRegen")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 BridgeGPT.PlayerEnergyRegen
{
	[BepInPlugin("com.bridgegpt.repo.playerenergyregen", "Player Energy Regen", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerController), "Update")]
		private static class PlayerEnergyUpdatePatch
		{
			private static void Prefix(PlayerController __instance)
			{
				if ((Object)(object)__instance == (Object)null || (Object)(object)__instance != (Object)(object)PlayerController.instance)
				{
					return;
				}
				try
				{
					if (Enabled == null || !Enabled.Value)
					{
						RechargeTimeField.SetValue(__instance, 1f);
						RechargeAmountField.SetValue(__instance, 2f);
					}
					else
					{
						RechargeTimeField.SetValue(__instance, RechargeDelay.Value);
						RechargeAmountField.SetValue(__instance, RechargeRate.Value);
					}
				}
				catch
				{
				}
			}
		}

		public const string PluginGuid = "com.bridgegpt.repo.playerenergyregen";

		public const string PluginName = "Player Energy Regen";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> RechargeRate;

		internal static ConfigEntry<float> RechargeDelay;

		internal static readonly FieldInfo RechargeTimeField = AccessTools.Field(typeof(PlayerController), "sprintRechargeTime");

		internal static readonly FieldInfo RechargeAmountField = AccessTools.Field(typeof(PlayerController), "sprintRechargeAmount");

		private Harmony _harmony;

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable configurable player energy regeneration.");
			RechargeRate = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RechargeRate", 8f, new ConfigDescription("Energy restored per second (vanilla: 2).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 50f), Array.Empty<object>()));
			RechargeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RechargeDelay", 0f, new ConfigDescription("Delay in seconds after sprinting before energy starts regenerating (vanilla: 1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			if (RechargeTimeField == null || RechargeAmountField == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find PlayerController stamina recharge fields. Plugin will not patch.");
				return;
			}
			_harmony = new Harmony("com.bridgegpt.repo.playerenergyregen");
			_harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Energy Regen loaded. Rate and delay are configurable.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}

src/bin/Release/netstandard2.1/PlayerEnergyRegen.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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("PlayerEnergyRegen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlayerEnergyRegen")]
[assembly: AssemblyTitle("PlayerEnergyRegen")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 BridgeGPT.PlayerEnergyRegen
{
	[BepInPlugin("com.bridgegpt.repo.playerenergyregen", "Player Energy Regen", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerController), "Update")]
		private static class PlayerEnergyUpdatePatch
		{
			private static void Prefix(PlayerController __instance)
			{
				if ((Object)(object)__instance == (Object)null || (Object)(object)__instance != (Object)(object)PlayerController.instance)
				{
					return;
				}
				try
				{
					if (Enabled == null || !Enabled.Value)
					{
						RechargeTimeField.SetValue(__instance, 1f);
						RechargeAmountField.SetValue(__instance, 2f);
					}
					else
					{
						RechargeTimeField.SetValue(__instance, RechargeDelay.Value);
						RechargeAmountField.SetValue(__instance, RechargeRate.Value);
					}
				}
				catch
				{
				}
			}
		}

		public const string PluginGuid = "com.bridgegpt.repo.playerenergyregen";

		public const string PluginName = "Player Energy Regen";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> RechargeRate;

		internal static ConfigEntry<float> RechargeDelay;

		internal static readonly FieldInfo RechargeTimeField = AccessTools.Field(typeof(PlayerController), "sprintRechargeTime");

		internal static readonly FieldInfo RechargeAmountField = AccessTools.Field(typeof(PlayerController), "sprintRechargeAmount");

		private Harmony _harmony;

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable configurable player energy regeneration.");
			RechargeRate = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RechargeRate", 8f, new ConfigDescription("Energy restored per second (vanilla: 2).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 50f), Array.Empty<object>()));
			RechargeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RechargeDelay", 0f, new ConfigDescription("Delay in seconds after sprinting before energy starts regenerating (vanilla: 1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			if (RechargeTimeField == null || RechargeAmountField == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find PlayerController stamina recharge fields. Plugin will not patch.");
				return;
			}
			_harmony = new Harmony("com.bridgegpt.repo.playerenergyregen");
			_harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Energy Regen loaded. Rate and delay are configurable.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}

src/obj/Release/netstandard2.1/PlayerEnergyRegen.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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("PlayerEnergyRegen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlayerEnergyRegen")]
[assembly: AssemblyTitle("PlayerEnergyRegen")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 BridgeGPT.PlayerEnergyRegen
{
	[BepInPlugin("com.bridgegpt.repo.playerenergyregen", "Player Energy Regen", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerController), "Update")]
		private static class PlayerEnergyUpdatePatch
		{
			private static void Prefix(PlayerController __instance)
			{
				if ((Object)(object)__instance == (Object)null || (Object)(object)__instance != (Object)(object)PlayerController.instance)
				{
					return;
				}
				try
				{
					if (Enabled == null || !Enabled.Value)
					{
						RechargeTimeField.SetValue(__instance, 1f);
						RechargeAmountField.SetValue(__instance, 2f);
					}
					else
					{
						RechargeTimeField.SetValue(__instance, RechargeDelay.Value);
						RechargeAmountField.SetValue(__instance, RechargeRate.Value);
					}
				}
				catch
				{
				}
			}
		}

		public const string PluginGuid = "com.bridgegpt.repo.playerenergyregen";

		public const string PluginName = "Player Energy Regen";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> RechargeRate;

		internal static ConfigEntry<float> RechargeDelay;

		internal static readonly FieldInfo RechargeTimeField = AccessTools.Field(typeof(PlayerController), "sprintRechargeTime");

		internal static readonly FieldInfo RechargeAmountField = AccessTools.Field(typeof(PlayerController), "sprintRechargeAmount");

		private Harmony _harmony;

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable configurable player energy regeneration.");
			RechargeRate = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RechargeRate", 8f, new ConfigDescription("Energy restored per second (vanilla: 2).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 50f), Array.Empty<object>()));
			RechargeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RechargeDelay", 0f, new ConfigDescription("Delay in seconds after sprinting before energy starts regenerating (vanilla: 1).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			if (RechargeTimeField == null || RechargeAmountField == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find PlayerController stamina recharge fields. Plugin will not patch.");
				return;
			}
			_harmony = new Harmony("com.bridgegpt.repo.playerenergyregen");
			_harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Player Energy Regen loaded. Rate and delay are configurable.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}