Decompiled source of InfiniteStamina v1.0.1

InfiniteStamina.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using InfiniteStamina;
using MelonLoader;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "InfiniteStamina", "1.0.1", "ToxesFoxes", null)]
[assembly: MelonGame("ReLUGames", "MIMESIS")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("InfiniteStamina")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bc20fe3cdfa76dc56dd001733c271fb380aa5ccd")]
[assembly: AssemblyProduct("InfiniteStamina")]
[assembly: AssemblyTitle("InfiniteStamina")]
[assembly: NeutralResourcesLanguage("en-US")]
[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 InfiniteStamina
{
	public class Core : MelonMod
	{
		public override void OnInitializeMelon()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			MelonLogger.Msg("=================================================");
			MelonLogger.Msg("InfiniteStamina Mod v1.0.0 - Initializing...");
			MelonLogger.Msg("=================================================");
			MelonLogger.Msg("Author: github.com/ToxesFoxes");
			MelonLogger.Msg("Target: StatManager");
			try
			{
				Harmony val = new Harmony("com.toxesfoxes.infinitestamina.mod");
				MelonLogger.Msg("Applying Harmony patches...");
				val.PatchAll(Assembly.GetExecutingAssembly());
				MelonLogger.Msg("=================================================");
				MelonLogger.Msg("SUCCESS: All Harmony patches applied!");
				MelonLogger.Msg("=================================================");
				MelonLogger.Msg("Active patches:");
				MelonLogger.Msg("  [1] GetCurrentStamina() - Prefix");
				MelonLogger.Msg("  [2] RegenerateStamina() - Prefix");
				MelonLogger.Msg("=================================================");
			}
			catch (Exception ex)
			{
				MelonLogger.Error("=================================================");
				MelonLogger.Error("FAILED to apply Harmony patches!");
				MelonLogger.Error("Exception: " + ex.Message);
				MelonLogger.Error("Stack: " + ex.StackTrace);
				MelonLogger.Error("=================================================");
				MelonLogger.Error("Please report this error with full log!");
			}
		}
	}
	[HarmonyPatch(typeof(StatManager), "GetCurrentStamina")]
	public class GetCurrentStamina_Patch
	{
		private static bool Prefix(StatManager __instance, ref long __result)
		{
			try
			{
				__instance.GetStats();
				__result = 10000L;
				return false;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Error in GetCurrentStamina_Patch: " + ex.Message);
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(StatManager), "RegenerateStamina")]
	public class RegenerateStamina_Patch
	{
		private static bool Prefix(StatManager __instance, ref long delta)
		{
			try
			{
				__instance.SetMutableStat((MutableStatType)7, 10000L, (VActor)null, (VActorEventArgs)null);
				return false;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Error in GetCurrentStamina_Patch: " + ex.Message);
				return true;
			}
		}
	}
}