Decompiled source of SprintSpeedLimit v1.0.0

SprintSpeedLimit.dll

Decompiled an hour ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
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: AssemblyVersion("0.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 SprintSpeedLimit
{
	[BepInPlugin("wuguishifu.SprintSpeedLimit", "SprintSpeedLimit", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "wuguishifu.SprintSpeedLimit";

		public const string PluginName = "SprintSpeedLimit";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<int> MaxSprintUpgrades;

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			MaxSprintUpgrades = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxSprintSpeedUpgrades", 3, new ConfigDescription("Maximum number of sprint speed upgrades a single player can have. Upgrades used beyond this limit are consumed and do nothing.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			new Harmony("wuguishifu.SprintSpeedLimit").PatchAll(typeof(Plugin).Assembly);
			Log.LogInfo((object)string.Format("{0} {1} loaded (max sprint upgrades: {2})", "SprintSpeedLimit", "1.0.0", MaxSprintUpgrades.Value));
		}
	}
	[HarmonyPatch(typeof(PunManager), "UpgradePlayerSprintSpeed")]
	internal static class UpgradePlayerSprintSpeedPatch
	{
		private static void Prefix(string _steamID, ref int value)
		{
			if (value > 0 && !((Object)(object)StatsManager.instance == (Object)null))
			{
				int value2 = Plugin.MaxSprintUpgrades.Value;
				StatsManager.instance.playerUpgradeSpeed.TryGetValue(_steamID, out var value3);
				int num = Math.Max(0, value2 - value3);
				if (value > num)
				{
					Plugin.Log.LogInfo((object)$"Sprint upgrade for {_steamID} clamped: has {value3}, requested +{value}, cap {value2} -> +{num}");
					value = num;
				}
			}
		}
	}
}