Decompiled source of ConfigurableWeightEffect v1.0.0

ConfigurableWeightEffect.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConfigurableWeightEffect.Patches;
using GameNetcodeStuff;
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("ConfigurableWeightEffect")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fbdd2609fbba525bbc8598587bfd0a14c3190a4d")]
[assembly: AssemblyProduct("Makes the effect of weight on the players speed less or more. (config file)")]
[assembly: AssemblyTitle("ConfigurableWeightEffect")]
[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 ConfigurableWeightEffect
{
	[BepInPlugin("org.configurable-weight-effect.axian", "Configurable Weight Effect", "1.0.0")]
	public class ConfigurableWeightEffect : BaseUnityPlugin
	{
		public const string modGUID = "org.configurable-weight-effect.axian";

		public const string modName = "Configurable Weight Effect";

		public const string modVersion = "1.0.0";

		internal static ManualLogSource Logger;

		private readonly Harmony harmony = new Harmony("org.configurable-weight-effect.axian");

		private static ConfigurableWeightEffect Instance;

		private ConfigEntry<float> divisorConfigEntry;

		public static float divisor;

		public static float Weight;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin org.configurable-weight-effect.axian is loaded!");
			harmony.PatchAll(typeof(ConfigurableWeightEffect));
			harmony.PatchAll(typeof(PlayerControllerB_patches));
			divisorConfigEntry = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Divisor", 2f, "The divisor of the weight effect.");
			divisor = divisorConfigEntry.Value;
		}

		[HarmonyPatch(typeof(ItemCharger))]
		[HarmonyPatch("ChargeItem")]
		[HarmonyPostfix]
		private static void OnItemCharge()
		{
			Logger.LogInfo((object)$"Current Player Weight is: {Weight}");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ConfigurableWeightEffect";

		public const string PLUGIN_NAME = "Makes the effect of weight on the players speed less or more. (config file)";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ConfigurableWeightEffect.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	[HarmonyPatch("Update")]
	public class PlayerControllerB_patches
	{
		private static float float1;

		public static float divisor = ConfigurableWeightEffect.divisor;

		[HarmonyPrefix]
		public static void PrefixPatch(PlayerControllerB __instance)
		{
			float1 = __instance.carryWeight - 1f;
			float1 /= divisor;
			__instance.carryWeight = float1 + 1f;
			ConfigurableWeightEffect.Weight = __instance.carryWeight;
		}

		[HarmonyPostfix]
		public static void PostfixPatch(PlayerControllerB __instance)
		{
			float1 = __instance.carryWeight - 1f;
			float1 *= divisor;
			__instance.carryWeight = float1 + 1f;
		}
	}
}