Decompiled source of NoWeightMod v1.0.0

NoWeightMod.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoWeightMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoWeightMod")]
[assembly: AssemblyTitle("NoWeightMod")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace NoWeightMod
{
	[BepInPlugin("com.Ho0o0oniii.NoWeightMod", "No Weight Mod", "1.0.0")]
	public class WeightMod : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static WeightMod Instance;

		public static ConfigEntry<bool> C_EnableMod;

		public static ConfigEntry<bool> C_InfiniteStamina;

		public static ConfigEntry<float> C_WeightMultiplier;

		public static bool S_EnableMod;

		public static bool S_InfiniteStamina;

		public static float S_WeightMultiplier;

		private void Awake()
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			Instance = this;
			C_EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "모드 사용 여부 (호스트 설정 우선)");
			C_InfiniteStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "InfiniteStamina", false, "무한 스태미나 (호스트 설정 우선)");
			C_WeightMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "WeightMultiplier", 0f, "무게 배율 (0.0 = 무게 없음, 1.0 = 정상)");
			S_EnableMod = C_EnableMod.Value;
			S_InfiniteStamina = C_InfiniteStamina.Value;
			S_WeightMultiplier = C_WeightMultiplier.Value;
			_harmony = new Harmony("com.Ho0o0oniii.NoWeightMod");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)">>> [No Weight Mod] Loaded <<<");
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class NetworkPatch
	{
		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void OnConnect()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			if (NetworkManager.Singleton.IsHost)
			{
				WeightMod.S_EnableMod = WeightMod.C_EnableMod.Value;
				WeightMod.S_InfiniteStamina = WeightMod.C_InfiniteStamina.Value;
				WeightMod.S_WeightMultiplier = WeightMod.C_WeightMultiplier.Value;
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("NoWeight_Sync", new HandleNamedMessageDelegate(ReceiveConfig));
				Debug.Log((object)">>> [Host] 설정 동기화 서버 시작 <<<");
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("NoWeight_Sync", new HandleNamedMessageDelegate(ReceiveConfig));
				Debug.Log((object)">>> [Client] 호스트 설정을 대기 중... <<<");
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void SyncTrigger(PlayerControllerB __instance)
		{
			if (NetworkManager.Singleton.IsHost && ((NetworkBehaviour)__instance).IsOwner && Time.frameCount % 60 == 0)
			{
				SendConfigToClients();
			}
		}

		public static void SendConfigToClients()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref WeightMod.S_EnableMod, default(ForPrimitives));
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref WeightMod.S_InfiniteStamina, default(ForPrimitives));
			((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref WeightMod.S_WeightMultiplier, default(ForPrimitives));
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("NoWeight_Sync", val, (NetworkDelivery)3);
		}

		public static void ReceiveConfig(ulong senderId, FastBufferReader reader)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsClient)
			{
				bool s_EnableMod = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref s_EnableMod, default(ForPrimitives));
				bool s_InfiniteStamina = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref s_InfiniteStamina, default(ForPrimitives));
				float s_WeightMultiplier = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref s_WeightMultiplier, default(ForPrimitives));
				WeightMod.S_EnableMod = s_EnableMod;
				WeightMod.S_InfiniteStamina = s_InfiniteStamina;
				WeightMod.S_WeightMultiplier = s_WeightMultiplier;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class GamePatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void ApplyCheats(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && WeightMod.S_EnableMod)
			{
				float carryWeight = __instance.carryWeight;
				float num = 1f;
				float num2 = Mathf.Max(0f, carryWeight - num);
				__instance.carryWeight = num + num2 * WeightMod.S_WeightMultiplier;
				if (WeightMod.S_InfiniteStamina)
				{
					__instance.sprintMeter = 1f;
				}
			}
		}
	}
}