Decompiled source of 196Charmosa v1.0.1

com.mrsaltedbeef.Charmosa.dll

Decompiled a day 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.Logging;
using GameNetcodeStuff;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using Unity.Netcode;
using UnityEngine;
using com.mrsaltedbeef.Charmosa.NetcodePatcher;

[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("MrSaltedBeef")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright (c) 2026 MrSaltedBeef")]
[assembly: AssemblyFileVersion("0.1.0.1")]
[assembly: AssemblyInformationalVersion("0.1.0+39b7f5288791d2471025443dfc09e1069d73e249")]
[assembly: AssemblyProduct("com.mrsaltedbeef.Charmosa")]
[assembly: AssemblyTitle("Charmosa")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
	[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 Charmosa
{
	internal sealed class ModNetwork : NetworkBehaviour
	{
		public static ModNetwork? Instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		public override void OnNetworkDespawn()
		{
			Instance = null;
			((NetworkBehaviour)this).OnNetworkDespawn();
		}

		[ClientRpc]
		public void AnnounceClientRpc(string text)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2494969264u, val2, (RpcDelivery)0);
				bool flag = text != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2494969264u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				Plugin.Log.LogInfo((object)("Host says: " + text));
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2494969264u, new RpcReceiveHandler(__rpc_handler_2494969264), "AnnounceClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_2494969264(NetworkBehaviour? target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string text = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ModNetwork)(object)target).AnnounceClientRpc(text);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string? __getTypeName()
		{
			return "ModNetwork";
		}
	}
	internal static class ModNetworkSetup
	{
		private const uint PrefabId = 1152511527u;

		private static GameObject? prefab;

		private static Hook? registerHook;

		private static Hook? spawnHook;

		internal static void Install()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			Type[] array = LoadableTypes();
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			registerHook = new Hook((MethodBase)typeof(GameNetworkManager).GetMethod("Start", BindingFlags.Instance | BindingFlags.NonPublic), (Delegate)new Action<Action<GameNetworkManager>, GameNetworkManager>(Register));
			spawnHook = new Hook((MethodBase)typeof(StartOfRound).GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic), (Delegate)new Action<Action<StartOfRound>, StartOfRound>(Spawn));
		}

		private static Type[] LoadableTypes()
		{
			try
			{
				return Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return Array.FindAll(ex.Types, (Type t) => t != null);
			}
		}

		private static void Register(Action<GameNetworkManager> orig, GameNetworkManager self)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			orig(self);
			prefab = new GameObject("ModNetwork")
			{
				hideFlags = (HideFlags)61
			};
			NetworkObject val = prefab.AddComponent<NetworkObject>();
			val.GlobalObjectIdHash = 1152511527u;
			prefab.AddComponent<ModNetwork>();
			NetworkManager.Singleton.AddNetworkPrefab(prefab);
		}

		private static void Spawn(Action<StartOfRound> orig, StartOfRound self)
		{
			orig(self);
			if ((Object)(object)prefab != (Object)null && NetworkManager.Singleton.IsServer)
			{
				Object.Instantiate<GameObject>(prefab).GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
	[BepInPlugin("com.mrsaltedbeef.Charmosa", "Charmosa", "0.1.0")]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			ModNetworkSetup.Install();
			Log.LogInfo((object)"Charmosa 0.1.0 loaded");
		}
	}
	public class WeepingAI : SpringManAI
	{
		public override void Awake()
		{
			((EnemyAI)this).Awake();
			base.currentChaseSpeed = 9.333f;
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (!base.stoppingMovement && ((EnemyAI)this).currentBehaviourStateIndex == 1 && !((double)base.hitPlayerTimer >= 0.0) && !base.setOnCooldown && !((double)Time.realtimeSinceStartup - (double)base.timeAtLastCooldown < 0.45))
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, true);
				if ((Object)(object)val != (Object)null)
				{
					base.hitPlayerTimer = 0.2f;
					val.DamagePlayer(90, true, true, (CauseOfDeath)4, 9, false, default(Vector3));
					val.JumpToFearLevel(1f, true);
					base.timeSinceHittingPlayer = Time.realtimeSinceStartup;
				}
			}
		}

		protected override void __initializeVariables()
		{
			((SpringManAI)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			((SpringManAI)this).__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "WeepingAI";
		}
	}
	internal static class MyPluginInfo
	{
		public const string Id = "com.mrsaltedbeef.Charmosa";

		public const string Name = "Charmosa";

		public const string Version = "0.1.0";
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace com.mrsaltedbeef.Charmosa.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}