Decompiled source of LethalShygo v0.0.4

plugins/LethalShygo.dll

Decompiled 9 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalCompany_Shygo.Patches;
using LethalShygo.Properties;
using LethalThings;
using Microsoft.CodeAnalysis;
using ShygoMod;
using ShygoMod.Modules;
using ShygoMod.Patches;
using ShygoMod.Utils;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[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("LethalShygo")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("LethalCompany_Shygo")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalShygo")]
[assembly: AssemblyTitle("LethalShygo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 LethalShygo.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("LethalShygo.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] AssetsBundles
		{
			get
			{
				object @object = ResourceManager.GetObject("AssetsBundles", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] AssetsBundles_manifest
		{
			get
			{
				object @object = ResourceManager.GetObject("AssetsBundles_manifest", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] AssetsBundles1
		{
			get
			{
				object @object = ResourceManager.GetObject("AssetsBundles1", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] AssetsBundles2
		{
			get
			{
				object @object = ResourceManager.GetObject("AssetsBundles2", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] shygoobject
		{
			get
			{
				object @object = ResourceManager.GetObject("shygoobject", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] shygoobject_manifest
		{
			get
			{
				object @object = ResourceManager.GetObject("shygoobject_manifest", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] shygoobject1
		{
			get
			{
				object @object = ResourceManager.GetObject("shygoobject1", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] shygoobject2
		{
			get
			{
				object @object = ResourceManager.GetObject("shygoobject2", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace LethalCompany_Shygo.Patches
{
	[HarmonyPatch]
	internal class RoundManager_Pathe
	{
		private static ExampleNetworkHandler handler;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(RoundManager), "RefreshEnemiesList")]
		private static void RefreshEnemiesList()
		{
			try
			{
				if (NetworkManager.Singleton.IsServer)
				{
					if ((Object)(object)handler == (Object)null)
					{
						handler = Object.FindObjectOfType<ExampleNetworkHandler>();
					}
					if ((Object)(object)handler != (Object)null)
					{
						handler.TeleportAllPlayerInRound();
					}
				}
			}
			catch
			{
				ShygoModBase.Log.LogError((object)"Failed to instantiate network prefab!");
			}
		}
	}
}
namespace ShygoMod
{
	[BepInPlugin("Shygo", "LethalCompany_Shygo", "1.0.0.0")]
	public class ShygoModBase : BaseUnityPlugin
	{
		public static readonly Lazy<ShygoModBase> Instance = new Lazy<ShygoModBase>(() => new ShygoModBase());

		private const string modGUID = "Shygo";

		private const string modName = "LethalCompany_Shygo";

		private const string modVersion = "1.0.0.0";

		public static ManualLogSource Log = new ManualLogSource("LethalCompany_Shygo");

		private readonly Harmony harmony = new Harmony("Shygo");

		private void Awake()
		{
			Log = Logger.CreateLogSource("Shygo");
			Log.LogInfo((object)"PluginName: LethalCompany_Shygo, VersionString: 1.0.0.0 is loading...");
			ConfigSetup();
			LoadBundle();
			harmony.PatchAll(typeof(NetworkObjectManager));
			harmony.PatchAll(typeof(RoundManager_Pathe));
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		private void ConfigSetup()
		{
		}

		private void LoadBundle()
		{
		}
	}
}
namespace ShygoMod.Utils
{
	public class AssetBundlesManager
	{
		private static AssetBundlesManager _instance;

		private AssetBundle MainAssetBundle = AssetBundle.LoadFromMemory(Resources.shygoobject);

		private Dictionary<string, GameObject> assetBundles = new Dictionary<string, GameObject>();

		public static AssetBundlesManager Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new AssetBundlesManager();
				}
				return _instance;
			}
		}

		public GameObject Load(string name = "shygoobject")
		{
			if (!assetBundles.TryGetValue(name.ToLower(), out var value))
			{
				value = MainAssetBundle.LoadAsset<GameObject>(name.ToLower() + ".prefab");
				if ((Object)(object)value != (Object)null)
				{
					assetBundles.Add(name.ToLower(), value);
				}
				else
				{
					ShygoModBase.Log.LogError((object)"Failed to LoadAsset<GameObject>()!");
				}
			}
			return value;
		}
	}
}
namespace ShygoMod.Patches
{
	[HarmonyPatch]
	internal class NetworkObjectManager
	{
		private static GameObject networkPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		private static void Start_Prefix(GameNetworkManager __instance)
		{
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = AssetBundlesManager.Instance.Load();
				if ((Object)(object)networkPrefab != (Object)null)
				{
					networkPrefab.AddComponent<ExampleNetworkHandler>();
					NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
}
namespace ShygoMod.Modules
{
	public class ExampleNetworkHandler : NetworkBehaviour
	{
		public void TeleportAllPlayerInRound()
		{
			((MonoBehaviour)this).StartCoroutine(TeleportPlayerInRoundCoroutine());
		}

		public void TeleportAllPlayerInSpawn()
		{
			((MonoBehaviour)this).StartCoroutine(TeleportPlayerInSpawnCoroutine());
		}

		private IEnumerator TeleportPlayerInRoundCoroutine()
		{
			yield return (object)new WaitForSeconds(15f);
			for (int i = 0; i < NetworkManager.Singleton.ConnectedClients.Count; i++)
			{
				Vector3 position2 = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
				position2 = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(position2, 10f, default(NavMeshHit));
				TeleportPlayerInRoundServerRpc(i, position2);
				yield return null;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void TeleportPlayerInRoundServerRpc(int playerObj, Vector3 teleportPos)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2326039350u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerObj);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref teleportPos);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2326039350u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					TeleportPlayerInRoundClientRpc(playerObj, teleportPos);
				}
			}
		}

		[ClientRpc]
		public void TeleportPlayerInRoundClientRpc(int playerObj, Vector3 teleportPos)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1000866703u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerObj);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref teleportPos);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1000866703u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Utilities.TeleportPlayer(playerObj, teleportPos);
				}
			}
		}

		private IEnumerator TeleportPlayerInSpawnCoroutine()
		{
			yield return (object)new WaitForSeconds(4f);
			for (int i = 0; i < NetworkManager.Singleton.ConnectedClients.Count; i++)
			{
				TeleportPlayerInSpawnServerRpc(i);
				yield return null;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void TeleportPlayerInSpawnServerRpc(int playerObj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3853993999u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerObj);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3853993999u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					TeleportPlayerInSpawnClientRpc(playerObj);
				}
			}
		}

		[ClientRpc]
		public void TeleportPlayerInSpawnClientRpc(int playerObj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(806288107u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerObj);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 806288107u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					StartOfRound.Instance.allPlayerScripts[playerObj].TeleportPlayer(StartOfRound.Instance.GetPlayerSpawnPosition(playerObj, false), false, 0f, false, true);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ExampleNetworkHandler()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2326039350u, new RpcReceiveHandler(__rpc_handler_2326039350));
			NetworkManager.__rpc_func_table.Add(1000866703u, new RpcReceiveHandler(__rpc_handler_1000866703));
			NetworkManager.__rpc_func_table.Add(3853993999u, new RpcReceiveHandler(__rpc_handler_3853993999));
			NetworkManager.__rpc_func_table.Add(806288107u, new RpcReceiveHandler(__rpc_handler_806288107));
		}

		private static void __rpc_handler_2326039350(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerObj = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObj);
				Vector3 teleportPos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref teleportPos);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ExampleNetworkHandler)(object)target).TeleportPlayerInRoundServerRpc(playerObj, teleportPos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1000866703(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerObj = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObj);
				Vector3 teleportPos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref teleportPos);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ExampleNetworkHandler)(object)target).TeleportPlayerInRoundClientRpc(playerObj, teleportPos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3853993999(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerObj = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObj);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ExampleNetworkHandler)(object)target).TeleportPlayerInSpawnServerRpc(playerObj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_806288107(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerObj = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerObj);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ExampleNetworkHandler)(object)target).TeleportPlayerInSpawnClientRpc(playerObj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ExampleNetworkHandler";
		}
	}
}
namespace ShygoMod.ConfigAttributes
{
	internal sealed class ConfigurationManagerAttributes
	{
		public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

		public bool? ShowRangeAsPercent;

		public Action<ConfigEntryBase> CustomDrawer;

		public CustomHotkeyDrawerFunc CustomHotkeyDrawer;

		public bool? Browsable;

		public string Category;

		public object DefaultValue;

		public bool? HideDefaultButton;

		public bool? HideSettingName;

		public string Description;

		public string DispName;

		public int? Order;

		public bool? ReadOnly;

		public bool? IsAdvanced;

		public Func<object, string> ObjToStr;

		public Func<string, object> StrToObj;
	}
}