Decompiled source of Hard Mode v1.0.0

plugins/2018-Brutal_Company/BrutalCompany.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using BrutalCompany.Component;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Project1.Data;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("BrutalCompany")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BrutalCompany")]
[assembly: AssemblyTitle("BrutalCompany")]
[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 Project1
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BrutalCompany";

		public const string PLUGIN_NAME = "BrutalCompany";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Project1.Data
{
	internal enum EventEnum
	{
		None,
		Turret,
		Landmine,
		Hoarding,
		Lasso,
		Unfair,
		OopsAllSnareFlea,
		BrackenAndCoil,
		Chaos,
		GoToRend,
		All,
		Delivery,
		ReplaceItems,
		Schizophrenia,
		SupriseLandmines,
		ResetHeat,
		SpawnTurret
	}
}
namespace BrutalCompany
{
	[BepInPlugin("BrutalCompany", "BrutalCompany", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static bool loaded;

		private Harmony _harmony = new Harmony("BrutalCompany");

		public static List<SelectableLevel> levelsModified = new List<SelectableLevel>();

		public static Dictionary<SelectableLevel, float> levelHeatVal;

		public static Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>> levelEnemySpawns;

		public static Dictionary<SpawnableEnemyWithRarity, int> enemyRaritys;

		public static Dictionary<SpawnableEnemyWithRarity, AnimationCurve> enemyPropCurves;

		public static ManualLogSource mls;

		private void Awake()
		{
			mls = Logger.CreateLogSource("BrutalCompany");
			mls.LogInfo((object)"Loaded Brutal Company and applying patches.");
			_harmony.PatchAll(typeof(Plugin));
			mls = ((BaseUnityPlugin)this).Logger;
			levelHeatVal = new Dictionary<SelectableLevel, float>();
			enemyRaritys = new Dictionary<SpawnableEnemyWithRarity, int>();
			levelEnemySpawns = new Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>>();
			enemyPropCurves = new Dictionary<SpawnableEnemyWithRarity, AnimationCurve>();
		}

		public void OnDestroy()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (!loaded)
			{
				GameObject val = new GameObject("QuotaChanger");
				Object.DontDestroyOnLoad((Object)val);
				val.AddComponent<QuotaAjuster>();
				loaded = true;
			}
		}

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool ModifyLevel(ref SelectableLevel newLevel)
		{
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Expected O, but got Unknown
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Expected O, but got Unknown
			//IL_0a4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a74: Expected O, but got Unknown
			//IL_0a07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a31: Expected O, but got Unknown
			//IL_0afc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b26: Expected O, but got Unknown
			//IL_0abc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae6: Expected O, but got Unknown
			//IL_0ced: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d19: Expected O, but got Unknown
			//IL_0d2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d5e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d63: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d72: Expected O, but got Unknown
			//IL_0c78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca2: Expected O, but got Unknown
			//IL_0d93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dcd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd7: Expected O, but got Unknown
			//IL_0df8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dfd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e0c: Expected O, but got Unknown
			//IL_0e2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e41: Expected O, but got Unknown
			if (((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				QuotaAjuster.CleanupAllSpawns();
				EventEnum eventEnum = (EventEnum)Mathf.Clamp(Random.Range(-1, 17), 0, 99);
				if (!levelHeatVal.ContainsKey(newLevel))
				{
					levelHeatVal.Add(newLevel, 0f);
				}
				if (!levelEnemySpawns.ContainsKey(newLevel))
				{
					List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
					foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
					{
						list.Add(enemy);
					}
					levelEnemySpawns.Add(newLevel, list);
				}
				levelEnemySpawns.TryGetValue(newLevel, out var value);
				newLevel.Enemies = value;
				foreach (SelectableLevel item3 in levelHeatVal.Keys.ToList())
				{
					levelHeatVal.TryGetValue(item3, out var value2);
					levelHeatVal[item3] = Mathf.Clamp(value2 - 5f, 0f, 100f);
					if (eventEnum == EventEnum.ResetHeat || eventEnum == EventEnum.All)
					{
						levelHeatVal[item3] = 0f;
					}
				}
				levelHeatVal.TryGetValue(newLevel, out var value3);
				foreach (SpawnableEnemyWithRarity enemy2 in newLevel.Enemies)
				{
					if (!enemyRaritys.ContainsKey(enemy2))
					{
						enemyRaritys.Add(enemy2, enemy2.rarity);
					}
					int value4 = 0;
					enemyRaritys.TryGetValue(enemy2, out value4);
					enemy2.rarity = value4;
				}
				foreach (SpawnableEnemyWithRarity enemy3 in newLevel.Enemies)
				{
					if (!enemyPropCurves.ContainsKey(enemy3))
					{
						enemyPropCurves.Add(enemy3, enemy3.enemyType.probabilityCurve);
					}
					AnimationCurve value5 = new AnimationCurve();
					enemyPropCurves.TryGetValue(enemy3, out value5);
					enemy3.enemyType.probabilityCurve = value5;
				}
				HUDManager.Instance.AddTextToChatOnServer("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", -1);
				HUDManager.Instance.AddTextToChatOnServer("<color=orange>MOON IS AT " + value3 + "% HEAT</color>", -1);
				if (value3 > 49f)
				{
					HUDManager.Instance.AddTextToChatOnServer("<color=red>HEAT LEVEL IS DANGEROUSLY HIGH. <color=white>\nVISIT OTHER MOONS TO LOWER HEAT LEVEL.</color>", -1);
				}
				Random.Range(-5, 3);
				Random.Range(-5, 3);
				if (newLevel.sceneName == "CompanyBuilding")
				{
					eventEnum = EventEnum.None;
				}
				switch (eventEnum)
				{
				default:
					HUDManager.Instance.AddTextToChatOnServer("<color=green>Level event: NONE</color>", -1);
					break;
				case EventEnum.None:
					HUDManager.Instance.AddTextToChatOnServer("<color=green>Level event: NONE</color>", -1);
					break;
				case EventEnum.Turret:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: TURRET HELL</color>", -1);
					break;
				case EventEnum.Landmine:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: LANDMINE HELL</color>", -1);
					break;
				case EventEnum.Hoarding:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: HOARDER TOWN</color>", -1);
					foreach (SpawnableEnemyWithRarity enemy4 in newLevel.Enemies)
					{
						if ((Object)(object)enemy4.enemyType.enemyPrefab.GetComponent<HoarderBugAI>() != (Object)null)
						{
							enemy4.rarity = 999;
						}
					}
					break;
				case EventEnum.Lasso:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: LASSO MAN IS REAL</color>", -1);
					AddLassomanToLevel(newLevel);
					break;
				case EventEnum.Unfair:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: UNFAIR COMPANY</color>", -1);
					break;
				case EventEnum.OopsAllSnareFlea:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: OOPS, ALL SNARE FLEAS!</color>", -1);
					foreach (SpawnableEnemyWithRarity enemy5 in newLevel.Enemies)
					{
						enemy5.rarity = 0;
						if ((Object)(object)enemy5.enemyType.enemyPrefab.GetComponent<CentipedeAI>() != (Object)null)
						{
							enemy5.rarity = 999;
						}
					}
					break;
				case EventEnum.BrackenAndCoil:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: THE WORST COMBO OF ALL TIME</color>", -1);
					foreach (SpawnableEnemyWithRarity enemy6 in newLevel.Enemies)
					{
						enemy6.rarity = 0;
						if ((Object)(object)enemy6.enemyType.enemyPrefab.GetComponent<FlowermanAI>() != (Object)null)
						{
							enemy6.rarity = 999;
						}
						if ((Object)(object)enemy6.enemyType.enemyPrefab.GetComponent<SpringManAI>() != (Object)null)
						{
							enemy6.rarity = 999;
						}
					}
					break;
				case EventEnum.Chaos:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: CHAOS COMPANY</color>", -1);
					foreach (SpawnableEnemyWithRarity enemy7 in newLevel.Enemies)
					{
						enemy7.enemyType.probabilityCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
						{
							new Keyframe(0f, 1000f)
						});
					}
					break;
				case EventEnum.All:
				{
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: ALL</color>", -1);
					foreach (SpawnableEnemyWithRarity enemy8 in newLevel.Enemies)
					{
						enemy8.enemyType.probabilityCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
						{
							new Keyframe(0f, 1000f)
						});
					}
					foreach (SpawnableEnemyWithRarity enemy9 in newLevel.Enemies)
					{
						enemy9.rarity = 0;
						if ((Object)(object)enemy9.enemyType.enemyPrefab.GetComponent<FlowermanAI>() != (Object)null)
						{
							enemy9.rarity = 999;
						}
						if ((Object)(object)enemy9.enemyType.enemyPrefab.GetComponent<SpringManAI>() != (Object)null)
						{
							enemy9.rarity = 999;
						}
					}
					foreach (SpawnableEnemyWithRarity enemy10 in newLevel.Enemies)
					{
						if ((Object)(object)enemy10.enemyType.enemyPrefab.GetComponent<CentipedeAI>() != (Object)null)
						{
							enemy10.rarity = 999;
						}
					}
					AddLassomanToLevel(newLevel);
					foreach (SpawnableEnemyWithRarity enemy11 in newLevel.Enemies)
					{
						if ((Object)(object)enemy11.enemyType.enemyPrefab.GetComponent<LassoManAI>() != (Object)null)
						{
							enemy11.rarity = 999;
						}
					}
					foreach (SpawnableEnemyWithRarity enemy12 in newLevel.Enemies)
					{
						if ((Object)(object)enemy12.enemyType.enemyPrefab.GetComponent<HoarderBugAI>() != (Object)null)
						{
							enemy12.rarity = 999;
						}
					}
					foreach (SpawnableEnemyWithRarity enemy13 in newLevel.Enemies)
					{
						if ((Object)(object)enemy13.enemyType.enemyPrefab.GetComponent<DressGirlAI>() != (Object)null)
						{
							enemy13.rarity = 9999;
						}
					}
					int num3 = Random.Range(2, 9);
					for (int k = 0; k < num3; k++)
					{
						int item2 = Random.Range(0, 3);
						Object.FindObjectOfType<Terminal>().orderedItemsFromTerminal.Add(item2);
					}
					Terminal val2 = Object.FindObjectOfType<Terminal>();
					int count = val2.orderedItemsFromTerminal.Count;
					val2.orderedItemsFromTerminal.Clear();
					for (int l = 0; l < count; l++)
					{
						val2.orderedItemsFromTerminal.Add(0);
					}
					QuotaAjuster.slSpawnTimer = -10f;
					QuotaAjuster.surpriseLandmines += 120;
					break;
				}
				case EventEnum.Delivery:
				{
					HUDManager.Instance.AddTextToChatOnServer("<color=green>Level event: DELIVERY!</color>", -1);
					int num2 = Random.Range(2, 9);
					for (int j = 0; j < num2; j++)
					{
						int item = Random.Range(0, 6);
						Object.FindObjectOfType<Terminal>().orderedItemsFromTerminal.Add(item);
					}
					break;
				}
				case EventEnum.ReplaceItems:
				{
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: YOU BOUGHT WALKIES, RIGHT?</color>", -1);
					Terminal val = Object.FindObjectOfType<Terminal>();
					int num = val.orderedItemsFromTerminal.Count;
					if (num == 0)
					{
						num = 1;
					}
					val.orderedItemsFromTerminal.Clear();
					for (int i = 0; i < num; i++)
					{
						val.orderedItemsFromTerminal.Add(0);
					}
					break;
				}
				case EventEnum.Schizophrenia:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: SCHIZOPHRENIA</color>", -1);
					foreach (SpawnableEnemyWithRarity enemy14 in newLevel.Enemies)
					{
						if ((Object)(object)enemy14.enemyType.enemyPrefab.GetComponent<DressGirlAI>() != (Object)null)
						{
							enemy14.rarity = 9999;
						}
					}
					break;
				case EventEnum.SupriseLandmines:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: SPONTANEOUS COMBUSTION</color>", -1);
					QuotaAjuster.slSpawnTimer = -10f;
					QuotaAjuster.surpriseLandmines += 120;
					break;
				case EventEnum.ResetHeat:
					HUDManager.Instance.AddTextToChatOnServer("<color=green>Level event: RESET ALL HEAT</color>", -1);
					break;
				case EventEnum.SpawnTurret:
					HUDManager.Instance.AddTextToChatOnServer("<color=red>Level event: THE COMPANIES AUTOMATED DEFENSE SYSTEM</color>", -1);
					QuotaAjuster.shouldSpawnTurret = true;
					break;
				}
				SelectableLevel val3 = newLevel;
				mls.LogWarning((object)"Map Objects");
				SpawnableMapObject[] spawnableMapObjects = val3.spawnableMapObjects;
				foreach (SpawnableMapObject val4 in spawnableMapObjects)
				{
					if ((Object)(object)val4.prefabToSpawn.GetComponentInChildren<Turret>() != (Object)null)
					{
						QuotaAjuster.turret = val4.prefabToSpawn;
						if (eventEnum == EventEnum.Turret || eventEnum == EventEnum.All)
						{
							val4.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
							{
								new Keyframe(0f, 200f),
								new Keyframe(1f, 25f)
							});
						}
						else
						{
							val4.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
							{
								new Keyframe(0f, 0f),
								new Keyframe(1f, 10f)
							});
						}
					}
					else if ((Object)(object)val4.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
					{
						QuotaAjuster.landmine = val4.prefabToSpawn;
						if (eventEnum == EventEnum.Landmine || eventEnum == EventEnum.All)
						{
							val4.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
							{
								new Keyframe(0f, 300f),
								new Keyframe(1f, 170f)
							});
						}
						else
						{
							val4.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
							{
								new Keyframe(0f, 0f),
								new Keyframe(1f, 70f)
							});
						}
					}
					mls.LogInfo((object)((object)val4.prefabToSpawn).ToString());
				}
				mls.LogWarning((object)"Enemies");
				foreach (SpawnableEnemyWithRarity enemy15 in val3.Enemies)
				{
					mls.LogInfo((object)(enemy15.enemyType.enemyName + "--rarity = " + enemy15.rarity));
				}
				mls.LogWarning((object)"Daytime Enemies");
				foreach (SpawnableEnemyWithRarity daytimeEnemy in val3.DaytimeEnemies)
				{
					mls.LogInfo((object)daytimeEnemy.enemyType.enemyName);
				}
				if (!levelsModified.Contains(newLevel))
				{
					levelsModified.Add(newLevel);
					val3.minScrap = val3.minScrap;
					val3.maxScrap += 45;
					val3.minTotalScrapValue = val3.minTotalScrapValue;
					val3.maxTotalScrapValue += 800;
					val3.daytimeEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
					{
						new Keyframe(0f, 7f),
						new Keyframe(0.5f, 7f)
					});
					val3.maxEnemyPowerCount += 2000;
					val3.maxOutsideEnemyPowerCount += 20;
					val3.maxDaytimeEnemyPowerCount += 200;
					newLevel = val3;
				}
				val3.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 0.1f + value3),
					new Keyframe(0.5f, 500f + value3)
				});
				val3.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(0f, -30f + value3),
					new Keyframe(20f, -30f + value3),
					new Keyframe(21f, 10f + value3)
				});
				if (eventEnum == EventEnum.Unfair || eventEnum == EventEnum.All)
				{
					val3.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
					{
						new Keyframe(0f, 10f + value3),
						new Keyframe(20f, 10f + value3),
						new Keyframe(21f, 10f + value3)
					});
				}
				if (eventEnum == EventEnum.Hoarding || eventEnum == EventEnum.All)
				{
					val3.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
					{
						new Keyframe(0f, 500f + value3)
					});
				}
				if (eventEnum == EventEnum.Chaos || eventEnum == EventEnum.All)
				{
					val3.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
					{
						new Keyframe(0f, 500f + value3)
					});
				}
				levelHeatVal.TryGetValue(newLevel, out value3);
				levelHeatVal[newLevel] = Mathf.Clamp(value3 + 20f, 0f, 100f);
				Terminal val5 = Object.FindObjectOfType<Terminal>();
				val5.groupCredits += 120;
				val5.SyncGroupCreditsServerRpc(val5.groupCredits, val5.numberOfItemsInDropship);
				if (val5.groupCredits > 250)
				{
					HUDManager.Instance.AddTextToChatOnServer("<color=green>(You get free money every time you land, spend it!)</color>", -1);
				}
			}
			return true;
		}

		private static void AddLassomanToLevel(SelectableLevel newLevel)
		{
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			bool flag = false;
			bool flag2 = false;
			foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
			{
				if ((Object)(object)enemy.enemyType.enemyPrefab.GetComponent<LassoManAI>() != (Object)null)
				{
					flag = true;
				}
			}
			if (!flag)
			{
				SelectableLevel[] levels = StartOfRound.Instance.levels;
				for (int i = 0; i < levels.Length; i++)
				{
					foreach (SpawnableEnemyWithRarity enemy2 in levels[i].Enemies)
					{
						if ((Object)(object)enemy2.enemyType.enemyPrefab.GetComponent<LassoManAI>() != (Object)null && !flag2)
						{
							flag2 = true;
							newLevel.Enemies.Add(enemy2);
						}
					}
				}
			}
			foreach (SpawnableEnemyWithRarity enemy3 in newLevel.Enemies)
			{
				if ((Object)(object)enemy3.enemyType.enemyPrefab.GetComponent<LassoManAI>() != (Object)null)
				{
					enemy3.rarity = 999;
					enemy3.enemyType.probabilityCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
					{
						new Keyframe(0f, 10000f)
					});
				}
			}
		}
	}
}
namespace BrutalCompany.ManualPatches
{
	[HarmonyPatch(typeof(TimeOfDay), "Start")]
	internal class Patch_QuotaAjuster
	{
		private static void Prefix(TimeOfDay __instance)
		{
			Plugin.mls.LogWarning((object)"Changing quota variables in patch!");
			__instance.quotaVariables.startingQuota = 1000;
			__instance.quotaVariables.startingCredits = 250;
			__instance.quotaVariables.baseIncrease = 500f;
			__instance.quotaVariables.randomizerMultiplier = 0f;
			__instance.quotaVariables.deadlineDaysAmount = 10;
		}
	}
}
namespace BrutalCompany.Component
{
	internal class QuotaAjuster : MonoBehaviour
	{
		public TimeOfDay TOD;

		public float messageTimer = 58f;

		public static int surpriseLandmines;

		public static GameObject landmine;

		public static GameObject turret;

		public static List<GameObject> objectsToCleanUp = new List<GameObject>();

		public static float slSpawnTimer;

		public static bool shouldSpawnTurret;

		public void Awake()
		{
			Plugin.mls.LogWarning((object)"Changing quota variables");
		}

		public void Update()
		{
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)TOD == (Object)null)
			{
				TOD = Object.FindFirstObjectByType<TimeOfDay>();
			}
			else
			{
				TOD.quotaVariables.baseIncrease = 275f;
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.shipIsLeaving)
			{
				surpriseLandmines = -1;
			}
			if (surpriseLandmines > 0)
			{
				if (slSpawnTimer > 0f)
				{
					slSpawnTimer = Random.Range(-4, -1);
					PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
					PlayerControllerB val = allPlayerScripts[Random.Range(0, allPlayerScripts.Length)];
					if ((Object)(object)val != (Object)null)
					{
						if (Vector3.Distance(((Component)val).transform.position, new Vector3(9.33f, 5.2f, 1021f)) < 1f)
						{
							slSpawnTimer = 1f;
							return;
						}
						GameObject val2 = Object.Instantiate<GameObject>(landmine, ((Component)val).transform.position, Quaternion.identity);
						val2.transform.position = ((Component)val).transform.position;
						Plugin.mls.LogWarning((object)((Component)val).transform.position);
						val2.GetComponent<NetworkObject>().Spawn(true);
						objectsToCleanUp.Add(val2);
					}
				}
				else
				{
					slSpawnTimer += Time.deltaTime;
				}
			}
			if (shouldSpawnTurret & ((Object)(object)turret != (Object)null))
			{
				shouldSpawnTurret = false;
				GameObject val3 = Object.Instantiate<GameObject>(turret, new Vector3(3.87f, 0.84f, -14.23f), Quaternion.identity);
				val3.transform.position = new Vector3(3.87f, 0.84f, -14.23f);
				val3.transform.forward = new Vector3(1f, 0f, 0f);
				val3.GetComponent<NetworkObject>().Spawn(true);
				objectsToCleanUp.Add(val3);
			}
		}

		public static void CleanupAllSpawns()
		{
			foreach (GameObject item in objectsToCleanUp)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			objectsToCleanUp.Clear();
		}
	}
}

plugins/2018-LC_API/LC_API.dll

Decompiled 2 years ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LC_API.BundleAPI;
using LC_API.ClientAPI;
using LC_API.Comp;
using LC_API.Data;
using LC_API.Extensions;
using LC_API.GameInterfaceAPI;
using LC_API.ManualPatches;
using LC_API.ServerAPI;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("LC_API")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Utilities for plugin devs")]
[assembly: AssemblyFileVersion("2.1.4.0")]
[assembly: AssemblyInformationalVersion("2.1.4")]
[assembly: AssemblyProduct("LC_API")]
[assembly: AssemblyTitle("LC_API")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.4.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 LC_API
{
	internal static class CheatDatabase
	{
		private const string DAT_CD_BROADCAST = "LC_API_CD_Broadcast";

		private const string SIG_REQ_GUID = "LC_API_ReqGUID";

		private const string SIG_SEND_MODS = "LC_APISendMods";

		private static Dictionary<string, PluginInfo> PluginsLoaded = new Dictionary<string, PluginInfo>();

		public static void RunLocalCheatDetector()
		{
			PluginsLoaded = Chainloader.PluginInfos;
			using Dictionary<string, PluginInfo>.ValueCollection.Enumerator enumerator = PluginsLoaded.Values.GetEnumerator();
			while (enumerator.MoveNext())
			{
				switch (enumerator.Current.Metadata.GUID)
				{
				case "mikes.lethalcompany.mikestweaks":
				case "mom.llama.enhancer":
				case "Posiedon.GameMaster":
				case "LethalCompanyScalingMaster":
				case "verity.amberalert":
					ModdedServer.SetServerModdedOnly();
					break;
				}
			}
		}

		public static void OtherPlayerCheatDetector()
		{
			Plugin.Log.LogWarning((object)"Asking all other players for their mod list..");
			GameTips.ShowTip("Mod List:", "Asking all other players for installed mods..");
			GameTips.ShowTip("Mod List:", "Check the logs for more detailed results.\n<size=13>(Note that if someone doesnt show up on the list, they may not have LC_API installed)</size>");
			Networking.Broadcast("LC_API_CD_Broadcast", "LC_API_ReqGUID");
		}

		internal static void CDNetGetString(string data, string signature)
		{
			if (data == "LC_API_CD_Broadcast" && signature == "LC_API_ReqGUID")
			{
				string text = "";
				foreach (PluginInfo value in PluginsLoaded.Values)
				{
					text = text + "\n" + value.Metadata.GUID;
				}
				Networking.Broadcast(GameNetworkManager.Instance.localPlayerController.playerUsername + " responded with these mods:" + text, "LC_APISendMods");
			}
			if (signature == "LC_APISendMods")
			{
				GameTips.ShowTip("Mod List:", data);
				Plugin.Log.LogWarning((object)data);
			}
		}
	}
	[BepInPlugin("LC_API", "LC_API", "2.1.4")]
	public sealed class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private ConfigEntry<bool> configOverrideModServer;

		private ConfigEntry<bool> configLegacyAssetLoading;

		private ConfigEntry<bool> configDisableBundleLoader;

		public static bool Initialized { get; private set; }

		private void Awake()
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Expected O, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Expected O, but got Unknown
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			configOverrideModServer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Force modded server browser", false, "Should the API force you into the modded server browser?");
			configLegacyAssetLoading = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Legacy asset bundle loading", false, "Should the BundleLoader use legacy asset loading? Turning this on may help with loading assets from older plugins.");
			configDisableBundleLoader = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable BundleLoader", false, "Should the BundleLoader be turned off? Enable this if you are having problems with mods that load assets using a different method from LC_API's BundleLoader.");
			CommandHandler.commandPrefix = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Prefix", "/", "Command prefix");
			Log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogWarning((object)"\n.____    _________           _____  __________ .___  \r\n|    |   \\_   ___ \\         /  _  \\ \\______   \\|   | \r\n|    |   /    \\  \\/        /  /_\\  \\ |     ___/|   | \r\n|    |___\\     \\____      /    |    \\|    |    |   | \r\n|_______ \\\\______  /______\\____|__  /|____|    |___| \r\n        \\/       \\//_____/        \\/                 \r\n                                                     ");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Starting up..");
			if (configOverrideModServer.Value)
			{
				ModdedServer.SetServerModdedOnly();
			}
			Harmony val = new Harmony("ModAPI");
			MethodInfo methodInfo = AccessTools.Method(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyCreated", (Type[])null, (Type[])null);
			AccessTools.Method(typeof(GameNetworkManager), "LobbyDataIsJoinable", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(ServerPatch), "OnLobbyCreate", (Type[])null, (Type[])null);
			MethodInfo methodInfo3 = AccessTools.Method(typeof(MenuManager), "Awake", (Type[])null, (Type[])null);
			MethodInfo methodInfo4 = AccessTools.Method(typeof(ServerPatch), "CacheMenuManager", (Type[])null, (Type[])null);
			MethodInfo methodInfo5 = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null);
			MethodInfo methodInfo6 = AccessTools.Method(typeof(ServerPatch), "ChatInterpreter", (Type[])null, (Type[])null);
			MethodInfo methodInfo7 = AccessTools.Method(typeof(HUDManager), "SubmitChat_performed", (Type[])null, (Type[])null);
			MethodInfo methodInfo8 = AccessTools.Method(typeof(CommandHandler.SubmitChatPatch), "Transpiler", (Type[])null, (Type[])null);
			val.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)methodInfo7, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null);
			Networking.GetString = (Action<string, string>)Delegate.Combine(Networking.GetString, new Action<string, string>(CheatDatabase.CDNetGetString));
			Networking.GetListString = (Action<List<string>, string>)Delegate.Combine(Networking.GetListString, new Action<List<string>, string>(Networking.LCAPI_NET_SYNCVAR_SET));
		}

		internal void Start()
		{
			Initialize();
		}

		internal void OnDestroy()
		{
			Initialize();
		}

		internal void Initialize()
		{
			//IL_002f: 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_003a: Expected O, but got Unknown
			if (!Initialized)
			{
				Initialized = true;
				if (!configDisableBundleLoader.Value)
				{
					BundleLoader.Load(configLegacyAssetLoading.Value);
				}
				GameObject val = new GameObject("API");
				Object.DontDestroyOnLoad((Object)val);
				val.AddComponent<LC_APIManager>();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Started!");
				CheatDatabase.RunLocalCheatDetector();
			}
		}

		internal static void PatchMethodManual(MethodInfo method, MethodInfo patch, Harmony harmony)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			harmony.Patch((MethodBase)method, new HarmonyMethod(patch), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LC_API";

		public const string PLUGIN_NAME = "LC_API";

		public const string PLUGIN_VERSION = "2.1.4";
	}
}
namespace LC_API.ServerAPI
{
	public static class ModdedServer
	{
		private static bool moddedOnly;

		[Obsolete("Use SetServerModdedOnly() instead. This will be removed/private in a future update.")]
		public static bool setModdedOnly;

		public static bool ModdedOnly => moddedOnly;

		public static void SetServerModdedOnly()
		{
			moddedOnly = true;
			Plugin.Log.LogMessage((object)"A plugin has set your game to only allow you to play with other people who have mods!");
		}

		public static void OnSceneLoaded()
		{
			if (Object.op_Implicit((Object)(object)GameNetworkManager.Instance) && ModdedOnly)
			{
				GameNetworkManager instance = GameNetworkManager.Instance;
				instance.gameVersionNum += 16440;
				setModdedOnly = true;
			}
		}
	}
	public static class Networking
	{
		public static Action<string, string> GetString = delegate
		{
		};

		public static Action<List<string>, string> GetListString = delegate
		{
		};

		public static Action<int, string> GetInt = delegate
		{
		};

		public static Action<float, string> GetFloat = delegate
		{
		};

		public static Action<Vector3, string> GetVector3 = delegate
		{
		};

		private static Dictionary<string, string> syncStringVars = new Dictionary<string, string>();

		public static void Broadcast(string data, string signature)
		{
			if (data.Contains("/"))
			{
				Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )");
				return;
			}
			HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDstring.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1);
		}

		public static void Broadcast(List<string> data, string signature)
		{
			string text = "";
			foreach (string datum in data)
			{
				if (datum.Contains("/"))
				{
					Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )");
					return;
				}
				if (datum.Contains("\n"))
				{
					Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( NewLine )");
					return;
				}
				text = text + datum + "\n";
			}
			HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data?.ToString() + "/" + signature + "/" + NetworkBroadcastDataType.BDlistString.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1);
		}

		public static void Broadcast(int data, string signature)
		{
			HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDint.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1);
		}

		public static void Broadcast(float data, string signature)
		{
			HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDfloat.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1);
		}

		public static void Broadcast(Vector3 data, string signature)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			HUDManager instance = HUDManager.Instance;
			string[] obj = new string[9] { "<size=0>NWE/", null, null, null, null, null, null, null, null };
			Vector3 val = data;
			obj[1] = ((object)(Vector3)(ref val)).ToString();
			obj[2] = "/";
			obj[3] = signature;
			obj[4] = "/";
			obj[5] = NetworkBroadcastDataType.BDvector3.ToString();
			obj[6] = "/";
			obj[7] = GameNetworkManager.Instance.localPlayerController.playerClientId.ToString();
			obj[8] = "/</size>";
			instance.AddTextToChatOnServer(string.Concat(obj), -1);
		}

		public static void RegisterSyncVariable(string name)
		{
			if (!syncStringVars.ContainsKey(name))
			{
				syncStringVars.Add(name, "");
			}
			else
			{
				Plugin.Log.LogError((object)("Cannot register Sync Variable! A Sync Variable has already been registered with name " + name));
			}
		}

		public static void SetSyncVariable(string name, string value)
		{
			if (syncStringVars.ContainsKey(name))
			{
				syncStringVars[name] = value;
				Broadcast(new List<string> { name, value }, "LCAPI_NET_SYNCVAR_SET");
			}
			else
			{
				Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!"));
			}
		}

		private static void SetSyncVariableB(string name, string value)
		{
			if (syncStringVars.ContainsKey(name))
			{
				syncStringVars[name] = value;
			}
			else
			{
				Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!"));
			}
		}

		internal static void LCAPI_NET_SYNCVAR_SET(List<string> list, string arg2)
		{
			if (arg2 == "LCAPI_NET_SYNCVAR_SET")
			{
				SetSyncVariableB(list[0], list[1]);
			}
		}

		public static string GetSyncVariable(string name)
		{
			if (syncStringVars.ContainsKey(name))
			{
				return syncStringVars[name];
			}
			Plugin.Log.LogError((object)("Cannot get the value of Sync Variable " + name + " as it is not registered!"));
			return "";
		}

		private static void GotString(string data, string signature)
		{
		}

		private static void GotInt(int data, string signature)
		{
		}

		private static void GotFloat(float data, string signature)
		{
		}

		private static void GotVector3(Vector3 data, string signature)
		{
		}
	}
}
namespace LC_API.ManualPatches
{
	internal static class ServerPatch
	{
		internal static bool OnLobbyCreate(GameNetworkManager __instance, Result result, Lobby lobby)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if ((int)result != 1)
			{
				Debug.LogError((object)$"Lobby could not be created! {result}", (Object)(object)__instance);
			}
			__instance.lobbyHostSettings.lobbyName = "[MODDED]" + __instance.lobbyHostSettings.lobbyName.ToString();
			Plugin.Log.LogMessage((object)"server pre-setup success");
			return true;
		}

		internal static bool CacheMenuManager(MenuManager __instance)
		{
			LC_APIManager.MenuManager = __instance;
			return true;
		}

		internal static bool ChatInterpreter(HUDManager __instance, string chatMessage)
		{
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			if (!chatMessage.Contains("NWE") || !chatMessage.Contains("<size=0>"))
			{
				return true;
			}
			string[] array = chatMessage.Split(new char[1] { '/' });
			if (array.Length < 5)
			{
				if (array.Length >= 3)
				{
					if (!int.TryParse(array[4], out var result))
					{
						Plugin.Log.LogWarning((object)"Failed to parse player ID!!");
						return false;
					}
					if ((result == (int)GameNetworkManager.Instance.localPlayerController.playerClientId) & !LC_APIManager.netTester)
					{
						return false;
					}
					Enum.TryParse<NetworkBroadcastDataType>(array[3], out var result2);
					switch (result2)
					{
					case NetworkBroadcastDataType.BDstring:
						Networking.GetString(array[1], array[2]);
						break;
					case NetworkBroadcastDataType.BDint:
						Networking.GetInt(int.Parse(array[1]), array[2]);
						break;
					case NetworkBroadcastDataType.BDfloat:
						Networking.GetFloat(float.Parse(array[1]), array[2]);
						break;
					case NetworkBroadcastDataType.BDvector3:
					{
						string[] array2 = array[1].Replace("(", "").Replace(")", "").Split(new char[1] { ',' });
						Vector3 arg = default(Vector3);
						if (array2.Length == 3)
						{
							if (float.TryParse(array2[0], out var result3) && float.TryParse(array2[1], out var result4) && float.TryParse(array2[2], out var result5))
							{
								arg.x = result3;
								arg.y = result4;
								arg.z = result5;
							}
							else
							{
								Plugin.Log.LogError((object)"Vector3 Network receive fail. This is a failure of the API, and it should be reported as a bug.");
							}
						}
						else
						{
							Plugin.Log.LogError((object)"Vector3 Network receive fail. This is a failure of the API, and it should be reported as a bug.");
						}
						Networking.GetVector3(arg, array[2]);
						break;
					}
					case NetworkBroadcastDataType.BDlistString:
					{
						string[] source = array[1].Split(new char[1] { '\n' });
						Networking.GetListString(source.ToList(), array[2]);
						break;
					}
					}
					_ = LC_APIManager.netTester;
					return false;
				}
				Plugin.Log.LogError((object)"Generic Network receive fail. This is a failure of the API, and it should be reported as a bug.");
				Plugin.Log.LogError((object)$"Generic Network receive fail (expected 5+ data fragments, got {array.Length}). This is a failure of the API, and it should be reported as a bug.");
				return true;
			}
			if (!int.TryParse(array[4], out var result6))
			{
				Plugin.Log.LogWarning((object)("Failed to parse player ID '" + array[4] + "'!!"));
				return false;
			}
			if ((result6 == (int)GameNetworkManager.Instance.localPlayerController.playerClientId) & !LC_APIManager.netTester)
			{
				return false;
			}
			if (!Enum.TryParse<NetworkBroadcastDataType>(array[3], out var result7))
			{
				Plugin.Log.LogError((object)("Unknown datatype - unable to parse '" + array[3] + "' into a known data type!"));
				return false;
			}
			switch (result7)
			{
			case NetworkBroadcastDataType.BDstring:
				Networking.GetString.InvokeActionSafe(array[1], array[2]);
				break;
			case NetworkBroadcastDataType.BDint:
				Networking.GetInt.InvokeActionSafe(int.Parse(array[1]), array[2]);
				break;
			case NetworkBroadcastDataType.BDfloat:
				Networking.GetFloat.InvokeActionSafe(float.Parse(array[1]), array[2]);
				break;
			case NetworkBroadcastDataType.BDvector3:
			{
				string text = array[1].Trim('(', ')');
				string[] array3 = text.Split(new char[1] { ',' });
				Vector3 param = default(Vector3);
				float result8;
				float result9;
				float result10;
				if (array3.Length != 3)
				{
					Plugin.Log.LogError((object)$"Vector3 Network receive fail (expected 3 numbers, got {array3.Length} number(?)(s) instead). This is a failure of the API, and it should be reported as a bug. (passing an empty Vector3 in its place)");
				}
				else if (float.TryParse(array3[0], out result8) && float.TryParse(array3[1], out result9) && float.TryParse(array3[2], out result10))
				{
					param.x = result8;
					param.y = result9;
					param.z = result10;
				}
				else
				{
					Plugin.Log.LogError((object)("Vector3 Network receive fail (failed to parse '" + text + "' as numbers). This is a failure of the API, and it should be reported as a bug."));
				}
				Networking.GetVector3.InvokeActionSafe(param, array[2]);
				break;
			}
			}
			_ = LC_APIManager.netTester;
			return false;
		}

		internal static bool ChatCommands(HUDManager __instance, CallbackContext context)
		{
			if (__instance.chatTextField.text.ToLower().Contains("/modcheck"))
			{
				CheatDatabase.OtherPlayerCheatDetector();
				return false;
			}
			return true;
		}
	}
}
namespace LC_API.GameInterfaceAPI
{
	public static class GameState
	{
		private static readonly Action NothingAction = delegate
		{
		};

		public static int AlivePlayerCount { get; private set; }

		public static ShipState ShipState { get; private set; }

		public static event Action PlayerDied;

		public static event Action LandOnMoon;

		public static event Action WentIntoOrbit;

		public static event Action ShipStartedLeaving;

		internal static void GSUpdate()
		{
			if (!((Object)(object)StartOfRound.Instance == (Object)null))
			{
				if (StartOfRound.Instance.shipHasLanded && ShipState != ShipState.OnMoon)
				{
					ShipState = ShipState.OnMoon;
					GameState.LandOnMoon.InvokeActionSafe();
				}
				if (StartOfRound.Instance.inShipPhase && ShipState != 0)
				{
					ShipState = ShipState.InOrbit;
					GameState.WentIntoOrbit.InvokeActionSafe();
				}
				if (StartOfRound.Instance.shipIsLeaving && ShipState != ShipState.LeavingMoon)
				{
					ShipState = ShipState.LeavingMoon;
					GameState.ShipStartedLeaving.InvokeActionSafe();
				}
				if (AlivePlayerCount < StartOfRound.Instance.livingPlayers)
				{
					GameState.PlayerDied.InvokeActionSafe();
				}
				AlivePlayerCount = StartOfRound.Instance.livingPlayers;
			}
		}

		static GameState()
		{
			GameState.PlayerDied = NothingAction;
			GameState.LandOnMoon = NothingAction;
			GameState.WentIntoOrbit = NothingAction;
			GameState.ShipStartedLeaving = NothingAction;
		}
	}
	public class GameTips
	{
		private static List<string> tipHeaders = new List<string>();

		private static List<string> tipBodys = new List<string>();

		private static float lastMessageTime;

		public static void ShowTip(string header, string body)
		{
			tipHeaders.Add(header);
			tipBodys.Add(body);
		}

		public static void UpdateInternal()
		{
			lastMessageTime -= Time.deltaTime;
			if ((tipHeaders.Count > 0) & (lastMessageTime < 0f))
			{
				lastMessageTime = 5f;
				if ((Object)(object)HUDManager.Instance != (Object)null)
				{
					HUDManager.Instance.DisplayTip(tipHeaders[0], tipBodys[0], false, false, "LC_Tip1");
				}
				tipHeaders.RemoveAt(0);
				tipBodys.RemoveAt(0);
			}
		}
	}
}
namespace LC_API.Extensions
{
	public static class DelegateExtensions
	{
		private static readonly PropertyInfo PluginGetLogger = AccessTools.Property(typeof(BaseUnityPlugin), "Logger");

		public static void InvokeActionSafe(this Action action)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			if (action == null)
			{
				return;
			}
			Delegate[] invocationList = action.GetInvocationList();
			foreach (Delegate @delegate in invocationList)
			{
				try
				{
					((Action)@delegate)();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)"Exception while invoking hook callback!");
					string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName;
					PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName));
					if (val == null)
					{
						Plugin.Log.LogError((object)ex.ToString());
						break;
					}
					((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString());
				}
			}
		}

		public static void InvokeActionSafe<T>(this Action<T> action, T param)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (action == null)
			{
				return;
			}
			Delegate[] invocationList = action.GetInvocationList();
			foreach (Delegate @delegate in invocationList)
			{
				try
				{
					((Action<T>)@delegate)(param);
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)"Exception while invoking hook callback!");
					string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName;
					PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName));
					if (val == null)
					{
						Plugin.Log.LogError((object)ex.ToString());
						break;
					}
					((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString());
				}
			}
		}

		public static void InvokeActionSafe<T1, T2>(this Action<T1, T2> action, T1 param1, T2 param2)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (action == null)
			{
				return;
			}
			Delegate[] invocationList = action.GetInvocationList();
			foreach (Delegate @delegate in invocationList)
			{
				try
				{
					((Action<T1, T2>)@delegate)(param1, param2);
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)"Exception while invoking hook callback!");
					string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName;
					PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName));
					if (val == null)
					{
						Plugin.Log.LogError((object)ex.ToString());
						break;
					}
					((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString());
				}
			}
		}

		internal static void InvokeParameterlessDelegate<T>(this T paramlessDelegate) where T : Delegate
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			if ((Delegate?)paramlessDelegate == (Delegate?)null)
			{
				return;
			}
			Delegate[] invocationList = paramlessDelegate.GetInvocationList();
			foreach (Delegate @delegate in invocationList)
			{
				try
				{
					((T)@delegate).DynamicInvoke();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)"Exception while invoking hook callback!");
					string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName;
					PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName));
					if (val == null)
					{
						Plugin.Log.LogError((object)ex.ToString());
						break;
					}
					((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString());
				}
			}
		}
	}
}
namespace LC_API.Data
{
	internal enum NetworkBroadcastDataType
	{
		Unknown,
		BDint,
		BDfloat,
		BDvector3,
		BDstring,
		BDlistString
	}
	public enum ShipState
	{
		InOrbit,
		OnMoon,
		LeavingMoon
	}
}
namespace LC_API.Comp
{
	internal class LC_APIManager : MonoBehaviour
	{
		public static MenuManager MenuManager;

		public static bool netTester;

		private static int playerCount;

		private static bool wanttoCheckMods;

		private static float lobbychecktimer;

		public void Update()
		{
			GameState.GSUpdate();
			GameTips.UpdateInternal();
			if ((((Object)(object)HUDManager.Instance != (Object)null) & netTester) && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				Networking.Broadcast("testerData", "testerSignature");
			}
			if (!ModdedServer.setModdedOnly)
			{
				ModdedServer.OnSceneLoaded();
			}
			else if (ModdedServer.ModdedOnly && (Object)(object)MenuManager != (Object)null && Object.op_Implicit((Object)(object)MenuManager.versionNumberText))
			{
				((TMP_Text)MenuManager.versionNumberText).text = $"v{GameNetworkManager.Instance.gameVersionNum - 16440}\nMOD";
			}
			if ((Object)(object)GameNetworkManager.Instance != (Object)null)
			{
				if (playerCount < GameNetworkManager.Instance.connectedPlayers)
				{
					lobbychecktimer = -4.5f;
					wanttoCheckMods = true;
				}
				playerCount = GameNetworkManager.Instance.connectedPlayers;
			}
			if (lobbychecktimer < 0f)
			{
				lobbychecktimer += Time.deltaTime;
			}
			else if (wanttoCheckMods && (Object)(object)HUDManager.Instance != (Object)null)
			{
				wanttoCheckMods = false;
				CD();
			}
		}

		private void CD()
		{
			CheatDatabase.OtherPlayerCheatDetector();
		}
	}
}
namespace LC_API.ClientAPI
{
	public static class CommandHandler
	{
		internal static class SubmitChatPatch
		{
			private static bool HandleMessage(HUDManager manager)
			{
				string text = manager.chatTextField.text;
				if (!Utility.IsNullOrWhiteSpace(text) && text.StartsWith(commandPrefix.Value))
				{
					string[] array = text.Split(new char[1] { ' ' });
					string text2 = array[0].Substring(commandPrefix.Value.Length);
					if (TryGetCommandHandler(text2, out var handler))
					{
						string[] obj = array.Skip(1).ToArray();
						try
						{
							handler(obj);
						}
						catch (Exception ex)
						{
							Plugin.Log.LogError((object)("Error handling command: " + text2));
							Plugin.Log.LogError((object)ex);
						}
					}
					manager.localPlayer.isTypingChat = false;
					manager.chatTextField.text = "";
					EventSystem.current.SetSelectedGameObject((GameObject)null);
					((Behaviour)manager.typingIndicator).enabled = false;
					return true;
				}
				return false;
			}

			internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
			{
				List<CodeInstruction> newInstructions = new List<CodeInstruction>(instructions);
				Label label = generator.DefineLabel();
				newInstructions[newInstructions.Count - 1].labels.Add(label);
				int index = newInstructions.FindIndex((CodeInstruction i) => i.opcode == OpCodes.Ldfld && (FieldInfo)i.operand == AccessTools.Field(typeof(PlayerControllerB), "isPlayerDead")) - 2;
				newInstructions.InsertRange(index, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3]
				{
					CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldarg_0, (object)null), newInstructions[index]),
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SubmitChatPatch), "HandleMessage", (Type[])null, (Type[])null)),
					new CodeInstruction(OpCodes.Brtrue, (object)label)
				});
				for (int z = 0; z < newInstructions.Count; z++)
				{
					yield return newInstructions[z];
				}
			}
		}

		internal static ConfigEntry<string> commandPrefix;

		internal static Dictionary<string, Action<string[]>> CommandHandlers = new Dictionary<string, Action<string[]>>();

		internal static Dictionary<string, List<string>> CommandAliases = new Dictionary<string, List<string>>();

		public static bool RegisterCommand(string command, Action<string[]> handler)
		{
			if (command.Contains(" ") || CommandHandlers.ContainsKey(command))
			{
				return false;
			}
			CommandHandlers.Add(command, handler);
			return true;
		}

		public static bool RegisterCommand(string command, List<string> aliases, Action<string[]> handler)
		{
			if (command.Contains(" ") || GetCommandHandler(command) != null)
			{
				return false;
			}
			foreach (string alias in aliases)
			{
				if (alias.Contains(" ") || GetCommandHandler(alias) != null)
				{
					return false;
				}
			}
			CommandHandlers.Add(command, handler);
			CommandAliases.Add(command, aliases);
			return true;
		}

		public static bool UnregisterCommand(string command)
		{
			CommandAliases.Remove(command);
			return CommandHandlers.Remove(command);
		}

		internal static Action<string[]> GetCommandHandler(string command)
		{
			if (CommandHandlers.TryGetValue(command, out var value))
			{
				return value;
			}
			foreach (KeyValuePair<string, List<string>> commandAlias in CommandAliases)
			{
				if (commandAlias.Value.Contains(command))
				{
					return CommandHandlers[commandAlias.Key];
				}
			}
			return null;
		}

		internal static bool TryGetCommandHandler(string command, out Action<string[]> handler)
		{
			handler = GetCommandHandler(command);
			return handler != null;
		}
	}
}
namespace LC_API.BundleAPI
{
	public static class BundleLoader
	{
		[Obsolete("Use OnLoadedBundles instead. This will be removed/private in a future update.")]
		public delegate void OnLoadedAssetsDelegate();

		[Obsolete("Use GetLoadedAsset instead. This will be removed/private in a future update.")]
		public static ConcurrentDictionary<string, Object> assets = new ConcurrentDictionary<string, Object>();

		[Obsolete("Use OnLoadedBundles instead. This will be removed/private in a future update.")]
		public static OnLoadedAssetsDelegate OnLoadedAssets = LoadAssetsCompleted;

		public static bool AssetsInLegacyDirectory { get; private set; }

		public static bool LegacyLoadingEnabled { get; private set; }

		public static event Action OnLoadedBundles;

		internal static void Load(bool legacyLoading)
		{
			LegacyLoadingEnabled = legacyLoading;
			Plugin.Log.LogMessage((object)"BundleAPI will now load all asset bundles...");
			string path = Path.Combine(Paths.BepInExRootPath, "Bundles");
			if (!Directory.Exists(path))
			{
				Directory.CreateDirectory(path);
				Plugin.Log.LogMessage((object)"BundleAPI Created legacy bundle directory in BepInEx/Bundles");
			}
			string[] array = (from x in Directory.GetFiles(path, "*", SearchOption.AllDirectories)
				where !x.EndsWith(".manifest", StringComparison.CurrentCultureIgnoreCase)
				select x).ToArray();
			AssetsInLegacyDirectory = array.Length != 0;
			if (!AssetsInLegacyDirectory)
			{
				Plugin.Log.LogMessage((object)"BundleAPI got no assets to load from legacy directory");
			}
			if (AssetsInLegacyDirectory)
			{
				Plugin.Log.LogWarning((object)"The path BepInEx > Bundles is outdated and should not be used anymore! Bundles will be loaded from BepInEx > plugins from now on");
				LoadAllAssetsFromDirectory(array, legacyLoading);
			}
			string[] invalidEndings = new string[8] { ".dll", ".json", ".png", ".md", ".old", ".txt", ".exe", ".lem" };
			path = Path.Combine(Paths.BepInExRootPath, "plugins");
			array = (from file in Directory.GetFiles(path, "*", SearchOption.AllDirectories)
				where !invalidEndings.Any((string ending) => file.EndsWith(ending, StringComparison.CurrentCultureIgnoreCase))
				select file).ToArray();
			byte[] bytes = Encoding.ASCII.GetBytes("UnityFS");
			List<string> list = new List<string>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				byte[] array3 = new byte[bytes.Length];
				using (FileStream fileStream = File.Open(text, FileMode.Open))
				{
					fileStream.Read(array3, 0, array3.Length);
				}
				if (array3.SequenceEqual(bytes))
				{
					list.Add(text);
				}
			}
			array = list.ToArray();
			if (array.Length == 0)
			{
				Plugin.Log.LogMessage((object)"BundleAPI got no assets to load from plugins folder");
			}
			else
			{
				LoadAllAssetsFromDirectory(array, legacyLoading);
			}
			OnLoadedAssets.InvokeParameterlessDelegate();
			BundleLoader.OnLoadedBundles.InvokeActionSafe();
		}

		private static void LoadAllAssetsFromDirectory(string[] array, bool legacyLoading)
		{
			if (legacyLoading)
			{
				Plugin.Log.LogMessage((object)("BundleAPI got " + array.Length + " AssetBundles to load!"));
				for (int i = 0; i < array.Length; i++)
				{
					try
					{
						SaveAsset(array[i], legacyLoading);
					}
					catch (Exception)
					{
						Plugin.Log.LogError((object)("Failed to load an assetbundle! Path: " + array[i]));
					}
				}
				return;
			}
			Plugin.Log.LogMessage((object)("BundleAPI got " + array.Length + " AssetBundles to load!"));
			for (int j = 0; j < array.Length; j++)
			{
				try
				{
					SaveAsset(array[j], legacyLoading);
				}
				catch (Exception)
				{
					Plugin.Log.LogError((object)("Failed to load an assetbundle! Path: " + array[j]));
				}
			}
		}

		public static void SaveAsset(string path, bool legacyLoad)
		{
			AssetBundle val = AssetBundle.LoadFromFile(path);
			try
			{
				string[] allAssetNames = val.GetAllAssetNames();
				foreach (string text in allAssetNames)
				{
					Plugin.Log.LogMessage((object)("Got asset for load: " + text));
					Object val2 = val.LoadAsset(text);
					if (val2 == (Object)null)
					{
						Plugin.Log.LogWarning((object)$"Skipped/failed loading an asset (from bundle '{((Object)val).name}') - Asset path: {val2}");
						continue;
					}
					string key = (legacyLoad ? text.ToUpper() : text.ToLower());
					if (assets.ContainsKey(key))
					{
						Plugin.Log.LogError((object)"BundleAPI got duplicate asset!");
						break;
					}
					assets.TryAdd(key, val2);
					Plugin.Log.LogMessage((object)("Loaded asset: " + val2.name));
				}
			}
			finally
			{
				if (val != null)
				{
					val.Unload(false);
				}
			}
		}

		public static TAsset GetLoadedAsset<TAsset>(string itemPath) where TAsset : Object
		{
			Object value = null;
			if (LegacyLoadingEnabled)
			{
				assets.TryGetValue(itemPath.ToUpper(), out value);
			}
			if (value == (Object)null)
			{
				assets.TryGetValue(itemPath.ToLower(), out value);
			}
			return (TAsset)(object)value;
		}

		private static void LoadAssetsCompleted()
		{
			Plugin.Log.LogMessage((object)"BundleAPI finished loading all assets.");
		}

		static BundleLoader()
		{
			BundleLoader.OnLoadedBundles = LoadAssetsCompleted;
		}
	}
}

plugins/AllToasters-SpectateEnemies/SpectateEnemy.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[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("SpectateEnemy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyInformationalVersion("1.5.0+fedd7299567cd8f4569b5f35b2cc9b6f25f17c2f")]
[assembly: AssemblyProduct("SpectateEnemy")]
[assembly: AssemblyTitle("SpectateEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.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 SpectateEnemy
{
	[BepInPlugin("SpectateEnemy", "SpectateEnemy", "1.5.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static int spectatedEnemyIndex = -1;

		public static bool spectatingEnemies = false;

		public static MethodInfo raycastSpectate = null;

		public static MethodInfo displaySpectatorTip = null;

		private ConfigEntry<bool> spectateTurrets;

		private ConfigEntry<bool> spectateLandmines;

		private ConfigEntry<bool> spectatePassives;

		public static bool doSpectateTurrets;

		public static bool doSpectateLandmines;

		public static bool doSpectatePassives;

		private Harmony harmony;

		private void Awake()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			spectateTurrets = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "Spectate Turrets", false, "Enables spectating turrets.");
			doSpectateTurrets = spectateTurrets.Value;
			spectateLandmines = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "Spectate Landmines", false, "Enables spectating landmines.");
			doSpectateLandmines = spectateLandmines.Value;
			spectatePassives = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "Spectate Passives", false, "Enables spectating passive enemies, such as Docile Locust Bees and Manticoils.");
			doSpectatePassives = spectatePassives.Value;
			harmony = new Harmony("SpectateEnemy");
			harmony.PatchAll();
			raycastSpectate = AccessTools.Method(typeof(PlayerControllerB), "RaycastSpectateCameraAroundPivot", (Type[])null, (Type[])null);
			displaySpectatorTip = AccessTools.Method(typeof(HUDManager), "DisplaySpectatorTip", (Type[])null, (Type[])null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"SpectateEnemy loaded!");
		}
	}
	public class Spectatable : MonoBehaviour
	{
		public SpectatableType type = SpectatableType.Enemy;

		public string enemyName = "Enemy";
	}
	public enum SpectatableType
	{
		Enemy,
		Turret,
		Landmine
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SpectateEnemy";

		public const string PLUGIN_NAME = "SpectateEnemy";

		public const string PLUGIN_VERSION = "1.5.0";
	}
}
namespace SpectateEnemy.Patches
{
	[HarmonyPatch(typeof(EnemyAI), "Start")]
	public class EnemyAI_Patches
	{
		private static void Postfix(EnemyAI __instance)
		{
			if (Plugin.doSpectatePassives || (!(__instance.enemyType.enemyName == "Docile Locust Bees") && !(__instance.enemyType.enemyName == "Manticoil")))
			{
				Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>();
				spectatable.enemyName = __instance.enemyType.enemyName;
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
	public class GameNetworkManager_Patches
	{
		private static void Postfix()
		{
			Plugin.spectatedEnemyIndex = -1;
			Plugin.spectatingEnemies = false;
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Update")]
	public class HUDManager_Patches
	{
		private static void Postfix(HUDManager __instance)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead)
			{
				return;
			}
			if (StartOfRound.Instance.shipIsLeaving)
			{
				Light component = ((Component)__instance.playersManager.spectateCamera).GetComponent<Light>();
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = false;
				}
				return;
			}
			MovementActions movement = __instance.playerActions.Movement;
			InputBinding val = ((MovementActions)(ref movement)).Interact.bindings[0];
			string text = InputControlPath.ToHumanReadableString(((InputBinding)(ref val)).effectivePath, (HumanReadableStringOptions)2, (InputControl)null);
			TextMeshProUGUI holdButtonToEndGameEarlyText = __instance.holdButtonToEndGameEarlyText;
			((TMP_Text)holdButtonToEndGameEarlyText).text = ((TMP_Text)holdButtonToEndGameEarlyText).text + "\n\n\n\n\nSwitch to " + (Plugin.spectatingEnemies ? "Players" : "Enemies") + ": [" + text + "]\nToggle Flashlight : [RMB] (Click)";
			movement = __instance.playerActions.Movement;
			if (((MovementActions)(ref movement)).PingScan.WasReleasedThisFrame())
			{
				Light component2 = ((Component)__instance.playersManager.spectateCamera).GetComponent<Light>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Behaviour)component2).enabled = !((Behaviour)component2).enabled;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Landmine), "Start")]
	public class Landmine_Patches
	{
		private static void Postfix(Landmine __instance)
		{
			if (Plugin.doSpectateLandmines)
			{
				Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>();
				spectatable.type = SpectatableType.Landmine;
				spectatable.enemyName = "Landmine";
			}
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")]
	public class MaskedPlayerEnemy_Patches
	{
		private static void Postfix(MaskedPlayerEnemy __instance)
		{
			Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>();
			if ((Object)(object)__instance.mimickingPlayer != (Object)null)
			{
				spectatable.enemyName = __instance.mimickingPlayer.playerUsername;
			}
			else
			{
				spectatable.enemyName = ((EnemyAI)__instance).enemyType.enemyName;
			}
		}
	}
	internal class Handler
	{
		public static Spectatable[] spectatorList;

		public static bool Spectate()
		{
			if (Plugin.spectatingEnemies)
			{
				if (spectatorList.Length == 0)
				{
					Plugin.spectatingEnemies = false;
					return true;
				}
				Plugin.spectatedEnemyIndex++;
				if (Plugin.spectatedEnemyIndex >= spectatorList.Length)
				{
					Plugin.spectatedEnemyIndex = 0;
				}
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Interact_performed")]
	public class PlayerControllerB_Interact
	{
		private static bool Prefix(PlayerControllerB __instance)
		{
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead && !StartOfRound.Instance.shipIsLeaving && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject))
			{
				Plugin.spectatingEnemies = !Plugin.spectatingEnemies;
				if (Plugin.spectatingEnemies)
				{
					Handler.spectatorList = Object.FindObjectsByType<Spectatable>((FindObjectsSortMode)0);
					if (Handler.spectatorList.Length == 0)
					{
						Plugin.spectatingEnemies = false;
						Plugin.displaySpectatorTip.Invoke(HUDManager.Instance, new object[1] { "No enemies to spectate" });
						return false;
					}
					if (Plugin.spectatedEnemyIndex == -1 || Plugin.spectatedEnemyIndex >= Handler.spectatorList.Length)
					{
						if ((Object)(object)__instance.spectatedPlayerScript == (Object)null)
						{
							Plugin.spectatedEnemyIndex = 0;
						}
						else
						{
							float num = 999999f;
							int spectatedEnemyIndex = 0;
							for (int i = 0; i < Handler.spectatorList.Length; i++)
							{
								Vector3 val = ((Component)Handler.spectatorList[i]).transform.position - ((Component)__instance.spectatedPlayerScript).transform.position;
								float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
								if (sqrMagnitude < num * num)
								{
									num = sqrMagnitude;
									spectatedEnemyIndex = i;
								}
							}
							Plugin.spectatedEnemyIndex = spectatedEnemyIndex;
						}
					}
					__instance.spectatedPlayerScript = null;
				}
				else
				{
					__instance.spectatedPlayerScript = ((IEnumerable<PlayerControllerB>)__instance.playersManager.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => !x.isPlayerDead));
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "ActivateItem_performed")]
	public class PlayerControllerB_Use
	{
		private static bool Prefix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead && !StartOfRound.Instance.shipIsLeaving && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject))
			{
				return Handler.Spectate();
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
	public class PlayerControllerB_LateUpdate
	{
		private static void Postfix(PlayerControllerB __instance)
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.spectatingEnemies)
			{
				return;
			}
			if (Handler.spectatorList.Length == 0)
			{
				Plugin.spectatingEnemies = false;
				return;
			}
			if (Plugin.spectatedEnemyIndex >= Handler.spectatorList.Length)
			{
				Plugin.spectatedEnemyIndex = 0;
			}
			Spectatable obj = Handler.spectatorList[Plugin.spectatedEnemyIndex];
			if ((Object)(object)obj == (Object)null)
			{
				Plugin.spectatedEnemyIndex++;
				if (Plugin.spectatedEnemyIndex >= Handler.spectatorList.Length)
				{
					Plugin.spectatedEnemyIndex = 0;
				}
				return;
			}
			Vector3? spectatePosition = GetSpectatePosition(obj);
			if (!spectatePosition.HasValue)
			{
				Plugin.spectatedEnemyIndex++;
				if (Plugin.spectatedEnemyIndex >= Handler.spectatorList.Length)
				{
					Plugin.spectatedEnemyIndex = 0;
				}
				return;
			}
			if (obj.enemyName == "Enemy")
			{
				TryFixName(ref obj);
			}
			__instance.spectateCameraPivot.position = spectatePosition.Value + GetZoomDistance(obj);
			((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = "(Spectating: " + obj.enemyName + ")";
			Plugin.raycastSpectate.Invoke(__instance, Array.Empty<object>());
		}

		private static void TryFixName(ref Spectatable obj)
		{
			EnemyAI val = default(EnemyAI);
			Turret val2 = default(Turret);
			Landmine val3 = default(Landmine);
			if (((Component)obj).gameObject.TryGetComponent<EnemyAI>(ref val))
			{
				obj.enemyName = val.enemyType.enemyName;
			}
			else if (((Component)obj).gameObject.TryGetComponent<Turret>(ref val2))
			{
				obj.enemyName = "Turret";
			}
			else if (((Component)obj).gameObject.TryGetComponent<Landmine>(ref val3))
			{
				obj.enemyName = "Landmine";
			}
		}

		private static Vector3 GetZoomDistance(Spectatable obj)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (obj.enemyName == "ForestGiant")
			{
				return Vector3.up * 3f;
			}
			if (obj.enemyName == "MouthDog" || obj.enemyName == "Jester")
			{
				return Vector3.up * 2f;
			}
			return Vector3.up;
		}

		private static Vector3? GetSpectatePosition(Spectatable obj)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			if (obj.type == SpectatableType.Enemy)
			{
				EnemyAI component = ((Component)obj).GetComponent<EnemyAI>();
				if ((Object)(object)component != (Object)null)
				{
					return ((Object)(object)component.eye == (Object)null) ? ((Component)component).transform.position : component.eye.position;
				}
			}
			else if (obj.type == SpectatableType.Turret)
			{
				Turret component2 = ((Component)obj).GetComponent<Turret>();
				if ((Object)(object)component2 != (Object)null)
				{
					return ((Component)component2.centerPoint).transform.position;
				}
			}
			else
			{
				if (obj.type == SpectatableType.Landmine)
				{
					return ((Component)obj).transform.position;
				}
				Debug.LogError((object)("[SpectateEnemy]: Error when spectating: no handler for SpectatableType " + obj.type));
			}
			return null;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "SpectateNextPlayer")]
	public class PlayerControllerB_SpectateNext
	{
		private static bool Prefix()
		{
			return !Plugin.spectatingEnemies;
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
	public class StartOfRound_Patches
	{
		private static void Postfix()
		{
			Plugin.spectatedEnemyIndex = -1;
			Plugin.spectatingEnemies = false;
		}
	}
	[HarmonyPatch(typeof(Turret), "Start")]
	public class Turret_Patches
	{
		private static void Postfix(Turret __instance)
		{
			if (Plugin.doSpectateTurrets)
			{
				Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>();
				spectatable.type = SpectatableType.Turret;
				spectatable.enemyName = "Turret";
			}
		}
	}
}

plugins/Blorb-WeatherMultipliers/WeatherMultipliers.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("WeatherMultipliers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WeatherMultipliers")]
[assembly: AssemblyTitle("WeatherMultipliers")]
[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 WeatherMultipliers
{
	[BepInPlugin("WeatherMultipliers", "WeatherMultipliers", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Dictionary<LevelWeatherType, ConfigEntry<float>> ValueMultipliers = new Dictionary<LevelWeatherType, ConfigEntry<float>>();

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

		private static readonly Dictionary<LevelWeatherType, float> defaultValueMultipliers = new Dictionary<LevelWeatherType, float>
		{
			{
				(LevelWeatherType)1,
				1.1f
			},
			{
				(LevelWeatherType)2,
				1.35f
			},
			{
				(LevelWeatherType)3,
				1.25f
			},
			{
				(LevelWeatherType)4,
				1.35f
			},
			{
				(LevelWeatherType)5,
				1.7f
			}
		};

		private void Awake()
		{
			//IL_001c: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<LevelWeatherType, float> defaultValueMultiplier in defaultValueMultipliers)
			{
				Dictionary<LevelWeatherType, ConfigEntry<float>> valueMultipliers = ValueMultipliers;
				LevelWeatherType key = defaultValueMultiplier.Key;
				ConfigFile config = ((BaseUnityPlugin)this).Config;
				LevelWeatherType key2 = defaultValueMultiplier.Key;
				valueMultipliers[key] = config.Bind<float>("Multipliers", ((object)(LevelWeatherType)(ref key2)).ToString(), Mathf.Clamp(defaultValueMultiplier.Value, 1f, 1000f), $"Scrap value multiplier for {defaultValueMultiplier.Key} weather");
			}
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin WeatherMultipliers is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "WeatherMultipliers";

		public const string PLUGIN_NAME = "WeatherMultipliers";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace WeatherMultipliers.patches
{
	[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
	public class ApplyOnScrapGeneration
	{
		private static readonly ManualLogSource logger = Logger.CreateLogSource("WeatherMultipliers.ApplyOnScrapGeneration");

		private static void Prefix(RoundManager __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0024: 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)
			LevelWeatherType currentWeather = __instance.currentLevel.currentWeather;
			if (Plugin.ValueMultipliers.ContainsKey(currentWeather))
			{
				float value = Plugin.ValueMultipliers[__instance.currentLevel.currentWeather].Value;
				__instance.scrapValueMultiplier *= value;
				logger.LogInfo((object)$"Set scrap value multiplier ({value}) for current weather \"{currentWeather}\"");
			}
			else
			{
				logger.LogInfo((object)$"No weather multiplier found for \"{currentWeather}\"");
			}
		}

		private static void Postfix(RoundManager __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			LevelWeatherType currentWeather = __instance.currentLevel.currentWeather;
			if (Plugin.ValueMultipliers.ContainsKey(currentWeather))
			{
				float value = Plugin.ValueMultipliers[__instance.currentLevel.currentWeather].Value;
				__instance.scrapValueMultiplier /= value;
				logger.LogInfo((object)$"Scrap generated, resetting scrap value multiplier to its original value of {__instance.scrapValueMultiplier}");
			}
		}
	}
	[HarmonyPatch(typeof(LungProp), "DisconnectFromMachinery")]
	public class ApplyLungPropMultiplier
	{
		private static readonly ManualLogSource logger = Logger.CreateLogSource("WeatherMultipliers.ApplyLungPropMultiplier");

		private static void Prefix(LungProp __instance)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			LevelWeatherType currentWeather = __instance.roundManager.currentLevel.currentWeather;
			if (Plugin.ValueMultipliers.ContainsKey(currentWeather))
			{
				float value = Plugin.ValueMultipliers[currentWeather].Value;
				((GrabbableObject)__instance).scrapValue = (int)(value * (float)((GrabbableObject)__instance).scrapValue);
				logger.LogInfo((object)$"Adjusting LungProp (Apparatus) value for weather {currentWeather}: {((GrabbableObject)__instance).scrapValue}");
			}
		}
	}
}

plugins/boxofbiscuits97-QuotaRollover/QuotaRollover.dll

Decompiled 2 years ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using QuotaRollover.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("QuotaRollover")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("QuotaRollover")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bc931127-211b-4882-bb8e-44687a45d42b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace QuotaRollover
{
	[BepInPlugin("Boxofbiscuits97.QuotraRollover", "Quota Rollover", "2.1.0")]
	public class QuotaRolloverBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Boxofbiscuits97.QuotraRollover");

		private static QuotaRolloverBase Instance;

		public static ManualLogSource logger;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = ((BaseUnityPlugin)this).Logger;
			logger.LogInfo((object)"Mod Boxofbiscuits97.QuotraRollover is loaded!");
			harmony.PatchAll(typeof(QuotaRolloverBase));
			harmony.PatchAll(typeof(TimeOfDayPatch));
		}
	}
}
namespace QuotaRollover.Patches
{
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		[HarmonyPatch("SetNewProfitQuota")]
		[HarmonyPrefix]
		private static bool GetQuotaFulfilledHost(ref int ___quotaFulfilled, ref int ___profitQuota, out int __state)
		{
			if (TimeOfDay.Instance.timeUntilDeadline <= 0f)
			{
				__state = ___quotaFulfilled - ___profitQuota;
				QuotaRolloverBase.logger.LogInfo((object)$"Host Got New Quota at: {__state} ful: {___quotaFulfilled}");
				return true;
			}
			__state = ___quotaFulfilled;
			return false;
		}

		[HarmonyPatch("SetNewProfitQuota")]
		[HarmonyPostfix]
		private static void SetQuotaFulfilledHost(ref int ___quotaFulfilled, int __state)
		{
			___quotaFulfilled = __state;
			QuotaRolloverBase.logger.LogInfo((object)$"Host Set New Quota at: {__state}");
		}

		[HarmonyPatch("SyncNewProfitQuotaClientRpc")]
		[HarmonyPrefix]
		private static void GetNewQuotaFulfilledClient(ref int ___quotaFulfilled, ref int ___profitQuota, out int __state)
		{
			__state = ___quotaFulfilled - ___profitQuota;
			QuotaRolloverBase.logger.LogInfo((object)$"Client Got New Quota at: {__state}");
		}

		[HarmonyPatch("SyncNewProfitQuotaClientRpc")]
		[HarmonyPostfix]
		private static void SetNewQuotaFulfiledClient(ref int ___quotaFulfilled, int __state)
		{
			if (___quotaFulfilled == 0)
			{
				___quotaFulfilled = __state;
				QuotaRolloverBase.logger.LogInfo((object)$"Client Set New Quota at: {__state}");
			}
		}
	}
}

plugins/FlipMods-MoreBlood/MoreBlood.dll

Decompiled 2 years ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using MoreBlood.Config;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoreBlood")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreBlood")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d1f1321d-30a3-4600-9bf8-1e69fe1abf8c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreBlood
{
	[BepInPlugin("FlipMods.MoreBlood", "MoreBlood", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			instance = this;
			_harmony = new Harmony("MoreBlood");
			ConfigSettings.BindConfigSettings();
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MoreBlood loaded");
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.MoreBlood";

		public const string PLUGIN_NAME = "MoreBlood";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace MoreBlood.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class MoreBloodPatcher
	{
		private static int bloodCount;

		[HarmonyPatch("DropBlood")]
		[HarmonyPostfix]
		public static void MoreBlood(PlayerControllerB __instance, Vector3 direction = default(Vector3), bool leaveBlood = true, bool leaveFootprint = false)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			bloodCount++;
			if (bloodCount < ConfigSettings.numBloodPools.Value)
			{
				__instance.DropBlood(direction, leaveBlood, leaveFootprint);
			}
			else
			{
				bloodCount = 0;
			}
		}

		[HarmonyPatch("RandomizeBloodRotationAndScale")]
		[HarmonyPostfix]
		public static void RandomizeBloodScale(ref Transform blood, PlayerControllerB __instance)
		{
			//IL_0004: 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_0022: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = blood;
			obj.localScale *= ConfigSettings.bloodScale.Value;
			blood.position += new Vector3((float)Random.Range(-1, 1) * ConfigSettings.bloodScale.Value, 0.55f, (float)Random.Range(-1, 1) * ConfigSettings.bloodScale.Value);
		}
	}
}
namespace MoreBlood.Config
{
	public static class ConfigSettings
	{
		public static ConfigEntry<float> bloodScale;

		public static ConfigEntry<int> numBloodPools;

		public static void BindConfigSettings()
		{
			Plugin.Log("BindingConfigs");
			bloodScale = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("MoreBlood", "BloodScale", 4f, "The size of the blood pools");
			numBloodPools = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("MoreBlood", "NumberOfBloodPools", 4, "Max number of blood pools spread around the blood source.");
		}
	}
}

plugins/FlipMods-ReservedFlashlightSlot/ReservedFlashlightSlot.dll

Decompiled 2 years ago
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using ReservedFlashlightSlot.Patches;
using ReservedItemSlotCore;
using ReservedItemSlotCore.Networking;
using ReservedItemSlotCore.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ReservedFlashlightSlot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReservedFlashlightSlot")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5b7d6563-4e51-4a69-bcf9-fa1dea6eff75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ReservedFlashlightSlot
{
	public static class ConfigSettings
	{
		public static ConfigEntry<string> activateFlashlightKey;

		public static ConfigEntry<bool> hideFlashlightMeshShoulder;

		public static string activateFlashlightDisplayName;

		public static void BindConfigSettings()
		{
			Plugin.Log("BindingConfigs");
			activateFlashlightKey = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("ReservedItemSlotCore", "ActivateFlashlightKey", "<Keyboard>/f", "Activate flashlight keybind.");
			hideFlashlightMeshShoulder = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("ReservedItemSlotCore", "HideFlashlightOnShoulder", false, "Hides the flashlight mesh while on your shoulder.");
			activateFlashlightDisplayName = GetDisplayName(activateFlashlightKey.Value);
		}

		public static string GetDisplayName(string key)
		{
			key = key.Replace("<Keyboard>/", "");
			key = key.Replace("<Mouse>/", "");
			string text = key;
			text = text.Replace("leftAlt", "Alt");
			text = text.Replace("rightAlt", "Alt");
			text = text.Replace("leftCtrl", "Ctrl");
			text = text.Replace("rightCtrl", "Ctrl");
			text = text.Replace("leftShift", "Shift");
			text = text.Replace("rightShift", "Shift");
			text = text.Replace("leftButton", "LMB");
			text = text.Replace("rightButton", "RMB");
			return text.Replace("middleButton", "MMB");
		}
	}
	[HarmonyPatch]
	internal static class Keybinds
	{
		public static PlayerControllerB localPlayerController;

		private static InputAction activateFlashlightAction;

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void OnLocalPlayerConnect(PlayerControllerB __instance)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			localPlayerController = __instance;
			activateFlashlightAction = new InputAction((string)null, (InputActionType)0, ConfigSettings.activateFlashlightKey.Value, "Press", (string)null, (string)null);
			if (((Component)localPlayerController).gameObject.activeSelf)
			{
				SubscribeToEvents();
			}
		}

		private static void SubscribeToEvents()
		{
			if (activateFlashlightAction != null)
			{
				activateFlashlightAction.Enable();
				activateFlashlightAction.performed += OnActivateFlashlightPerformed;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "OnEnable")]
		[HarmonyPostfix]
		public static void OnEnable(PlayerControllerB __instance)
		{
			if ((Object)(object)__instance == (Object)(object)localPlayerController)
			{
				SubscribeToEvents();
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "OnDisable")]
		[HarmonyPostfix]
		public static void OnDisable(PlayerControllerB __instance)
		{
			if (activateFlashlightAction != null && !((Object)(object)__instance != (Object)(object)localPlayerController))
			{
				activateFlashlightAction.performed -= OnActivateFlashlightPerformed;
				activateFlashlightAction.Disable();
			}
		}

		private static void OnActivateFlashlightPerformed(CallbackContext context)
		{
			if ((Object)(object)localPlayerController == (Object)null || !localPlayerController.isPlayerControlled || localPlayerController.inTerminalMenu || (((NetworkBehaviour)localPlayerController).IsServer && !localPlayerController.isHostPlayerObject))
			{
				return;
			}
			FlashlightItem mainFlashlight = ReservedFlashlightSlotPatcher.GetMainFlashlight(localPlayerController);
			if (((CallbackContext)(ref context)).performed && !((Object)(object)mainFlashlight == (Object)null))
			{
				float num = (float)Traverse.Create((object)localPlayerController).Field("timeSinceSwitchingSlots").GetValue();
				if (!(num < 0.075f))
				{
					((GrabbableObject)mainFlashlight).UseItemOnClient(!((GrabbableObject)mainFlashlight).isBeingUsed);
					Traverse.Create((object)localPlayerController).Field("timeSinceSwitchingSlots").SetValue((object)0);
				}
			}
		}
	}
	[BepInPlugin("FlipMods.ReservedFlashlightSlot", "ReservedFlashlightSlot", "1.4.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance;

		private Harmony _harmony;

		public static ReservedItemInfo proFlashlightInfo = new ReservedItemInfo("Pro-flashlight", 120, true, true, true, true);

		public static ReservedItemInfo flashlightInfo = new ReservedItemInfo("Flashlight", 120, true, true, true, true);

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			instance = this;
			ConfigSettings.BindConfigSettings();
			_harmony = new Harmony("ReservedFlashlightSlot");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ReservedFlashlightSlot loaded");
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.ReservedFlashlightSlot";

		public const string PLUGIN_NAME = "ReservedFlashlightSlot";

		public const string PLUGIN_VERSION = "1.4.5";
	}
}
namespace ReservedFlashlightSlot.Patches
{
	[HarmonyPatch]
	internal static class ReservedFlashlightSlotPatcher
	{
		private static Vector3 playerShoulderPositionOffset = new Vector3(0.2f, 0f, 0f);

		private static Vector3 playerShoulderRotationOffset = new Vector3(90f, 0f, 0f);

		private static string originalControlTooltip = "";

		public static PlayerControllerB localPlayerController => PlayerPatcher.localPlayerController;

		public static PlayerControllerB GetPreviousPlayerHeldBy(FlashlightItem flashlightItem)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			return (PlayerControllerB)Traverse.Create((object)flashlightItem).Field("previousPlayerHeldBy").GetValue();
		}

		public static FlashlightItem GetMainFlashlight(PlayerControllerB playerController)
		{
			return GetCurrentlySelectedFlashlight(playerController) ?? GetReservedFlashlight(playerController);
		}

		public static FlashlightItem GetReservedFlashlight(PlayerControllerB playerController)
		{
			GrabbableObject obj = ((playerController != null) ? playerController.ItemSlots[Plugin.flashlightInfo.indexInInventory] : null);
			return (FlashlightItem)(object)((obj is FlashlightItem) ? obj : null);
		}

		public static FlashlightItem GetCurrentlySelectedFlashlight(PlayerControllerB playerController)
		{
			GrabbableObject obj = ((playerController != null) ? playerController.ItemSlots[playerController.currentItemSlot] : null);
			return (FlashlightItem)(object)((obj is FlashlightItem) ? obj : null);
		}

		public static bool IsFlashlightOn(PlayerControllerB playerController)
		{
			return ((GrabbableObject)(GetMainFlashlight(playerController)?)).isBeingUsed ?? false;
		}

		[HarmonyPatch(typeof(FlashlightItem), "__initializeVariables")]
		[HarmonyPostfix]
		public static void EditTooltips(FlashlightItem __instance)
		{
			if (originalControlTooltip == "")
			{
				originalControlTooltip = ((GrabbableObject)__instance).itemProperties.toolTips[((GrabbableObject)__instance).itemProperties.toolTips.Length - 1];
			}
			((GrabbableObject)__instance).itemProperties.toolTips[((GrabbableObject)__instance).itemProperties.toolTips.Length - 1] = $"{originalControlTooltip}[{ConfigSettings.activateFlashlightDisplayName.ToUpper()}]";
		}

		[HarmonyPatch(typeof(MenuManager), "OnEnable")]
		[HarmonyPostfix]
		public static void ResetVariables()
		{
			Keybinds.localPlayerController = null;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ActivateItem_performed")]
		[HarmonyPrefix]
		public static bool PreventActivatingDuplicateItem(CallbackContext context, PlayerControllerB __instance)
		{
			FlashlightItem currentlySelectedFlashlight = GetCurrentlySelectedFlashlight(__instance);
			if ((Object)(object)__instance != (Object)(object)localPlayerController || (Object)(object)currentlySelectedFlashlight == (Object)null)
			{
				return true;
			}
			if (!((CallbackContext)(ref context)).performed)
			{
				return false;
			}
			FlashlightItem reservedFlashlight = GetReservedFlashlight(__instance);
			if ((Object)(object)currentlySelectedFlashlight != (Object)(object)reservedFlashlight && (!((GrabbableObject)reservedFlashlight).itemProperties.requiresBattery || !((GrabbableObject)reservedFlashlight).insertedBattery.empty))
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(FlashlightItem), "SwitchFlashlight")]
		[HarmonyPostfix]
		public static void OnSwitchOnOffFlashlight(bool on, FlashlightItem __instance)
		{
			if (!((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null))
			{
				UpdateAllFlashlightStates(((GrabbableObject)__instance).playerHeldBy, on);
			}
		}

		[HarmonyPatch(typeof(FlashlightItem), "PocketItem")]
		[HarmonyPostfix]
		public static void OnPocketFlashlightLocal(FlashlightItem __instance)
		{
			OnPocketFlashlight(__instance, ((GrabbableObject)__instance).isBeingUsed);
		}

		[HarmonyPatch(typeof(FlashlightItem), "PocketFlashlightClientRpc")]
		[HarmonyPrefix]
		public static bool OnPocketFlashlightClientRpc(bool stillUsingFlashlight, FlashlightItem __instance)
		{
			if (!NetworkHelper.IsValidClientRpcExecStage((NetworkBehaviour)(object)__instance) || ((NetworkBehaviour)__instance).IsOwner || (Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null || (Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)localPlayerController || !NetworkHelper.IsClientExecStage((NetworkBehaviour)(object)__instance))
			{
				return false;
			}
			((MonoBehaviour)__instance).StartCoroutine(OnPocketFlashlightEndOfFrame(__instance, stillUsingFlashlight));
			return true;
		}

		private static IEnumerator OnPocketFlashlightEndOfFrame(FlashlightItem flashlightItem, bool stillUsingFlashlight)
		{
			yield return (object)new WaitForEndOfFrame();
			OnPocketFlashlight(flashlightItem, stillUsingFlashlight);
		}

		private static void OnPocketFlashlight(FlashlightItem flashlightItem, bool stillUsingFlashlight = false)
		{
			if (!((Object)(object)((GrabbableObject)flashlightItem).playerHeldBy == (Object)null))
			{
				((GrabbableObject)flashlightItem).playerHeldBy.pocketedFlashlight = (GrabbableObject)(object)flashlightItem;
				((GrabbableObject)flashlightItem).parentObject = ((GrabbableObject)flashlightItem).playerHeldBy.playerGlobalHead;
				bool flag = (Object)(object)((GrabbableObject)flashlightItem).playerHeldBy == (Object)(object)localPlayerController;
			}
		}

		[HarmonyPatch(typeof(FlashlightItem), "EquipItem")]
		[HarmonyPostfix]
		public static void OnEquipFlashlight(FlashlightItem __instance)
		{
			if (!((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null))
			{
				if ((Object)(object)__instance == (Object)(object)((GrabbableObject)__instance).playerHeldBy.pocketedFlashlight)
				{
					((GrabbableObject)__instance).playerHeldBy.pocketedFlashlight = null;
				}
				((GrabbableObject)__instance).parentObject = (((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)localPlayerController) ? ((GrabbableObject)__instance).playerHeldBy.localItemHolder : ((GrabbableObject)__instance).playerHeldBy.serverItemHolder);
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		[HarmonyPostfix]
		public static void SetPositionOffset(GrabbableObject __instance)
		{
			//IL_006c: 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_0076: 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)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			if (__instance is FlashlightItem && (Object)(object)__instance.playerHeldBy != (Object)null && __instance.isPocketed && (Object)(object)__instance.parentObject != (Object)null && (Object)(object)__instance != (Object)(object)GetCurrentlySelectedFlashlight(__instance.playerHeldBy))
			{
				Transform transform = ((Component)__instance.parentObject).transform;
				((Component)__instance).transform.rotation = ((Component)__instance.parentObject).transform.rotation * Quaternion.Euler(playerShoulderRotationOffset);
				((Component)__instance).transform.position = transform.position + transform.rotation * playerShoulderPositionOffset;
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "EnableItemMeshes")]
		[HarmonyPrefix]
		public static void OnEnableItemMeshes(ref bool enable, GrabbableObject __instance)
		{
			if (__instance is FlashlightItem && (Object)(object)__instance.playerHeldBy != (Object)null && ((Object)(object)__instance == (Object)(object)GetCurrentlySelectedFlashlight(__instance.playerHeldBy) || ((Object)(object)__instance == (Object)(object)GetReservedFlashlight(__instance.playerHeldBy) && (Object)(object)__instance.playerHeldBy != (Object)(object)localPlayerController)))
			{
				enable = true;
			}
		}

		private static void UpdateAllFlashlightStates(PlayerControllerB playerController, bool mainFlashlightActive = true)
		{
			FlashlightItem mainFlashlight = GetMainFlashlight(playerController);
			if ((Object)(object)mainFlashlight == (Object)null)
			{
				((Behaviour)playerController.helmetLight).enabled = false;
				mainFlashlightActive = false;
			}
			else
			{
				playerController.ChangeHelmetLight(mainFlashlight.flashlightTypeID, mainFlashlightActive && (Object)(object)playerController == (Object)(object)localPlayerController && (Object)(object)playerController.ItemSlots[playerController.currentItemSlot] != (Object)(object)mainFlashlight);
			}
			for (int i = 0; i < PlayerPatcher.combinedHotbarSize; i++)
			{
				GrabbableObject obj = playerController.ItemSlots[i];
				FlashlightItem val = (FlashlightItem)(object)((obj is FlashlightItem) ? obj : null);
				if ((Object)(object)val != (Object)null)
				{
					UpdateFlashlightState(val, (Object)(object)val == (Object)(object)mainFlashlight && mainFlashlightActive);
				}
			}
		}

		private static void UpdateFlashlightState(FlashlightItem flashlightItem, bool active)
		{
			if (!((Object)(object)((GrabbableObject)flashlightItem).playerHeldBy == (Object)null))
			{
				PlayerControllerB playerHeldBy = ((GrabbableObject)flashlightItem).playerHeldBy;
				((GrabbableObject)flashlightItem).isBeingUsed = active;
				bool flag = (Object)(object)playerHeldBy != (Object)(object)localPlayerController || (Object)(object)playerHeldBy.ItemSlots[playerHeldBy.currentItemSlot] == (Object)(object)flashlightItem;
				((Behaviour)flashlightItem.flashlightBulb).enabled = active && flag;
				((Behaviour)flashlightItem.flashlightBulbGlow).enabled = active && flag;
				flashlightItem.usingPlayerHelmetLight = active && !flag;
			}
		}
	}
}

plugins/FlipMods-ReservedItemSlotCore/ReservedItemSlotCore.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using ReservedItemSlotCore.Networking;
using ReservedItemSlotCore.Patches;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ReservedItemSlotCore")]
[assembly: AssemblyDescription("Mod made by flipf17")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReservedItemSlotCore")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("238ce080-e339-46b6-9b08-992a950453a1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ReservedItemSlotCore
{
	public static class ConfigSettings
	{
		public static ConfigEntry<string> focusReservedHotbarHotkey;

		public static ConfigEntry<string> specialReservedItemUseHotkey;

		public static string focusReservedHotbarHotkeyDisplayName;

		public static void BindConfigSettings()
		{
			Plugin.Log("BindingConfigs");
			focusReservedHotbarHotkey = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("ReservedItemSlotCore", "FocusReservedItemSlotsHotkey", "<Keyboard>/leftAlt", "Which key will focus your reserved item slots hotbar to allow selcting, dropping, charging, etc.");
			specialReservedItemUseHotkey = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("ReservedItemSlotCore", "SpecialReservedItemUseHotkey", "<Mouse>/middleButton", "[REMOVED] Which key will focus your reserved item slots hotbar to allow selcting, dropping, charging, etc.");
			focusReservedHotbarHotkeyDisplayName = GetDisplayName(focusReservedHotbarHotkey.Value);
		}

		public static string GetDisplayName(string key)
		{
			key = key.Replace("<Keyboard>/", "");
			key = key.Replace("<Mouse>/", "");
			string text = key;
			text = text.Replace("leftAlt", "Alt");
			text = text.Replace("rightAlt", "Alt");
			text = text.Replace("leftCtrl", "Ctrl");
			text = text.Replace("rightCtrl", "Ctrl");
			text = text.Replace("leftShift", "Shift");
			text = text.Replace("rightShift", "Shift");
			text = text.Replace("leftButton", "LMB");
			text = text.Replace("rightButton", "RMB");
			return text.Replace("middleButton", "MMB");
		}
	}
	[HarmonyPatch]
	internal static class HotbarSlotSync
	{
		public static PlayerControllerB localPlayerController;

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void Init(PlayerControllerB __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			localPlayerController = __instance;
			NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("OnSwapHotbarClientRpc", new HandleNamedMessageDelegate(OnSwapHotbarClientRpc));
			if (NetworkManager.Singleton.IsServer)
			{
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("OnSwapHotbarServerRpc", new HandleNamedMessageDelegate(OnSwapHotbarServerRpc));
			}
		}

		private static void SendSwapHotbarUpdate(int hotbarSlot)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsClient)
			{
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
				try
				{
					Plugin.Log("Sending hotbar swap slot: " + hotbarSlot);
					((FastBufferWriter)(ref val)).WriteValue<int>(ref hotbarSlot, default(ForPrimitives));
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("OnSwapHotbarServerRpc", 0uL, val, (NetworkDelivery)3);
					return;
				}
				finally
				{
					((IDisposable)(FastBufferWriter)(ref val)).Dispose();
				}
			}
			Plugin.Log("Failed to send hotbar swap index.");
		}

		private static void OnSwapHotbarServerRpc(ulong clientId, FastBufferReader reader)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			if (((FastBufferReader)(ref reader)).TryBeginRead(4))
			{
				int num = default(int);
				((FastBufferReader)(ref reader)).ReadValue<int>(ref num, default(ForPrimitives));
				Plugin.Log("Receiving request for hotbar swap. Slot: " + num + " ClientId: " + clientId);
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(12, (Allocator)2, -1);
				try
				{
					((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
					((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref clientId, default(ForPrimitives));
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("OnSwapHotbarClientRpc", val, (NetworkDelivery)3);
					return;
				}
				finally
				{
					((IDisposable)(FastBufferWriter)(ref val)).Dispose();
				}
			}
			Plugin.Log("Failed to receive hotbar swap index from Client: " + clientId);
		}

		private static void OnSwapHotbarClientRpc(ulong clientId, FastBufferReader reader)
		{
			//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)
			{
				return;
			}
			if (((FastBufferReader)(ref reader)).TryBeginRead(12))
			{
				int hotbarSlot = default(int);
				((FastBufferReader)(ref reader)).ReadValue<int>(ref hotbarSlot, default(ForPrimitives));
				ulong num = default(ulong);
				((FastBufferReader)(ref reader)).ReadValue<ulong>(ref num, default(ForPrimitives));
				Plugin.Log("Receiving update for hotbar swap. Slot: " + hotbarSlot + " ClientId: " + num);
				if (num == localPlayerController.actualClientId || UpdateClientHotbarSlot(num, hotbarSlot))
				{
					return;
				}
				Plugin.Log("Failed to receive hotbar swap index from Client: " + num);
			}
			Plugin.Log("Failed to receive hotbar swap index from Client");
		}

		private static bool UpdateClientHotbarSlot(ulong clientId, int hotbarSlot)
		{
			Plugin.Log("Updating hotbar slot: " + hotbarSlot + " ClientId: " + clientId);
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				if (StartOfRound.Instance.allPlayerScripts[i].actualClientId == clientId)
				{
					CallSwitchToItemSlotMethod(StartOfRound.Instance.allPlayerScripts[i], hotbarSlot);
					return true;
				}
			}
			return false;
		}

		public static void SwapHotbarSlot(int hotbarIndex)
		{
			SendSwapHotbarUpdate(hotbarIndex);
			CallSwitchToItemSlotMethod(localPlayerController, hotbarIndex);
			Traverse.Create((object)localPlayerController).Field("timeSinceSwitchingSlots").SetValue((object)0);
		}

		private static void CallSwitchToItemSlotMethod(PlayerControllerB playerController, int hotbarIndex)
		{
			ShipBuildModeManager.Instance.CancelBuildMode(true);
			MethodInfo method = ((object)playerController).GetType().GetMethod("SwitchToItemSlot", BindingFlags.Instance | BindingFlags.NonPublic);
			method.Invoke(playerController, new object[2] { hotbarIndex, null });
			if ((Object)(object)playerController.currentlyHeldObjectServer != (Object)null)
			{
				((Component)playerController.currentlyHeldObjectServer).gameObject.GetComponent<AudioSource>().PlayOneShot(playerController.currentlyHeldObjectServer.itemProperties.grabSFX, 0.6f);
			}
		}
	}
	[HarmonyPatch]
	internal static class Keybinds
	{
		public static PlayerControllerB localPlayerController;

		public static InputAction focusReservedHotbarAction;

		public static bool holdingModifierKey;

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void OnLocalPlayerConnect(PlayerControllerB __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			localPlayerController = __instance;
			focusReservedHotbarAction = new InputAction((string)null, (InputActionType)0, ConfigSettings.focusReservedHotbarHotkey.Value, (string)null, (string)null, (string)null);
			if (((Component)localPlayerController).gameObject.activeSelf)
			{
				SubscribeToEvents();
			}
		}

		private static void SubscribeToEvents()
		{
			if (focusReservedHotbarAction != null && Plugin.numReservedItemSlots > 0)
			{
				focusReservedHotbarAction.performed += FocusReservedHotbarSlotsAction;
				focusReservedHotbarAction.canceled += UnfocusReservedHotbarSlotsPerformed;
				focusReservedHotbarAction.Enable();
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "OnEnable")]
		[HarmonyPostfix]
		public static void OnEnable(PlayerControllerB __instance)
		{
			if ((Object)(object)__instance == (Object)(object)localPlayerController)
			{
				SubscribeToEvents();
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "OnDisable")]
		[HarmonyPostfix]
		public static void OnDisable(PlayerControllerB __instance)
		{
			if (focusReservedHotbarAction != null && Plugin.numReservedItemSlots > 0 && !((Object)(object)__instance != (Object)(object)localPlayerController))
			{
				focusReservedHotbarAction.performed -= FocusReservedHotbarSlotsAction;
				focusReservedHotbarAction.canceled -= UnfocusReservedHotbarSlotsPerformed;
				focusReservedHotbarAction.Disable();
			}
		}

		private static void FocusReservedHotbarSlotsAction(CallbackContext context)
		{
			if (!((Object)(object)localPlayerController == (Object)null) && !((Object)(object)localPlayerController == (Object)null) && ((NetworkBehaviour)localPlayerController).IsOwner && localPlayerController.isPlayerControlled && (!((NetworkBehaviour)localPlayerController).IsServer || localPlayerController.isHostPlayerObject))
			{
				holdingModifierKey = true;
				bool flag = (bool)Traverse.Create((object)localPlayerController).Field("throwingObject").GetValue();
				if (!(localPlayerController.inTerminalMenu || localPlayerController.isPlayerDead || localPlayerController.isGrabbingObjectAnimation || localPlayerController.inSpecialInteractAnimation || flag) && !localPlayerController.isTypingChat && !localPlayerController.twoHanded && !localPlayerController.activatingItem && ((CallbackContext)(ref context)).performed)
				{
					ReservedItemPatcher.SetFocusReservedHotbarSlots(active: true);
				}
			}
		}

		private static void UnfocusReservedHotbarSlotsPerformed(CallbackContext context)
		{
			if (!((Object)(object)localPlayerController == (Object)null) && ((NetworkBehaviour)localPlayerController).IsOwner && (!((NetworkBehaviour)localPlayerController).IsServer || localPlayerController.isHostPlayerObject))
			{
				holdingModifierKey = false;
				if (ReservedItemPatcher.CanSwapToReservedHotbarSlot() && ((CallbackContext)(ref context)).canceled)
				{
					ReservedItemPatcher.SetFocusReservedHotbarSlots(active: false);
				}
			}
		}
	}
	[BepInPlugin("FlipMods.ReservedItemSlotCore", "ReservedItemSlotCore", "1.4.4")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static Plugin instance;

		public static Dictionary<string, ReservedItemInfo> reservedItemsDict => ReservedItemInfo.reservedItemsDict;

		public static List<ReservedItemInfo> reservedItemsList => ReservedItemInfo.reservedItemsList;

		public static List<ReservedItemInfo> reservedItemSlotReps => ReservedItemInfo.reservedItemSlotReps;

		public static int numReservedItemSlots => ReservedItemInfo.numReservedItemSlots;

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			instance = this;
			_harmony = new Harmony("ReservedItemSlotCore");
			ConfigSettings.BindConfigSettings();
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ReservedItemSlotCore loaded");
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}

		public static bool IsReservedItem(string itemName)
		{
			return reservedItemsDict.ContainsKey(itemName);
		}

		public static ReservedItemInfo GetReservedItemInfo(string itemName)
		{
			return IsReservedItem(itemName) ? reservedItemsDict[itemName] : null;
		}

		public static ReservedItemInfo GetReservedItemInfo(GrabbableObject item)
		{
			return ((Object)(object)item != (Object)null) ? GetReservedItemInfo(item.itemProperties.itemName) : null;
		}

		public static int GetReservedItemHotbarIndex(string itemName)
		{
			return IsReservedItem(itemName) ? reservedItemsDict[itemName].indexInInventory : (-1);
		}
	}
	public class ReservedItemInfo
	{
		public static Dictionary<string, ReservedItemInfo> reservedItemsDict = new Dictionary<string, ReservedItemInfo>();

		public static List<ReservedItemInfo> reservedItemsList = new List<ReservedItemInfo>();

		public static List<ReservedItemInfo> reservedItemSlotReps = new List<ReservedItemInfo>();

		public static int defaultHotbarSlotPriority = 10;

		public static int currentUndefinedHotbarSlotPriority = 0;

		public string itemName;

		public int hotbarSlotPriority;

		private int undefinedHotbarSlotPriority = -1;

		public int reservedItemIndex;

		public bool forceUpdateCanBeGrabbedBeforeGameStart = false;

		public bool canBeGrabbedBeforeGameStart = false;

		public bool forceUpdateRequiresBattery = false;

		public bool requiresBattery = false;

		public static int numReservedItemSlots => reservedItemSlotReps.Count;

		public int indexInInventory => ((Object)(object)PlayerPatcher.localPlayerController != (Object)null) ? (PlayerPatcher.localPlayerController.ItemSlots.Length - (numReservedItemSlots - reservedItemIndex)) : (-1);

		public ReservedItemInfo(string itemName, int hotbarSlotPriority = -1, bool forceUpdateCanBeGrabbedBeforeGameStart = false, bool canBeGrabbedBeforeGameStart = false, bool forceUpdateRequiresBattery = false, bool requiresBattery = false)
		{
			this.itemName = itemName;
			this.forceUpdateCanBeGrabbedBeforeGameStart = forceUpdateCanBeGrabbedBeforeGameStart;
			this.canBeGrabbedBeforeGameStart = canBeGrabbedBeforeGameStart;
			this.forceUpdateRequiresBattery = forceUpdateRequiresBattery;
			this.requiresBattery = requiresBattery;
			if (hotbarSlotPriority != -1)
			{
				this.hotbarSlotPriority = hotbarSlotPriority;
			}
			else
			{
				this.hotbarSlotPriority = defaultHotbarSlotPriority;
				undefinedHotbarSlotPriority = ++currentUndefinedHotbarSlotPriority;
			}
			if (!reservedItemsDict.ContainsKey(this.itemName))
			{
				reservedItemsDict.Add(this.itemName, this);
				reservedItemsList.Add(this);
				int i;
				for (i = 0; i < reservedItemSlotReps.Count; i++)
				{
					ReservedItemInfo reservedItemInfo = reservedItemSlotReps[i];
					if (this.hotbarSlotPriority == reservedItemInfo.hotbarSlotPriority)
					{
						if (undefinedHotbarSlotPriority == reservedItemInfo.undefinedHotbarSlotPriority)
						{
							i = -1;
						}
						break;
					}
					if (this.hotbarSlotPriority > reservedItemInfo.hotbarSlotPriority)
					{
						break;
					}
				}
				if (i >= 0)
				{
					reservedItemIndex = i;
					reservedItemSlotReps.Insert(i, this);
					for (int j = i + 1; j < reservedItemSlotReps.Count; j++)
					{
						reservedItemSlotReps[j].reservedItemIndex = j;
					}
				}
			}
			else
			{
				Plugin.Log($"Tried to add duplicate item name to the ReservedItems list: {this.itemName}");
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.ReservedItemSlotCore";

		public const string PLUGIN_NAME = "ReservedItemSlotCore";

		public const string PLUGIN_VERSION = "1.4.4";
	}
}
namespace ReservedItemSlotCore.Networking
{
	public static class NetworkHelper
	{
		private static int NONE_EXEC_STAGE = 0;

		private static int SERVER_EXEC_STAGE = 1;

		private static int CLIENT_EXEC_STAGE = 2;

		public static int GetExecStage(NetworkBehaviour __instance)
		{
			return (int)Traverse.Create((object)__instance).Field("__rpc_exec_stage").GetValue();
		}

		public static bool IsClientExecStage(NetworkBehaviour __instance)
		{
			return GetExecStage(__instance) == CLIENT_EXEC_STAGE;
		}

		public static bool IsServerExecStage(NetworkBehaviour __instance)
		{
			return GetExecStage(__instance) == SERVER_EXEC_STAGE;
		}

		public static bool IsValidClientRpcExecStage(NetworkBehaviour __instance)
		{
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || !singleton.IsListening)
			{
				return false;
			}
			int num = (int)Traverse.Create((object)__instance).Field("__rpc_exec_stage").GetValue();
			if ((singleton.IsServer || singleton.IsHost) && num != 2)
			{
				return false;
			}
			return true;
		}
	}
}
namespace ReservedItemSlotCore.Patches
{
	[HarmonyPatch]
	public static class HUDPatcher
	{
		private static CanvasScaler canvasScaler;

		private static AspectRatioFitter aspectRatioFitter;

		private static float iconWidth;

		private static float xPos;

		[HarmonyPatch(typeof(HUDManager), "Awake")]
		[HarmonyPrefix]
		public static void Initialize(HUDManager __instance)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			canvasScaler = ((Component)__instance.itemSlotIconFrames[0]).GetComponentInParent<CanvasScaler>();
			aspectRatioFitter = ((Component)__instance.itemSlotIconFrames[0]).GetComponentInParent<AspectRatioFitter>();
			iconWidth = ((Component)__instance.itemSlotIconFrames[0]).GetComponent<RectTransform>().sizeDelta.x;
			xPos = canvasScaler.referenceResolution.x / 2f / aspectRatioFitter.aspectRatio - iconWidth / 4f;
		}

		[HarmonyPatch(typeof(HUDManager), "Start")]
		[HarmonyPostfix]
		public static void AddNewHotbarSlotsHud(HUDManager __instance)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerPatcher.reservedHotbarSize > 0)
			{
				List<Image> list = new List<Image>(__instance.itemSlotIconFrames);
				List<Image> list2 = new List<Image>(__instance.itemSlotIcons);
				float y = ((Component)HUDManager.Instance.itemSlotIconFrames[0]).GetComponent<RectTransform>().sizeDelta.y;
				Vector3 eulerAngles = ((Transform)((Component)HUDManager.Instance.itemSlotIconFrames[0]).GetComponent<RectTransform>()).eulerAngles;
				Vector3 eulerAngles2 = ((Transform)((Component)HUDManager.Instance.itemSlotIcons[0]).GetComponent<RectTransform>()).eulerAngles;
				Plugin.Log($"Adding {ReservedItemInfo.reservedItemsList.Count} Reserved Item slots to the inventory HUD. Previous inventory HUD size: {PlayerPatcher.unreservedHotbarSize}");
				for (int i = 0; i < Plugin.reservedItemSlotReps.Count; i++)
				{
					ReservedItemInfo reservedItemInfo = Plugin.reservedItemSlotReps[i];
					Plugin.Log($"Adding Reserved Item slot for item types [{reservedItemInfo.itemName}]. Inventory index: {list.Count}");
					float num = ((Graphic)HUDManager.Instance.itemSlotIconFrames[0]).rectTransform.anchoredPosition.y + 1.125f * y * (float)i;
					Image val = Object.Instantiate<Image>(HUDManager.Instance.itemSlotIconFrames[PlayerPatcher.unreservedHotbarSize - 1], ((Component)HUDManager.Instance.itemSlotIconFrames[0]).transform.parent);
					((Object)val).name = $"ReservedItemSlot{i} [{reservedItemInfo.itemName}]";
					((Graphic)val).rectTransform.anchoredPosition = new Vector2(xPos, num);
					((Transform)((Graphic)val).rectTransform).eulerAngles = eulerAngles;
					CanvasGroup val2 = ((Component)val).gameObject.AddComponent<CanvasGroup>();
					val2.ignoreParentGroups = true;
					val2.alpha = 1f;
					Image component = ((Component)((Component)val).transform.GetChild(0)).GetComponent<Image>();
					((Object)component).name = "Icon";
					((Transform)((Graphic)component).rectTransform).eulerAngles = eulerAngles2;
					list.Add(val);
					list2.Add(component);
				}
				if (Plugin.numReservedItemSlots > 0)
				{
					TextMeshProUGUI component2 = new GameObject("ReservedItemSlotTooltip", new Type[2]
					{
						typeof(RectTransform),
						typeof(TextMeshProUGUI)
					}).GetComponent<TextMeshProUGUI>();
					RectTransform rectTransform = ((TMP_Text)component2).rectTransform;
					((Component)rectTransform).transform.parent = ((Component)list[PlayerPatcher.unreservedHotbarSize]).transform;
					((Transform)rectTransform).localScale = Vector3.one;
					rectTransform.sizeDelta = new Vector2(((Graphic)list[0]).rectTransform.sizeDelta.x * 2f, 10f);
					rectTransform.pivot = Vector2.one / 2f;
					rectTransform.anchoredPosition3D = new Vector3(0f, (0f - rectTransform.sizeDelta.x / 2f) * 1.2f, 0f);
					((TMP_Text)component2).font = ((TMP_Text)__instance.controlTipLines[0]).font;
					((TMP_Text)component2).fontSize = 7f;
					((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
					((TMP_Text)component2).text = string.Format($"Hold: [{ConfigSettings.GetDisplayName(ConfigSettings.focusReservedHotbarHotkey.Value)}]");
				}
				__instance.itemSlotIconFrames = list.ToArray();
				__instance.itemSlotIcons = list2.ToArray();
				Plugin.Log($"Finished adding {PlayerPatcher.reservedHotbarSize} Reserved Item slots in the inventory HUD.");
			}
		}
	}
	[HarmonyPatch]
	public static class ReservedItemPatcher
	{
		public static bool isReservedHotbarFocused;

		public static int indexUnfocusedReservedHotbar;

		public static int indexFocusedReservedHotbar;

		public static Dictionary<PlayerControllerB, ReservedItemInfo> grabbingReservedItemInfoDict;

		private static GrabbableObject previouslyHeldObjectServer;

		public static PlayerControllerB localPlayerController => PlayerPatcher.localPlayerController;

		public static int unreservedHotbarSize => PlayerPatcher.unreservedHotbarSize;

		public static int reservedHotbarSize => Plugin.numReservedItemSlots;

		public static int combinedHotbarSize => PlayerPatcher.combinedHotbarSize;

		public static ReservedItemInfo grabbingReservedItemInfoLocal
		{
			get
			{
				return ((Object)(object)localPlayerController != (Object)null) ? grabbingReservedItemInfoDict[localPlayerController] : null;
			}
			set
			{
				if (!((Object)(object)localPlayerController == (Object)null))
				{
					grabbingReservedItemInfoDict[localPlayerController] = value;
				}
			}
		}

		[HarmonyPatch(typeof(MenuManager), "OnEnable")]
		[HarmonyPrefix]
		public static void ResetVariables(MenuManager __instance)
		{
			if (grabbingReservedItemInfoDict == null)
			{
				grabbingReservedItemInfoDict = new Dictionary<PlayerControllerB, ReservedItemInfo>();
			}
			if (grabbingReservedItemInfoDict.Count > 0)
			{
				grabbingReservedItemInfoDict.Clear();
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPrefix]
		public static void OnLocalPlayerConnect(PlayerControllerB __instance)
		{
			grabbingReservedItemInfoDict[__instance] = null;
		}

		private static GrabbableObject GetCurrentlyGrabbingObject(PlayerControllerB playerController)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			return (GrabbableObject)Traverse.Create((object)playerController).Field("currentlyGrabbingObject").GetValue();
		}

		private static void SetCurrentlyGrabbingObject(PlayerControllerB playerController, GrabbableObject grabbable)
		{
			Traverse.Create((object)playerController).Field("currentlyGrabbingObject").SetValue((object)grabbable);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "BeginGrabObject")]
		[HarmonyPrefix]
		public static bool GrabReservedItemPrefix(PlayerControllerB __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			if (isReservedHotbarFocused)
			{
				return false;
			}
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)__instance.gameplayCamera).transform.position, ((Component)__instance.gameplayCamera).transform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(val, ref val2, __instance.grabDistance, PlayerPatcher.INTERACTABLE_OBJECT_MASK) || ((Component)((RaycastHit)(ref val2)).collider).gameObject.layer == 8 || !(((Component)((RaycastHit)(ref val2)).collider).tag == "PhysicsProp") || __instance.twoHanded || __instance.sinkingValue > 0.73f)
			{
				grabbingReservedItemInfoLocal = null;
				return true;
			}
			GrabbableObject component = ((Component)((Component)((RaycastHit)(ref val2)).collider).transform).gameObject.GetComponent<GrabbableObject>();
			grabbingReservedItemInfoLocal = Plugin.GetReservedItemInfo(component);
			if (grabbingReservedItemInfoLocal == null)
			{
				return true;
			}
			if (!GameNetworkManager.Instance.gameHasStarted && !component.itemProperties.canBeGrabbedBeforeGameStart && !StartOfRound.Instance.testRoom.activeSelf)
			{
				return false;
			}
			Traverse.Create((object)__instance).Field("grabInvalidated").SetValue((object)false);
			SetCurrentlyGrabbingObject(__instance, component);
			if (__instance.inSpecialInteractAnimation || component.isHeld || component.isPocketed)
			{
				return false;
			}
			NetworkObject networkObject = ((NetworkBehaviour)component).NetworkObject;
			if ((Object)(object)networkObject == (Object)null || !networkObject.IsSpawned)
			{
				return false;
			}
			if (grabbingReservedItemInfoLocal == null || !IsItemSlotEmpty(grabbingReservedItemInfoLocal))
			{
				return true;
			}
			((Behaviour)__instance.cursorIcon).enabled = false;
			((TMP_Text)__instance.cursorTip).text = "";
			__instance.twoHanded = component.itemProperties.twoHanded;
			__instance.carryWeight += Mathf.Clamp(component.itemProperties.weight - 1f, 0f, 10f);
			__instance.grabObjectAnimationTime = 0f;
			MethodInfo method = ((object)__instance).GetType().GetMethod("GrabObjectServerRpc", BindingFlags.Instance | BindingFlags.NonPublic);
			method.Invoke(__instance, new object[1] { NetworkObjectReference.op_Implicit(networkObject) });
			Coroutine val3 = (Coroutine)Traverse.Create((object)__instance).Field("grabObjectCoroutine").GetValue();
			if (val3 != null)
			{
				((MonoBehaviour)__instance).StopCoroutine(val3);
			}
			MethodInfo method2 = ((object)__instance).GetType().GetMethod("GrabObject", BindingFlags.Instance | BindingFlags.NonPublic);
			val3 = ((MonoBehaviour)__instance).StartCoroutine((IEnumerator)method2.Invoke(__instance, new object[0]));
			Traverse.Create((object)__instance).Field("grabObjectCoroutine").SetValue((object)val3);
			return false;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectClientRpc")]
		[HarmonyPrefix]
		public static bool GrabReservedItemClientRpcPrefix(bool grabValidated, NetworkObjectReference grabbedObject, PlayerControllerB __instance)
		{
			if (!NetworkHelper.IsClientExecStage((NetworkBehaviour)(object)__instance))
			{
				return true;
			}
			if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsListening)
			{
				if (grabValidated)
				{
					NetworkObject val = default(NetworkObject);
					if (((NetworkObjectReference)(ref grabbedObject)).TryGet(ref val, (NetworkManager)null))
					{
						GrabbableObject component = ((Component)val).GetComponent<GrabbableObject>();
						ReservedItemInfo reservedItemInfo = Plugin.GetReservedItemInfo(component);
						if (reservedItemInfo != null && IsItemSlotEmpty(reservedItemInfo, __instance))
						{
							__instance.ItemSlots[reservedItemInfo.indexInInventory] = component;
							component.playerHeldBy = __instance;
							component.isHeld = true;
							component.EnablePhysics(false);
							component.hasHitGround = false;
							component.isInFactory = __instance.isInsideFactory;
							component.EnableItemMeshes(false);
							Traverse.Create((object)component).Field("previousPlayerHeldBy").SetValue((object)__instance);
							component.PocketItem();
							if ((Object)(object)__instance != (Object)(object)localPlayerController)
							{
								Plugin.Log("Grab object completed on player: " + ((Object)__instance).name);
								if ((Object)(object)component.itemProperties.grabSFX != (Object)null)
								{
									__instance.itemAudio.PlayOneShot(component.itemProperties.grabSFX, 1f);
								}
								grabbingReservedItemInfoDict[__instance] = null;
							}
							else
							{
								HUDManager.Instance.itemSlotIcons[reservedItemInfo.indexInInventory].sprite = component.itemProperties.itemIcon;
								((Behaviour)HUDManager.Instance.itemSlotIcons[reservedItemInfo.indexInInventory]).enabled = true;
								HUDManager.Instance.PingHUDElement(HUDManager.Instance.Inventory, 1.5f, 1f, 0.13f);
								previouslyHeldObjectServer = localPlayerController.currentlyHeldObjectServer;
								localPlayerController.currentlyHeldObjectServer = component;
							}
							return false;
						}
					}
				}
				else if ((Object)(object)__instance == (Object)(object)localPlayerController)
				{
					Plugin.Log("Failed to validate ReservedItemGrab by the local player. Object id: " + ((NetworkObjectReference)(ref grabbedObject)).NetworkObjectId + ".");
					Traverse.Create((object)localPlayerController).Field("grabInvalidated").SetValue((object)true);
				}
				else
				{
					Plugin.Log("Failed to validate ReservedItemGrab by player with id: " + ((Object)__instance).name + ". Object id: " + ((NetworkObjectReference)(ref grabbedObject)).NetworkObjectId + ".");
				}
			}
			grabbingReservedItemInfoDict[__instance] = null;
			return true;
		}

		[HarmonyPatch(typeof(GrabbableObject), "GrabItemOnClient")]
		[HarmonyPrefix]
		public static void OnReservedItemGrabbed(GrabbableObject __instance)
		{
			if (grabbingReservedItemInfoLocal != null && !((Object)(object)__instance != (Object)(object)GetCurrentlyGrabbingObject(localPlayerController)))
			{
				OnLocalPlayerGrabbedReservedItem();
				__instance.PocketItem();
			}
		}

		private static void OnLocalPlayerGrabbedReservedItem()
		{
			localPlayerController.currentlyHeldObjectServer = previouslyHeldObjectServer;
			previouslyHeldObjectServer = null;
			grabbingReservedItemInfoLocal = null;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "FirstEmptyItemSlot")]
		[HarmonyPostfix]
		public static void GetReservedItemSlotPlacementIndex(ref int __result, PlayerControllerB __instance)
		{
			ReservedItemInfo reservedItemInfo = grabbingReservedItemInfoDict[__instance];
			if (reservedItemInfo != null)
			{
				if (__result == reservedItemInfo.indexInInventory && IsItemSlotEmpty(reservedItemInfo, __instance))
				{
					return;
				}
				grabbingReservedItemInfoDict[__instance] = null;
			}
			if (__result < unreservedHotbarSize)
			{
				return;
			}
			__result = -1;
			for (int i = 0; i < unreservedHotbarSize; i++)
			{
				if ((Object)(object)__instance.ItemSlots[i] == (Object)null)
				{
					__result = i;
					break;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "NextItemSlot")]
		[HarmonyPrefix]
		public static bool PreventScrollingOtherHotbar(ref int __result, bool forward, PlayerControllerB __instance)
		{
			__result = __instance.currentItemSlot;
			bool flag = __instance.currentItemSlot >= unreservedHotbarSize;
			int num = (forward ? 1 : (-1));
			if (!flag)
			{
				__result = Mathf.Clamp(__result, 0, unreservedHotbarSize - 1) + num;
				if (__result < 0)
				{
					__result = unreservedHotbarSize - 1;
				}
				else if (__result >= unreservedHotbarSize)
				{
					__result = 0;
				}
			}
			else
			{
				__result = Mathf.Clamp(__result, unreservedHotbarSize, combinedHotbarSize - 1) + num;
				if (__result < unreservedHotbarSize)
				{
					__result = combinedHotbarSize - 1;
				}
				else if (__result >= combinedHotbarSize)
				{
					__result = unreservedHotbarSize;
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPrefix]
		public static void RefocusReservedHotbarAfterAnimation(PlayerControllerB __instance)
		{
			if (!((Object)(object)__instance != (Object)(object)localPlayerController) && Keybinds.holdingModifierKey != isReservedHotbarFocused && CanSwapToReservedHotbarSlot())
			{
				SetFocusReservedHotbarSlots(Keybinds.holdingModifierKey);
			}
		}

		public static bool CanSwapToReservedHotbarSlot()
		{
			bool flag = (bool)Traverse.Create((object)localPlayerController).Field("throwingObject").GetValue();
			return !(localPlayerController.inTerminalMenu || localPlayerController.isPlayerDead || localPlayerController.isGrabbingObjectAnimation || localPlayerController.inSpecialInteractAnimation || flag) && !localPlayerController.isTypingChat && !localPlayerController.twoHanded && !localPlayerController.activatingItem;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "UpdateSpecialAnimationValue")]
		[HarmonyPostfix]
		public static void OnSpecialAnimationUpdate(bool specialAnimation, PlayerControllerB __instance, short yVal = 0, float timed = 0f, bool climbingLadder = false)
		{
			if (!((Object)(object)__instance != (Object)(object)localPlayerController))
			{
				if (specialAnimation && isReservedHotbarFocused)
				{
					SetFocusReservedHotbarSlots(active: false);
				}
				if (!specialAnimation && isReservedHotbarFocused != Keybinds.holdingModifierKey)
				{
					SetFocusReservedHotbarSlots(Keybinds.holdingModifierKey);
				}
			}
		}

		public static void SetFocusReservedHotbarSlots(bool active)
		{
			if (reservedHotbarSize <= 0 || isReservedHotbarFocused == active)
			{
				return;
			}
			Plugin.Log("SettingFocusReservedHotbar to: " + active);
			isReservedHotbarFocused = active;
			int num = localPlayerController.currentItemSlot;
			if (isReservedHotbarFocused && num < unreservedHotbarSize)
			{
				if (indexFocusedReservedHotbar == -1)
				{
					indexFocusedReservedHotbar = unreservedHotbarSize;
				}
				indexUnfocusedReservedHotbar = num;
				num = Mathf.Max(indexFocusedReservedHotbar, unreservedHotbarSize);
				if ((Object)(object)localPlayerController.ItemSlots[num] == (Object)null)
				{
					for (int i = 0; i < reservedHotbarSize; i++)
					{
						int num2 = unreservedHotbarSize + i;
						if ((Object)(object)localPlayerController.ItemSlots[num2] != (Object)null)
						{
							num = num2;
							break;
						}
					}
				}
			}
			else if (!isReservedHotbarFocused && num >= unreservedHotbarSize)
			{
				indexFocusedReservedHotbar = num;
				num = Mathf.Min(indexUnfocusedReservedHotbar, unreservedHotbarSize - 1);
			}
			HotbarSlotSync.SwapHotbarSlot(num);
		}

		public static bool IsItemSlotEmpty(string itemName, PlayerControllerB player = null)
		{
			return IsItemSlotEmpty(Plugin.GetReservedItemInfo(itemName), player);
		}

		public static bool IsItemSlotEmpty(ReservedItemInfo itemInfo, PlayerControllerB player = null)
		{
			if ((Object)(object)player == (Object)null)
			{
				player = localPlayerController;
			}
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			return itemInfo != null && itemInfo.indexInInventory < player.ItemSlots.Length && (Object)(object)player.ItemSlots[itemInfo.indexInInventory] == (Object)null;
		}

		public static GrabbableObject GetHeldReservedObject(string itemName, PlayerControllerB player = null)
		{
			if ((Object)(object)player == (Object)null)
			{
				player = localPlayerController;
			}
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			int reservedItemHotbarIndex = Plugin.GetReservedItemHotbarIndex(itemName);
			return (reservedItemHotbarIndex >= 0 && reservedItemHotbarIndex < player.ItemSlots.Length && (Object)(object)player.ItemSlots[reservedItemHotbarIndex] != (Object)null) ? player.ItemSlots[reservedItemHotbarIndex] : null;
		}

		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		[HarmonyPostfix]
		public static void InitializeReservedItemProperties(GrabbableObject __instance)
		{
			ReservedItemInfo reservedItemInfo = Plugin.GetReservedItemInfo(__instance.itemProperties.itemName);
			if (reservedItemInfo != null)
			{
				if (reservedItemInfo.forceUpdateCanBeGrabbedBeforeGameStart)
				{
					__instance.itemProperties.canBeGrabbedBeforeGameStart = reservedItemInfo.canBeGrabbedBeforeGameStart;
				}
				if (reservedItemInfo.forceUpdateRequiresBattery)
				{
					__instance.itemProperties.requiresBattery = reservedItemInfo.requiresBattery;
				}
			}
		}
	}
	[HarmonyPatch]
	public static class PlayerPatcher
	{
		public static PlayerControllerB localPlayerController;

		public static int vanillaHotbarSize = -1;

		public static int INTERACTABLE_OBJECT_MASK { get; private set; }

		public static int unreservedHotbarSize => ((Object)(object)localPlayerController != (Object)null) ? (localPlayerController.ItemSlots.Length - reservedHotbarSize) : vanillaHotbarSize;

		public static int reservedHotbarSize => Plugin.numReservedItemSlots;

		public static int combinedHotbarSize => unreservedHotbarSize + reservedHotbarSize;

		[HarmonyPatch(typeof(MenuManager), "OnEnable")]
		[HarmonyPrefix]
		public static void ResetVariables(MenuManager __instance)
		{
			localPlayerController = null;
			vanillaHotbarSize = -1;
			ReservedItemPatcher.isReservedHotbarFocused = false;
			ReservedItemPatcher.indexUnfocusedReservedHotbar = 0;
			ReservedItemPatcher.indexFocusedReservedHotbar = -1;
			Keybinds.localPlayerController = null;
			Keybinds.focusReservedHotbarAction = null;
			Keybinds.holdingModifierKey = false;
			HotbarSlotSync.localPlayerController = null;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Awake")]
		[HarmonyPostfix]
		public static void InitializePlayerController(PlayerControllerB __instance)
		{
			if (vanillaHotbarSize == -1)
			{
				vanillaHotbarSize = __instance.ItemSlots.Length;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPostfix]
		public static void InitializePlayerControllerLate(PlayerControllerB __instance)
		{
			__instance.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[__instance.ItemSlots.Length + reservedHotbarSize];
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPrefix]
		public static void OnLocalPlayerConnect(PlayerControllerB __instance)
		{
			localPlayerController = __instance;
			INTERACTABLE_OBJECT_MASK = (int)Traverse.Create((object)__instance).Field("interactableObjectsMask").GetValue();
		}
	}
}

plugins/FlipMods-ReservedWalkieSlot/ReservedWalkieSlot.dll

Decompiled 2 years ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using ReservedItemSlotCore;
using ReservedItemSlotCore.Patches;
using ReservedWalkieSlot.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ReservedWalkieSlot")]
[assembly: AssemblyDescription("Mod made by flipf17")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReservedWalkieSlot")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c15c320f-d8fc-4f1c-be3c-f2d2ffc41edd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ReservedWalkieSlot
{
	public static class ConfigSettings
	{
		public static ConfigEntry<string> activateWalkieKey;

		public static string activateWalkieDisplayName;

		public static void BindConfigSettings()
		{
			Plugin.Log("BindingConfigs");
			activateWalkieKey = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("ReservedWalkieSlot", "ActivateWalkieKey", "<Keyboard>/x", "Activate walkie keybind.");
			activateWalkieDisplayName = GetDisplayName(activateWalkieKey.Value);
		}

		public static string GetDisplayName(string key)
		{
			key = key.Replace("<Keyboard>/", "");
			key = key.Replace("<Mouse>/", "");
			string text = key;
			text = text.Replace("leftAlt", "Alt");
			text = text.Replace("rightAlt", "Alt");
			text = text.Replace("leftCtrl", "Ctrl");
			text = text.Replace("rightCtrl", "Ctrl");
			text = text.Replace("leftShift", "Shift");
			text = text.Replace("rightShift", "Shift");
			text = text.Replace("leftButton", "LMB");
			text = text.Replace("rightButton", "RMB");
			return text.Replace("middleButton", "MMB");
		}
	}
	[HarmonyPatch]
	internal static class Keybinds
	{
		public static PlayerControllerB localPlayerController;

		private static InputAction activateWalkieAction;

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void OnLocalPlayerConnect(PlayerControllerB __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			localPlayerController = __instance;
			activateWalkieAction = new InputAction((string)null, (InputActionType)0, ConfigSettings.activateWalkieKey.Value, (string)null, (string)null, (string)null);
			if (((Component)localPlayerController).gameObject.activeSelf)
			{
				SubscribeToEvents();
			}
		}

		private static void SubscribeToEvents()
		{
			if (activateWalkieAction != null)
			{
				activateWalkieAction.performed += OnPressWalkieButtonPerformed;
				activateWalkieAction.canceled += OnReleaseWalkieButtonPerformed;
				activateWalkieAction.Enable();
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "OnEnable")]
		[HarmonyPostfix]
		public static void OnEnable(PlayerControllerB __instance)
		{
			if ((Object)(object)__instance == (Object)(object)localPlayerController)
			{
				SubscribeToEvents();
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "OnDisable")]
		[HarmonyPostfix]
		public static void OnDisable(PlayerControllerB __instance)
		{
			if (activateWalkieAction != null && !((Object)(object)__instance != (Object)(object)localPlayerController))
			{
				activateWalkieAction.performed -= OnPressWalkieButtonPerformed;
				activateWalkieAction.canceled -= OnReleaseWalkieButtonPerformed;
				activateWalkieAction.Disable();
			}
		}

		private static void OnPressWalkieButtonPerformed(CallbackContext context)
		{
			if ((Object)(object)localPlayerController == (Object)null || !localPlayerController.isPlayerControlled || (((NetworkBehaviour)localPlayerController).IsServer && !localPlayerController.isHostPlayerObject))
			{
				return;
			}
			WalkieTalkie mainWalkie = ReservedWalkieSlotPatcher.GetMainWalkie(localPlayerController);
			if (((CallbackContext)(ref context)).performed && !((Object)(object)mainWalkie == (Object)null) && ((GrabbableObject)mainWalkie).isBeingUsed)
			{
				float num = (float)Traverse.Create((object)localPlayerController).Field("timeSinceSwitchingSlots").GetValue();
				if (!(num < 0.075f))
				{
					Plugin.Log("Talking into walkie");
					ShipBuildModeManager.Instance.CancelBuildMode(true);
					((GrabbableObject)mainWalkie).UseItemOnClient(true);
					Traverse.Create((object)localPlayerController).Field("timeSinceSwitchingSlots").SetValue((object)0);
				}
			}
		}

		private static void OnReleaseWalkieButtonPerformed(CallbackContext context)
		{
			if (!((Object)(object)localPlayerController == (Object)null) && localPlayerController.isPlayerControlled && (!((NetworkBehaviour)localPlayerController).IsServer || localPlayerController.isHostPlayerObject))
			{
				WalkieTalkie mainWalkie = ReservedWalkieSlotPatcher.GetMainWalkie(localPlayerController);
				if (((CallbackContext)(ref context)).canceled && !((Object)(object)mainWalkie == (Object)null))
				{
					Plugin.Log("Not talking into walkie");
					ShipBuildModeManager.Instance.CancelBuildMode(true);
					((GrabbableObject)mainWalkie).UseItemOnClient(false);
				}
			}
		}
	}
	[BepInPlugin("FlipMods.ReservedWalkieSlot", "ReservedWalkieSlot", "1.4.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance;

		private Harmony _harmony;

		public static ReservedItemInfo walkieInfo = new ReservedItemInfo("Walkie-talkie", 100, true, true, true, true);

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			instance = this;
			ConfigSettings.BindConfigSettings();
			_harmony = new Harmony("ReservedWalkieSlot");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ReservedWalkieSlot loaded");
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.ReservedWalkieSlot";

		public const string PLUGIN_NAME = "ReservedWalkieSlot";

		public const string PLUGIN_VERSION = "1.4.6";
	}
}
namespace ReservedWalkieSlot.Patches
{
	[HarmonyPatch]
	internal static class ReservedWalkieSlotPatcher
	{
		private static Vector3 localPlayerShoulderPositionOffset = new Vector3(0.125f, 0.4f, 0.125f);

		private static Vector3 playerShoulderPositionOffset = new Vector3(0.15f, -0.05f, 0.25f);

		private static Vector3 playerShoulderRotationOffset = new Vector3(0f, 270f, 100f);

		private static string originalControlTooltip = "";

		public static PlayerControllerB localPlayerController => PlayerPatcher.localPlayerController;

		public static WalkieTalkie GetMainWalkie(PlayerControllerB playerController)
		{
			return GetCurrentlySelectedWalkie(playerController) ?? GetReservedWalkie(playerController);
		}

		public static WalkieTalkie GetReservedWalkie(PlayerControllerB playerController)
		{
			GrabbableObject obj = ((playerController != null) ? playerController.ItemSlots[Plugin.walkieInfo.indexInInventory] : null);
			return (WalkieTalkie)(object)((obj is WalkieTalkie) ? obj : null);
		}

		public static WalkieTalkie GetCurrentlySelectedWalkie(PlayerControllerB playerController)
		{
			GrabbableObject obj = ((playerController != null) ? playerController.ItemSlots[playerController.currentItemSlot] : null);
			return (WalkieTalkie)(object)((obj is WalkieTalkie) ? obj : null);
		}

		[HarmonyPatch(typeof(WalkieTalkie), "__initializeVariables")]
		[HarmonyPostfix]
		public static void EditTooltips(WalkieTalkie __instance)
		{
			if (originalControlTooltip == "")
			{
				originalControlTooltip = ((GrabbableObject)__instance).itemProperties.toolTips[((GrabbableObject)__instance).itemProperties.toolTips.Length - 1];
			}
			((GrabbableObject)__instance).itemProperties.toolTips[((GrabbableObject)__instance).itemProperties.toolTips.Length - 1] = $"{originalControlTooltip}[{ConfigSettings.activateWalkieDisplayName.ToUpper()}]";
		}

		[HarmonyPatch(typeof(MenuManager), "OnEnable")]
		[HarmonyPostfix]
		public static void ResetVariables()
		{
			Keybinds.localPlayerController = null;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ActivateItem_performed")]
		[HarmonyPrefix]
		public static bool PreventActivatingDuplicateItem(CallbackContext context, PlayerControllerB __instance)
		{
			WalkieTalkie currentlySelectedWalkie = GetCurrentlySelectedWalkie(__instance);
			if ((Object)(object)__instance != (Object)(object)localPlayerController || (Object)(object)currentlySelectedWalkie == (Object)null)
			{
				return true;
			}
			if (!((CallbackContext)(ref context)).performed)
			{
				return false;
			}
			WalkieTalkie reservedWalkie = GetReservedWalkie(__instance);
			if ((Object)(object)currentlySelectedWalkie != (Object)(object)reservedWalkie && (!((GrabbableObject)reservedWalkie).itemProperties.requiresBattery || !((GrabbableObject)reservedWalkie).insertedBattery.empty))
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(WalkieTalkie), "PocketItem")]
		[HarmonyPostfix]
		public static void OnPocketWalkie(WalkieTalkie __instance)
		{
			if (!((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null))
			{
				((GrabbableObject)__instance).parentObject = ((Component)((GrabbableObject)__instance).playerHeldBy.playerBadgeMesh).transform.parent;
			}
		}

		[HarmonyPatch(typeof(WalkieTalkie), "EquipItem")]
		[HarmonyPostfix]
		public static void OnEquipWalkie(WalkieTalkie __instance)
		{
			if (!((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null))
			{
				((GrabbableObject)__instance).parentObject = (((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)localPlayerController) ? ((GrabbableObject)__instance).playerHeldBy.localItemHolder : ((GrabbableObject)__instance).playerHeldBy.serverItemHolder);
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "LateUpdate")]
		[HarmonyPostfix]
		public static void SetPositionOffset(GrabbableObject __instance)
		{
			//IL_006c: 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_0076: 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)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			if (__instance is WalkieTalkie && (Object)(object)__instance.playerHeldBy != (Object)null && __instance.isPocketed && (Object)(object)__instance.parentObject != (Object)null && (Object)(object)__instance != (Object)(object)GetCurrentlySelectedWalkie(__instance.playerHeldBy))
			{
				Transform transform = ((Component)__instance.parentObject).transform;
				((Component)__instance).transform.rotation = ((Component)__instance.parentObject).transform.rotation * Quaternion.Euler(playerShoulderRotationOffset);
				((Component)__instance).transform.position = transform.position + transform.rotation * playerShoulderPositionOffset;
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "EnableItemMeshes")]
		[HarmonyPrefix]
		public static void OnEnableItemMeshes(ref bool enable, GrabbableObject __instance)
		{
			if (__instance is WalkieTalkie && (Object)(object)__instance.playerHeldBy != (Object)null && ((Object)(object)__instance == (Object)(object)GetCurrentlySelectedWalkie(__instance.playerHeldBy) || ((Object)(object)__instance == (Object)(object)GetReservedWalkie(__instance.playerHeldBy) && (Object)(object)__instance.playerHeldBy != (Object)(object)localPlayerController)))
			{
				enable = true;
			}
		}
	}
}

plugins/Nips-Brutal_Company_Plus/BrutalCompanyPlus.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BrutalCompanyPlus.BCP;
using BrutalCompanyPlus.HarmPatches;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ExampleAssembly")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Biney")]
[assembly: AssemblyProduct("ExampleAssembly")]
[assembly: AssemblyCopyright("Copyright © Biney")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("251a7ff8-4d39-4f8b-9838-61124bf62f99")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BrutalCompanyPlus
{
	[BepInPlugin("BrutalCompanyPlus", "BrutalCompanyPlus", "3.3.1")]
	public class Plugin : BaseUnityPlugin
	{
		public static Dictionary<EventEnum, ConfigEntry<int>> eventWeightEntries = new Dictionary<EventEnum, ConfigEntry<int>>();

		private bool brutalPlusInitialized;

		public static List<string> correctEnemyNames = new List<string>
		{
			"Centipede", "Bunker Spider", "Hoarding bug", "Flowerman", "Crawler", "Blob", "Girl", "Puffer", "Nutcracker", "Spring",
			"Jester", "Masked", "LassoMan"
		};

		private string configFilePath = Path.Combine(Paths.ConfigPath, "BrutalCompanyPlus.cfg");

		public static ConfigEntry<float> FactoryStartOfDaySpawnChance { get; private set; }

		public static ConfigEntry<float> FactoryMidDaySpawnChance { get; private set; }

		public static ConfigEntry<float> FactoryEndOfDaySpawnChance { get; private set; }

		public static ConfigEntry<float> OutsideStartOfDaySpawnChance { get; private set; }

		public static ConfigEntry<float> OutsideMidDaySpawnChance { get; private set; }

		public static ConfigEntry<float> OutsideEndOfDaySpawnChance { get; private set; }

		public static ConfigEntry<float> MoonHeatDecreaseRate { get; private set; }

		public static ConfigEntry<float> MoonHeatIncreaseRate { get; private set; }

		public static ConfigEntry<bool> EnableTurretModifications { get; private set; }

		public static ConfigEntry<bool> EnableLandmineModifications { get; private set; }

		public static ConfigEntry<float> TurretSpawnRate { get; private set; }

		public static ConfigEntry<float> LandmineSpawnRate { get; private set; }

		public static ConfigEntry<string> ExperimentationLevelRarities { get; private set; }

		public static ConfigEntry<string> AssuranceLevelRarities { get; private set; }

		public static ConfigEntry<string> VowLevelRarities { get; private set; }

		public static ConfigEntry<string> MarchLevelRarities { get; private set; }

		public static ConfigEntry<string> RendLevelRarities { get; private set; }

		public static ConfigEntry<string> DineLevelRarities { get; private set; }

		public static ConfigEntry<string> OffenseLevelRarities { get; private set; }

		public static ConfigEntry<string> TitanLevelRarities { get; private set; }

		public static ConfigEntry<bool> EnableFreeMoney { get; private set; }

		public static ConfigEntry<int> FreeMoneyValue { get; private set; }

		public static ConfigEntry<bool> EnableAllEnemy { get; private set; }

		public static ConfigEntry<int> DeadlineDaysAmount { get; private set; }

		public static ConfigEntry<int> StartingCredits { get; private set; }

		public static ConfigEntry<int> StartingQuota { get; private set; }

		public static ConfigEntry<float> BaseIncrease { get; private set; }

		public static ConfigEntry<int> MinScrap { get; private set; }

		public static ConfigEntry<int> MaxScrap { get; private set; }

		public static ConfigEntry<int> MinTotalScrapValue { get; private set; }

		public static ConfigEntry<int> MaxTotalScrapValue { get; private set; }

		private void Awake()
		{
			InitializeVariables();
			SetupPatches();
			InitializeBCP_ConfigSettings();
			InitializeDefaultEnemyRarities();
			UpdateConfigurations();
			RemoveConfigSection(configFilePath, "EventEnabledConfig");
		}

		private void Start()
		{
			if (!brutalPlusInitialized)
			{
				CreateBrutalPlusGameObject();
				brutalPlusInitialized = true;
			}
		}

		private void OnDestroy()
		{
			if (!brutalPlusInitialized)
			{
				CreateBrutalPlusGameObject();
				brutalPlusInitialized = true;
			}
		}

		public static void UpdateConfigurations()
		{
			foreach (ConfigEntry<string> item in new List<ConfigEntry<string>> { ExperimentationLevelRarities, AssuranceLevelRarities, VowLevelRarities, MarchLevelRarities, RendLevelRarities, DineLevelRarities, OffenseLevelRarities, TitanLevelRarities })
			{
				Dictionary<string, string> dictionary = ParseConfigRarities(item.Value);
				List<string> list = new List<string>();
				foreach (string correctEnemyName in correctEnemyNames)
				{
					string value;
					string text = (dictionary.TryGetValue(correctEnemyName, out value) ? value : "-1");
					list.Add(correctEnemyName + ":" + text);
				}
				string text2 = string.Join(",", list);
				if (item.Value != text2)
				{
					item.Value = text2;
					BcpLogger.Log("Updated configuration for " + ((ConfigEntryBase)item).Definition.Section + ", " + ((ConfigEntryBase)item).Definition.Key + ": " + text2);
				}
			}
		}

		private static Dictionary<string, string> ParseConfigRarities(string configValue)
		{
			return (from part in configValue.Split(new char[1] { ',' })
				select part.Split(new char[1] { ':' }) into parts
				where parts.Length == 2
				select parts).ToDictionary((string[] parts) => parts[0].Trim(), (string[] parts) => parts[1].Trim());
		}

		public void RemoveConfigSection(string filePath, string sectionName)
		{
			try
			{
				List<string> list = File.ReadAllLines(filePath).ToList();
				List<string> list2 = new List<string>();
				bool flag = false;
				foreach (string item in list)
				{
					if (item.Trim().Equals("[" + sectionName + "]"))
					{
						flag = true;
						continue;
					}
					if (flag && item.StartsWith("["))
					{
						flag = false;
					}
					if (!flag)
					{
						list2.Add(item);
					}
				}
				File.WriteAllLines(filePath, list2);
			}
			catch (Exception ex)
			{
				BcpLogger.Log("Error occurred: " + ex.Message);
			}
		}

		public static void InitializeDefaultEnemyRarities()
		{
			Dictionary<string, int> value = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 25 },
				{ "Hoarding bug", 30 },
				{ "Flowerman", 30 },
				{ "Crawler", 20 },
				{ "Blob", 25 },
				{ "Girl", 2 },
				{ "Puffer", 40 },
				{ "Nutcracker", 25 },
				{ "Spring", 25 },
				{ "Jester", 3 },
				{ "Masked", 5 },
				{ "LassoMan", 1 }
			};
			Variables.DefaultEnemyRarities["ExperimentationLevel"] = value;
			Dictionary<string, int> value2 = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 40 },
				{ "Hoarding bug", 50 },
				{ "Flowerman", 30 },
				{ "Crawler", 20 },
				{ "Blob", 25 },
				{ "Girl", 2 },
				{ "Puffer", 40 },
				{ "Nutcracker", 25 },
				{ "Spring", 25 },
				{ "Jester", 3 },
				{ "Masked", 10 },
				{ "LassoMan", 1 }
			};
			Variables.DefaultEnemyRarities["AssuranceLevel"] = value2;
			Dictionary<string, int> value3 = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 40 },
				{ "Hoarding bug", 50 },
				{ "Flowerman", 30 },
				{ "Crawler", 20 },
				{ "Blob", 25 },
				{ "Girl", 10 },
				{ "Puffer", 40 },
				{ "Nutcracker", 25 },
				{ "Spring", 40 },
				{ "Jester", 15 },
				{ "Masked", 20 },
				{ "LassoMan", 0 }
			};
			Variables.DefaultEnemyRarities["VowLevel"] = value3;
			Dictionary<string, int> value4 = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 40 },
				{ "Hoarding bug", 50 },
				{ "Flowerman", 30 },
				{ "Crawler", 20 },
				{ "Blob", 25 },
				{ "Girl", 10 },
				{ "Puffer", 40 },
				{ "Nutcracker", 25 },
				{ "Spring", 40 },
				{ "Jester", 15 },
				{ "Masked", 20 },
				{ "LassoMan", 0 }
			};
			Variables.DefaultEnemyRarities["OffenseLevel"] = value4;
			Dictionary<string, int> value5 = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 40 },
				{ "Hoarding bug", 50 },
				{ "Flowerman", 30 },
				{ "Crawler", 20 },
				{ "Blob", 25 },
				{ "Girl", 10 },
				{ "Puffer", 40 },
				{ "Nutcracker", 25 },
				{ "Spring", 40 },
				{ "Jester", 15 },
				{ "Masked", 20 },
				{ "LassoMan", 0 }
			};
			Variables.DefaultEnemyRarities["MarchLevel"] = value5;
			Dictionary<string, int> value6 = new Dictionary<string, int>
			{
				{ "Centipede", 35 },
				{ "Bunker Spider", 25 },
				{ "Hoarding bug", 30 },
				{ "Flowerman", 56 },
				{ "Crawler", 60 },
				{ "Blob", 40 },
				{ "Girl", 50 },
				{ "Puffer", 40 },
				{ "Nutcracker", 60 },
				{ "Spring", 58 },
				{ "Jester", 57 },
				{ "Masked", 50 },
				{ "LassoMan", 2 }
			};
			Variables.DefaultEnemyRarities["RendLevel"] = value6;
			Dictionary<string, int> value7 = new Dictionary<string, int>
			{
				{ "Centipede", 35 },
				{ "Bunker Spider", 25 },
				{ "Hoarding bug", 30 },
				{ "Flowerman", 56 },
				{ "Crawler", 60 },
				{ "Blob", 40 },
				{ "Girl", 50 },
				{ "Puffer", 40 },
				{ "Nutcracker", 60 },
				{ "Spring", 58 },
				{ "Jester", 57 },
				{ "Masked", 50 },
				{ "LassoMan", 2 }
			};
			Variables.DefaultEnemyRarities["DineLevel"] = value7;
			Dictionary<string, int> value8 = new Dictionary<string, int>
			{
				{ "Centipede", 35 },
				{ "Bunker Spider", 25 },
				{ "Hoarding bug", 30 },
				{ "Flowerman", 56 },
				{ "Crawler", 60 },
				{ "Blob", 40 },
				{ "Girl", 50 },
				{ "Puffer", 40 },
				{ "Nutcracker", 60 },
				{ "Spring", 58 },
				{ "Jester", 57 },
				{ "Masked", 50 },
				{ "LassoMan", 2 }
			};
			Variables.DefaultEnemyRarities["TitanLevel"] = value8;
		}

		public void InitializeBCP_ConfigSettings()
		{
			FactoryStartOfDaySpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("EnemySpawnSettings.Factory", "StartOfDaySpawnChance", -1f, "Factory enemy spawn chance at the start of the day. Set to -1 to use Brutals default value. (vanilla is around 2-5 depending on moon)");
			FactoryMidDaySpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("EnemySpawnSettings.Factory", "MidDaySpawnChance", -1f, "Factory enemy spawn chance at midday. Set to -1 to use Brutals default value. (vanilla is around 5-10 depending on moon)");
			FactoryEndOfDaySpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("EnemySpawnSettings.Factory", "EndOfDaySpawnChance", -1f, "Factory enemy spawn chance at the end of the day. Set to -1 to use Brutals default value. (vanilla is around 10-15 depending on moon)");
			OutsideStartOfDaySpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("EnemySpawnSettings.Outside", "StartOfDaySpawnChance", -1f, "Outside enemy spawn chance at the start of the day. Set to -1 to use default value. (vanilla is 0)");
			OutsideMidDaySpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("EnemySpawnSettings.Outside", "MidDaySpawnChance", -1f, "Outside enemy spawn chance at midday. Set to -1 to use default value. (vanilla is 0.5)");
			OutsideEndOfDaySpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("EnemySpawnSettings.Outside", "EndOfDaySpawnChance", -1f, "Outside enemy spawn chance at the end of the day. Set to -1 to use default value. (vanilla is 5)");
			MoonHeatDecreaseRate = ((BaseUnityPlugin)this).Config.Bind<float>("MoonHeatSettings", "MoonHeatDecreaseRate", 10f, "Amount by which moon heat decreases when not visiting the planet");
			MoonHeatIncreaseRate = ((BaseUnityPlugin)this).Config.Bind<float>("MoonHeatSettings", "MoonHeatIncreaseRate", 20f, "Amount by which moon heat increases when landing back on the same planet");
			EnableTurretModifications = ((BaseUnityPlugin)this).Config.Bind<bool>("MapObjectModificationSettings", "EnableTurretModifications", true, "Enable modifications to turret spawn rates on every moon, False would default to game logic");
			TurretSpawnRate = ((BaseUnityPlugin)this).Config.Bind<float>("MapObjectModificationSettings", "TurretSpawnRate", 8f, "Default spawn amount for turrets on every moon");
			EnableLandmineModifications = ((BaseUnityPlugin)this).Config.Bind<bool>("MapObjectModificationSettings", "EnableLandmineModifications", true, "Enable modifications to landmine spawn rates on every moon, False would default to game logic");
			LandmineSpawnRate = ((BaseUnityPlugin)this).Config.Bind<float>("MapObjectModificationSettings", "LandmineSpawnRate", 30f, "Default spawn amount for landmines on every moon");
			ExperimentationLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Experimentation", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Experimentation (0 = no spawn, 100 = max chance, -1 = default Brutals rarity)");
			AssuranceLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Assurance", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Assurance (0 = no spawn, 100 = max chance, -1 = default Brutals rarity)");
			VowLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Vow", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Vow (0 = no spawn, 100 = max chance, -1 = default Brutals rarity)");
			MarchLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "March", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for March (0 = no spawn, 100 = max chance, -1 = default Brutals rarity)");
			RendLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Rend", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Rend (0 = no spawn, 100 = max chance, -1 = default Brutals rarity)");
			DineLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Dine", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Dine (0 = no spawn, 100 = max chance, -1 = default Brutals rarity)");
			OffenseLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Offense", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Offense (0 = no spawn, 100 = max chance, -1 = default Brutals rarity)");
			TitanLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Titan", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Titan (0 = no spawn, 100 = max chance, -1 = default Brutals rarity)");
			EnableFreeMoney = ((BaseUnityPlugin)this).Config.Bind<bool>("EventOptions", "EnableFreeMoney", true, "This will give free money everytime survive and escape the planet");
			FreeMoneyValue = ((BaseUnityPlugin)this).Config.Bind<int>("EventOptions", "FreeMoneyValue", 150, "This will control the amount of money you get when EnableFreeMoney is true");
			EnableAllEnemy = ((BaseUnityPlugin)this).Config.Bind<bool>("EnemySettings", "EnableAllEnemy", true, "This will add every enemy type to each moon as a spawn chance");
			DeadlineDaysAmount = ((BaseUnityPlugin)this).Config.Bind<int>("QuotaSettings", "DeadlineDaysAmount", 4, "Days available before deadline");
			StartingCredits = ((BaseUnityPlugin)this).Config.Bind<int>("QuotaSettings", "StartingCredits", 200, "Credits at the start of a new session");
			StartingQuota = ((BaseUnityPlugin)this).Config.Bind<int>("QuotaSettings", "StartingQuota", 400, "Starting quota amount in a new session");
			BaseIncrease = ((BaseUnityPlugin)this).Config.Bind<float>("QuotaSettings", "BaseIncrease", 275f, "Quota increase after meeting the previous quota");
			MinScrap = ((BaseUnityPlugin)this).Config.Bind<int>("ScrapSettings", "MinScrap", 6, "Minimum scraps that can spawn on each moon");
			MaxScrap = ((BaseUnityPlugin)this).Config.Bind<int>("ScrapSettings", "MaxScrap", 30, "Maximum scraps that can spawn on each moon");
			MinTotalScrapValue = ((BaseUnityPlugin)this).Config.Bind<int>("ScrapSettings", "MinTotalScrapValue", 400, "Minimum total scrap value on the moon");
			MaxTotalScrapValue = ((BaseUnityPlugin)this).Config.Bind<int>("ScrapSettings", "MaxTotalScrapValue", 3000, "Maximum total scrap value on the moon");
			eventWeightEntries[EventEnum.None] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "None", 100, "[Nothing Happened Today] Nothing special will happen (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Turret] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Turret", 100, "[Turret Terror] This will spawn turrets all over the place inside the factory (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Delivery] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Delivery", 100, "[ICE SCREAM] This will order between 3 - 9 random items from the shop (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.BlobEvolution] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "BlobEvolution", 100, "[They have EVOLVED] This will spawn only Blobs and they can open doors and move much faster (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Chaos] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Chaos", 100, "[CHAOS COMPANY] This will increase the spawn rates of enemyies inside the factory at a significant rate (Set Chance between 0 -100)");
			eventWeightEntries[EventEnum.SurfaceExplosion] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "SurfaceExplosion", 100, "[The Surface is explosive] Mines wills spawn at the feet of players not in the ship or factory, they also have a delayed fuse (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.FaceHuggers] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "FaceHuggers", 100, "[Internecivus Raptus?] This will ONLY spawn MANY Centipedes into the factory (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.TheRumbling] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "TheRumbling", 100, "[The Rumbling] This will spawn MANY Forest Giants when the ship has fully landed (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.TheyWant2Play] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "TheyWant2Play", 100, "[The just want to play] This will spawn several Ghost girls into the level (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.BeastInside] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "BeastInside", 100, "[The Beasts Inside] This will spawn ONLY Eyeless Dogs into the Factory, spawn rate changes depending on moon (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Unfair] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Unfair", 100, "[This is just unfair] This will spawn several outside enemies and inside enemies at a significant rate (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.BadPlanet] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "BadPlanet", 100, "[This planet is NOT safe] This will trigger several events, SurfaceExplosion, InstaJester, BlobEvolution, ShipTurret, Unfair (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.InstaJester] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "InstaJester", 100, "[Pop goes the... HOLY FUC-] This will spawn several jesters that have a short crank timer between 0 - 10 seconds instead of 30 - 45 seconds (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.InsideOut] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "InsideOut", 100, "[Inside Out!] This will spawn 4 Coil heads outside, they will instantly roam around the ship (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Landmine] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Landmine", 100, "[Minescape Terror] This will spawn MANY landmines inside the factory (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Sacrifice] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Sacrifice", 100, "[The Hunger Games?] This will rotate through players at a given rate, when the selected player steps inside the factory.. They get choosen for death. (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.ShipTurret] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "ShipTurret", 100, "[When did we get this installed?!?] This will spawn a turret inside the ship facing the controls (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.HoardTown] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "HoardTown", 100, "[Hoarder Town] This will ONLY spawn MANY Hoarder Bugs inside the factory (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.TheyAreShy] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "TheyAreShy", 100, "[They are shy!] This will ONLY spawn several Spring Heads and Brackens inside the factory (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.ResetHeat] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "ResetHeat", 100, "[All Moons Heat Reset] This will reset the moon heat for all moons (Set Chance between 0 - 100)");
		}

		private void InitializeVariables()
		{
			Variables.mls = Logger.CreateLogSource("BrutalCompanyPlus");
			Variables.mls.LogWarning((object)"Loaded Brutal Company Plus and applying patches.");
			Variables.mls = ((BaseUnityPlugin)this).Logger;
			Variables.levelHeatVal = new Dictionary<SelectableLevel, float>();
			Variables.enemyRaritys = new Dictionary<SpawnableEnemyWithRarity, int>();
			Variables.levelEnemySpawns = new Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>>();
			Variables.enemyPropCurves = new Dictionary<SpawnableEnemyWithRarity, AnimationCurve>();
		}

		private void SetupPatches()
		{
			Variables._harmony.PatchAll(typeof(LevelEventsPatches));
			Variables._harmony.PatchAll(typeof(QuotaPatches));
			Variables._harmony.PatchAll(typeof(EnemyAIPatches));
		}

		private void CreateBrutalPlusGameObject()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0031: Expected O, but got Unknown
			try
			{
				Variables.mls.LogInfo((object)"Attempting to Initialize BrutalPlus");
				GameObject val = new GameObject("BrutalPlus");
				val.SetActive(true);
				((Behaviour)val.AddComponent<BrutalPlus>()).enabled = true;
				Object.DontDestroyOnLoad((Object)val);
				Variables.loaded = true;
			}
			catch (Exception ex)
			{
				Variables.mls.LogInfo((object)("Exception in CreateBrutalPlusGameObject: " + ex.Message));
				BcpLogger.Log("Exception in CreateBrutalPlusGameObject: " + ex.Message);
			}
		}

		public static void CleanupAndResetAI()
		{
			Functions.CleanUpAllVariables();
			BrutalPlus.CleanupAllSpawns();
		}

		public static void UpdateAIInNewLevel(SelectableLevel newLevel)
		{
			foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
			{
				GameObject enemyPrefab = enemy.enemyType.enemyPrefab;
				foreach (Type item in Variables.aiPresence.Keys.ToList())
				{
					if ((Object)(object)enemyPrefab.GetComponent(item) != (Object)null)
					{
						Variables.aiPresence[item] = true;
					}
				}
			}
		}

		public static void AddMissingAIToNewLevel(SelectableLevel newLevel)
		{
			if (!EnableAllEnemy.Value)
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			for (int i = 0; i < levels.Length; i++)
			{
				foreach (SpawnableEnemyWithRarity enemy in levels[i].Enemies)
				{
					GameObject enemyPrefab = enemy.enemyType.enemyPrefab;
					foreach (Type item in Variables.aiPresence.Keys.ToList())
					{
						if ((Object)(object)enemyPrefab.GetComponent(item) != (Object)null && !Variables.aiPresence[item])
						{
							Variables.aiPresence[item] = true;
							newLevel.Enemies.Add(enemy);
							Variables.mls.LogWarning((object)("\n\nAdded Enemy: > " + ((Object)enemy.enemyType.enemyPrefab).name + " < to the Enemy list\n\n"));
						}
					}
				}
			}
		}

		public static EventEnum SelectRandomEvent()
		{
			var list = (from kvp in eventWeightEntries
				where kvp.Value.Value > 0
				select new
				{
					Event = kvp.Key,
					Weight = kvp.Value.Value
				}).ToList();
			if (list.Count > 1)
			{
				list = list.Where(e => e.Event != Variables.lastEvent).ToList();
			}
			if (list.Count == 0)
			{
				return EventEnum.None;
			}
			int num = list.Sum(e => e.Weight);
			int num2 = Random.Range(0, num);
			int num3 = 0;
			foreach (var item in list)
			{
				num3 += item.Weight;
				if (num2 <= num3)
				{
					Variables.lastEvent = item.Event;
					return item.Event;
				}
			}
			return EventEnum.None;
		}

		public static void ApplyCustomLevelEnemyRarities(List<SpawnableEnemyWithRarity> enemies, string levelName)
		{
			try
			{
				BcpLogger.Log("Applying custom rarities for level: " + levelName);
				ConfigEntry<string> configForLevel = GetConfigForLevel(levelName);
				BcpLogger.Log("Config for level " + levelName + ": " + configForLevel?.Value);
				if (configForLevel == null || string.IsNullOrWhiteSpace(configForLevel.Value))
				{
					BcpLogger.Log("No custom config found or config is empty for level " + levelName + ". Using default rarities.");
					return;
				}
				Dictionary<string, int> dictionary = (from r in configForLevel.Value.Split(new char[1] { ',' })
					select r.Split(new char[1] { ':' }) into r
					where r.Length == 2
					select r).ToDictionary((string[] r) => r[0].Trim(), (string[] r) => int.Parse(r[1]));
				if (!Variables.DefaultEnemyRarities.TryGetValue(levelName, out var value))
				{
					BcpLogger.Log("No default rarities found for level " + levelName);
					return;
				}
				foreach (SpawnableEnemyWithRarity enemy in enemies)
				{
					int value4;
					if (dictionary.TryGetValue(enemy.enemyType.enemyName, out var value2))
					{
						int value3;
						if (value2 != -1)
						{
							BcpLogger.Log($"Setting custom rarity for {enemy.enemyType.enemyName} to {value2}");
							enemy.rarity = value2;
						}
						else if (value.TryGetValue(enemy.enemyType.enemyName, out value3))
						{
							BcpLogger.Log($"Using default rarity for {enemy.enemyType.enemyName}: {value3}");
							enemy.rarity = value3;
						}
					}
					else if (value.TryGetValue(enemy.enemyType.enemyName, out value4))
					{
						BcpLogger.Log($"No custom rarity for {enemy.enemyType.enemyName}. Using default rarity: {value4}");
						enemy.rarity = value4;
					}
					else
					{
						BcpLogger.Log("No rarity information found for " + enemy.enemyType.enemyName + ". Skipping.");
					}
				}
			}
			catch (Exception ex)
			{
				BcpLogger.Log("Exception in ApplyCustomLevelEnemyRarities: " + ex.ToString());
			}
		}

		private static ConfigEntry<string> GetConfigForLevel(string levelName)
		{
			return (ConfigEntry<string>)(levelName switch
			{
				"ExperimentationLevel" => ExperimentationLevelRarities, 
				"AssuranceLevel" => AssuranceLevelRarities, 
				"VowLevel" => VowLevelRarities, 
				"MarchLevel" => MarchLevelRarities, 
				"RendLevel" => RendLevelRarities, 
				"DineLevel" => DineLevelRarities, 
				"OffenseLevel" => OffenseLevelRarities, 
				"TitanLevel" => TitanLevelRarities, 
				_ => null, 
			});
		}

		public static void UpdateLevelEnemies(SelectableLevel newLevel, float MoonHeat)
		{
			if (Variables.levelEnemySpawns.TryGetValue(newLevel, out var value))
			{
				ApplyCustomLevelEnemyRarities(value, ((Object)newLevel).name);
				newLevel.Enemies = value;
			}
		}

		public static void InitializeLevelHeatValues(SelectableLevel newLevel)
		{
			if (!Variables.levelHeatVal.ContainsKey(newLevel))
			{
				Variables.levelHeatVal.Add(newLevel, 0f);
			}
			if (Variables.levelEnemySpawns.ContainsKey(newLevel))
			{
				return;
			}
			List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
			foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
			{
				list.Add(enemy);
			}
			Variables.levelEnemySpawns.Add(newLevel, list);
		}

		public static void AdjustHeatValuesForAllLevels(EventEnum eventEnum, SelectableLevel newLevel)
		{
			foreach (SelectableLevel item in Variables.levelHeatVal.Keys.ToList())
			{
				if ((Object)(object)newLevel != (Object)(object)item)
				{
					Variables.levelHeatVal.TryGetValue(item, out var value);
					Variables.levelHeatVal[item] = Mathf.Clamp(value - MoonHeatDecreaseRate.Value, 0f, 100f);
				}
				if (eventEnum == EventEnum.ResetHeat || eventEnum == EventEnum.BadPlanet)
				{
					Variables.levelHeatVal[item] = 0f;
				}
			}
		}

		public static float DisplayHeatMessages(SelectableLevel newLevel)
		{
			Variables.levelHeatVal.TryGetValue(newLevel, out var value);
			HUDManager.Instance.AddTextToChatOnServer("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", -1);
			HUDManager.Instance.AddTextToChatOnServer("<color=orange>MOON IS AT " + value + "% HEAT</color>", -1);
			if (value >= 30f)
			{
				HUDManager.Instance.AddTextToChatOnServer("<size=10><color=red>Your Moon Heat is Getting HIGH (Things might starting spawning). <color=white>\nVisit other moons to decrease your moon heat!</color></size>", -1);
			}
			return value;
		}

		public static void HandleEventSpecificAdjustments(EventEnum eventEnum, SelectableLevel newLevel)
		{
			if (newLevel.sceneName == "CompanyBuilding")
			{
				eventEnum = EventEnum.None;
			}
			switch (eventEnum)
			{
			case EventEnum.None:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=green>Nothing Happened Today!</color>", -1);
				break;
			case EventEnum.Turret:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Turret Terror</color>", -1);
				break;
			case EventEnum.Landmine:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Minescape Terror</color>", -1);
				break;
			case EventEnum.InsideOut:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Inside Out!</color>", -1);
				Variables.SpawnInsideOut = true;
				break;
			case EventEnum.HoardTown:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Hoarder Town</color>", -1);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(HoarderBugAI), 15, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				Functions.FindEnemyPrefabByType(typeof(HoarderBugAI), newLevel.Enemies, newLevel);
				{
					foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
					{
						enemy.rarity = 0;
						if ((Object)(object)enemy.enemyType.enemyPrefab.GetComponent<HoarderBugAI>() != (Object)null)
						{
							enemy.rarity = 100;
						}
					}
					break;
				}
			case EventEnum.BeastInside:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>The Beasts Inside!</color>", -1);
				Functions.TheBeastsInside();
				{
					foreach (SpawnableEnemyWithRarity enemy2 in newLevel.Enemies)
					{
						enemy2.rarity = 0;
					}
					break;
				}
			case EventEnum.TheRumbling:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>The Rumbling!</color>", -1);
				Functions.TheRumbling();
				Variables.TheRumbling = true;
				break;
			case EventEnum.Sacrifice:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>The Hunger Games?</color>", -1);
				Variables.Tribute = true;
				break;
			case EventEnum.BadPlanet:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>This planet is NOT friendly!!!</color>", -1);
				Functions.FindEnemyPrefabByType(typeof(CentipedeAI), newLevel.Enemies, newLevel);
				Functions.FindEnemyPrefabByType(typeof(JesterAI), newLevel.Enemies, newLevel);
				Functions.FindEnemyPrefabByType(typeof(DressGirlAI), newLevel.Enemies, newLevel);
				Functions.FindEnemyPrefabByType(typeof(SpringManAI), newLevel.Enemies, newLevel);
				Functions.FindEnemyPrefabByType(typeof(BlobAI), newLevel.Enemies, newLevel);
				foreach (SpawnableEnemyWithRarity enemy3 in newLevel.Enemies)
				{
					if ((Object)(object)enemy3.enemyType.enemyPrefab.GetComponent<CentipedeAI>() != (Object)null)
					{
						enemy3.rarity = 100;
					}
					if ((Object)(object)enemy3.enemyType.enemyPrefab.GetComponent<JesterAI>() != (Object)null)
					{
						enemy3.rarity = 100;
					}
					if ((Object)(object)enemy3.enemyType.enemyPrefab.GetComponent<DressGirlAI>() != (Object)null)
					{
						enemy3.rarity = 100;
					}
					if ((Object)(object)enemy3.enemyType.enemyPrefab.GetComponent<SpringManAI>() != (Object)null)
					{
						enemy3.rarity = 100;
					}
					if ((Object)(object)enemy3.enemyType.enemyPrefab.GetComponent<BlobAI>() != (Object)null)
					{
						enemy3.rarity = 100;
					}
				}
				Variables.InstaJester = true;
				Variables.BlobsHaveEvolved = true;
				Variables.shouldSpawnTurret = true;
				Variables.slSpawnTimer = -10f;
				Variables.surpriseLandmines += 120;
				break;
			case EventEnum.Chaos:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>CHAOS COMPANY</color>", -1);
				Functions.FindEnemyPrefabByType(typeof(CentipedeAI), newLevel.Enemies, newLevel);
				Functions.FindEnemyPrefabByType(typeof(JesterAI), newLevel.Enemies, newLevel);
				Functions.FindEnemyPrefabByType(typeof(DressGirlAI), newLevel.Enemies, newLevel);
				Functions.FindEnemyPrefabByType(typeof(SpringManAI), newLevel.Enemies, newLevel);
				Functions.FindEnemyPrefabByType(typeof(BlobAI), newLevel.Enemies, newLevel);
				{
					foreach (SpawnableEnemyWithRarity enemy4 in newLevel.Enemies)
					{
						if ((Object)(object)enemy4.enemyType.enemyPrefab.GetComponent<CentipedeAI>() != (Object)null)
						{
							enemy4.rarity = 100;
						}
						if ((Object)(object)enemy4.enemyType.enemyPrefab.GetComponent<JesterAI>() != (Object)null)
						{
							enemy4.rarity = 100;
						}
						if ((Object)(object)enemy4.enemyType.enemyPrefab.GetComponent<DressGirlAI>() != (Object)null)
						{
							enemy4.rarity = 100;
						}
						if ((Object)(object)enemy4.enemyType.enemyPrefab.GetComponent<SpringManAI>() != (Object)null)
						{
							enemy4.rarity = 100;
						}
						if ((Object)(object)enemy4.enemyType.enemyPrefab.GetComponent<BlobAI>() != (Object)null)
						{
							enemy4.rarity = 100;
						}
					}
					break;
				}
			case EventEnum.Unfair:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>That's just unfair</color>", -1);
				break;
			case EventEnum.FaceHuggers:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Internecivus Raptus?</color>", -1);
				Variables.WaitUntilPlayerInside = true;
				Functions.FindEnemyPrefabByType(typeof(CentipedeAI), newLevel.Enemies, newLevel);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(CentipedeAI), 15, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				{
					foreach (SpawnableEnemyWithRarity enemy5 in newLevel.Enemies)
					{
						enemy5.rarity = 0;
						if ((Object)(object)enemy5.enemyType.enemyPrefab.GetComponent<CentipedeAI>() != (Object)null)
						{
							enemy5.rarity = 100;
						}
					}
					break;
				}
			case EventEnum.BlobEvolution:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>They are EVOLVING?!?</color>", -1);
				Functions.FindEnemyPrefabByType(typeof(BlobAI), newLevel.Enemies, newLevel);
				foreach (SpawnableEnemyWithRarity enemy6 in newLevel.Enemies)
				{
					enemy6.rarity = 0;
					if ((Object)(object)enemy6.enemyType.enemyPrefab.GetComponent<BlobAI>() != (Object)null)
					{
						enemy6.rarity = 100;
					}
				}
				Variables.BlobsHaveEvolved = true;
				break;
			case EventEnum.Delivery:
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=green>ICE SCREAM!!!</color>", -1);
				int num = Random.Range(2, 9);
				for (int i = 0; i < num; i++)
				{
					int item = Random.Range(0, 12);
					Object.FindObjectOfType<Terminal>().orderedItemsFromTerminal.Add(item);
				}
				break;
			}
			case EventEnum.InstaJester:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Pop goes the.. HOLY FUC- </color>", -1);
				Functions.FindEnemyPrefabByType(typeof(JesterAI), newLevel.Enemies, newLevel);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(JesterAI), 2, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				Variables.InstaJester = true;
				break;
			case EventEnum.TheyAreShy:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>They are shy!</color>", -1);
				Functions.FindEnemyPrefabByType(typeof(FlowermanAI), newLevel.Enemies, newLevel);
				{
					foreach (SpawnableEnemyWithRarity enemy7 in newLevel.Enemies)
					{
						enemy7.rarity = 0;
						if ((Object)(object)enemy7.enemyType.enemyPrefab.GetComponent<FlowermanAI>() != (Object)null)
						{
							enemy7.rarity = 100;
						}
						if ((Object)(object)enemy7.enemyType.enemyPrefab.GetComponent<SpringManAI>() != (Object)null)
						{
							enemy7.rarity = 100;
						}
					}
					break;
				}
			case EventEnum.TheyWant2Play:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>They just wants to play!!</color>", -1);
				Functions.FindEnemyPrefabByType(typeof(DressGirlAI), newLevel.Enemies, newLevel);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(DressGirlAI), 5, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				break;
			case EventEnum.SurfaceExplosion:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>The surface is explosive</color>", -1);
				Variables.slSpawnTimer = -10f;
				Variables.surpriseLandmines += 120;
				break;
			case EventEnum.ResetHeat:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=green>All Moons Heat Reset</color>", -1);
				break;
			case EventEnum.ShipTurret:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>When did we get this installed?!?</color>", -1);
				Variables.shouldSpawnTurret = true;
				break;
			default:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=green>Nothing happened today!</color>", -1);
				break;
			}
		}

		public static void UpdateMapObjects(SelectableLevel newLevel, EventEnum eventEnum)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			SpawnableMapObject[] spawnableMapObjects = newLevel.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Turret>() != (Object)null)
				{
					Variables.turret = val.prefabToSpawn;
					if (eventEnum == EventEnum.Turret || eventEnum == EventEnum.BadPlanet)
					{
						val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
						{
							new Keyframe(0f, 200f),
							new Keyframe(1f, 25f)
						});
					}
					else if (EnableTurretModifications.Value)
					{
						val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
						{
							new Keyframe(0f, 0f),
							new Keyframe(1f, TurretSpawnRate.Value)
						});
					}
				}
				else if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
				{
					Variables.landmine = val.prefabToSpawn;
					if (eventEnum == EventEnum.Landmine || eventEnum == EventEnum.BadPlanet)
					{
						val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
						{
							new Keyframe(0f, 300f),
							new Keyframe(1f, 170f)
						});
					}
					else if (EnableLandmineModifications.Value)
					{
						val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
						{
							new Keyframe(0f, 0f),
							new Keyframe(1f, LandmineSpawnRate.Value)
						});
					}
				}
				Variables.mls.LogInfo((object)((object)val.prefabToSpawn).ToString());
			}
		}

		public static void LogEnemyInformation(SelectableLevel newLevel)
		{
			Variables.mls.LogWarning((object)"Map Objects");
			SpawnableMapObject[] spawnableMapObjects = newLevel.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				Variables.mls.LogInfo((object)((object)val.prefabToSpawn).ToString());
			}
			Variables.mls.LogWarning((object)"Enemies");
			foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
			{
				Variables.mls.LogInfo((object)(enemy.enemyType.enemyName + "--rarity = " + enemy.rarity));
			}
		}

		public static void UpdateLevelProperties(SelectableLevel newLevel)
		{
			if (!Variables.levelsModified.Contains(newLevel))
			{
				Variables.levelsModified.Add(newLevel);
				newLevel.minScrap += MinScrap.Value;
				newLevel.maxScrap += MaxScrap.Value;
				newLevel.minTotalScrapValue += MinTotalScrapValue.Value;
				newLevel.maxTotalScrapValue += MaxTotalScrapValue.Value;
				newLevel.maxEnemyPowerCount += 70;
				newLevel.maxOutsideEnemyPowerCount += 10;
				newLevel.maxDaytimeEnemyPowerCount += 50;
			}
		}

		public static void ModifyEnemySpawnChances(SelectableLevel newLevel, EventEnum eventEnum, float MoonHeat)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Expected O, but got Unknown
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Expected O, but got Unknown
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			float num = 0f;
			if (MoonHeat > 30f)
			{
				num = MoonHeat / 100f * 10f;
			}
			float num2 = ((FactoryStartOfDaySpawnChance.Value != -1f) ? FactoryStartOfDaySpawnChance.Value : 3f);
			float num3 = ((FactoryMidDaySpawnChance.Value != -1f) ? FactoryMidDaySpawnChance.Value : 7f);
			float num4 = ((FactoryEndOfDaySpawnChance.Value != -1f) ? FactoryEndOfDaySpawnChance.Value : 15f);
			newLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, num2),
				new Keyframe(0.5f, num3),
				new Keyframe(1f, num4)
			});
			float num5 = ((OutsideStartOfDaySpawnChance.Value != -1f) ? OutsideStartOfDaySpawnChance.Value : (-2f));
			float num6 = ((OutsideMidDaySpawnChance.Value != -1f) ? OutsideMidDaySpawnChance.Value : 0f);
			float num7 = ((OutsideEndOfDaySpawnChance.Value != -1f) ? OutsideEndOfDaySpawnChance.Value : 5f);
			newLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, num5 + num),
				new Keyframe(0.5f, num6 + num),
				new Keyframe(1f, num7 + num)
			});
			switch (eventEnum)
			{
			case EventEnum.Unfair:
				newLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(0f, 5f),
					new Keyframe(0.5f, 5f),
					new Keyframe(1f, 5.3f)
				});
				break;
			case EventEnum.BadPlanet:
				newLevel.maxEnemyPowerCount += 200;
				newLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(0f, 5f),
					new Keyframe(0.5f, 5f),
					new Keyframe(1f, 5.3f)
				});
				newLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(0f, 10f),
					new Keyframe(0.5f, 50f),
					new Keyframe(1f, 100f)
				});
				break;
			case EventEnum.Chaos:
				newLevel.maxEnemyPowerCount += 200;
				newLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(0f, 10f),
					new Keyframe(0.5f, 50f),
					new Keyframe(1f, 100f)
				});
				break;
			}
		}
	}
}
namespace BrutalCompanyPlus.HarmPatches
{
	public static class EnemyAIPatches
	{
		[HarmonyPatch(typeof(BlobAI), "Update")]
		[HarmonyPostfix]
		public static void BlobModifications(BlobAI __instance)
		{
			if (Variables.BlobsHaveEvolved && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
				{
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
					return;
				}
				((EnemyAI)__instance).agent.speed = 3.8f;
				Functions.OpenDoors();
			}
		}

		[HarmonyPatch(typeof(SpringManAI), "Update")]
		[HarmonyPostfix]
		public static void InsideOutSpringManModifications(SpringManAI __instance)
		{
			if (Variables.InsideOutOwnership && ((NetworkBehaviour)RoundManager.Instance).IsHost && Variables.SpawnedInsideOutID.Contains(((Object)__instance).GetInstanceID()) && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "StartSearch")]
		[HarmonyPrefix]
		public static bool InsideOutStartSearchModification(EnemyAI __instance, ref Vector3 startOfSearch, AISearchRoutine newSearch)
		{
			//IL_0031: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.InsideOutOwnership && ((NetworkBehaviour)RoundManager.Instance).IsHost && Variables.SpawnedInsideOutID.Contains(((Object)__instance).GetInstanceID()))
			{
				Vector3 position = StartOfRound.Instance.playerSpawnPositions[0].position;
				startOfSearch = Functions.GetNearbyLocation(position);
				Variables.mls.LogError((object)"Changed Search Start Location of Enemy insideOut");
				return true;
			}
			return true;
		}

		[HarmonyPatch(typeof(JesterAI), "Update")]
		[HarmonyPostfix]
		public static void InstaJesterModifications(JesterAI __instance)
		{
			if (Variables.InstaJester && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId && ((EnemyAI)__instance).currentBehaviourStateIndex < 2)
				{
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
				}
				else if (((EnemyAI)__instance).currentBehaviourStateIndex == 1 && __instance.popUpTimer > 10f)
				{
					__instance.popUpTimer = Random.Range(0f, 10f);
				}
			}
		}

		[HarmonyPatch(typeof(ForestGiantAI), "Update")]
		[HarmonyPostfix]
		public static void RumblingForestGiantModifications(ForestGiantAI __instance, bool ___inEatingPlayerAnimation)
		{
			if (Variables.TheRumbling && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId && ((EnemyAI)__instance).currentBehaviourStateIndex < 2)
				{
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
				}
				else if (((EnemyAI)__instance).currentBehaviourStateIndex == 1 && !___inEatingPlayerAnimation)
				{
					((EnemyAI)__instance).agent.speed = 6f;
				}
			}
		}

		[HarmonyPatch(typeof(MouthDogAI), "Update")]
		[HarmonyPostfix]
		public static void InsideMouthDogModifications(MouthDogAI __instance)
		{
			if (Variables.DogForceOwnership && ((NetworkBehaviour)RoundManager.Instance).IsHost && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(MouthDogAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		public static bool OnCollideWithPlayerPatch(MouthDogAI __instance, ref Collider other, bool ___inKillAnimation, Collider ___debugCollider, bool ___inLunge, Ray ___ray, RaycastHit ___rayHit, RoundManager ___roundManager)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.DogForceOwnership && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && !___inKillAnimation)
				{
					Vector3 val = Vector3.Normalize((((Component)__instance).transform.position + Vector3.up - ((Component)component.gameplayCamera).transform.position) * 100f);
					RaycastHit val2 = default(RaycastHit);
					if (Physics.Linecast(((Component)__instance).transform.position + Vector3.up + val * 0.5f, ((Component)component.gameplayCamera).transform.position, ref val2, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
					{
						if ((Object)(object)((RaycastHit)(ref val2)).collider == (Object)(object)___debugCollider)
						{
							return false;
						}
						___debugCollider = ((RaycastHit)(ref val2)).collider;
						return false;
					}
					if (((EnemyAI)__instance).currentBehaviourStateIndex == 3)
					{
						component.inAnimationWithEnemy = (EnemyAI)(object)__instance;
						__instance.KillPlayerServerRpc((int)component.playerClientId);
						return false;
					}
					if (((EnemyAI)__instance).currentBehaviourStateIndex == 0 || ((EnemyAI)__instance).currentBehaviourStateIndex == 1)
					{
						((EnemyAI)__instance).SwitchToBehaviourState(2);
						((EnemyAI)__instance).SetDestinationToPosition(((Component)component).transform.position, false);
						return false;
					}
					if (((EnemyAI)__instance).currentBehaviourStateIndex == 2 && !___inLunge)
					{
						((Component)__instance).transform.LookAt(((Component)other).transform.position);
						((Component)__instance).transform.localEulerAngles = new Vector3(0f, ((Component)__instance).transform.eulerAngles.y, 0f);
						___inLunge = true;
						Functions.EnterLunge(__instance, ___ray, ___rayHit, ___roundManager);
						return false;
					}
				}
			}
			return true;
		}
	}
	public static class LevelEventsPatches
	{
		public static bool test;

		public static bool test2;

		public static bool test3;

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool ModifyLevel(ref SelectableLevel newLevel)
		{
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return true;
			}
			Variables.CurrentLevel = newLevel;
			Plugin.CleanupAndResetAI();
			Plugin.UpdateAIInNewLevel(newLevel);
			Plugin.AddMissingAIToNewLevel(newLevel);
			EventEnum eventEnum = Plugin.SelectRandomEvent();
			Plugin.InitializeLevelHeatValues(newLevel);
			Plugin.AdjustHeatValuesForAllLevels(eventEnum, newLevel);
			Variables.CurrentLevelHeatValue = Plugin.DisplayHeatMessages(newLevel);
			Plugin.ApplyCustomLevelEnemyRarities(newLevel.Enemies, ((Object)newLevel).name);
			Plugin.HandleEventSpecificAdjustments(eventEnum, newLevel);
			Plugin.UpdateMapObjects(newLevel, eventEnum);
			Plugin.LogEnemyInformation(newLevel);
			Plugin.UpdateLevelProperties(newLevel);
			Plugin.ModifyEnemySpawnChances(newLevel, eventEnum, Variables.CurrentLevelHeatValue);
			Variables.levelHeatVal.TryGetValue(newLevel, out var value);
			Variables.levelHeatVal[newLevel] = Mathf.Clamp(value + Plugin.MoonHeatIncreaseRate.Value, 0f, 100f);
			return true;
		}
	}
	public static class QuotaPatches
	{
		[HarmonyPatch(typeof(TimeOfDay), "Awake")]
		[HarmonyPostfix]
		private static void ModifyTimeOfDay(TimeOfDay __instance)
		{
			Variables.mls.LogWarning((object)"Modifying the Starting Quota Values based on Config");
			__instance.quotaVariables.deadlineDaysAmount = Plugin.DeadlineDaysAmount.Value;
			__instance.quotaVariables.startingCredits = Plugin.StartingCredits.Value;
			__instance.quotaVariables.startingQuota = Plugin.StartingQuota.Value;
			__instance.quotaVariables.baseIncrease = Plugin.BaseIncrease.Value;
		}
	}
}
namespace BrutalCompanyPlus.BCP
{
	public class BcpLogger
	{
		private static string logFilePath;

		private const long MaxFileSize = 524288000L;

		static BcpLogger()
		{
			try
			{
				logFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "bcp_logDUMP.txt");
				if (!File.Exists(logFilePath))
				{
					File.Create(logFilePath).Dispose();
				}
			}
			catch (Exception ex)
			{
				Variables.mls.LogError((object)("Error in BcpLogger static constructor: " + ex.Message));
			}
		}

		public static void Log(string message)
		{
			try
			{
				if (new FileInfo(logFilePath).Length > 524288000)
				{
					File.WriteAllText(logFilePath, "");
				}
				using StreamWriter streamWriter = File.AppendText(logFilePath);
				streamWriter.WriteLine($"{DateTime.Now}: {message}\n");
			}
			catch (Exception ex)
			{
				Variables.mls.LogError((object)("--------- Error in logging: " + ex.Message + " ---------"));
			}
		}

		public static void Close()
		{
			Log("---End of Session---");
		}

		public static void Start()
		{
			Log("---Start of Session---");
		}
	}
	public static class Functions
	{
		public static void AddSpecificEnemiesForEvent(SelectableLevel newLevel, List<Type> enemyAITypes)
		{
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			for (int i = 0; i < levels.Length; i++)
			{
				foreach (SpawnableEnemyWithRarity enemy in levels[i].Enemies)
				{
					GameObject enemyPrefab = enemy.enemyType.enemyPrefab;
					foreach (Type enemyAIType in enemyAITypes)
					{
						if ((Object)(object)enemyPrefab.GetComponent(enemyAIType) != (Object)null && !newLevel.Enemies.Any((SpawnableEnemyWithRarity e) => (Object)(object)e.enemyType.enemyPrefab == (Object)(object)enemyPrefab))
						{
							newLevel.Enemies.Add(enemy);
							Variables.mls.LogInfo((object)("Added specific Enemy: > " + ((Object)enemy.enemyType.enemyPrefab).name + " < for event"));
						}
					}
				}
			}
		}

		public static GameObject FindEnemyPrefabByType(Type enemyType, List<SpawnableEnemyWithRarity> enemyList, SelectableLevel newLevel)
		{
			foreach (SpawnableEnemyWithRarity enemy in enemyList)
			{
				if ((Object)(object)enemy.enemyType.enemyPrefab.GetComponent(enemyType) != (Object)null)
				{
					return enemy.enemyType.enemyPrefab;
				}
			}
			AddSpecificEnemiesForEvent(newLevel, new List<Type> { enemyType });
			foreach (SpawnableEnemyWithRarity enemy2 in newLevel.Enemies)
			{
				if ((Object)(object)enemy2.enemyType.enemyPrefab.GetComponent(enemyType) != (Object)null)
				{
					return enemy2.enemyType.enemyPrefab;
				}
			}
			throw new Exception("Enemy type " + enemyType.Name + " not found and could not be added.");
		}

		public static EnemyAI SpawnEnemyOutside(Type enemyType, bool ForceOutside)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			GameObject val = null;
			val = ((!ForceOutside) ? FindEnemyPrefabByType(enemyType, RoundManager.Instance.currentLevel.OutsideEnemies, Variables.CurrentLevel) : FindEnemyPrefabByType(enemyType, RoundManager.Instance.currentLevel.Enemies, Variables.CurrentLevel));
			GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode");
			Vector3 position = array[Random.Range(0, array.Length)].transform.position;
			GameObject obj = Object.Instantiate<GameObject>(val, position, Quaternion.identity);
			obj.GetComponentInChildren<NetworkObject>().Spawn(true);
			EnemyAI component = obj.GetComponent<EnemyAI>();
			if (ForceOutside)
			{
				component.enemyType.isOutsideEnemy = true;
				component.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
				component.SyncPositionToClients();
			}
			RoundManager.Instance.SpawnedEnemies.Add(component);
			return component;
		}

		public static EnemyAI SpawnEnemyFromVent(Type enemyType, bool ForceInside)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = null;
			val = ((!ForceInside) ? FindEnemyPrefabByType(enemyType, RoundManager.Instance.currentLevel.Enemies, Variables.CurrentLevel) : FindEnemyPrefabByType(enemyType, RoundManager.Instance.currentLevel.OutsideEnemies, Variables.CurrentLevel));
			int num = Random.Range(0, RoundManager.Instance.allEnemyVents.Length);
			Vector3 position = RoundManager.Instance.allEnemyVents[num].floorNode.position;
			Quaternion val2 = Quaternion.Euler(0f, RoundManager.Instance.allEnemyVents[num].floorNode.eulerAngles.y, 0f);
			GameObject obj = Object.Instantiate<GameObject>(val, position, val2);
			obj.GetComponentInChildren<NetworkObject>().Spawn(true);
			EnemyAI component = obj.GetComponent<EnemyAI>();
			if (ForceInside)
			{
				component.enemyType.isOutsideEnemy = false;
				component.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
				component.SyncPositionToClients();
			}
			RoundManager.Instance.SpawnedEnemies.Add(component);
			return component;
		}

		public static void SpawnMultipleEnemies(List<Variables.EnemySpawnInfo> enemiesToSpawn)
		{
			foreach (Variables.EnemySpawnInfo item in enemiesToSpawn)
			{
				for (int i = 0; i < item.Amount; i++)
				{
					switch (item.Location)
					{
					case SpawnLocation.Outside:
						SpawnEnemyOutside(item.EnemyType, item.ForceOutside);
						break;
					case SpawnLocation.Vent:
						SpawnEnemyFromVent(item.EnemyType, item.ForceInside);
						break;
					}
				}
			}
		}

		public static void TheBeastsInside()
		{
			string sceneName = Variables.CurrentLevel.sceneName;
			int num = 0;
			Variables.DogForceOwnership = true;
			switch (sceneName)
			{
			case "Titan":
				num = 6;
				break;
			case "Rend":
			case "Dine":
				num = 4;
				break;
			case "March":
			case "Offense":
				num = 3;
				break;
			default:
				num = 2;
				break;
			}
			Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(MouthDogAI), num, SpawnLocation.Vent, forceinside: true, forceoutside: false));
		}

		public static void TheRumbling()
		{
			string sceneName = Variables.CurrentLevel.sceneName;
			int num = 0;
			switch (sceneName)
			{
			case "March":
			case "Titan":
			case "Offense":
			case "Vow":
				num = 8;
				break;
			case "Dine":
			case "Rend":
				num = 10;
				break;
			case "Experimentation":
				num = 6;
				break;
			default:
				num = 8;
				break;
			}
			Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(ForestGiantAI), num, SpawnLocation.Outside, forceinside: false, forceoutside: false));
		}

		public static void InsideOutEnemies()
		{
			Variables.InsideOutOwnership = true;
			for (int i = 0; i < 4; i++)
			{
				EnemyAI val = SpawnEnemyOutside(typeof(SpringManAI), ForceOutside: true);
				Variables.SpawnedInsideOutID.Add(((Object)val).GetInstanceID());
			}
		}

		public static void SetLightningStrikeInterval()
		{
			Variables.lightningStrikeInterval = Random.Range(0f, 10f);
		}

		public static void LightningStrikeRandom()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.Smite_outsideNodes == null || Variables.Smite_outsideNodes.Length == 0)
			{
				Variables.mls.LogError((object)"Smite_outsideNodes is null or empty.");
				InitializeSmiteOutsideNodes();
				if (Variables.Smite_outsideNodes == null || Variables.Smite_outsideNodes.Length == 0)
				{
					return;
				}
			}
			try
			{
				Vector3 val;
				if (Variables.Smite_seed.Next(0, 100) < 60 && (Variables.randomThunderTime - Variables.timeAtLastStrike) * (float)TimeOfDay.Instance.currentWeatherVariable < 3f)
				{
					val = Variables.lastRandomStrikePosition;
				}
				else
				{
					int num = Variables.Smite_seed.Next(0, Variables.Smite_outsideNodes.Length);
					val = Variables.Smite_outsideNodes[num].transform.position;
					val = (Variables.lastRandomStrikePosition = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(val, 15f, Variables.Smite_navHit, Variables.Smite_seed, -1));
				}
				if (StartOfRound.Instance.shipHasLanded)
				{
					RoundManager.Instance.LightningStrikeServerRpc(val);
				}
			}
			catch (Exception ex)
			{
				Variables.mls.LogError((object)("Error in LightningStrikeRandom: " + ex.Message + "\nStack Trace: " + ex.StackTrace));
				BcpLogger.Log("Error in LightningStrikeRandom: " + ex.Message + "\nStack Trace: " + ex.StackTrace);
			}
		}

		public static void InitializeSmiteOutsideNodes()
		{
			Variables.Smite_outsideNodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			if (Variables.Smite_outsideNodes != null && Variables.Smite_outsideNodes.Length != 0)
			{
				Variables.mls.LogInfo((object)$"Found {Variables.Smite_outsideNodes.Length} OutsideAINode objects.");
			}
			else
			{
				Variables.mls.LogError((object)"No OutsideAINode objects found in the scene.");
			}
		}

		public static void SurfaceExplosionLoop()
		{
			//IL_0067: 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)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.slSpawnTimer > 0f)
			{
				Variables.slSpawnTimer = Random.Range(-4, -1);
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				PlayerControllerB val = allPlayerScripts[Random.Range(0, allPlayerScripts.Length)];
				if ((Object)(object)val != (Object)null && !val.isInHangarShipRoom && !val.isInsideFactory && val.isGroundedOnServer)
				{
					if (Vector3.Distance(((Component)val).transform.position, new Vector3(9.33f, 5.2f, 1021f)) < 1f)
					{
						Variables.slSpawnTimer = 1f;
						return;
					}
					GameObject val2 = Object.Instantiate<GameObject>(Variables.landmine, ((Component)val).transform.position, Quaternion.identity);
					val2.transform.position = ((Component)val).transform.position;
					Variables.mls.LogWarning((object)((Component)val).transform.position);
					val2.GetComponent<NetworkObject>().Spawn(true);
					Variables.objectsToCleanUp.Add(val2);
				}
			}
			else
			{
				Variables.slSpawnTimer += Time.deltaTime;
			}
		}

		public static void HungerGamesLoop()
		{
			if (Variables.sacrificeTargetChangeTimer >= Variables.TargetChangeInterval || (Object)(object)Variables.SacrificeTarget == (Object)null || !Variables.SacrificeTarget.isPlayerControlled)
			{
				PickNewSacrificeTarget();
				Variables.sacrificeTargetChangeTimer = 0f;
			}
			if ((Object)(object)Variables.SacrificeTarget != (Object)null && Variables.SacrificeTarget.isInsideFactory)
			{
				ApplySacrificeEffect();
				Variables.Tribute = false;
			}
		}

		public static void PickNewSacrificeTarget()
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			if (allPlayerScripts.Length != 0)
			{
				Variables.SacrificeTarget = allPlayerScripts[Random.Range(0, allPlayerScripts.Length)];
			}
		}

		public static void ApplySacrificeEffect()
		{
			//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)
			if (!Variables.SacrificeTarget.isPlayerDead)
			{
				Variables.SacrificeTarget.DamagePlayerFromOtherClientServerRpc(500, default(Vector3), (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
				HUDManager.Instance.AddTextToChatOnServer("<color=purple>" + Variables.SacrificeTarget.playerUsername + "</color> <color=orange>volunteered as Tribute!</color>", -1);
			}
		}

		public static void EnterLunge(MouthDogAI __instance, Ray ray, RaycastHit rayHit, RoundManager roundManager)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002b: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)__instance).SwitchToBehaviourState(3);
			__instance.endingLunge = false;
			((Ray)(ref ray))..ctor(((Component)__instance).transform.position + Vector3.up, ((Component)__instance).transform.forward);
			Vector3 val = ((!Physics.Raycast(ray, ref rayHit, 17f, StartOfRound.Instance.collidersAndRoomMask)) ? ((Ray)(ref ray)).GetPoint(17f) : ((RaycastHit)(ref rayHit)).point);
			val = roundManager.GetNavMeshPosition(val, default(NavMeshHit), 5f, -1);
			((EnemyAI)__instance).SetDestinationToPosition(val, false);
			((EnemyAI)__instance).agent.speed = 13f;
		}

		public static Vector3 GetNearbyLocation(Vector3 baseLocation)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			float num = 10f;
			Vector3 val = Random.insideUnitSphere * num;
			return baseLocation + val;
		}

		public static void OpenDoors()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			DoorLock[] array = Object.FindObjectsOfType<DoorLock>();
			foreach (DoorLock val in array)
			{
				Collider[] array2 = Physics.OverlapSphere(((Component)val).transform.position, 2f);
				bool flag = false;
				Collider[] array3 = array2;
				for (int j = 0; j < array3.Length; j++)
				{
					if (((Component)array3[j]).CompareTag("Enemy"))
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					FieldInfo field = typeof(DoorLock).GetField("isDoorOpened", BindingFlags.Instance | BindingFlags.NonPublic);
					if (field == null)
					{
						break;
					}
					if (!val.isLocked && !(bool)field.GetValue(val))
					{
						val.OpenOrCloseDoor((PlayerControllerB)null);
					}
				}
			}
		}

		public static void LogEnemyList(SelectableLevel level)
		{
			if (!((Object)(object)level != (Object)null) || level.Enemies.Count <= 0)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity enemy in level.Enemies)
			{
				BcpLogger.Log($"{enemy.enemyType.enemyName} with a Rarity of {enemy.rarity} on {level.sceneName}");
			}
		}

		public static void CloneEnemyList(SelectableLevel level)
		{
			if (!((Object)(object)level != (Object)null) || level.Enemies.Count <= 0)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity enemy in level.Enemies)
			{
				Variables.OriginalEnemyListWithRarity.Add(enemy);
				BcpLogger.Log($"{enemy.enemyType.enemyName} with a Rarity of {enemy.rarity} on {level.sceneName}");
			}
		}

		public static void SetEnemyListOriginalState(SelectableLevel level)
		{
			if (!((Object)(object)level != (Object)null) || Variables.OriginalEnemyListWithRarity.Count <= 0)
			{
				return;
			}
			level.Enemies.Clear();
			foreach (SpawnableEnemyWithRarity item in Variables.OriginalEnemyListWithRarity)
			{
				level.Enemies.Add(item);
				BcpLogger.Log($"Reverting {item.enemyType.enemyName} with a Rarity of {item.rarity} on {level.sceneName}");
			}
			Variables.OriginalEnemyListWithRarity.Clear();
		}

		public static void CleanUpAllVariables()
		{
			Variables.DogForceOwnership = false;
			Variables.InsideOutOwnership = false;
			Variables.BlobsHaveEvolved = false;
			Variables.InstaJester = false;
			Variables.TheRumbling = false;
			Variables.SmiteEnabled = false;
			Variables.SacrificeTarget = null;
			Variables.Tribute = false;
			Variables.SpawnInsideOut = false;
			Variables.WaitUntilPlayerInside = false;
			Variables.Landed = false;
			Variables.sacrificeTargetChangeTimer = 0f;
			Variables.surpriseLandmines = -1;
			Variables.SpawnedInsideOutID.Clear();
			Variables.presetEnemiesToSpawn.Clear();
			Variables.DogsSpawnedInside.Clear();
			foreach (Type item in Variables.aiPresence.Keys.ToList())
			{
				Variables.aiPresence[item] = false;
			}
		}
	}
	public static class Variables
	{
		public struct EnemySpawnInfo
		{
			public Type EnemyType;

			public int Amount;

			public SpawnLocation Location;

			public bool ForceInside;

			public bool ForceOutside;

			public EnemySpawnInfo(Type enemyType, int amount, SpawnLocation location, bool forceinside, bool forceoutside)
			{
				EnemyType = enemyType;
				Amount = amount;
				Location = location;
				ForceInside = forceinside;
				ForceOutside = forceoutside;
			}
		}

		public static bool BlobsHaveEvolved = false;

		public static bool InstaJester = false;

		public static bool WaitUntilPlayerInside = false;

		public static PlayerControllerB SacrificeTarget = null;

		public static bool Tribute = false;

		public static float sacrificeTargetChangeTimer = 0f;

		public static float TargetChangeInterval = 30f;

		public static HashSet<int> DogsSpawnedInside = new HashSet<int>();

		public static bool DogForceOwnership = false;

		public static bool SpawnDogsInside = false;

		public static bool DogIsLunging = false;

		public static HashSet<int> SpawnedInsideOutID = new HashSet<int>();

		public static bool InsideOutOwnership = false;

		public static bool SpawnInsideOut = false;

		public static List<SpawnableEnemyWithRarity> OriginalEnemyListWithRarity = new List<SpawnableEnemyWithRarity>();

		public static bool TheRumbling = false;

		public static float timeNearDoor = 0f;

		public static float requiredTime = 2f;

		public static bool Landed = false;

		public static bool TakeOffExecuted = false;

		public static TimeOfDay TOD;

		public static float messageTimer = 58f;

		public static int surpriseLandmines;

		public static GameObject landmine;

		public static GameObject turret;

		public static List<GameObject> objectsToCleanUp = new List<GameObject>();

		public static float slSpawnTimer;

		public static bool shouldSpawnTurret;

		public static bool TurretSpawned = false;

		public static bool loaded;

		public static EventEnum lastEvent = EventEnum.None;

		public static float CurrentLevelHeatValue = 0f;

		public static readonly Harmony _harmony = new Harmony("BrutalCompanyPlus");

		public static SelectableLevel CurrentLevel = null;

		public static List<SelectableLevel> levelsModified = new List<SelectableLevel>();

		public static Dictionary<SelectableLevel, float> levelHeatVal;

		public static Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>> levelEnemySpawns;

		public static Dictionary<SpawnableEnemyWithRarity, int> enemyRaritys;

		public static Dictionary<SpawnableEnemyWithRarity, AnimationCurve> enemyPropCurves;

		public static ManualLogSource mls;

		public static Dictionary<Type, bool> aiPresence = new Dictionary<Type, bool>
		{
			{
				typeof(BaboonBirdAI),
				false
			},
			{
				typeof(BlobAI),
				false
			},
			{
				typeof(CentipedeAI),
				false
			},
			{
				typeof(CrawlerAI),
				false
			},
			{
				typeof(DoublewingAI),
				false
			},
			{
				typeof(DressGirlAI),
				false
			},
			{
				typeof(FlowermanAI),
				false
			},
			{
				typeof(ForestGiantAI),
				false
			},
			{
				typeof(HoarderBugAI),
				false
			},
			{
				typeof(JesterAI),
				false
			},
			{
				typeof(MouthDogAI),
				false
			},
			{
				typeof(PufferAI),
				false
			},
			{
				typeof(RedLocustBees),
				false
			},
			{
				typeof(SandSpiderAI),
				false
			},
			{
				typeof(SandWormAI),
				false
			},
			{
				typeof(SpringManAI),
				false
			},
			{
				typeof(NutcrackerEnemyAI),
				false
			},
			{
				typeof(MaskedPlayerEnemy),
				false
			}
		};

		public static Dictionary<string, Dictionary<string, int>> DefaultEnemyRarities = new Dictionary<string, Dictionary<string, int>>();

		public static Random Smite_seed = new Random();

		public static GameObject[] Smite_outsideNodes;

		public static Vector3 lastRandomStrikePosition;

		public static float timeAtLastStrike;

		public static float randomThunderTime;

		public static NavMeshHit Smite_navHit;

		public static float lightningStrikeInterval = 3f;

		public static float lastStrikeTime;

		public static bool SmiteEnabled = false;

		public static List<EnemySpawnInfo> presetEnemiesToSpawn = new List<EnemySpawnInfo>();
	}
	public class BrutalPlus : MonoBehaviour
	{
		public void Awake()
		{
			Variables.mls.LogWarning((object)"Brutal Plus is Awake");
		}

		public void Start()
		{
			BcpLogger.Start();
		}

		public void OnDestroy()
		{
			BcpLogger.Close();
		}

		private void Update()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)StartOfRound.Instance != (Object)null) || !((NetworkBehaviour)RoundManager.Instance).IsHost)
				{
					return;
				}
				if (Variables.SmiteEnabled)
				{
					Functions.SetLightningStrikeInterval();
					if (Time.time - Variables.lastStrikeTime > Variables.lightningStrikeInterval)
					{
						Functions.LightningStrikeRandom();
						Variables.lastStrikeTime = Time.time;
					}
				}
				if (Variables.Tribute)
				{
					Functions.HungerGamesLoop();
				}
				if (Variables.surpriseLandmines > 0 && Variables.Landed)
				{
					Functions.SurfaceExplosionLoop();
				}
				if (Variables.shouldSpawnTurret & ((Object)(object)Variables.turret != (Object)null))
				{
					Variables.shouldSpawnTurret = false;
					Variables.TurretSpawned = true;
					GameObject val = Object.Instantiate<GameObject>(Variables.turret, new Vector3(3.87f, 0.84f, -14.23f), Quaternion.identity);
					val.transform.position = new Vector3(3.87f, 0.84f, -14.23f);
					val.transform.forward = new Vector3(1f, 0f, 0f);
					val.GetComponent<NetworkObject>().Spawn(true);
					Variables.objectsToCleanUp.Add(val);
				}
				if (Variables.presetEnemiesToSpawn.Count > 0 && Variables.WaitUntilPlayerInside)
				{
					for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
					{
						if (StartOfRound.Instance.allPlayerScripts[i].isInsideFactory)
						{
							Functions.SpawnMultipleEnemies(Variables.presetEnemiesToSpawn);
							Variables.presetEnemiesToSpawn.Clear();
						}
					}
				}
				if (StartOfRound.Instance.shipHasLanded && !Variables.Landed)
				{
					Variables.Landed = true;
					if (Variables.presetEnemiesToSpawn.Count > 0 && !Variables.WaitUntilPlayerInside)
					{
						Functions.SpawnMultipleEnemies(Variables.presetEnemiesToSpawn);
					}
					if (Variables.SpawnInsideOut)
					{
						Functions.InsideOutEnemies();
					}
				}
				if (StartOfRound.Instance.shipIsLeaving)
				{
					if (Variables.TakeOffExecuted)
					{
						return;
					}
					if (Plugin.EnableFreeMoney.Value)
					{
						if (!StartOfRound.Instance.allPlayersDead)
						{
							Terminal val2 = Object.FindObjectOfType<Terminal>();
							val2.groupCredits += Plugin.FreeMoneyValue.Value;
							val2.SyncGroupCreditsServerRpc(val2.groupCredits, val2.numberOfItemsInDropship);
							HUDManager.Instance.AddTextToChatOnServer("\"<size=10><color=green> You survived another day! Here's free cash c: </color></size>", -1);
						}
						else
						{
							HUDManager.Instance.AddTextToChatOnServer("\"<size=10><color=red> That was Brutal! No free cash today :c </color></size>", -1);
						}
					}
					if (Variables.TurretSpawned)
					{
						Variables.mls.LogWarning((object)"Disabling Turret due to ship leaving");
						Turret[] array = Object.FindObjectsOfType<Turret>();
						for (int j = 0; j < array.Length; j++)
						{
							array[j].ToggleTurretEnabled(false);
						}
						Variables.TurretSpawned = false;
					}
					Functions.CleanUpAllVariables();
					Variables.TakeOffExecuted = true;
				}
				else
				{
					Variables.TakeOffExecuted = false;
				}
			}
			catch (Exception ex)
			{
				Variables.mls.LogError((object)("Error in Update: " + ex.Message));
				BcpLogger.Log("Error in Update: " + ex.Message);
			}
		}

		public static void CleanupAllSpawns()
		{
			foreach (GameObject item in Variables.objectsToCleanUp)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			Variables.objectsToCleanUp.Clear();
		}
	}
	public enum EventEnum
	{
		None,
		Turret,
		Delivery,
		BlobEvolution,
		Chaos,
		SurfaceExplosion,
		FaceHuggers,
		TheRumbling,
		TheyWant2Play,
		BeastInside,
		Unfair,
		InsideOut,
		BadPlanet,
		InstaJester,
		Landmine,
		Sacrifice,
		ShipTurret,
		HoardTown,
		TheyAreShy,
		ResetHeat
	}
	public enum InsideEnemyEnum
	{
		Centipede,
		SandSpider,
		HoarderBug,
		FlowerMan,
		Crawler,
		Blob,
		DressGirl,
		Puffer,
		SpringMan,
		Jester
	}
	public enum OutsideEnemyEnum
	{
		MouthDog,
		ForestGiant,
		SandWorm,
		RedLocustBees,
		DoubleWing,
		DocileLocustBees
	}
	public enum SpawnLocation
	{
		Outside,
		Vent
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BrutalCompanyPlus";

		public const string PLUGIN_NAME = "BrutalCompanyPlus";

		public const string PLUGIN_VERSION = "3.3.1";
	}
}

plugins/phawitpp-SuperLandmine/SuperLandmine.dll

Decompiled 2 years ago
using System;
using System.Collections;
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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("SuperLandmine")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("SuperLandmine mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+494216e2c83f01493bb3bbe4e963fdf667503d01")]
[assembly: AssemblyProduct("SuperLandmine")]
[assembly: AssemblyTitle("SuperLandmine")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 SuperLandmine
{
	[BepInPlugin("Superlandmine", "SuperLandmine", "1.1.2")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource log;

		public Harmony harmony = new Harmony("Superlandmine");

		public static ConfigEntry<int> config_LandmineMinAmount;

		public static ConfigEntry<int> config_LandmineMaxAmount;

		public static ConfigEntry<bool> config_EnableLandmineSound;

		public static ConfigEntry<bool> config_EnemyCanTriggerLandmine;

		public static ConfigEntry<bool> config_LandmineCanSpawnOutside;

		public static ConfigEntry<bool> config_UseDefaultLandmineSpawnRate;

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			log.LogInfo((object)"Loading plugin SuperLandmine ...");
			ConfigSetup();
			harmony.PatchAll();
			log.LogInfo((object)"Plugin SuperLandmine loaded!");
		}

		private void ConfigSetup()
		{
			config_LandmineMinAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Landmine min amount", "Value", 10, "Min landmine to be spawned in the map");
			config_LandmineMaxAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Landmine max amount", "Value", 15, "Max landmine to be spawned in the map");
			config_EnableLandmineSound = ((BaseUnityPlugin)this).Config.Bind<bool>("Disable landmine sound", "Value", true, "Enable or disable landmine sound");
			config_EnemyCanTriggerLandmine = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemy trigger landmine", "Value", true, "Enable or disable enemy can trigger landmine");
			config_LandmineCanSpawnOutside = ((BaseUnityPlugin)this).Config.Bind<bool>("Landmine can spawn outside", "Value", true, "Enable or disable landmine can spawn outside");
			config_UseDefaultLandmineSpawnRate = ((BaseUnityPlugin)this).Config.Bind<bool>("Use default landmine spawn rate", "Value", false, "Enable or disable default landmine spawn rate");
		}
	}
	internal class PluginInfo
	{
		public const string PLUGIN_GUID = "Superlandmine";

		public const string PLUGIN_NAME = "SuperLandmine";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}
namespace SuperLandmine.Patchs
{
	[HarmonyPatch(typeof(Landmine))]
	public class SuperLandminePatch
	{
		[HarmonyPatch("PressMineClientRpc")]
		[HarmonyPostfix]
		public static void playTriggerSound(Landmine __instance)
		{
			Plugin.log.LogInfo((object)"Play trigger sound");
			__instance.mineAudio.volume = 1.3f;
			__instance.mineFarAudio.volume = 1.3f;
			Traverse.Create((object)__instance).Field("pressMineDebounceTimer").SetValue((object)0.5f);
			__instance.mineAudio.PlayOneShot(__instance.minePress, 1.3f);
			WalkieTalkie.TransmitOneShotAudio(__instance.mineAudio, __instance.minePress, 1f);
		}

		[HarmonyPatch("Detonate")]
		[HarmonyPrefix]
		public static void IncreaseAudioVolume(Landmine __instance)
		{
			Plugin.log.LogInfo((object)"Increase landmine volume and kill range");
			((MonoBehaviour)__instance).StartCoroutine(DelayedActions(__instance));
		}

		private static IEnumerator DelayedActions(Landmine __instance)
		{
			yield return (object)new WaitForSeconds(0.5f);
			__instance.mineAudio.volume = 1.2f;
			__instance.mineFarAudio.volume = 1.3f;
			__instance.mineAudio.pitch = Random.Range(0.93f, 1.07f);
			__instance.mineAudio.PlayOneShot(__instance.mineDetonate, 1.2f);
			Landmine.SpawnExplosion(((Component)__instance).transform.position + Vector3.up, true, 10f, 12f);
			yield return (object)new WaitForSeconds(0.5f);
		}

		[HarmonyPatch("Detonate")]
		[HarmonyPostfix]
		public static void disableSoundAfterExplode(Landmine __instance)
		{
			if (Plugin.config_EnableLandmineSound.Value)
			{
				__instance.mineAudio.volume = 0f;
				__instance.mineFarAudio.volume = 0f;
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void enabledLandMineSound(Landmine __instance)
		{
			if (Plugin.config_EnableLandmineSound.Value)
			{
				__instance.mineAudio.volume = 0f;
				__instance.mineFarAudio.volume = 0f;
			}
		}

		[HarmonyPatch("OnTriggerEnter")]
		[HarmonyPrefix]
		public static void anyObjectTriggerLandmineEnter(ref Collider other, Landmine __instance)
		{
			if (!Plugin.config_EnemyCanTriggerLandmine.Value)
			{
				return;
			}
			float value = Traverse.Create((object)__instance).Field("pressMineDebounceTimer").GetValue<float>();
			if (__instance.hasExploded || value > 0f)
			{
				return;
			}
			if (((Component)other).CompareTag("Player"))
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if (!((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController) && (Object)(object)component != (Object)null && !component.isPlayerDead)
				{
					Traverse.Create((object)__instance).Field("localPlayerOnMine").SetValue((object)true);
					Traverse.Create((object)__instance).Field("pressMineDebounceTimer").SetValue((object)0.5f);
					__instance.PressMineServerRpc();
				}
			}
			else
			{
				if (!((Component)other).CompareTag("PlayerRagdoll") && !((Component)other).CompareTag("PhysicsProp") && !((Component)other).CompareTag("Enemy"))
				{
					return;
				}
				if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<DeadBodyInfo>()))
				{
					if ((Object)(object)((Component)other).GetComponent<DeadBodyInfo>().playerScript != (Object)(object)GameNetworkManager.Instance.localPlayerController)
					{
						return;
					}
				}
				else if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<GrabbableObject>()) && !((NetworkBehaviour)((Component)other).GetComponent<GrabbableObject>()).NetworkObject.IsOwner)
				{
					return;
				}
				Traverse.Create((object)__instance).Field("pressMineDebounceTimer").SetValue((object)0.5f);
				__instance.PressMineServerRpc();
			}
		}

		[HarmonyPatch("OnTriggerExit")]
		[HarmonyPrefix]
		public static void anyObjectTriggerLandmineExit(ref Collider other, Landmine __instance)
		{
			if (!Plugin.config_EnemyCanTriggerLandmine.Value)
			{
				return;
			}
			bool value = Traverse.Create((object)__instance).Field("mineActivated").GetValue<bool>();
			if (__instance.hasExploded || !value)
			{
				return;
			}
			if (((Component)other).CompareTag("Player"))
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && !((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController))
				{
					Traverse.Create((object)__instance).Field("localPlayerOnMine").SetValue((object)false);
					Traverse.Create((object)__instance).Method("TriggerMineOnLocalClientByExiting", Array.Empty<object>()).GetValue();
				}
			}
			else
			{
				if (!((Component)other).CompareTag("PlayerRagdoll") && !((Component)other).CompareTag("PhysicsProp") && !((Component)other).CompareTag("Enemy"))
				{
					return;
				}
				if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<DeadBodyInfo>()))
				{
					if ((Object)(object)((Component)other).GetComponent<DeadBodyInfo>().playerScript != (Object)(object)GameNetworkManager.Instance.localPlayerController)
					{
						return;
					}
				}
				else if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<GrabbableObject>()) && !((NetworkBehaviour)((Component)other).GetComponent<GrabbableObject>()).NetworkObject.IsOwner)
				{
					return;
				}
				Traverse.Create((object)__instance).Method("TriggerMineOnLocalClientByExiting", Array.Empty<object>()).GetValue();
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class RoundManagerPatch
	{
		[HarmonyPatch("LoadNewLevel")]
		[HarmonyPrefix]
		public static void spawnLanmineInside(ref SelectableLevel newLevel)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			if (Plugin.config_UseDefaultLandmineSpawnRate.Value)
			{
				return;
			}
			Plugin.log.LogInfo((object)"Load landmine");
			SelectableLevel val = newLevel;
			SpawnableMapObject[] spawnableMapObjects = val.spawnableMapObjects;
			if (val.spawnableMapObjects.Length == 0)
			{
				return;
			}
			Plugin.log.LogInfo((object)"Spawn landmine inside");
			SpawnableMapObject[] array = spawnableMapObjects;
			foreach (SpawnableMapObject val2 in array)
			{
				if ((Object)val2.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
				{
					val2.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
					{
						new Keyframe(0f, (float)Plugin.config_LandmineMinAmount.Value),
						new Keyframe(1f, (float)Plugin.config_LandmineMaxAmount.Value)
					});
				}
			}
		}

		[HarmonyPatch("SpawnOutsideHazards")]
		[HarmonyPrefix]
		public static void spawnLandmineOutside(RoundManager __instance)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.config_LandmineCanSpawnOutside.Value || !((NetworkBehaviour)__instance).IsServer || !((NetworkBehaviour)__instance).IsHost)
			{
				return;
			}
			Plugin.log.LogInfo((object)"Load landmine");
			SelectableLevel currentLevel = __instance.currentLevel;
			SpawnableMapObject[] spawnableMapObjects = currentLevel.spawnableMapObjects;
			if (currentLevel.spawnableMapObjects.Length == 0)
			{
				return;
			}
			Plugin.log.LogInfo((object)"Spawn landmine outside");
			SpawnableMapObject[] array = spawnableMapObjects;
			foreach (SpawnableMapObject val in array)
			{
				if (!((Object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null))
				{
					continue;
				}
				AnimationCurve val2 = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, (float)Plugin.config_LandmineMinAmount.Value),
					new Keyframe(1f, (float)Plugin.config_LandmineMaxAmount.Value)
				});
				Transform[] shipSpawnPathPoints = __instance.shipSpawnPathPoints;
				for (int j = 0; j < shipSpawnPathPoints.Length; j++)
				{
					for (int k = 0; (float)k < val2.Evaluate(Random.Range(0f, 1f)); k++)
					{
						Random random = new Random();
						Vector3 randomNavMeshPositionInBoxPredictable = __instance.GetRandomNavMeshPositionInBoxPredictable(shipSpawnPathPoints[j].position, 300f, __instance.navHit, random, -5);
						Plugin.log.LogInfo((object)("Spawn landmine outside at" + ((object)(Vector3)(ref randomNavMeshPositionInBoxPredictable)).ToString()));
						GameObject val3 = Object.Instantiate<GameObject>(val.prefabToSpawn, randomNavMeshPositionInBoxPredictable, Quaternion.identity);
						val3.SetActive(true);
						val3.GetComponent<NetworkObject>().Spawn(false);
					}
				}
			}
		}
	}
}

plugins/RickArg-Helmet_Cameras/HelmetCamera.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("HelmetCamera")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HelmetCamera")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b99c4d46-5f13-47b3-a5af-5e3f37772e77")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HelmetCamera
{
	[BepInPlugin("RickArg.lethalcompany.helmetcameras", "Helmet_Cameras", "2.1.5")]
	public class PluginInit : BaseUnityPlugin
	{
		public static Harmony _harmony;

		public static ConfigEntry<int> config_isHighQuality;

		public static ConfigEntry<int> config_renderDistance;

		public static ConfigEntry<int> config_cameraFps;

		private void Awake()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			config_isHighQuality = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "monitorResolution", 0, "Low FPS affection. High Quality mode. 0 - vanilla (48x48), 1 - vanilla+ (128x128), 2 - mid quality (256x256), 3 - high quality (512x512), 4 - Very High Quality (1024x1024)");
			config_renderDistance = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "renderDistance", 20, "Low FPS affection. Render distance for helmet camera.");
			config_cameraFps = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "cameraFps", 30, "Very high FPS affection. FPS for helmet camera. To increase YOUR fps, you should low cameraFps value.");
			_harmony = new Harmony("HelmetCamera");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Helmet_Cameras is loaded with version 2.1.5!");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"--------Helmet camera patch done.---------");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RickArg.lethalcompany.helmetcameras";

		public const string PLUGIN_NAME = "Helmet_Cameras";

		public const string PLUGIN_VERSION = "2.1.5";
	}
	public class Plugin : MonoBehaviour
	{
		private RenderTexture renderTexture;

		private bool isMonitorChanged = false;

		private GameObject helmetCameraNew;

		private bool isSceneLoaded = false;

		private bool isCoroutineStarted = false;

		private int currentTransformIndex;

		private int resolution = 0;

		private int renderDistance = 50;

		private float cameraFps = 30f;

		private float elapsed;

		private void Awake()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			resolution = PluginInit.config_isHighQuality.Value;
			renderDistance = PluginInit.config_renderDistance.Value;
			cameraFps = PluginInit.config_cameraFps.Value;
			switch (resolution)
			{
			case 0:
				renderTexture = new RenderTexture(48, 48, 24);
				break;
			case 1:
				renderTexture = new RenderTexture(128, 128, 24);
				break;
			case 2:
				renderTexture = new RenderTexture(256, 256, 24);
				break;
			case 3:
				renderTexture = new RenderTexture(512, 512, 24);
				break;
			case 4:
				renderTexture = new RenderTexture(1024, 1024, 24);
				break;
			}
		}

		public void Start()
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			isCoroutineStarted = false;
			while ((Object)(object)helmetCameraNew == (Object)null)
			{
				helmetCameraNew = new GameObject("HelmetCamera");
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "MainMenu")
			{
				activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name != "InitScene")
				{
					activeScene = SceneManager.GetActiveScene();
					if (((Scene)(ref activeScene)).name != "InitSceneLaunchOptions")
					{
						isSceneLoaded = true;
						Debug.Log((object)"[HELMET_CAMERAS] Starting coroutine...");
						((MonoBehaviour)this).StartCoroutine(LoadSceneEnter());
						return;
					}
				}
			}
			isSceneLoaded = false;
			isMonitorChanged = false;
		}

		private IEnumerator LoadSceneEnter()
		{
			Debug.Log((object)"[HELMET_CAMERAS] 5 seconds for init mode... Please wait...");
			yield return (object)new WaitForSeconds(5f);
			isCoroutineStarted = true;
			if ((Object)(object)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera") != (Object)null)
			{
				Debug.Log((object)"[HELMET_CAMERAS] Ship camera founded...");
				if (!isMonitorChanged)
				{
					((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube").GetComponent<MeshRenderer>()).materials[2].mainTexture = ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture;
					((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture = (Texture)(object)renderTexture;
					helmetCameraNew.AddComponent<Camera>();
					((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false;
					helmetCameraNew.GetComponent<Camera>().targetTexture = renderTexture;
					helmetCameraNew.GetComponent<Camera>().cullingMask = 20649983;
					helmetCameraNew.GetComponent<Camera>().farClipPlane = renderDistance;
					helmetCameraNew.GetComponent<Camera>().nearClipPlane = 0.55f;
					isMonitorChanged = true;
					Debug.Log((object)"[HELMET_CAMERAS] Monitors were changed...");
					Debug.Log((object)"[HELMET_CAMERAS] Turning off vanilla internal ship camera");
					((Behaviour)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera").GetComponent<Camera>()).enabled = false;
				}
			}
		}

		public void Update()
		{
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			bool flag = isSceneLoaded && isCoroutineStarted;
			if (flag && StartOfRound.Instance.localPlayerController.isInHangarShipRoom)
			{
				helmetCameraNew.SetActive(true);
				elapsed += Time.deltaTime;
				if (elapsed > 1f / cameraFps)
				{
					elapsed = 0f;
					((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = true;
				}
				else
				{
					((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false;
				}
				GameObject val = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001/CameraMonitorScript");
				currentTransformIndex = val.GetComponent<ManualCameraRenderer>().targetTransformIndex;
				TransformAndName val2 = val.GetComponent<ManualCameraRenderer>().radarTargets[currentTransformIndex];
				if (!val2.isNonPlayer)
				{
					try
					{
						helmetCameraNew.transform.SetPositionAndRotation(val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").position + new Vector3(0f, 0f, 0f), val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").rotation * Quaternion.Euler(0f, 0f, 0f));
						DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>();
						for (int i = 0; i < array.Length; i++)
						{
							if (array[i].playerScript.playerUsername == val2.name)
							{
								helmetCameraNew.transform.SetPositionAndRotation(((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").position, ((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").rotation * Quaternion.Euler(0f, 0f, 0f));
							}
						}
						return;
					}
					catch (NullReferenceException)
					{
						Debug.Log((object)"[HELMET_CAMERAS] ERROR NULL REFERENCE");
						return;
					}
				}
				helmetCameraNew.transform.SetPositionAndRotation(val2.transform.position + new Vector3(0f, 1.6f, 0f), val2.transform.rotation * Quaternion.Euler(0f, -90f, 0f));
			}
			else if (flag && !StartOfRound.Instance.localPlayerController.isInHangarShipRoom)
			{
				helmetCameraNew.SetActive(false);
			}
		}
	}
}
namespace HelmetCamera.Patches
{
	[HarmonyPatch]
	internal class HelmetCamera
	{
		public static void InitCameras()
		{
			GameObject val = GameObject.Find("Environment/HangarShip/Cameras/ShipCamera");
			val.AddComponent<Plugin>();
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		public static void InitCamera(ref ManualCameraRenderer __instance)
		{
			InitCameras();
		}
	}
}

plugins/RugbugRedfern-Skinwalkers/SkinwalkerMod.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dissonance.Config;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SkinwalkerMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SkinwalkerMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fd4979a2-cef0-46af-8bf8-97e630b11475")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>();
	}
}
namespace SkinwalkerMod;

[BepInPlugin("RugbugRedfern.SkinwalkerMod", "Skinwalker Mod", "1.0.8")]
internal class PluginLoader : BaseUnityPlugin
{
	private readonly Harmony harmony = new Harmony("RugbugRedfern.SkinwalkerMod");

	private const string modGUID = "RugbugRedfern.SkinwalkerMod";

	private const string modVersion = "1.0.8";

	private static bool initialized;

	public static PluginLoader Instance { get; private set; }

	private void Awake()
	{
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Expected O, but got Unknown
		if (initialized)
		{
			return;
		}
		initialized = true;
		Instance = this;
		harmony.PatchAll(Assembly.GetExecutingAssembly());
		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);
				}
			}
		}
		SkinwalkerLogger.Initialize("RugbugRedfern.SkinwalkerMod");
		SkinwalkerLogger.Log("SKINWALKER MOD STARTING UP 1.0.8");
		SkinwalkerConfig.InitConfig();
		SceneManager.sceneLoaded += SkinwalkerNetworkManagerHandler.ClientConnectInitializer;
		GameObject val = new GameObject("Skinwalker Mod");
		val.AddComponent<SkinwalkerModPersistent>();
		((Object)val).hideFlags = (HideFlags)61;
		Object.DontDestroyOnLoad((Object)(object)val);
	}

	public void BindConfig<T>(ref ConfigEntry<T> config, string section, string key, T defaultValue, string description = "")
	{
		config = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description);
	}
}
internal class SkinwalkerBehaviour : MonoBehaviour
{
	private AudioSource audioSource;

	public const float PLAY_INTERVAL_MIN = 15f;

	public const float PLAY_INTERVAL_MAX = 40f;

	private const float MAX_DIST = 100f;

	private float nextTimeToPlayAudio;

	private EnemyAI ai;

	public void Initialize(EnemyAI ai)
	{
		this.ai = ai;
		audioSource = ai.creatureVoice;
		SetNextTime();
	}

	private void Update()
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		if (!(Time.time > nextTimeToPlayAudio))
		{
			return;
		}
		SetNextTime();
		float num = -1f;
		if (Object.op_Implicit((Object)(object)ai) && !ai.isEnemyDead)
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)this).transform.position)) < 100f)
			{
				AudioClip sample = SkinwalkerModPersistent.Instance.GetSample();
				if (Object.op_Implicit((Object)(object)sample))
				{
					SkinwalkerLogger.Log(((Object)this).name + " played voice line 1");
					audioSource.PlayOneShot(sample);
				}
				else
				{
					SkinwalkerLogger.Log(((Object)this).name + " played voice line 0");
				}
			}
			else
			{
				SkinwalkerLogger.Log(((Object)this).name + " played voice line no (too far away) " + num);
			}
		}
		else
		{
			SkinwalkerLogger.Log(((Object)this).name + " played voice line no (dead) EnemyAI: " + (object)ai);
		}
	}

	private void SetNextTime()
	{
		if (SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value <= 0f)
		{
			nextTimeToPlayAudio = Time.time + 100000000f;
		}
		else
		{
			nextTimeToPlayAudio = Time.time + Random.Range(15f, 40f) / SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value;
		}
	}

	private T CopyComponent<T>(T original, GameObject destination) where T : Component
	{
		Type type = ((object)original).GetType();
		Component val = destination.AddComponent(type);
		FieldInfo[] fields = type.GetFields();
		FieldInfo[] array = fields;
		foreach (FieldInfo fieldInfo in array)
		{
			fieldInfo.SetValue(val, fieldInfo.GetValue(original));
		}
		return (T)(object)((val is T) ? val : null);
	}
}
internal class SkinwalkerConfig
{
	public static ConfigEntry<bool> VoiceEnabled_BaboonHawk;

	public static ConfigEntry<bool> VoiceEnabled_Bracken;

	public static ConfigEntry<bool> VoiceEnabled_BunkerSpider;

	public static ConfigEntry<bool> VoiceEnabled_Centipede;

	public static ConfigEntry<bool> VoiceEnabled_CoilHead;

	public static ConfigEntry<bool> VoiceEnabled_EyelessDog;

	public static ConfigEntry<bool> VoiceEnabled_ForestGiant;

	public static ConfigEntry<bool> VoiceEnabled_GhostGirl;

	public static ConfigEntry<bool> VoiceEnabled_GiantWorm;

	public static ConfigEntry<bool> VoiceEnabled_HoardingBug;

	public static ConfigEntry<bool> VoiceEnabled_Hygrodere;

	public static ConfigEntry<bool> VoiceEnabled_Jester;

	public static ConfigEntry<bool> VoiceEnabled_Masked;

	public static ConfigEntry<bool> VoiceEnabled_Nutcracker;

	public static ConfigEntry<bool> VoiceEnabled_SporeLizard;

	public static ConfigEntry<bool> VoiceEnabled_Thumper;

	public static ConfigEntry<float> VoiceLineFrequency;

	public static void InitConfig()
	{
		PluginLoader.Instance.BindConfig(ref VoiceLineFrequency, "Voice Settings", "VoiceLineFrequency", 1f, "1 is the default, and voice lines will occur every " + 15f.ToString("0") + " to " + 40f.ToString("0") + " seconds per enemy. Setting this to 2 means they will occur twice as often, 0.5 means half as often, etc.");
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_BaboonHawk, "Monster Voices", "Baboon Hawk", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_Bracken, "Monster Voices", "Bracken", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_BunkerSpider, "Monster Voices", "Bunker Spider", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_Centipede, "Monster Voices", "Centipede", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_CoilHead, "Monster Voices", "Coil Head", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_EyelessDog, "Monster Voices", "Eyeless Dog", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_ForestGiant, "Monster Voices", "Forest Giant", defaultValue: false);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_GhostGirl, "Monster Voices", "Ghost Girl", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_GiantWorm, "Monster Voices", "Giant Worm", defaultValue: false);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_HoardingBug, "Monster Voices", "Hoarding Bug", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_Hygrodere, "Monster Voices", "Hygrodere", defaultValue: false);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_Jester, "Monster Voices", "Jester", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_Masked, "Monster Voices", "Masked", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_Nutcracker, "Monster Voices", "Nutcracker", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_SporeLizard, "Monster Voices", "Spore Lizard", defaultValue: true);
		PluginLoader.Instance.BindConfig(ref VoiceEnabled_Thumper, "Monster Voices", "Thumper", defaultValue: true);
		SkinwalkerLogger.Log("VoiceEnabled_BaboonHawk" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BaboonHawk.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_Bracken" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Bracken.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_BunkerSpider" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BunkerSpider.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_Centipede" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Centipede.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_CoilHead" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_CoilHead.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_EyelessDog" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_EyelessDog.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_ForestGiant" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_ForestGiant.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_GhostGirl" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GhostGirl.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_GiantWorm" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GiantWorm.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_HoardingBug" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_HoardingBug.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_Hygrodere" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Hygrodere.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_Jester" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Jester.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_Masked" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Masked.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_Nutcracker" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Nutcracker.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_SporeLizard" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_SporeLizard.Value}]");
		SkinwalkerLogger.Log("VoiceEnabled_Thumper" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Thumper.Value}]");
		SkinwalkerLogger.Log("VoiceLineFrequency" + $" VALUE LOADED FROM CONFIG: [{VoiceLineFrequency.Value}]");
	}
}
internal static class SkinwalkerLogger
{
	internal static ManualLogSource logSource;

	public static void Initialize(string modGUID)
	{
		logSource = Logger.CreateLogSource(modGUID);
	}

	public static void Log(object message)
	{
		logSource.LogInfo(message);
	}

	public static void LogError(object message)
	{
		logSource.LogError(message);
	}

	public static void LogWarning(object message)
	{
		logSource.LogWarning(message);
	}
}
public class SkinwalkerModPersistent : MonoBehaviour
{
	private string audioFolder;

	private List<AudioClip> cachedAudio = new List<AudioClip>();

	private float nextTimeToCheckFolder = 30f;

	private float nextTimeToCheckEnemies = 30f;

	private const float folderScanInterval = 8f;

	private const float enemyScanInterval = 5f;

	public static SkinwalkerModPersistent Instance { get; private set; }

	private void Awake()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		((Component)this).transform.position = Vector3.zero;
		SkinwalkerLogger.Log("Skinwalker Mod Object Initialized");
		audioFolder = Path.Combine(Application.dataPath, "..", "Dissonance_Diagnostics");
		EnableRecording();
		if (!Directory.Exists(audioFolder))
		{
			Directory.CreateDirectory(audioFolder);
		}
	}

	private void Start()
	{
		try
		{
			if (Directory.Exists(audioFolder))
			{
				Directory.Delete(audioFolder, recursive: true);
			}
		}
		catch (Exception message)
		{
			SkinwalkerLogger.Log(message);
		}
	}

	private void OnApplicationQuit()
	{
		DisableRecording();
	}

	private void EnableRecording()
	{
		DebugSettings.Instance.EnablePlaybackDiagnostics = true;
		DebugSettings.Instance.RecordFinalAudio = true;
	}

	private void Update()
	{
		if (Time.realtimeSinceStartup > nextTimeToCheckFolder)
		{
			nextTimeToCheckFolder = Time.realtimeSinceStartup + 8f;
			if (!Directory.Exists(audioFolder))
			{
				SkinwalkerLogger.Log("Audio folder not present. Don't worry about it, it will be created automatically when you play with friends. (" + audioFolder + ")");
				return;
			}
			string[] files = Directory.GetFiles(audioFolder);
			SkinwalkerLogger.Log($"Got audio file paths ({files.Length})");
			string[] array = files;
			foreach (string path in array)
			{
				((MonoBehaviour)this).StartCoroutine(LoadWavFile(path, delegate(AudioClip audioClip)
				{
					cachedAudio.Add(audioClip);
				}));
			}
		}
		if (!(Time.realtimeSinceStartup > nextTimeToCheckEnemies))
		{
			return;
		}
		nextTimeToCheckEnemies = Time.realtimeSinceStartup + 5f;
		EnemyAI[] array2 = Object.FindObjectsOfType<EnemyAI>(true);
		EnemyAI[] array3 = array2;
		SkinwalkerBehaviour skinwalkerBehaviour = default(SkinwalkerBehaviour);
		foreach (EnemyAI val in array3)
		{
			SkinwalkerLogger.Log("IsEnemyEnabled " + ((Object)val).name + " " + IsEnemyEnabled(val));
			if (IsEnemyEnabled(val) && !((Component)val).TryGetComponent<SkinwalkerBehaviour>(ref skinwalkerBehaviour))
			{
				((Component)val).gameObject.AddComponent<SkinwalkerBehaviour>().Initialize(val);
			}
		}
	}

	private bool IsEnemyEnabled(EnemyAI enemy)
	{
		if ((Object)(object)enemy == (Object)null)
		{
			return false;
		}
		return ((Object)((Component)enemy).gameObject).name switch
		{
			"MaskedPlayerEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Masked.Value, 
			"NutcrackerEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Nutcracker.Value, 
			"BaboonHawkEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BaboonHawk.Value, 
			"Flowerman(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Bracken.Value, 
			"SandSpider(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BunkerSpider.Value, 
			"RedLocustBees(Clone)" => false, 
			"Centipede(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Centipede.Value, 
			"SpringMan(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_CoilHead.Value, 
			"MouthDog(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_EyelessDog.Value, 
			"ForestGiant(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_ForestGiant.Value, 
			"DressGirl(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GhostGirl.Value, 
			"SandWorm(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GiantWorm.Value, 
			"HoarderBug(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_HoardingBug.Value, 
			"Blob(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Hygrodere.Value, 
			"JesterEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Jester.Value, 
			"PufferEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_SporeLizard.Value, 
			"Crawler(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Thumper.Value, 
			"DocileLocustBees(Clone)" => false, 
			"DoublewingedBird(Clone)" => false, 
			_ => true, 
		};
	}

	internal IEnumerator LoadWavFile(string path, Action<AudioClip> callback)
	{
		UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
		try
		{
			yield return www.SendWebRequest();
			if ((int)www.result == 1)
			{
				SkinwalkerLogger.Log("Loaded clip from path " + path);
				AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www);
				if (audioClip.length > 0.9f)
				{
					callback(audioClip);
				}
				try
				{
					File.Delete(path);
				}
				catch (Exception e)
				{
					SkinwalkerLogger.LogWarning(e);
				}
			}
		}
		finally
		{
			((IDisposable)www)?.Dispose();
		}
	}

	private void DisableRecording()
	{
		DebugSettings.Instance.EnablePlaybackDiagnostics = false;
		DebugSettings.Instance.RecordFinalAudio = false;
		if (Directory.Exists(audioFolder))
		{
			Directory.Delete(audioFolder, recursive: true);
		}
	}

	public AudioClip GetSample()
	{
		if (cachedAudio.Count > 0)
		{
			int index = Random.Range(0, cachedAudio.Count - 1);
			AudioClip result = cachedAudio[index];
			cachedAudio.RemoveAt(index);
			return result;
		}
		while (cachedAudio.Count > 200)
		{
			cachedAudio.RemoveAt(0);
		}
		return null;
	}

	public void ClearCache()
	{
		cachedAudio.Clear();
	}
}
internal static class SkinwalkerNetworkManagerHandler
{
	internal static void ClientConnectInitializer(Scene sceneName, LoadSceneMode sceneEnum)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		if (((Scene)(ref sceneName)).name == "SampleSceneRelay")
		{
			GameObject val = new GameObject("SkinwalkerNetworkManager");
			val.AddComponent<NetworkObject>();
			val.AddComponent<SkinwalkerNetworkManager>();
			Debug.Log((object)"Initialized SkinwalkerNetworkManager");
		}
	}
}
internal class SkinwalkerNetworkManager : NetworkBehaviour
{
	public NetworkVariable<bool> VoiceEnabled_BaboonHawk = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_Bracken = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_BunkerSpider = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_Centipede = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_CoilHead = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_EyelessDog = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_ForestGiant = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_GhostGirl = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_GiantWorm = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_HoardingBug = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_Hygrodere = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_Jester = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_Masked = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_Nutcracker = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_SporeLizard = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<bool> VoiceEnabled_Thumper = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public NetworkVariable<float> VoiceLineFrequency = new NetworkVariable<float>(1f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

	public static SkinwalkerNetworkManager Instance { get; private set; }

	private void Awake()
	{
		Instance = this;
		if (GameNetworkManager.Instance.isHostingGame)
		{
			VoiceEnabled_BaboonHawk.Value = SkinwalkerConfig.VoiceEnabled_BaboonHawk.Value;
			VoiceEnabled_Bracken.Value = SkinwalkerConfig.VoiceEnabled_Bracken.Value;
			VoiceEnabled_BunkerSpider.Value = SkinwalkerConfig.VoiceEnabled_BunkerSpider.Value;
			VoiceEnabled_Centipede.Value = SkinwalkerConfig.VoiceEnabled_Centipede.Value;
			VoiceEnabled_CoilHead.Value = SkinwalkerConfig.VoiceEnabled_CoilHead.Value;
			VoiceEnabled_EyelessDog.Value = SkinwalkerConfig.VoiceEnabled_EyelessDog.Value;
			VoiceEnabled_ForestGiant.Value = SkinwalkerConfig.VoiceEnabled_ForestGiant.Value;
			VoiceEnabled_GhostGirl.Value = SkinwalkerConfig.VoiceEnabled_GhostGirl.Value;
			VoiceEnabled_GiantWorm.Value = SkinwalkerConfig.VoiceEnabled_GiantWorm.Value;
			VoiceEnabled_HoardingBug.Value = SkinwalkerConfig.VoiceEnabled_HoardingBug.Value;
			VoiceEnabled_Hygrodere.Value = SkinwalkerConfig.VoiceEnabled_Hygrodere.Value;
			VoiceEnabled_Jester.Value = SkinwalkerConfig.VoiceEnabled_Jester.Value;
			VoiceEnabled_Masked.Value = SkinwalkerConfig.VoiceEnabled_Masked.Value;
			VoiceEnabled_Nutcracker.Value = SkinwalkerConfig.VoiceEnabled_Nutcracker.Value;
			VoiceEnabled_SporeLizard.Value = SkinwalkerConfig.VoiceEnabled_SporeLizard.Value;
			VoiceEnabled_Thumper.Value = SkinwalkerConfig.VoiceEnabled_Thumper.Value;
			VoiceLineFrequency.Value = SkinwalkerConfig.VoiceLineFrequency.Value;
			SkinwalkerLogger.Log("HOST SENDING CONFIG TO CLIENTS");
		}
		SkinwalkerLogger.Log("SkinwalkerNetworkManager Awake");
	}

	public override void OnDestroy()
	{
		((NetworkBehaviour)this).OnDestroy();
		SkinwalkerLogger.Log("SkinwalkerNetworkManager OnDestroy");
		SkinwalkerModPersistent.Instance?.ClearCache();
	}

	protected override void __initializeVariables()
	{
		if (VoiceEnabled_BaboonHawk == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BaboonHawk cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_BaboonHawk).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk, "VoiceEnabled_BaboonHawk");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk);
		if (VoiceEnabled_Bracken == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Bracken cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_Bracken).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Bracken, "VoiceEnabled_Bracken");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Bracken);
		if (VoiceEnabled_BunkerSpider == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BunkerSpider cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_BunkerSpider).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider, "VoiceEnabled_BunkerSpider");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider);
		if (VoiceEnabled_Centipede == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Centipede cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_Centipede).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Centipede, "VoiceEnabled_Centipede");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Centipede);
		if (VoiceEnabled_CoilHead == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_CoilHead cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_CoilHead).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_CoilHead, "VoiceEnabled_CoilHead");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_CoilHead);
		if (VoiceEnabled_EyelessDog == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_EyelessDog cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_EyelessDog).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_EyelessDog, "VoiceEnabled_EyelessDog");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_EyelessDog);
		if (VoiceEnabled_ForestGiant == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_ForestGiant cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_ForestGiant).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_ForestGiant, "VoiceEnabled_ForestGiant");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_ForestGiant);
		if (VoiceEnabled_GhostGirl == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GhostGirl cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_GhostGirl).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GhostGirl, "VoiceEnabled_GhostGirl");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GhostGirl);
		if (VoiceEnabled_GiantWorm == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GiantWorm cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_GiantWorm).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GiantWorm, "VoiceEnabled_GiantWorm");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GiantWorm);
		if (VoiceEnabled_HoardingBug == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_HoardingBug cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_HoardingBug).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_HoardingBug, "VoiceEnabled_HoardingBug");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_HoardingBug);
		if (VoiceEnabled_Hygrodere == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Hygrodere cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_Hygrodere).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Hygrodere, "VoiceEnabled_Hygrodere");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Hygrodere);
		if (VoiceEnabled_Jester == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Jester cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_Jester).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Jester, "VoiceEnabled_Jester");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Jester);
		if (VoiceEnabled_Masked == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Masked cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_Masked).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Masked, "VoiceEnabled_Masked");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Masked);
		if (VoiceEnabled_Nutcracker == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Nutcracker cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_Nutcracker).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Nutcracker, "VoiceEnabled_Nutcracker");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Nutcracker);
		if (VoiceEnabled_SporeLizard == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_SporeLizard cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_SporeLizard).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_SporeLizard, "VoiceEnabled_SporeLizard");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_SporeLizard);
		if (VoiceEnabled_Thumper == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Thumper cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceEnabled_Thumper).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Thumper, "VoiceEnabled_Thumper");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Thumper);
		if (VoiceLineFrequency == null)
		{
			throw new Exception("SkinwalkerNetworkManager.VoiceLineFrequency cannot be null. All NetworkVariableBase instances must be initialized.");
		}
		((NetworkVariableBase)VoiceLineFrequency).Initialize((NetworkBehaviour)(object)this);
		((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceLineFrequency, "VoiceLineFrequency");
		base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceLineFrequency);
		((NetworkBehaviour)this).__initializeVariables();
	}

	protected internal override string __getTypeName()
	{
		return "SkinwalkerNetworkManager";
	}
}

plugins/Ryokune-CompatibilityChecker/Ryokune.CompatibilityChecker.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using CompatibilityChecker.MonoBehaviours;
using CompatibilityChecker.Netcode;
using CompatibilityChecker.Patches;
using CompatibilityChecker.Utils;
using HarmonyLib;
using Newtonsoft.Json;
using Steamworks;
using Steamworks.Data;
using TMPro;
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 = "")]
[assembly: AssemblyCompany("Ryokune")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Lethal Company Library that lets you know which mods a modded server has.")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("CompatibilityChecker")]
[assembly: AssemblyTitle("Ryokune.CompatibilityChecker")]
[assembly: AssemblyVersion("1.1.1.0")]
namespace CompatibilityChecker
{
	[BepInPlugin("Ryokune.CompatibilityChecker", "CompatibilityChecker", "1.1.1")]
	[BepInProcess("Lethal Company.exe")]
	public class ModNotifyBase : BaseUnityPlugin
	{
		public static ModNotifyBase instance;

		public static ManualLogSource logger;

		private readonly Harmony harmony = new Harmony("Ryokune.CompatibilityChecker");

		public static Dictionary<string, PluginInfo> ModList = new Dictionary<string, PluginInfo>();

		public static string ModListString;

		public static string[] ModListArray;

		public static bool loadedMods;

		public static string seperator = "/@/";

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
				logger = ((BaseUnityPlugin)this).Logger;
			}
			CoroutineHandler.Instance.NewCoroutine(ThunderstoreAPI.Initialize());
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Ryokune.CompatibilityChecker is loaded!");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Modded servers with CompatibilityChecker will now notify you what mods are needed.");
			harmony.PatchAll(typeof(ModNotifyBase));
			harmony.PatchAll(typeof(PlayerJoinNetcode));
			harmony.PatchAll(typeof(SteamLobbyManagerPatch));
		}

		public static IEnumerator InitializeModsCoroutine()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => ThunderstoreAPI.Packages != null));
			ModList = Chainloader.PluginInfos;
			StringBuilder messageBuilder = new StringBuilder();
			MenuManager menuManager = Object.FindObjectOfType<MenuManager>();
			PlayerJoinNetcode.old = ((((Component)((TMP_Text)menuManager.menuNotificationButtonText).transform.parent).GetComponent<RectTransform>().sizeDelta != Vector2.zero) ? ((Component)((TMP_Text)menuManager.menuNotificationButtonText).transform.parent).GetComponent<RectTransform>().sizeDelta : PlayerJoinNetcode.old);
			int i = 0;
			int count = ModList.Count();
			menuManager.menuNotification.SetActive(true);
			foreach (PluginInfo info in ModList.Values)
			{
				i++;
				((TMP_Text)menuManager.menuNotificationText).text = $"Loading mods {i}/{count}";
				((TMP_Text)menuManager.menuNotificationButtonText).text = null;
				((Component)((TMP_Text)menuManager.menuNotificationButtonText).transform.parent).GetComponent<RectTransform>().sizeDelta = Vector2.zero;
				string noSpace = Regex.Replace(info.Metadata.Name, "[\\s\\-_]", "");
				Package package = ThunderstoreAPI.GetPackage(noSpace, info);
				if (package != null)
				{
					logger.LogInfo((object)$"[{info.Metadata.GUID}] Found package: {info.Metadata.Name}[{info.Metadata.Version}]\n\t\tDATA:\n\t\t--NAME: {package.FullName}\n\t\t--LINK: {package.PackageUrl}");
					if (VersionUtil.ConvertToNumber(package.Versions[0].VersionNumber) > VersionUtil.ConvertToNumber(info.Metadata.Version.ToString()))
					{
						messageBuilder.AppendLine($"\n\t\t--Mod {info.Metadata.Name} [{info.Metadata.GUID}] v{info.Metadata.Version} does not equal the latest release!");
						messageBuilder.AppendLine("\t\t--Latest version: v" + package.Versions[0].VersionNumber);
						messageBuilder.AppendLine("\t\t--Link: " + package.PackageUrl);
						messageBuilder.AppendLine("\t\t--Full mod name: " + package.FullName);
						messageBuilder.AppendLine("\t\t--(If this is wrong, please ignore this.)");
					}
				}
				if (package?.Categories.Contains("Server-side") ?? false)
				{
					if (package.Name == "CompatibilityChecker" && package.Versions[0].VersionNumber != "1.1.1")
					{
						string warning = "Current CompatibilityChecker v1.1.1 does not equal latest release v" + package.Versions[0].VersionNumber + "!\nPlease update to the latest version of CompatibilityChecker!!!";
						logger.LogWarning((object)warning);
						Object.FindObjectOfType<MenuManager>().DisplayMenuNotification(warning, (string)null);
					}
					ModListString += $"{info.Metadata.Name}[{info.Metadata.Version}]{seperator}";
				}
				else if (package == null)
				{
					logger.LogWarning((object)$"Couldn't find package: {info.Metadata.Name}[{info.Metadata.Version}]\n\t\t[{info.Metadata.GUID}]");
					ModListString += $"{info.Metadata.GUID}[{info.Metadata.Version}]{seperator}";
				}
				yield return null;
			}
			if (messageBuilder.Length != 0)
			{
				logger.LogWarning((object)messageBuilder.ToString());
			}
			ModListString = ModListString.Remove(ModListString.Length - 3, 3);
			ModListArray = ModListString.Split(seperator);
			logger.LogWarning((object)$"Server-sided Mod List Count: {ModListArray.Count()}");
			menuManager.menuNotification.SetActive(false);
			loadedMods = true;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Ryokune.CompatibilityChecker";

		public const string PLUGIN_NAME = "CompatibilityChecker";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace CompatibilityChecker.Utils
{
	[Serializable]
	public class Package
	{
		[JsonProperty("name")]
		public string Name;

		[JsonProperty("full_name")]
		public string FullName;

		[JsonProperty("owner")]
		public string Owner;

		[JsonProperty("package_url")]
		public string PackageUrl;

		[JsonProperty("categories")]
		public string[] Categories;

		[JsonProperty("versions")]
		public Version[] Versions;

		public long TotalDownloads;

		[JsonProperty("is_deprecated")]
		public bool IsDeprecated;
	}
	[Serializable]
	public class Version
	{
		[JsonProperty("name")]
		public string Name;

		[JsonProperty("full_name")]
		public string FullName;

		[JsonProperty("version_number")]
		public string VersionNumber;

		[JsonProperty("download_url")]
		public Uri DownloadUrl;

		[JsonProperty("downloads")]
		public long Downloads;

		[JsonProperty("website_url")]
		public Uri WebsiteUrl;
	}
	public static class ThunderstoreAPI
	{
		private const string ApiBaseUrl = "https://thunderstore.io/c/lethal-company/api/v1/package/";

		private static List<Package> packages;

		public static List<Package> Packages => packages;

		public static async Task InitializeThunderstorePackagesAsync(Action onComplete)
		{
			try
			{
				using HttpClient httpClient = new HttpClient();
				packages = JsonConvert.DeserializeObject<List<Package>>(await httpClient.GetStringAsync("https://thunderstore.io/c/lethal-company/api/v1/package/"));
				ModNotifyBase.logger.LogInfo((object)$"ThunderstoreAPI Initialized! Got packages: {packages.Count()}");
				foreach (Package pack in packages)
				{
					Version[] versions = pack.Versions;
					foreach (Version ver in versions)
					{
						pack.TotalDownloads += ver.Downloads;
					}
				}
			}
			catch (Exception ex2)
			{
				Exception ex = ex2;
				ModNotifyBase.logger.LogError((object)("Failed to initialize Thunderstore packages. Error: " + ex.Message));
			}
			onComplete?.Invoke();
		}

		private static bool IsSimilar(string s1, string s2)
		{
			string pattern = string.Join(".*?", s2.ToCharArray());
			Match match = Regex.Match(s1, pattern);
			if (match.Success)
			{
				return match.Success;
			}
			int[,] array = new int[s1.Length + 1, s2.Length + 1];
			for (int i = 0; i <= s1.Length; i++)
			{
				for (int j = 0; j <= s2.Length; j++)
				{
					if (i == 0)
					{
						array[i, j] = j;
					}
					else if (j == 0)
					{
						array[i, j] = i;
					}
					else
					{
						array[i, j] = Math.Min(Math.Min(array[i - 1, j] + 1, array[i, j - 1] + 1), array[i - 1, j - 1] + ((s1[i - 1] != s2[j - 1]) ? 1 : 0));
					}
				}
			}
			int num = Math.Max(s1.Length, s2.Length);
			int num2 = array[s1.Length, s2.Length];
			double num3 = 1.0 - (double)num2 / (double)num;
			return num3 > 0.6;
		}

		private static bool IsMatchingName(Package package, string searchString)
		{
			string[] array = Regex.Split(package.Name, "(?<=[a-z])(?=[A-Z])|[\\s_\\-]");
			string[] searchStringSplit = Regex.Split(searchString, "(?<=[a-z])(?=[A-Z])|[\\s_\\-]");
			int num = ((array.Length > searchStringSplit.Length) ? (searchStringSplit.Length / 2) : (array.Length / 2));
			int num2 = array.Count((string token) => searchStringSplit.Contains<string>(token, StringComparer.OrdinalIgnoreCase));
			return num2 >= num;
		}

		private static bool IsMatchingName(Package package, string searchString, string owner)
		{
			string[] source = Regex.Split(Regex.Replace(package.Name, "[\\s_]+(\\w)", (Match m) => m.Groups[1].Value.ToUpper()).Replace(" ", ""), "(?<=[a-z])(?=[A-Z])");
			string[] searchStringNameTokens = Regex.Split(searchString, "(?<=[a-z])(?=[A-Z])");
			int num = 2;
			int num2 = source.Count((string token) => searchStringNameTokens.Contains<string>(token, StringComparer.OrdinalIgnoreCase));
			return num2 >= num && owner.Contains(package.Owner, StringComparison.OrdinalIgnoreCase);
		}

		public static List<Package> GetPackages(string searchString)
		{
			return Packages?.Where((Package package) => IsMatchingName(package, searchString)).ToList();
		}

		public static List<Package> GetPackages(string searchString, string owner)
		{
			return Packages?.Where((Package package) => IsMatchingName(package, searchString, owner)).ToList();
		}

		public static Package GetPackage(string searchString)
		{
			return Packages?.FirstOrDefault((Package package) => package.Name == searchString);
		}

		public static Package GetPackage(string searchString, PluginInfo info)
		{
			Package result = null;
			bool flag = false;
			foreach (Package package in Packages)
			{
				if (package.IsDeprecated)
				{
					continue;
				}
				if (info.Metadata.GUID.Split(".").Contains(package.Owner))
				{
					flag = true;
				}
				string text = Regex.Replace(package.Name, "[\\s\\-_]", "");
				if (text.Equals(searchString, StringComparison.OrdinalIgnoreCase) || text.Equals(info.Metadata.Name, StringComparison.OrdinalIgnoreCase) || text.Equals(info.Metadata.GUID, StringComparison.OrdinalIgnoreCase))
				{
					if (flag)
					{
						return package;
					}
					result = package;
				}
				if (searchString.Contains(text, StringComparison.OrdinalIgnoreCase) || text.Contains(searchString, StringComparison.OrdinalIgnoreCase) || text.Contains(info.Metadata.Name, StringComparison.OrdinalIgnoreCase) || text.Contains(info.Metadata.GUID, StringComparison.OrdinalIgnoreCase))
				{
					result = package;
				}
				if (IsSimilar(package.Name, searchString))
				{
					result = package;
				}
			}
			return result;
		}

		public static IEnumerator Initialize(Action onComplete = null)
		{
			yield return InitializeThunderstorePackagesAsync(onComplete);
		}
	}
	internal static class VersionUtil
	{
		public static int ConvertToNumber(string version)
		{
			string s = version.Replace(".", "");
			if (int.TryParse(s, out var result))
			{
				return result;
			}
			ModNotifyBase.logger.LogWarning((object)("Error parsing version: " + version));
			return 0;
		}
	}
}
namespace CompatibilityChecker.Patches
{
	internal class SteamLobbyManagerPatch
	{
		[HarmonyPatch(typeof(SteamLobbyManager), "LoadServerList")]
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "me.swipez.melonloader.morecompany" })]
		public static void loadserverListPatch(ref SteamLobbyManager __instance, ref Lobby[] ___currentLobbyList)
		{
			CoroutineHandler.Instance.NewCoroutine(BetterCompatibility(__instance));
		}

		public static IEnumerator BetterCompatibility(SteamLobbyManager lobbyManager)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => ((Transform)((Component)lobbyManager.levelListContainer).GetComponent<RectTransform>()).childCount - 1 != 0 && ((Transform)((Component)lobbyManager.levelListContainer).GetComponent<RectTransform>()).childCount - 1 == Object.FindObjectsOfType(typeof(LobbySlot)).Length && !GameNetworkManager.Instance.waitingForLobbyDataRefresh));
			LobbySlot[] array = (LobbySlot[])(object)Object.FindObjectsOfType(typeof(LobbySlot));
			foreach (LobbySlot slot in array)
			{
				Lobby lobby = slot.thisLobby;
				if (!Utility.IsNullOrWhiteSpace(((Lobby)(ref lobby)).GetData("mods")) && !((TMP_Text)slot.LobbyName).text.Contains("[Checker]"))
				{
					((TMP_Text)slot.LobbyName).text = ((TMP_Text)slot.LobbyName).text + " [Checker]";
				}
				lobby = default(Lobby);
			}
			RectTransform rect = ((Component)lobbyManager.levelListContainer).GetComponent<RectTransform>();
			float newWidth = rect.sizeDelta.x;
			float newHeight = Mathf.Max(0f, (float)(((Transform)rect).childCount - 1) * 42f);
			rect.SetSizeWithCurrentAnchors((Axis)0, newWidth);
			rect.SetSizeWithCurrentAnchors((Axis)1, newHeight);
		}

		[HarmonyPatch(typeof(SteamLobbyManager), "loadLobbyListAndFilter")]
		[HarmonyAfter(new string[] { "me.swipez.melonloader.morecompany" })]
		[HarmonyPrefix]
		public static bool loadLobbyPrefixPatch(ref SteamLobbyManager __instance, ref Lobby[] ___currentLobbyList, ref float ___lobbySlotPositionOffset, ref IEnumerator __result)
		{
			__result = modifiedLoadLobbyIEnumerator(__instance, ___currentLobbyList, ___lobbySlotPositionOffset);
			return false;
		}

		public static IEnumerator modifiedLoadLobbyIEnumerator(SteamLobbyManager __instance, Lobby[] ___currentLobbyList, float ___lobbySlotPositionOffset)
		{
			string[] offensiveWords = new string[21]
			{
				"nigger", "faggot", "n1g", "nigers", "cunt", "pussies", "pussy", "minors", "chink", "buttrape",
				"molest", "rape", "coon", "negro", "beastiality", "cocks", "cumshot", "ejaculate", "pedophile", "furfag",
				"necrophilia"
			};
			for (int i = 0; i < ___currentLobbyList.Length; i++)
			{
				Lobby currentLobby = ___currentLobbyList[i];
				Friend[] blockedUsers = SteamFriends.GetBlocked().ToArray();
				if (blockedUsers != null)
				{
					Friend[] array = blockedUsers;
					for (int j = 0; j < array.Length; j++)
					{
						Friend blockedUser = array[j];
						if (((Lobby)(ref currentLobby)).IsOwnedBy(blockedUser.Id))
						{
						}
					}
				}
				string lobbyName = ((Lobby)(ref currentLobby)).GetData("name");
				bool lobbyModded = !Utility.IsNullOrWhiteSpace(((Lobby)(ref currentLobby)).GetData("mods"));
				if (!Utility.IsNullOrWhiteSpace(lobbyName))
				{
					string lobbyNameLowercase = lobbyName.ToLower();
					if (__instance.censorOffensiveLobbyNames)
					{
						string[] array2 = offensiveWords;
						foreach (string word in array2)
						{
							if (lobbyNameLowercase.Contains(word))
							{
							}
						}
					}
					GameObject gameObject = Object.Instantiate<GameObject>(__instance.LobbySlotPrefab, __instance.levelListContainer);
					gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, ___lobbySlotPositionOffset);
					___lobbySlotPositionOffset -= 42f;
					LobbySlot componentInChildren = gameObject.GetComponentInChildren<LobbySlot>();
					((TMP_Text)componentInChildren.LobbyName).text = lobbyName + " " + (lobbyModded ? "[Checker]" : "");
					((TMP_Text)componentInChildren.playerCount).text = $"{((Lobby)(ref currentLobby)).MemberCount} / 4";
					componentInChildren.lobbyId = ((Lobby)(ref currentLobby)).Id;
					componentInChildren.thisLobby = currentLobby;
				}
				currentLobby = default(Lobby);
			}
			yield break;
		}
	}
}
namespace CompatibilityChecker.Netcode
{
	[HarmonyPatch]
	internal class PlayerJoinNetcode
	{
		private static string[] serverModList = null;

		public static Vector2 old = Vector2.zero;

		public static IEnumerator SetLobbyData(Lobby lobby)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (GameNetworkManager.Instance.currentLobby.HasValue)
			{
				((Lobby)(ref lobby)).SetData("mods", ModNotifyBase.ModListString);
				ModNotifyBase.logger.LogInfo((object)("Set " + ((Lobby)(ref lobby)).GetData("name") + " mods to: " + ModNotifyBase.ModListString));
			}
			yield break;
		}

		[HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyCreated")]
		[HarmonyPrefix]
		public static bool OnLobbyCreated(ref GameNetworkManager __instance, Result result, ref Lobby lobby)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if ((int)result == 1)
			{
				CoroutineHandler.Instance.NewCoroutine(SetLobbyData(lobby));
			}
			return true;
		}

		[HarmonyPatch(typeof(GameNetworkManager), "StartHost")]
		[HarmonyPrefix]
		public static bool StartHost(ref GameNetworkManager __instance)
		{
			if (!ModNotifyBase.loadedMods)
			{
				CoroutineHandler.Instance.NewCoroutine(Connect());
				CoroutineHandler.Instance.NewCoroutine(ModNotifyBase.InitializeModsCoroutine());
				return false;
			}
			return true;
		}

		public static IEnumerator Connect()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => ModNotifyBase.loadedMods));
			GameNetworkManager.Instance.StartHost();
		}

		[HarmonyPatch(typeof(GameNetworkManager), "LobbyDataIsJoinable")]
		[HarmonyPrefix]
		public static bool IsJoinable(ref Lobby lobby)
		{
			string data = ((Lobby)(ref lobby)).GetData("mods");
			if (!Utility.IsNullOrWhiteSpace(data))
			{
				serverModList = data.Split(ModNotifyBase.seperator);
				ModNotifyBase.logger.LogWarning((object)(((Lobby)(ref lobby)).GetData("name") + " returned:"));
				try
				{
					string[] array = serverModList;
					foreach (string text in array)
					{
						string text2 = (Regex.Match(text, "\\[([\\d.]+)\\]").Success ? ("v" + Regex.Match(text, "\\[([\\d.]+)\\]").Value) : "No version number found");
						string text3 = "";
						if (Chainloader.PluginInfos.ContainsKey(text))
						{
							PluginInfo obj = Chainloader.PluginInfos[text];
							object obj2;
							if (obj == null)
							{
								obj2 = null;
							}
							else
							{
								BepInPlugin metadata = obj.Metadata;
								obj2 = ((metadata == null) ? null : metadata.Version?.ToString());
							}
							text3 = (string)obj2;
						}
						string text4 = text;
						string text5 = ((!Utility.IsNullOrWhiteSpace(text3) && !text2.Equals(text3)) ? (" (May be incompatible with your version v" + text3 + ")") : "");
						Package package = ThunderstoreAPI.GetPackage(text);
						if (package != null)
						{
							text4 = text + " " + text2 + text5;
						}
						ModNotifyBase.logger.LogWarning((object)text4);
					}
				}
				catch (Exception ex)
				{
					ModNotifyBase.logger.LogError((object)ex);
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")]
		[HarmonyPostfix]
		public static void JoinLobbyPostfix()
		{
			if (ModNotifyBase.ModList.Count == 0)
			{
				CoroutineHandler.Instance.NewCoroutine(ModNotifyBase.InitializeModsCoroutine());
			}
		}

		[HarmonyPatch(typeof(MenuManager), "SetLoadingScreen")]
		[HarmonyPostfix]
		public static void SetLoadingScreenPatch(ref MenuManager __instance, ref RoomEnter result, ref bool isLoading, ref string overrideMessage)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			if (old == Vector2.zero)
			{
				old = ((Component)((TMP_Text)__instance.menuNotificationButtonText).transform.parent).GetComponent<RectTransform>().sizeDelta;
			}
			if ((int)result != 5 || !Utility.IsNullOrWhiteSpace(overrideMessage))
			{
				((Component)((TMP_Text)__instance.menuNotificationButtonText).transform.parent).GetComponent<RectTransform>().sizeDelta = old;
				return;
			}
			((Component)((TMP_Text)__instance.menuNotificationButtonText).transform.parent).GetComponent<RectTransform>().sizeDelta = old;
			Package package = ThunderstoreAPI.GetPackage("CompatibilityChecker");
			bool flag = package.Versions[0].VersionNumber != "1.1.1";
			string text = (flag ? ("New CompatibilityChecker update is available! v" + package.Versions[0].VersionNumber + " != 1.1.1") : "[ Close ]");
			if (flag & !isLoading)
			{
				((Component)((TMP_Text)__instance.menuNotificationButtonText).transform.parent).GetComponent<RectTransform>().sizeDelta = new Vector2(256.375f, 58.244f);
			}
			if (ModNotifyBase.ModList.Count == 0)
			{
				CoroutineHandler.Instance.NewCoroutine(ModNotifyBase.InitializeModsCoroutine());
			}
			if (Utility.IsNullOrWhiteSpace(overrideMessage) && Utility.IsNullOrWhiteSpace(GameNetworkManager.Instance.disconnectionReasonMessage) && !isLoading)
			{
				if (serverModList == null)
				{
					__instance.DisplayMenuNotification("Failed to join Modded Crew!\n Missing mods:\nCan't display: Host does not have CompatibilityChecker!", text);
				}
				else
				{
					GameNetworkManager instance = GameNetworkManager.Instance;
					object obj;
					if (instance == null)
					{
						obj = null;
					}
					else
					{
						Lobby value = instance.currentLobby.Value;
						obj = ((Lobby)(ref value)).GetData("name");
					}
					string text2 = (string)obj;
					string[] array = serverModList.Except(ModNotifyBase.ModListArray).ToArray();
					string[] array2 = ModNotifyBase.ModListArray.Except(serverModList).ToArray();
					string text3 = ((array == null || array.Length == 0) ? "None..?" : string.Join("\n", array));
					string text4 = ((array2 == null || array2.Length == 0) ? "None." : string.Join("\n\t\t", array2));
					__instance.DisplayMenuNotification("Modded crew\n(Check logs/console for links)!\n Missing mods:\n" + text3, text);
					ModNotifyBase.logger.LogError((object)("\nMissing server-sided mods from lobby \"" + text2 + "\":"));
					string[] array3 = array;
					foreach (string text5 in array3)
					{
						string text6 = text5;
						Package package2 = ThunderstoreAPI.GetPackage(text5);
						if (package2 != null)
						{
							text6 = string.Format("\n\t--Name: {0}\n\t--Link: {1}\n\t--Downloads: {2}\n\t--Categories: [{3}]", text5, package2.PackageUrl, package2.Versions[0].Downloads, string.Join(", ", package2.Categories));
						}
						ModNotifyBase.logger.LogError((object)text6);
					}
					ModNotifyBase.logger.LogWarning((object)("Mods \"" + text2 + "\" may not be compatible with:\n\t\t" + text4));
					serverModList = null;
				}
			}
			if (flag)
			{
				ModNotifyBase.logger.LogWarning((object)("NEW VERSION OF COMPATIBILITY CHECKER IS AVAILABE. PLEASE UPDATE TO " + package.Versions[0].VersionNumber));
			}
		}

		[HarmonyPatch(typeof(MenuManager), "connectionTimeOut")]
		[HarmonyPostfix]
		public static void timeoutPatch()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (GameNetworkManager.Instance.currentLobby.HasValue && serverModList == null)
			{
				Lobby value = GameNetworkManager.Instance.currentLobby.Value;
				serverModList = ((Lobby)(ref value)).GetData("mods")?.Split(ModNotifyBase.seperator);
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "Singleton_OnClientConnectedCallback")]
		[HarmonyPostfix]
		public static void ConnectCallbackPatch()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			Lobby? currentLobby = GameNetworkManager.Instance.currentLobby;
			if ((Object)(object)StartOfRound.Instance != (Object)null && currentLobby.HasValue)
			{
				Lobby value = currentLobby.Value;
				if (Utility.IsNullOrWhiteSpace(((Lobby)(ref value)).GetData("mods")))
				{
					ModNotifyBase.logger.LogInfo((object)"Setting lobbys mods");
					CoroutineHandler.Instance.NewCoroutine(SetLobbyData(currentLobby.Value));
				}
			}
		}
	}
}
namespace CompatibilityChecker.MonoBehaviours
{
	internal class CoroutineHandler : MonoBehaviour
	{
		private static CoroutineHandler instance;

		private List<Type> runningCoroutines = new List<Type>();

		public static CoroutineHandler Instance
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)instance == (Object)null)
				{
					GameObject val = new GameObject("CoroutineHandler");
					instance = val.AddComponent<CoroutineHandler>();
					Object.DontDestroyOnLoad((Object)(object)val);
				}
				return instance;
			}
		}

		public void NewCoroutine(IEnumerator coroutine)
		{
			if (!IsCoroutineRunning(coroutine.GetType()))
			{
				runningCoroutines.Add(coroutine.GetType());
				((MonoBehaviour)this).StartCoroutine(ExecuteCoroutine(coroutine));
			}
			else
			{
				ModNotifyBase.logger.LogWarning((object)("Coroutine " + coroutine.GetType().FullName + " is already running"));
			}
		}

		private bool IsCoroutineRunning(Type coroutine)
		{
			return runningCoroutines.Any((Type runningCoroutine) => runningCoroutine == coroutine);
		}

		private IEnumerator ExecuteCoroutine(IEnumerator coroutine)
		{
			yield return ((MonoBehaviour)this).StartCoroutine(coroutine);
			runningCoroutines.Remove(coroutine.GetType());
		}
	}
}

plugins/Sligili-More_Emotes/MoreEmotes1.2.0.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using MoreEmotes.Patch;
using Tools;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FuckYouMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FuckYouMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5ecc2bf2-af12-4e83-a6f1-cf2eacbf3060")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Tools
{
	public class Reflection
	{
		public static object GetInstanceField(Type type, object instance, string fieldName)
		{
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
			FieldInfo field = type.GetField(fieldName, bindingAttr);
			return field.GetValue(instance);
		}

		public static object CallMethod(object instance, string methodName, params object[] args)
		{
			MethodInfo method = instance.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
			if (method != null)
			{
				return method.Invoke(instance, args);
			}
			return null;
		}
	}
}
namespace MoreEmotes
{
	[BepInPlugin("MoreEmotes", "MoreEmotes-Sligili", "1.2.0")]
	public class FuckYouModInitialization : BaseUnityPlugin
	{
		private Harmony _harmony;

		private ConfigEntry<string> config_KeyWheel;

		private ConfigEntry<bool> config_InventoryCheck;

		private ConfigEntry<string> config_KeyEmote3;

		private ConfigEntry<string> config_KeyEmote4;

		private ConfigEntry<string> config_KeyEmote5;

		private ConfigEntry<string> config_KeyEmote6;

		private ConfigEntry<string> config_KeyEmote7;

		private ConfigEntry<string> config_KeyEmote8;

		private ConfigEntry<bool> config_toggleEmote3;

		private ConfigEntry<bool> config_toggleEmote4;

		private ConfigEntry<bool> config_toggleEmote5;

		private ConfigEntry<bool> config_toggleEmote6;

		private ConfigEntry<bool> config_toggleEmote7;

		private ConfigEntry<bool> config_toggleEmote8;

		private void Awake()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MoreEmotes loaded");
			EmotePatch.animationsBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MoreEmotes/animationsbundle"));
			EmotePatch.animatorBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MoreEmotes/animatorbundle"));
			EmotePatch.local = EmotePatch.animatorBundle.LoadAsset<RuntimeAnimatorController>("Assets/MoreEmotes/NEWmetarig.controller");
			EmotePatch.others = EmotePatch.animatorBundle.LoadAsset<RuntimeAnimatorController>("Assets/MoreEmotes/NEWmetarigOtherPlayers.controller");
			CustomAudioAnimationEvent.claps[0] = EmotePatch.animationsBundle.LoadAsset<AudioClip>("Assets/MoreEmotes/SingleClapEmote1.wav");
			CustomAudioAnimationEvent.claps[1] = EmotePatch.animationsBundle.LoadAsset<AudioClip>("Assets/MoreEmotes/SingleClapEmote2.wav");
			ConfigFile();
			IncompatibilityAids();
			_harmony = new Harmony("MoreEmotes");
			_harmony.PatchAll(typeof(EmotePatch));
		}

		private void IncompatibilityAids()
		{
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				BepInPlugin metadata = pluginInfo.Value.Metadata;
				if (metadata.GUID.Equals("com.malco.lethalcompany.moreshipupgrades") || metadata.GUID.Equals("Stoneman.LethalProgression"))
				{
					EmotePatch.IncompatibleStuff = true;
					break;
				}
			}
		}

		private void ConfigFile()
		{
			EmotePatch.keybinds = new string[8];
			config_KeyWheel = ((BaseUnityPlugin)this).Config.Bind<string>("EMOTE WHEEL", "Key", "v", "SUPPORTED KEYS A-Z | 0-9 | F1-F12 ");
			EmotePatch.wheelKeybind = config_KeyWheel.Value;
			config_InventoryCheck = ((BaseUnityPlugin)this).Config.Bind<bool>("OTHERS", "InventoryCheck", true, "Prevents some emotes from performing while holding any item/scrap");
			EmotePatch.InvCheck = config_InventoryCheck.Value;
			config_KeyEmote3 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Middle Finger", "3", "MIDDLEFINGER: SUPPORTED KEYS A-Z | 0-9 | F1-F12 ");
			config_toggleEmote3 = ((BaseUnityPlugin)this).Config.Bind<bool>("QUICK EMOTES", "Enable Middle Finger", true, "ENABLE QUICK MIDDLEFINGER");
			EmotePatch.keybinds[2] = (config_toggleEmote3.Value ? config_KeyEmote3.Value : "/");
			EmotePatch.enable3 = config_toggleEmote3.Value;
			config_KeyEmote4 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "The Griddy", "6", "THE GRIDDY: SUPPORTED KEYS A-Z | 0-9 | F1-F12 ");
			config_toggleEmote4 = ((BaseUnityPlugin)this).Config.Bind<bool>("QUICK EMOTES", "Enable The Griddy", true, "ENABLE QUICK THE GRIDDY");
			EmotePatch.keybinds[5] = (config_toggleEmote4.Value ? config_KeyEmote4.Value : "/");
			EmotePatch.enable4 = config_toggleEmote4.Value;
			config_KeyEmote5 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Shy", "5", "SHY: SUPPORTED KEYS A-Z | 0-9 | F1-F12 ");
			config_toggleEmote5 = ((BaseUnityPlugin)this).Config.Bind<bool>("QUICK EMOTES", "Enable Shy", true, "ENABLE QUICK SHY");
			EmotePatch.keybinds[4] = (config_toggleEmote5.Value ? config_KeyEmote5.Value : "/");
			EmotePatch.enable5 = config_toggleEmote5.Value;
			config_KeyEmote6 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Clap", "4", "CLAP: SUPPORTED KEYS A-Z | 0-9 | F1-F12 ");
			config_toggleEmote6 = ((BaseUnityPlugin)this).Config.Bind<bool>("QUICK EMOTES", "Enable Clap", true, "ENABLE QUICK CLAP");
			EmotePatch.keybinds[3] = (config_toggleEmote6.Value ? config_KeyEmote6.Value : "/");
			EmotePatch.enable6 = config_toggleEmote6.Value;
			config_KeyEmote7 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Twerk", "7", "TWERK: SUPPORTED KEYS A-Z | 0-9 | F1-F12 ");
			config_toggleEmote7 = ((BaseUnityPlugin)this).Config.Bind<bool>("QUICK EMOTES", "Enable Twerk", true, "ENABLE QUICK TWERK");
			EmotePatch.keybinds[6] = (config_toggleEmote7.Value ? config_KeyEmote7.Value : "/");
			EmotePatch.enable7 = config_toggleEmote7.Value;
			config_KeyEmote8 = ((BaseUnityPlugin)this).Config.Bind<string>("QUICK EMOTES", "Salute", "8", "SALUTE: SUPPORTED KEYS A-Z | 0-9 | F1-F12 ");
			config_toggleEmote8 = ((BaseUnityPlugin)this).Config.Bind<bool>("QUICK EMOTES", "Enable Salute", true, "ENABLE QUICK SALUTE");
			EmotePatch.keybinds[7] = (config_toggleEmote8.Value ? config_KeyEmote8.Value : "/");
			EmotePatch.enable8 = config_toggleEmote8.Value;
		}
	}
	public static class PluginInfo
	{
		public const string Guid = "MoreEmotes";

		public const string Name = "MoreEmotes-Sligili";

		public const string Ver = "1.2.0";
	}
}
namespace MoreEmotes.Patch
{
	internal class EmotePatch
	{
		public static AssetBundle animationsBundle;

		public static AssetBundle animatorBundle;

		public static bool enable3;

		public static bool enable4;

		public static bool enable5;

		public static bool enable6;

		public static bool enable7;

		public static bool enable8;

		public static string[] keybinds;

		public static string wheelKeybind;

		private static CallbackContext context;

		public static RuntimeAnimatorController local;

		public static RuntimeAnimatorController others;

		private static int currentEmoteID;

		private static float svMovSpeed;

		public static bool IncompatibleStuff;

		public static bool InvCheck;

		public static bool emoteWheelIsOpened;

		public static GameObject wheel;

		private static SelectionWheel selectionWheel;

		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPostfix]
		private static void StartPostfix(PlayerControllerB __instance)
		{
			GameObject gameObject = ((Component)((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel")).transform.Find("metarig")).gameObject;
			CustomAudioAnimationEvent customAudioAnimationEvent = gameObject.AddComponent<CustomAudioAnimationEvent>();
			svMovSpeed = __instance.movementSpeed;
			customAudioAnimationEvent.player = __instance;
			if (Object.FindObjectsOfType(typeof(SelectionWheel)).Length == 0)
			{
				GameObject val = animationsBundle.LoadAsset<GameObject>("Assets/MoreEmotes/Resources/MoreEmotesMenu.prefab");
				GameObject gameObject2 = ((Component)((Component)GameObject.Find("Systems").gameObject.transform.Find("UI")).gameObject.transform.Find("Canvas")).gameObject;
				if ((Object)(object)wheel != (Object)null)
				{
					Object.Destroy((Object)(object)wheel.gameObject);
				}
				wheel = Object.Instantiate<GameObject>(val, gameObject2.transform);
				selectionWheel = wheel.AddComponent<SelectionWheel>();
				SelectionWheel.emotes_Keybinds = new string[keybinds.Length + 1];
				SelectionWheel.emotes_Keybinds = keybinds;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void UpdatePostfix(PlayerControllerB __instance)
		{
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.isPlayerControlled || !((NetworkBehaviour)__instance).IsOwner)
			{
				__instance.playerBodyAnimator.runtimeAnimatorController = others;
				return;
			}
			if ((Object)(object)__instance.playerBodyAnimator != (Object)(object)local)
			{
				__instance.playerBodyAnimator.runtimeAnimatorController = local;
			}
			if (__instance.performingEmote)
			{
				currentEmoteID = __instance.playerBodyAnimator.GetInteger("emoteNumber");
			}
			if (!IncompatibleStuff)
			{
				bool flag = (bool)Reflection.CallMethod(__instance, "CheckConditionsForEmote") && currentEmoteID == 6 && __instance.performingEmote;
				__instance.movementSpeed = (flag ? (svMovSpeed / 2f) : svMovSpeed);
			}
			if (InputControlExtensions.IsPressed(((InputControl)Keyboard.current)[wheelKeybind], 0f) && !emoteWheelIsOpened && !__instance.isPlayerDead && !__instance.inTerminalMenu && !__instance.quickMenuManager.isMenuOpen)
			{
				emoteWheelIsOpened = true;
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)2;
				wheel.SetActive(emoteWheelIsOpened);
				__instance.disableLookInput = true;
			}
			else if ((!InputControlExtensions.IsPressed(((InputControl)Keyboard.current)[wheelKeybind], 0f) && emoteWheelIsOpened) || __instance.quickMenuManager.isMenuOpen)
			{
				if (!__instance.quickMenuManager.isMenuOpen || __instance.isPlayerDead)
				{
					int selectedEmoteID = selectionWheel.selectedEmoteID;
					if (selectedEmoteID <= 3 || selectedEmoteID == 6 || !InvCheck)
					{
						__instance.PerformEmote(context, selectedEmoteID);
					}
					else if (!__instance.isHoldingObject)
					{
						__instance.PerformEmote(context, selectedEmoteID);
					}
					Cursor.visible = false;
					Cursor.lockState = (CursorLockMode)1;
				}
				if (__instance.isPlayerDead && !__instance.quickMenuManager.isMenuOpen)
				{
					Cursor.visible = false;
					Cursor.lockState = (CursorLockMode)1;
				}
				__instance.disableLookInput = false;
				emoteWheelIsOpened = false;
				wheel.SetActive(emoteWheelIsOpened);
			}
			if (!__instance.performingEmote || currentEmoteID == 7)
			{
			}
			if (!emoteWheelIsOpened)
			{
				EmoteInput(keybinds[2], enable3, needsEmptyHands: false, 3, __instance);
				EmoteInput(keybinds[3], enable6, needsEmptyHands: true, 4, __instance);
				EmoteInput(keybinds[4], enable5, needsEmptyHands: true, 5, __instance);
				EmoteInput(keybinds[5], enable4, needsEmptyHands: false, 6, __instance);
				EmoteInput(keybinds[6], enable7, needsEmptyHands: true, 7, __instance);
				EmoteInput(keybinds[7], enable8, needsEmptyHands: true, 8, __instance);
			}
		}

		private static void EmoteInput(string keyBind, bool enabled, bool needsEmptyHands, int emoteID, PlayerControllerB player)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (InputControlExtensions.IsPressed(((InputControl)Keyboard.current)[keyBind], 0f) && enabled && (!player.isHoldingObject || !needsEmptyHands || !InvCheck) && (!player.performingEmote || currentEmoteID != emoteID))
			{
				player.PerformEmote(context, emoteID);
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "CheckConditionsForEmote")]
		[HarmonyPrefix]
		private static bool prefixCheckConditions(ref bool __result, PlayerControllerB __instance)
		{
			bool flag = (bool)Reflection.GetInstanceField(typeof(PlayerControllerB), __instance, "isJumping");
			if (currentEmoteID == 6)
			{
				__result = !__instance.inSpecialInteractAnimation && !__instance.isPlayerDead && !flag && __instance.moveInputVector.x == 0f && !__instance.isSprinting && !__instance.isCrouching && !__instance.isClimbingLadder && !__instance.isGrabbingObjectAnimation && !__instance.inTerminalMenu && !__instance.isTypingChat;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "PerformEmote")]
		[HarmonyPrefix]
		private static void PerformEmotePrefix(CallbackContext context, int emoteID, PlayerControllerB __instance)
		{
			if ((emoteID >= 3 || emoteWheelIsOpened || ((CallbackContext)(ref context)).performed) && ((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer) && (bool)Reflection.CallMethod(__instance, "CheckConditionsForEmote") && !(__instance.timeSinceStartingEmote < 0.5f))
			{
				__instance.timeSinceStartingEmote = 0f;
				__instance.performingEmote = true;
				__instance.playerBodyAnimator.SetInteger("emoteNumber", emoteID);
				__instance.StartPerformingEmoteServerRpc();
			}
		}
	}
	public class CustomAudioAnimationEvent : MonoBehaviour
	{
		private Animator animator;

		private AudioSource SoundsSource;

		public static AudioClip[] claps = (AudioClip[])(object)new AudioClip[2];

		public PlayerControllerB player;

		private void Start()
		{
			animator = ((Component)this).GetComponent<Animator>();
			SoundsSource = player.movementAudio;
		}

		public void PlayClapSound()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (player.performingEmote && (!((NetworkBehaviour)player).IsOwner || !player.isPlayerControlled || animator.GetInteger("emoteNumber") == 4))
			{
				bool flag = player.isInHangarShipRoom && player.playersManager.hangarDoorsClosed;
				RoundManager.Instance.PlayAudibleNoise(((Component)player).transform.position, 22f, 0.6f, 0, flag, 6);
				SoundsSource.pitch = Random.Range(0.59f, 0.79f);
				SoundsSource.PlayOneShot(claps[Random.Range(0, claps.Length)]);
			}
		}

		public void PlayFootstepSound()
		{
			if (player.performingEmote && (!((NetworkBehaviour)player).IsOwner || !player.isPlayerControlled || animator.GetInteger("emoteNumber") == 6 || animator.GetInteger("emoteNumber") == 8) && ((Vector2)(ref player.moveInputVector)).sqrMagnitude == 0f)
			{
				player.PlayFootstepLocal();
				player.PlayFootstepServer();
			}
		}
	}
	public enum Emotes
	{
		Dance_1 = 1,
		Point,
		Middle_Finger,
		Clap,
		Shy,
		The_Griddy,
		Twerk,
		Salute
	}
	public class SelectionWheel : MonoBehaviour
	{
		public RectTransform selectionBlock;

		public Text emoteInformation;

		public Text pageInformation;

		private int blocksNumber = 8;

		private int currentBlock = 1;

		public int pageNumber;

		public int selectedEmoteID;

		private float angle;

		private float pageCooldown = 0.1f;

		public GameObject[] Pages;

		private int cuadrante = 0;

		public string selectedEmoteName;

		public float wheelMovementOffset = 3.3f;

		public static string[] emotes_Keybinds;

		private Vector2 center;

		private void OnEnable()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			center = new Vector2((float)(Screen.width / 2), (float)(Screen.height / 2));
			PlayerInput component = GameObject.Find("PlayerSettingsObject").GetComponent<PlayerInput>();
			emotes_Keybinds[0] = InputActionRebindingExtensions.GetBindingDisplayString(component.currentActionMap.FindAction("Emote1", false), 0, (DisplayStringOptions)0);
			emotes_Keybinds[1] = InputActionRebindingExtensions.GetBindingDisplayString(component.currentActionMap.FindAction("Emote2", false), 0, (DisplayStringOptions)0);
			Cursor.visible = true;
			selectionBlock = ((Component)((Component)this).gameObject.transform.Find("SelectedEmote")).gameObject.GetComponent<RectTransform>();
			GameObject gameObject = ((Component)((Component)this).gameObject.transform.Find("FunctionalContent")).gameObject;
			emoteInformation = ((Component)((Component)((Component)this).gameObject.transform.Find("Graphics")).gameObject.transform.Find("EmoteInfo")).GetComponent<Text>();
			Pages = (GameObject[])(object)new GameObject[gameObject.transform.childCount];
			pageInformation = ((Component)((Component)((Component)this).gameObject.transform.Find("Graphics")).gameObject.transform.Find("PageNumber")).GetComponent<Text>();
			pageInformation.text = "Page " + Pages.Length + "/" + (pageNumber + 1);
			for (int i = 0; i < gameObject.transform.childCount; i++)
			{
				Pages[i] = ((Component)gameObject.transform.GetChild(i)).gameObject;
			}
			Mouse.current.WarpCursorPosition(center);
		}

		private void Update()
		{
			wheelSelection();
			pageSelection();
			selectedEmoteID = currentBlock + Mathf.RoundToInt((float)(blocksNumber / 4)) + blocksNumber * pageNumber;
			displayEmoteInfo();
		}

		private void wheelSelection()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			if (!(Vector2.Distance(center, ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue()) < wheelMovementOffset))
			{
				bool flag = ((InputControl<float>)(object)((Pointer)Mouse.current).position.x).ReadValue() > center.x;
				bool flag2 = ((InputControl<float>)(object)((Pointer)Mouse.current).position.y).ReadValue() > center.y;
				cuadrante = ((!flag) ? (flag2 ? 2 : 3) : (flag2 ? 1 : 4));
				float num = (((InputControl<float>)(object)((Pointer)Mouse.current).position.y).ReadValue() - center.y) / (((InputControl<float>)(object)((Pointer)Mouse.current).position.x).ReadValue() - center.x);
				float num2 = 180 * (cuadrante - ((cuadrante <= 2) ? 1 : 2));
				angle = Mathf.Atan(num) * (180f / (float)Math.PI) + num2;
				if (angle == 90f)
				{
					angle = 270f;
				}
				else if (angle == 270f)
				{
					angle = 90f;
				}
				float num3 = 360 / blocksNumber;
				currentBlock = Mathf.RoundToInt((angle - num3 * 1.5f) / num3);
				((Transform)selectionBlock).localRotation = Quaternion.Euler(((Component)this).transform.rotation.z, ((Component)this).transform.rotation.y, num3 * (float)currentBlock);
			}
		}

		private void pageSelection()
		{
			pageInformation.text = "Page " + Pages.Length + "/" + (pageNumber + 1);
			if (pageCooldown > 0f)
			{
				pageCooldown -= Time.deltaTime;
			}
			else if (((InputControl<float>)(object)((Vector2Control)Mouse.current.scroll).y).ReadValue() != 0f)
			{
				GameObject[] pages = Pages;
				foreach (GameObject val in pages)
				{
					val.SetActive(false);
				}
				int num = ((((InputControl<float>)(object)((Vector2Control)Mouse.current.scroll).y).ReadValue() > 0f) ? 1 : (-1));
				if (pageNumber + 1 > Pages.Length - 1 && num > 0)
				{
					pageNumber = 0;
				}
				else if (pageNumber - 1 < 0 && num < 0)
				{
					pageNumber = Pages.Length - 1;
				}
				else
				{
					pageNumber += num;
				}
				Pages[pageNumber].SetActive(true);
				pageCooldown = 0.1f;
			}
		}

		private void displayEmoteInfo()
		{
			string text = ((selectedEmoteID > emotes_Keybinds.Length) ? "" : emotes_Keybinds[selectedEmoteID - 1]);
			object obj;
			if (selectedEmoteID <= Enum.GetValues(typeof(Emotes)).Length)
			{
				Emotes emotes = (Emotes)selectedEmoteID;
				obj = emotes.ToString().Replace("_", " ");
			}
			else
			{
				obj = "EMPTY";
			}
			string text2 = (string)obj;
			emoteInformation.text = text2 + "\n[" + text.ToUpper() + "]";
		}
	}
}

plugins/tinyhoot-ShipLoot/ShipLoot/ShipLoot.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ShipLoot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("ShipLoot")]
[assembly: AssemblyCopyright("Copyright © tinyhoot 2023")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ShipLoot
{
	[BepInPlugin("com.github.tinyhoot.ShipLoot", "ShipLoot", "1.0")]
	internal class ShipLoot : BaseUnityPlugin
	{
		public const string GUID = "com.github.tinyhoot.ShipLoot";

		public const string NAME = "ShipLoot";

		public const string VERSION = "1.0";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("com.github.tinyhoot.ShipLoot").PatchAll(Assembly.GetExecutingAssembly());
		}
	}
}
namespace ShipLoot.Patches
{
	[HarmonyPatch]
	internal class HudManagerPatcher
	{
		private static GameObject _totalCounter;

		private static TextMeshProUGUI _textMesh;

		private static float _displayTimeLeft;

		private const float DisplayTime = 5f;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
		private static void OnScan(HUDManager __instance, CallbackContext context)
		{
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && __instance.CanPlayerScan() && !(__instance.playerPingingScan > -0.5f) && (StartOfRound.Instance.inShipPhase || GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom))
			{
				if (!Object.op_Implicit((Object)(object)_totalCounter))
				{
					CopyValueCounter();
				}
				float num = CalculateLootValue();
				((TMP_Text)_textMesh).text = $"SHIP: ${num:F0}";
				_displayTimeLeft = 5f;
				if (!_totalCounter.activeSelf)
				{
					((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(ShipLootCoroutine());
				}
			}
		}

		private static IEnumerator ShipLootCoroutine()
		{
			_totalCounter.SetActive(true);
			while (_displayTimeLeft > 0f)
			{
				float displayTimeLeft = _displayTimeLeft;
				_displayTimeLeft = 0f;
				yield return (object)new WaitForSeconds(displayTimeLeft);
			}
			_totalCounter.SetActive(false);
		}

		private static float CalculateLootValue()
		{
			List<GrabbableObject> list = (from obj in GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>()
				where ((Object)obj).name != "ClipboardManual" && ((Object)obj).name != "StickyNoteItem"
				select obj).ToList();
			ShipLoot.Log.LogDebug((object)"Calculating total ship scrap value.");
			CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)list, (Action<GrabbableObject>)delegate(GrabbableObject scrap)
			{
				ShipLoot.Log.LogDebug((object)$"{((Object)scrap).name} - ${scrap.scrapValue}");
			});
			return list.Sum((GrabbableObject scrap) => scrap.scrapValue);
		}

		private static void CopyValueCounter()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/ValueCounter");
			if (!Object.op_Implicit((Object)(object)val))
			{
				ShipLoot.Log.LogError((object)"Failed to find ValueCounter object to copy!");
			}
			_totalCounter = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false);
			_totalCounter.transform.Translate(0f, 1f, 0f);
			Vector3 localPosition = _totalCounter.transform.localPosition;
			_totalCounter.transform.localPosition = new Vector3(localPosition.x + 50f, -50f, localPosition.z);
			_textMesh = _totalCounter.GetComponentInChildren<TextMeshProUGUI>();
		}
	}
}

plugins/togglemybits-Strange_Objects/StrangeObjects.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dissonance.Integrations.Unity_NFGO;
using GameNetcodeStuff;
using HarmonyLib;
using StrangeObjects.Patches;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StrangeObjects")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StrangeObjects")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e7e087a1-2426-4476-9b63-af35329e5ac2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StrangeObjects
{
	[BepInPlugin("Bits.StrangeObjects", "Strange Objects", "1.2.0.0")]
	public class StrangeObjectsBase : BaseUnityPlugin
	{
		private const string modGUID = "Bits.StrangeObjects";

		private const string modName = "Strange Objects";

		private const string modVersion = "1.2.0.0";

		private readonly Harmony harmony = new Harmony("Bits.StrangeObjects");

		private static StrangeObjectsBase Instance;

		internal ManualLogSource mls;

		public static ConfigEntry<int> StrangeObjectSpawnRate { get; private set; }

		public static ConfigEntry<float> StrangeObjectValueMultiplier { get; private set; }

		public static ConfigEntry<bool> EnableCurseOfPain { get; private set; }

		public static ConfigEntry<int> PainLevelOnePlayerDamage { get; private set; }

		public static ConfigEntry<bool> EnableCurseOfSight { get; private set; }

		public static ConfigEntry<float> SightLevelOneDrunkDebuff { get; private set; }

		public static ConfigEntry<float> SightLevelTwoDrunkDebuff { get; private set; }

		public static ConfigEntry<bool> EnableCurseOfSloth { get; private set; }

		public static ConfigEntry<float> SlothLevelOneMovementDebuff { get; private set; }

		public static ConfigEntry<float> SlothLevelTwoMovementDebuff { get; private set; }

		public static ConfigEntry<bool> EnableCurseOfMidas { get; private set; }

		public static ConfigEntry<int> MidasMaxScrapValue { get; private set; }

		public static ConfigEntry<bool> EnableCurseOfVoice { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Bits.StrangeObjects");
			StrangeObjectSpawnRate = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SpawnRate", 20, "Probability of a scrap item being strange. 20 means 20% chance. Range 1-100");
			StrangeObjectValueMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ValueMultiplier", 0.3f, "Controls how much value strange objects have. 0.3 is 30% higher value. Range 0.0-infinity");
			EnableCurseOfPain = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Pain", "EnableCurseofPain", true, "Disables curse if false");
			PainLevelOnePlayerDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Curse of Pain", "Level1Pain", 40, "Damage done to player from level one pain curse. Default is 40 same as falling down a cliff twice.");
			EnableCurseOfSight = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Sight", "EnableCurseofSight", true, "Disables curse if false");
			SightLevelOneDrunkDebuff = ((BaseUnityPlugin)this).Config.Bind<float>("Curse of Sight", "Level1DrunkDebuff", 0.2f, "Percentage of Drunkness for Level 1. Default is 20% or 0.2. Range 0.0-1.0");
			SightLevelTwoDrunkDebuff = ((BaseUnityPlugin)this).Config.Bind<float>("Curse of Sight", "Level2DrunkDebuff", 1f, "Percentage of Drunkness for Level 2. Default is 100% or 1.0. Range 0.0-1.0");
			EnableCurseOfSloth = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Sloth", "EnableCurseofSloth", true, "Disables curse if false");
			SlothLevelOneMovementDebuff = ((BaseUnityPlugin)this).Config.Bind<float>("Curse of Sloth", "Level1MovementDebuff", 0.75f, "Percentage of Movement Speed after Level 1 Debuff. Default is 75% or 0.75. Range 0.0-1.0");
			SlothLevelTwoMovementDebuff = ((BaseUnityPlugin)this).Config.Bind<float>("Curse of Sloth", "Level2MovementDebuff", 0.5f, "Percentage of Movement Speed after Level 2 Debuff. Default is 50% or 0.5. Range 0.0-1.0");
			EnableCurseOfMidas = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Midas", "EnableCurseofMidas", true, "Disables curse if false");
			MidasMaxScrapValue = ((BaseUnityPlugin)this).Config.Bind<int>("Curse of Midas", "MaxValueShinyObjects", 100, "This is the maximum scrap value a shiny object can randomly roll");
			EnableCurseOfVoice = ((BaseUnityPlugin)this).Config.Bind<bool>("Curse of Voice", "EnableCurseofVoice", false, "Disables curse if false");
			harmony.PatchAll(typeof(StrangeObjectsBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(SpawnScrapInLevelPatch));
			harmony.PatchAll(typeof(GrabbleObjectPatch));
			harmony.PatchAll(typeof(HUDManagerPatch));
			harmony.PatchAll(typeof(NegativeEffectPatch));
			harmony.PatchAll(typeof(ShipLeavingPatch));
			harmony.PatchAll(typeof(VoiceRefreshPatch));
			harmony.PatchAll(typeof(SyncScrapValuesPatch));
			harmony.PatchAll(typeof(PlaceObjectPatch));
			harmony.PatchAll(typeof(DropAllItemsPatch));
		}
	}
}
namespace StrangeObjects.Patches
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class DropAllItemsPatch
	{
		[HarmonyPostfix]
		private static void removeCurseEffectPatch(ref float ___drunkness, ref float ___movementSpeed)
		{
			___drunkness = 0f;
			___movementSpeed = 4.6f;
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				GameNetworkManager.Instance.localPlayerController.maxSlideFriction = 0f;
				GameNetworkManager.Instance.localPlayerController.voiceMuffledByEnemy = false;
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbleObjectPatch
	{
		[HarmonyPatch("SetScrapValue")]
		[HarmonyPostfix]
		private static void SubtextPatch(ref GrabbableObject __instance, ref Item ___itemProperties)
		{
			if (__instance.scrapValue < 900 && !(___itemProperties.batteryUsage >= 900f))
			{
				return;
			}
			List<string> list = new List<string> { "Strange", "Painful", "Sloth", "Shiny", "Tipsy", "Silent" };
			if (__instance.scrapValue >= 9000)
			{
				___itemProperties.batteryUsage = 999f;
				GrabbableObject obj = __instance;
				obj.scrapValue -= 9999;
			}
			Random random = new Random(__instance.scrapValue + __instance.itemProperties.minValue + __instance.itemProperties.maxValue + (int)__instance.itemProperties.weight);
			char c = (char)(65 + random.Next(0, 26));
			string text = random.Next(0, 10).ToString() + random.Next(0, 10);
			ScanNodeProperties componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<ScanNodeProperties>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				string[] array = componentInChildren.headerText.Split(new char[1] { ' ' });
				if (array.Length != 0 && !list.Contains(array[0]))
				{
					componentInChildren.headerText = "Strange " + componentInChildren.headerText;
				}
				componentInChildren.subText = $"Value: ${__instance.scrapValue}" + " \nObject: " + c + "-" + text;
				componentInChildren.scrapValue = __instance.scrapValue;
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("UpdateScanNodes")]
		[HarmonyPostfix]
		private static void SubtextPatch(ref HUDManager __instance, ref TextMeshProUGUI[] ___scanElementText, ref RectTransform[] ___scanElements)
		{
			for (int i = 0; i < ___scanElements.Length; i++)
			{
				try
				{
					___scanElementText = ((Component)___scanElements[i]).gameObject.GetComponentsInChildren<TextMeshProUGUI>();
					if (___scanElementText.Length > 1)
					{
						string[] array = ((TMP_Text)___scanElementText[1]).text.Split(new char[1] { ' ' });
						if (array.Length > 2 && array[2] == "\nObject:")
						{
							((Component)___scanElements[i]).GetComponent<Animator>().SetInteger("colorNumber", 1);
						}
					}
				}
				catch (Exception arg)
				{
					Debug.LogError((object)$"Error in updatescanNodes F: {arg}");
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class NegativeEffectPatch
	{
		[HarmonyPatch("GrabObject")]
		[HarmonyPostfix]
		private static void grabObjectPatch(ref bool ___grabInvalidated, ref GrabbableObject ___currentlyGrabbingObject, ref float ___insanityLevel, ref float ___maxSlideFriction)
		{
			if (___grabInvalidated)
			{
				return;
			}
			if (___currentlyGrabbingObject.itemProperties.batteryUsage == 995f)
			{
				Random random = new Random();
				Random random2 = new Random();
				___currentlyGrabbingObject.scrapValue = random.Next(1, random2.Next(10, Math.Min(___currentlyGrabbingObject.itemProperties.maxValue, StrangeObjectsBase.MidasMaxScrapValue.Value)));
			}
			if (___currentlyGrabbingObject.itemProperties.batteryUsage == 999f)
			{
				Random random3 = new Random(___currentlyGrabbingObject.scrapValue + ___currentlyGrabbingObject.itemProperties.minValue + ___currentlyGrabbingObject.itemProperties.maxValue + (int)___currentlyGrabbingObject.itemProperties.weight);
				List<float> list = new List<float>();
				if (StrangeObjectsBase.EnableCurseOfPain.Value)
				{
					list.Add(998f);
				}
				if (StrangeObjectsBase.EnableCurseOfSight.Value)
				{
					list.Add(997f);
				}
				if (StrangeObjectsBase.EnableCurseOfSloth.Value)
				{
					list.Add(996f);
				}
				if (StrangeObjectsBase.EnableCurseOfMidas.Value)
				{
					list.Add(995f);
				}
				if (StrangeObjectsBase.EnableCurseOfVoice.Value)
				{
					list.Add(994f);
				}
				if (list.Count == 0)
				{
					return;
				}
				int index = random3.Next(0, list.Count);
				float batteryUsage = list[index];
				___currentlyGrabbingObject.itemProperties.batteryUsage = batteryUsage;
				if (___currentlyGrabbingObject.itemProperties.batteryUsage == 995f)
				{
					Random random4 = new Random();
					Random random5 = new Random();
					___currentlyGrabbingObject.scrapValue = random4.Next(1, random5.Next(10, Math.Min(___currentlyGrabbingObject.itemProperties.maxValue, StrangeObjectsBase.MidasMaxScrapValue.Value)));
				}
				___insanityLevel += 10f;
				ScanNodeProperties componentInChildren = ((Component)___currentlyGrabbingObject).gameObject.GetComponentInChildren<ScanNodeProperties>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					string[] array = componentInChildren.headerText.Split(new char[1] { ' ' });
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 997f)
					{
						array[0] = "Tipsy";
					}
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 998f)
					{
						array[0] = "Painful";
					}
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 996f)
					{
						array[0] = "Sloth";
					}
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 995f)
					{
						array[0] = "Shiny";
					}
					if (___currentlyGrabbingObject.itemProperties.batteryUsage == 994f)
					{
						array[0] = "Silent";
					}
					componentInChildren.headerText = string.Join(" ", array);
				}
			}
			___currentlyGrabbingObject.SetScrapValue(___currentlyGrabbingObject.scrapValue);
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class PlaceObjectPatch
	{
		[HarmonyPostfix]
		private static void removeCurseEffectPatch(GrabbableObject placeObject, ref float ___drunkness, ref float ___movementSpeed)
		{
			if (placeObject.itemProperties.batteryUsage == 997f)
			{
				___drunkness = 0f;
			}
			if (placeObject.itemProperties.batteryUsage == 996f)
			{
				___movementSpeed = 4.6f;
			}
			if (placeObject.itemProperties.batteryUsage == 994f && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				GameNetworkManager.Instance.localPlayerController.maxSlideFriction = 0f;
				GameNetworkManager.Instance.localPlayerController.voiceMuffledByEnemy = false;
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void addNegativePatch(ref PlayerControllerB __instance, ref GrabbableObject[] ___ItemSlots, ref float ___maxSlideFriction, ref float ___drunkness, ref float ___movementSpeed, ref bool ___isPlayerDead, ref bool ___isPlayerControlled)
		{
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			if (___isPlayerDead || !___isPlayerControlled)
			{
				___drunkness = 0f;
				___movementSpeed = 4.6f;
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
				{
					GameNetworkManager.Instance.localPlayerController.maxSlideFriction = 0f;
				}
				return;
			}
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			int num6 = 0;
			List<int> list = new List<int>();
			for (int i = 0; i < ___ItemSlots.Length; i++)
			{
				if (!((Object)(object)___ItemSlots[i] == (Object)null))
				{
					if (___ItemSlots[i].itemProperties.batteryUsage == 998f)
					{
						num++;
						num2++;
						list.Add(i);
					}
					if (___ItemSlots[i].itemProperties.batteryUsage == 997f)
					{
						num++;
						num3++;
					}
					if (___ItemSlots[i].itemProperties.batteryUsage == 996f)
					{
						num++;
						num4++;
					}
					if (___ItemSlots[i].itemProperties.batteryUsage == 995f)
					{
						num++;
						num5++;
					}
					if (___ItemSlots[i].itemProperties.batteryUsage == 994f)
					{
						num++;
						num6++;
					}
				}
			}
			if (num3 == 1)
			{
				___drunkness = StrangeObjectsBase.SightLevelOneDrunkDebuff.Value;
			}
			if (num >= 2 && num3 >= 1)
			{
				___drunkness = StrangeObjectsBase.SightLevelTwoDrunkDebuff.Value;
			}
			if (num2 == 1)
			{
				__instance.DamagePlayer(StrangeObjectsBase.PainLevelOnePlayerDamage.Value, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				for (int j = 0; j < list.Count; j++)
				{
					___ItemSlots[list[j]].itemProperties.batteryUsage = 999f;
				}
			}
			if (num4 == 1)
			{
				___movementSpeed = 4.6f * StrangeObjectsBase.SlothLevelOneMovementDebuff.Value;
			}
			if (num >= 2 && num4 >= 1)
			{
				___movementSpeed = 4.6f * StrangeObjectsBase.SlothLevelTwoMovementDebuff.Value;
			}
			if (num6 == 1 && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				GameNetworkManager.Instance.localPlayerController.maxSlideFriction = -5f;
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
		}
	}
	[HarmonyPatch(typeof(ElevatorAnimationEvents))]
	internal class ShipLeavingPatch
	{
		[HarmonyPatch("ElevatorFullyRunning")]
		[HarmonyPostfix]
		private static void adjustMaxSlideFrictionPatch()
		{
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
			{
				GameNetworkManager.Instance.localPlayerController.drunkness = 0f;
				GameNetworkManager.Instance.localPlayerController.movementSpeed = 4.6f;
				GameNetworkManager.Instance.localPlayerController.maxSlideFriction = 0f;
				GameNetworkManager.Instance.localPlayerController.voiceMuffledByEnemy = false;
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class SpawnScrapInLevelPatch
	{
		private static FieldInfo f_someField = AccessTools.Field(typeof(GrabbableObject), "fallTime");

		private static FieldInfo f_someField_2 = AccessTools.Field(typeof(GrabbableObject), "scrapValue");

		private static FieldInfo f_someField_3 = AccessTools.Field(typeof(GrabbableObject), "itemProperties");

		private static FieldInfo f_someField_4 = AccessTools.Field(typeof(Item), "batteryUsage");

		private static FieldInfo f_someField_5 = AccessTools.Field(typeof(RoundManager), "scrapValueMultiplier");

		private static MethodInfo m_randomChance = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => randomChance()));

		private static MethodInfo m_multiValue = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => multiValue()));

		private static MethodInfo m_listCount = typeof(List<int>).GetProperty("Count").GetGetMethod();

		private static MethodInfo m_listGet = typeof(List<int>).GetProperty("Item").GetGetMethod();

		private static MethodInfo m_listSet = typeof(List<int>).GetProperty("Item").GetSetMethod();

		private static MethodInfo getComponentGenericMethod = AccessTools.Method(typeof(Component), "GetComponent", new Type[0], (Type[])null);

		private static MethodInfo m_component = getComponentGenericMethod.MakeGenericMethod(typeof(GrabbableObject));

		private static int myClamp(int value)
		{
			if (value < 1)
			{
				return 1;
			}
			if (value > 100)
			{
				return 100;
			}
			return value;
		}

		private static float multiValue()
		{
			return StrangeObjectsBase.StrangeObjectValueMultiplier.Value;
		}

		private static int randomChance()
		{
			Random random = new Random();
			int result = 0;
			if (random.Next(0, 100) < myClamp(StrangeObjectsBase.StrangeObjectSpawnRate.Value))
			{
				result = 1;
			}
			return result;
		}

		private static IEnumerable<CodeInstruction> Transpiler(ILGenerator generator, IEnumerable<CodeInstruction> instructions)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Expected O, but got Unknown
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Expected O, but got Unknown
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Expected O, but got Unknown
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Expected O, but got Unknown
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Expected O, but got Unknown
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Expected O, but got Unknown
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Expected O, but got Unknown
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Expected O, but got Unknown
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Expected O, but got Unknown
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Expected O, but got Unknown
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Expected O, but got Unknown
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Expected O, but got Unknown
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Expected O, but got Unknown
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			bool flag = false;
			bool flag2 = false;
			Label label = generator.DefineLabel();
			Label label2 = generator.DefineLabel();
			for (int i = 0; i < list.Count; i++)
			{
				if (CodeInstructionExtensions.StoresField(list[i], f_someField) && !flag)
				{
					list.Insert(i + 1, new CodeInstruction(OpCodes.Nop, (object)null)
					{
						labels = new List<Label> { label }
					});
					list.Insert(i + 1, new CodeInstruction(OpCodes.Stfld, (object)f_someField_5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Add, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_multiValue));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldfld, (object)f_someField_5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Beq_S, (object)label));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, (object)0));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_S, (object)5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Stloc_S, (object)5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_randomChance));
					flag = true;
				}
				if (CodeInstructionExtensions.StoresField(list[i], f_someField_2) && !flag2)
				{
					list.Insert(i + 1, new CodeInstruction(OpCodes.Nop, (object)null)
					{
						labels = new List<Label> { label2 }
					});
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listSet));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Add, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, (object)9999));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listGet));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Sub, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4_1, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listCount));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_1, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_1, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Sub, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4_1, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listCount));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_1, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_1, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Stfld, (object)f_someField_5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Sub, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_multiValue));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldfld, (object)f_someField_5));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Beq_S, (object)label2));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, (object)0));
					list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_S, (object)5));
					flag2 = true;
				}
			}
			return list;
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class SyncScrapValuesPatch
	{
		[HarmonyPostfix]
		private static void fixScrapTotalPatch(int[] allScrapValue, ref float ___totalScrapValueInLevel)
		{
			int num = 0;
			if (allScrapValue != null)
			{
				for (int i = 0; i < allScrapValue.Length; i++)
				{
					num = ((allScrapValue[i] < 9000) ? (num + allScrapValue[i]) : (num + (allScrapValue[i] - 9999)));
				}
			}
			___totalScrapValueInLevel = num;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class VoiceRefreshPatch
	{
		[HarmonyPatch("RefreshPlayerVoicePlaybackObjects")]
		[HarmonyPostfix]
		private static void addMufflePatch(ref PlayerControllerB[] ___allPlayerScripts)
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			PlayerVoiceIngameSettings[] array = Object.FindObjectsOfType<PlayerVoiceIngameSettings>(true);
			for (int i = 0; i < ___allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = ___allPlayerScripts[i];
				if (!val.isPlayerControlled && !val.isPlayerDead)
				{
					continue;
				}
				for (int j = 0; j < array.Length; j++)
				{
					if (array[j]._playerState == null)
					{
						array[j].FindPlayerIfNull();
						if (array[j]._playerState != null)
						{
						}
					}
					else if (((Behaviour)array[j]).isActiveAndEnabled && array[j]._playerState.Name == ((Component)val).gameObject.GetComponentInChildren<NfgoPlayer>().PlayerId)
					{
						val.voicePlayerState = array[j]._playerState;
						val.currentVoiceChatAudioSource = array[j].voiceAudio;
						val.currentVoiceChatIngameSettings = array[j];
						val.currentVoiceChatAudioSource.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[val.playerClientId];
						if (GameNetworkManager.Instance.localPlayerController.maxSlideFriction == -5f)
						{
							((Component)val.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 5f;
							OccludeAudio component = ((Component)val.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>();
							component.overridingLowPass = true;
							component.lowPassOverride = 500f;
							Debug.Log((object)$"Applied Muffle to player voice object #{j} and player object #{i}");
							val.voiceMuffledByEnemy = true;
						}
						else
						{
							((Component)val.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 1f;
							OccludeAudio component2 = ((Component)val.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>();
							component2.overridingLowPass = false;
							component2.lowPassOverride = 20000f;
							val.voiceMuffledByEnemy = false;
						}
					}
				}
			}
		}
	}
}

plugins/Venterok-HullBreaker_Company/HullBreakerCompany.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 GameNetcodeStuff;
using HarmonyLib;
using HullBreakerCompany.Events;
using HullBreakerCompany.Hull;
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 = "")]
[assembly: AssemblyCompany("HullBreakerCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Making it more challenging to work for the company")]
[assembly: AssemblyFileVersion("1.3.9.0")]
[assembly: AssemblyInformationalVersion("1.3.9")]
[assembly: AssemblyProduct("HullBreakerCompany")]
[assembly: AssemblyTitle("HullBreakerCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.9.0")]
[module: UnverifiableCode]
namespace HullBreakerCompany
{
	[BepInPlugin("HullBreakerCompany", "HullBreakerCompany", "1.3.9")]
	public class Plugin : BaseUnityPlugin
	{
		private static Dictionary<int, SelectableLevelState> _levelStates = new Dictionary<int, SelectableLevelState>();

		private static bool _loaded;

		public static ManualLogSource Mls;

		public static bool OneForAllIsActive;

		public static bool BountyIsActive;

		public static int DaysPassed;

		public static float BunkerEnemyScale;

		public static float LandMineTurretScale;

		public static bool UseShortChatMessages;

		public static bool EnableEventMessages;

		public static bool UseHullBreakerLevelSettings;

		public static bool UseDefaultGameSettings;

		public static int MaxEnemyPowerCount;

		public static int MaxOutsideEnemyPowerCount;

		public static int MaxDaytimeEnemyPowerCount;

		public static int MinScrap;

		public static int MaxScrap;

		public static int MinTotalScrapValue;

		public static int MaxTotalScrapValue;

		public static bool ChangeQuotaValue;

		public static int QuotaIncrease;

		public static bool IncreaseEventCountPerDay;

		public static int EventCount;

		public static List<SpawnableItemWithRarity> NotModifiedSpawnableItemsWithRarity = new List<SpawnableItemWithRarity>();

		public static Dictionary<string, Type> EnemyBase = new Dictionary<string, Type>
		{
			{
				"flowerman",
				typeof(FlowermanAI)
			},
			{
				"hoarderbug",
				typeof(HoarderBugAI)
			},
			{
				"springman",
				typeof(SpringManAI)
			},
			{
				"crawler",
				typeof(CrawlerAI)
			},
			{
				"sandspider",
				typeof(SandSpiderAI)
			},
			{
				"jester",
				typeof(JesterAI)
			},
			{
				"centipede",
				typeof(CentipedeAI)
			},
			{
				"blobai",
				typeof(BlobAI)
			},
			{
				"dressgirl",
				typeof(DressGirlAI)
			},
			{
				"pufferenemy",
				typeof(PufferAI)
			},
			{
				"eyelessdogs",
				typeof(MouthDogAI)
			},
			{
				"forestgiant",
				typeof(ForestGiantAI)
			},
			{
				"sandworm",
				typeof(SandWormAI)
			},
			{
				"baboonbird",
				typeof(BaboonBirdAI)
			},
			{
				"nutcrackerenemy",
				typeof(NutcrackerEnemyAI)
			},
			{
				"maskedplayerenemy",
				typeof(MaskedPlayerEnemy)
			}
		};

		public static List<HullEvent> EventDictionary = new List<HullEvent>
		{
			new FlowerManEvent(),
			new LandMineEvent(),
			new HoarderBugEvent(),
			new SpringManEvent(),
			new LizardsEvent(),
			new ArachnophobiaEvent(),
			new BeeEvent(),
			new SlimeEvent(),
			new DevochkaPizdecEvent(),
			new EnemyBountyEvent(),
			new OpenTheNoorEvent(),
			new OnAPowderKegEvent(),
			new OutSideEnemyDayEvent(),
			new HellEvent(),
			new NothingEvent(),
			new HackedTurretsEvent(),
			new BabkinPogrebEvent(),
			new HullBreakEvent(),
			new NutcrackerEvent()
		};

		private readonly Harmony _harmony = new Harmony("HULLBREAKER");

		private void Awake()
		{
			Mls = Logger.CreateLogSource("HULLBREAKER 1.3.9");
			Mls.LogInfo((object)"Ready to break hull; HullBreakerCompany");
			_harmony.PatchAll(typeof(Plugin));
			if (!_loaded)
			{
				Initialize();
			}
		}

		public void Start()
		{
			if (!_loaded)
			{
				Initialize();
			}
		}

		public void OnDestroy()
		{
			if (!_loaded)
			{
				Initialize();
			}
		}

		public void Initialize()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ConfigManager.SetConfigValue();
			GameObject val = new GameObject("HullManager");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<HullManager>();
			Mls.LogInfo((object)"HullManager created");
			CustomEventLoader.LoadCustomEvents();
			_loaded = true;
		}

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool ModifiedLoad(ref SelectableLevel newLevel)
		{
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Expected O, but got Unknown
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Expected O, but got Unknown
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Expected O, but got Unknown
			Mls.LogInfo((object)("Client is host: " + ((NetworkBehaviour)RoundManager.Instance).IsHost));
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return true;
			}
			CustomEventLoader.DebugLoadCustomEvents();
			int levelID = newLevel.levelID;
			if (!_levelStates.ContainsKey(levelID))
			{
				_levelStates[levelID] = new SelectableLevelState(newLevel);
			}
			else
			{
				_levelStates[levelID].RestoreState(newLevel);
			}
			if (newLevel.levelID == 3)
			{
				Mls.LogInfo((object)"Level is company, skipping");
				DaysPassed = 0;
				return true;
			}
			DaysPassed++;
			Mls.LogInfo((object)$"Days passed: {DaysPassed}");
			BountyIsActive = false;
			OneForAllIsActive = false;
			ResetLevelUnits(newLevel);
			SelectableLevel val = newLevel;
			List<string> randomGameEvents = RandomSelector.GetRandomGameEvents();
			Dictionary<Type, int> dictionary = new Dictionary<Type, int>();
			Dictionary<Type, int> dictionary2 = new Dictionary<Type, int>();
			dictionary.Clear();
			NotModifiedSpawnableItemsWithRarity.Clear();
			foreach (SpawnableItemWithRarity item in val.spawnableScrap)
			{
				NotModifiedSpawnableItemsWithRarity.Add(item);
			}
			if (EventCount != 0 && EnableEventMessages)
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=red>NOTES ABOUT MOON:</color>\"", -1);
			}
			foreach (string gameEvent in randomGameEvents)
			{
				try
				{
					HullEvent hullEvent = EventDictionary.FirstOrDefault((HullEvent e) => e.ID() == gameEvent);
					if (hullEvent != null)
					{
						hullEvent.Execute(newLevel, dictionary, dictionary2);
						Mls.LogInfo((object)("Event: " + gameEvent));
						UpdateRarity(newLevel.Enemies, dictionary);
						UpdateRarity(newLevel.OutsideEnemies, dictionary2);
					}
				}
				catch (NullReferenceException ex)
				{
					Mls.LogError((object)$"NullReferenceException caught while processing event: {gameEvent}. Exception message: {ex.Message}. Caused : {ex.InnerException}");
				}
			}
			HullManager.LogEnemyRarity(newLevel.Enemies, "⬛⬛⬛⬛⬛⬛ENEMIES RARITY⬛⬛⬛⬛⬛⬛");
			HullManager.LogEnemyRarity(newLevel.DaytimeEnemies, "⬛⬛⬛⬛⬛⬛DAYTIME ENEMIES RARITY⬛⬛⬛⬛⬛⬛");
			HullManager.LogEnemyRarity(newLevel.OutsideEnemies, "⬛⬛⬛⬛⬛⬛OUTSIDE ENEMIES RARITY⬛⬛⬛⬛⬛⬛");
			if (!randomGameEvents.Contains("Bee"))
			{
				using IEnumerator<SpawnableEnemyWithRarity> enumerator3 = val.DaytimeEnemies.Where((SpawnableEnemyWithRarity unit) => (Object)(object)unit.enemyType.enemyPrefab.GetComponent<RedLocustBees>() != (Object)null).GetEnumerator();
				if (enumerator3.MoveNext())
				{
					SpawnableEnemyWithRarity current2 = enumerator3.Current;
					current2.rarity = 22;
				}
			}
			if (UseHullBreakerLevelSettings)
			{
				val.maxEnemyPowerCount += 16;
				val.maxOutsideEnemyPowerCount += 20;
				val.maxScrap += Random.Range(6, 24);
				val.maxTotalScrapValue += Random.Range(400, 800);
				val.daytimeEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 5f),
					new Keyframe(0.5f, 5f)
				});
				val.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
				{
					new Keyframe(0f, 256f)
				});
			}
			else if (UseDefaultGameSettings)
			{
				Mls.LogInfo((object)"Default settings");
			}
			else
			{
				val.maxEnemyPowerCount = MaxEnemyPowerCount;
				val.maxOutsideEnemyPowerCount = MaxOutsideEnemyPowerCount;
				val.maxDaytimeEnemyPowerCount = MaxDaytimeEnemyPowerCount;
				val.minScrap = MinScrap;
				val.maxScrap = MaxScrap;
				val.minTotalScrapValue = MinTotalScrapValue;
				val.maxTotalScrapValue = MaxTotalScrapValue;
				val.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
				{
					new Keyframe(0f, BunkerEnemyScale)
				});
			}
			newLevel = val;
			return true;
		}

		private static void UpdateRarity(List<SpawnableEnemyWithRarity> enemies, Dictionary<Type, int> componentRarity)
		{
			if (componentRarity.Count <= 0)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity unit in enemies)
			{
				foreach (KeyValuePair<Type, int> item in componentRarity)
				{
					if ((Object)(object)unit.enemyType.enemyPrefab.GetComponent(item.Key) == (Object)null)
					{
						continue;
					}
					if (enemies.Any((SpawnableEnemyWithRarity e) => (Object)(object)e.enemyType == (Object)(object)unit.enemyType))
					{
						unit.rarity = item.Value;
						componentRarity.Remove(item.Key);
					}
					break;
				}
			}
		}

		public static void LevelUnits(SelectableLevel n, bool turret = false, bool landmine = false)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			Mls.LogInfo((object)$"Turret: {turret}, Landmine: {landmine}");
			AnimationCurve numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, LandMineTurretScale),
				new Keyframe(1f, 25f)
			});
			SpawnableMapObject[] spawnableMapObjects = n.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				Landmine componentInChildren = val.prefabToSpawn.GetComponentInChildren<Landmine>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					val.numberToSpawn = numberToSpawn;
				}
			}
		}

		private static void ResetLevelUnits(SelectableLevel level)
		{
			//IL_003f: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			SpawnableMapObject[] spawnableMapObjects = level.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				Landmine componentInChildren = val.prefabToSpawn.GetComponentInChildren<Landmine>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
					{
						new Keyframe(0f, 2.5f)
					});
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "KillEnemyServerRpc")]
		private static void EnemyBounty()
		{
			Mls.LogInfo((object)$"Enemy killed, bounty is active: {BountyIsActive}");
			if (BountyIsActive)
			{
				Terminal val = Object.FindObjectOfType<Terminal>();
				val.groupCredits += 30;
				val.SyncGroupCreditsServerRpc(val.groupCredits, val.numberOfItemsInDropship);
				HullManager.SendChatEventMessage("<color=green>Workers get paid for killing enemy</color>");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerServerRpc")]
		private static void OneForAll()
		{
			Mls.LogInfo((object)$"Player killed, one for all is active: {OneForAllIsActive}");
			if (OneForAllIsActive)
			{
				HullManager hullManager = Object.FindObjectOfType<HullManager>();
				hullManager.timeOfDay.votedShipToLeaveEarlyThisRound = true;
				hullManager.timeOfDay.SetShipLeaveEarlyServerRpc();
				HullManager.SendChatEventMessage("<color=red>One of the workers died, the ship will go into orbit in an hour</color>");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartHost")]
		private static void ResetDayPassed()
		{
			DaysPassed = 0;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "HullBreakerCompany";

		public const string PLUGIN_NAME = "HullBreakerCompany";

		public const string PLUGIN_VERSION = "1.3.9";
	}
}
namespace HullBreakerCompany.Hull
{
	public class ConfigManager
	{
		private static string _configPath = Path.Combine(Paths.ConfigPath, "HullBreakerCompany.cfg");

		private static ConfigFile _configFile;

		public static T GetConfigValue<T>(string key, T defaultValue, string description = null)
		{
			EnsureConfigExists();
			return _configFile.Bind<T>("Settings", key, defaultValue, description).Value;
		}

		public static void SetConfigValue()
		{
			Plugin.LandMineTurretScale = GetConfigValue("LandMineTurretScale", 64, "Should change amount of Landmines & Turrets when these events are active: (Landmine & Turret)");
			Plugin.UseShortChatMessages = GetConfigValue("UseShortChatMessages", defaultValue: false, "Use short event message (one/two words), can add surprise effect & difficulty");
			Plugin.EnableEventMessages = GetConfigValue("EnableEventMessages", defaultValue: true, "Enable chat event messages");
			Plugin.UseHullBreakerLevelSettings = GetConfigValue("UseHullBreakerLevelSettings", defaultValue: true, "Use HullBreaker level settings, if false, use default level settings");
			Plugin.UseDefaultGameSettings = GetConfigValue("UseDefaultLevelSettings", defaultValue: false, "Use default level settings, if false, you can change on one's own");
			Plugin.ChangeQuotaValue = GetConfigValue("ChangeQuota", defaultValue: true, "Change quota");
			Plugin.QuotaIncrease = GetConfigValue("IncreasedQuota", 256, "Increased quota");
			Plugin.MaxEnemyPowerCount = GetConfigValue("MaxEnemyPowerCount", 10, "Max enemy power count");
			Plugin.MaxOutsideEnemyPowerCount = GetConfigValue("MaxOutsideEnemyPowerCount", 10, "Max outside enemy power count");
			Plugin.MaxDaytimeEnemyPowerCount = GetConfigValue("MaxDaytimeEnemyPowerCount", 20, "Max daytime enemy power count");
			Plugin.MinScrap = GetConfigValue("MinScrap", 10, "Min scrap");
			Plugin.MaxScrap = GetConfigValue("MaxScrap", 15, "Max scrap");
			Plugin.MinTotalScrapValue = GetConfigValue("MinTotalScrapValue", 300, "Min total scrap value");
			Plugin.MaxTotalScrapValue = GetConfigValue("MaxTotalScrapValue", 700, "Max total scrap value");
			Plugin.BunkerEnemyScale = GetConfigValue("BunkerEnemyScale", 256, "Should change global bunker enemy spawn rate, not sure if its work");
			Plugin.IncreaseEventCountPerDay = GetConfigValue("IncreaseEventCountPerDay", defaultValue: false, "The number of events will increase every day. Visit the company building to reset");
			Plugin.EventCount = GetConfigValue("EventCount", 3, "The number of events that will be active at the same time");
		}

		public static Dictionary<string, int> GetWeights()
		{
			EnsureConfigExists();
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (HullEvent item in Plugin.EventDictionary)
			{
				dictionary[item.ID()] = _configFile.Bind<int>("Weights", item.ID(), item.GetWeight(), item.GetDescription()).Value;
			}
			return dictionary;
		}

		private static void EnsureConfigExists()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if (_configFile == null)
			{
				if (!File.Exists(_configPath))
				{
					CreateDefaultConfigFile();
				}
				_configFile = new ConfigFile(_configPath, true);
			}
		}

		private static void CreateDefaultConfigFile()
		{
			using StreamWriter streamWriter = File.CreateText(_configPath);
			streamWriter.WriteLine("[Weights]");
			foreach (HullEvent item in Plugin.EventDictionary)
			{
				streamWriter.WriteLine(item.ID() + "=" + item.GetWeight());
			}
		}
	}
	public class CustomEventLoader
	{
		public static void LoadCustomEvents()
		{
			List<Dictionary<string, string>> list = LoadEventDataFromCfgFiles();
			if (list.Count == 0)
			{
				return;
			}
			foreach (Dictionary<string, string> item in list)
			{
				CustomEvent customEvent = new CustomEvent();
				customEvent.SetID(item["EventID"]);
				customEvent.SetWeight(int.Parse(item["EventWeight"]));
				customEvent.Rarity = int.Parse(item["EnemyRarity"]);
				if (item.ContainsKey("SpawnableEnemies"))
				{
					customEvent.EnemySpawnList = new HashSet<string>(item["SpawnableEnemies"].Split(',')).ToList();
				}
				if (item.ContainsKey("SpawnableOutsideEnemies"))
				{
					customEvent.OutsideSpawnList = new HashSet<string>(item["SpawnableOutsideEnemies"].Split(',')).ToList();
				}
				customEvent.SetMessage(item["InGameMessage"]);
				customEvent.SetShortMessage(item["InGameShortMessage"]);
				Plugin.EventDictionary.Add(customEvent);
			}
		}

		private static List<Dictionary<string, string>> LoadEventDataFromCfgFiles()
		{
			string text = Paths.BepInExRootPath + "\\HullEvents";
			if (!Directory.Exists(text))
			{
				Plugin.Mls.LogError((object)("Directory does not exist: " + text));
				return new List<Dictionary<string, string>>();
			}
			string[] files = Directory.GetFiles(text, "*.cfg");
			List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
			string[] array = files;
			foreach (string path in array)
			{
				string[] array2 = File.ReadAllLines(path);
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				string[] array3 = array2;
				foreach (string text2 in array3)
				{
					if (!text2.StartsWith("[") && !string.IsNullOrWhiteSpace(text2))
					{
						string[] array4 = text2.Split('=');
						if (array4.Length == 2)
						{
							string key = array4[0].Trim();
							string value = array4[1].Trim();
							dictionary[key] = value;
						}
					}
				}
				list.Add(dictionary);
				Plugin.Mls.LogInfo((object)("Loaded event: " + dictionary["EventID"]));
			}
			return list;
		}

		public static void AddEvent(HullEvent newEvent)
		{
			Plugin.Mls.LogInfo((object)("Adding new event" + newEvent.ID() + " to dictionary"));
			Plugin.EventDictionary.Add(newEvent);
		}

		public static void DebugLoadCustomEvents()
		{
			foreach (HullEvent item in Plugin.EventDictionary)
			{
				if (item is CustomEvent customEvent)
				{
					Plugin.Mls.LogInfo((object)("Event ID: " + customEvent.ID()));
					Plugin.Mls.LogInfo((object)("Spawnable Enemies: " + string.Join(", ", customEvent.EnemySpawnList)));
					Plugin.Mls.LogInfo((object)("Message: " + customEvent.GetMessage()));
				}
			}
		}
	}
	public abstract class HullEvent
	{
		public abstract string ID();

		public virtual int GetWeight()
		{
			return 1;
		}

		public virtual string GetDescription()
		{
			return "Default description";
		}

		public virtual string GetMessage()
		{
			return "Default message";
		}

		public virtual string GetShortMessage()
		{
			return "SHORT";
		}

		public virtual void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
		}
	}
	public class HullManager : MonoBehaviour
	{
		public TimeOfDay timeOfDay;

		public static HullManager Instance { get; private set; }

		public void Update()
		{
			if ((Object)(object)timeOfDay == (Object)null)
			{
				timeOfDay = Object.FindFirstObjectByType<TimeOfDay>();
			}
			else if (Plugin.ChangeQuotaValue)
			{
				timeOfDay.quotaVariables.baseIncrease = Plugin.QuotaIncrease;
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void AddMoney(int amount)
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			val.groupCredits += amount;
			val.SyncGroupCreditsServerRpc(val.groupCredits, val.numberOfItemsInDropship);
		}

		public void ExecuteAfterDelay(Action action, float delay)
		{
			((MonoBehaviour)this).StartCoroutine(DelayedExecution(action, delay));
		}

		private IEnumerator DelayedExecution(Action action, float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			action();
		}

		public static void SendChatEventMessage(HullEvent hullEvent)
		{
			if ((Object)(object)HUDManager.Instance != (Object)null && hullEvent != null && Plugin.EnableEventMessages)
			{
				HUDManager.Instance.AddTextToChatOnServer(Plugin.UseShortChatMessages ? hullEvent.GetShortMessage() : hullEvent.GetMessage(), -1);
			}
		}

		public static void SendChatEventMessage(string message)
		{
			if ((Object)(object)HUDManager.Instance != (Object)null && message != null && Plugin.EnableEventMessages)
			{
				HUDManager.Instance.AddTextToChatOnServer(message, -1);
			}
		}

		public static void LogEnemyRarity(List<SpawnableEnemyWithRarity> enemies, string title)
		{
			Plugin.Mls.LogInfo((object)"");
			Plugin.Mls.LogInfo((object)title);
			foreach (SpawnableEnemyWithRarity enemy in enemies)
			{
				Plugin.Mls.LogInfo((object)$"{((Object)enemy.enemyType.enemyPrefab).name} - {enemy.rarity}");
			}
		}
	}
	public abstract class RandomSelector
	{
		private static Random _random = new Random();

		public static List<string> GetRandomGameEvents()
		{
			int count = (Plugin.IncreaseEventCountPerDay ? Plugin.DaysPassed : Plugin.EventCount);
			return GetWeightedRandomGameEvents(ConfigManager.GetWeights(), count);
		}

		private static List<T> GetWeightedRandomGameEvents<T>(Dictionary<T, int> weights, int count)
		{
			int maxValue = weights.Where((KeyValuePair<T, int> x) => x.Value > 0).Sum((KeyValuePair<T, int> x) => x.Value);
			HashSet<T> hashSet = new HashSet<T>();
			while (hashSet.Count < count)
			{
				int num = _random.Next(maxValue);
				foreach (KeyValuePair<T, int> weight in weights)
				{
					if (weight.Value != 0)
					{
						if (num < weight.Value)
						{
							hashSet.Add(weight.Key);
							break;
						}
						num -= weight.Value;
					}
				}
			}
			return hashSet.ToList();
		}

		private static void Shuffle<T>(IList<T> list)
		{
			int num = list.Count;
			while (num > 1)
			{
				num--;
				int num2 = _random.Next(num + 1);
				int index = num2;
				int index2 = num;
				T val = list[num];
				T val2 = list[num2];
				T val4 = (list[index] = val);
				val4 = (list[index2] = val2);
			}
		}
	}
	public class SelectableLevelState
	{
		public int MinScrap;

		public int MaxScrap;

		public int MinTotalScrapValue;

		public int MaxTotalScrapValue;

		public int MaxEnemyPowerCount = 8;

		public int MaxOutsideEnemyPowerCount = 15;

		public int MaxDaytimeEnemyPowerCount = 20;

		public AnimationCurve EnemySpawnChanceThroughoutDay;

		public AnimationCurve OutsideEnemySpawnChanceThroughDay;

		public AnimationCurve DaytimeEnemySpawnChanceThroughDay;

		public List<SpawnableEnemyWithRarity> EnemyList = new List<SpawnableEnemyWithRarity>();

		public List<SpawnableEnemyWithRarity> OutsideEnemyList = new List<SpawnableEnemyWithRarity>();

		public List<SpawnableEnemyWithRarity> DaytimeEnemyList = new List<SpawnableEnemyWithRarity>();

		public SelectableLevelState(SelectableLevel level)
		{
			MinScrap = level.minScrap;
			MaxScrap = level.maxScrap;
			MinTotalScrapValue = level.minTotalScrapValue;
			MaxTotalScrapValue = level.maxTotalScrapValue;
			MaxEnemyPowerCount = level.maxEnemyPowerCount;
			MaxOutsideEnemyPowerCount = level.maxOutsideEnemyPowerCount;
			MaxDaytimeEnemyPowerCount = level.maxDaytimeEnemyPowerCount;
			EnemySpawnChanceThroughoutDay = level.enemySpawnChanceThroughoutDay;
			OutsideEnemySpawnChanceThroughDay = level.outsideEnemySpawnChanceThroughDay;
			DaytimeEnemySpawnChanceThroughDay = level.daytimeEnemySpawnChanceThroughDay;
			CloneEnemies(level.Enemies, EnemyList);
			CloneEnemies(level.OutsideEnemies, OutsideEnemyList);
			CloneEnemies(level.DaytimeEnemies, DaytimeEnemyList);
		}

		public void RestoreState(SelectableLevel level)
		{
			level.minScrap = MinScrap;
			level.maxScrap = MaxScrap;
			level.minTotalScrapValue = MinTotalScrapValue;
			level.maxTotalScrapValue = MaxTotalScrapValue;
			level.maxEnemyPowerCount = MaxEnemyPowerCount;
			level.maxOutsideEnemyPowerCount = MaxOutsideEnemyPowerCount;
			level.maxDaytimeEnemyPowerCount = MaxDaytimeEnemyPowerCount;
			level.enemySpawnChanceThroughoutDay = EnemySpawnChanceThroughoutDay;
			level.outsideEnemySpawnChanceThroughDay = OutsideEnemySpawnChanceThroughDay;
			level.daytimeEnemySpawnChanceThroughDay = DaytimeEnemySpawnChanceThroughDay;
			level.Enemies.Clear();
			CloneEnemies(EnemyList, level.Enemies);
			level.OutsideEnemies.Clear();
			CloneEnemies(OutsideEnemyList, level.OutsideEnemies);
			level.DaytimeEnemies.Clear();
			CloneEnemies(DaytimeEnemyList, level.DaytimeEnemies);
		}

		private void CloneEnemies(List<SpawnableEnemyWithRarity> source, List<SpawnableEnemyWithRarity> destination)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			foreach (SpawnableEnemyWithRarity item2 in source)
			{
				SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity
				{
					enemyType = item2.enemyType,
					rarity = item2.rarity
				};
				destination.Add(item);
			}
		}
	}
}
namespace HullBreakerCompany.Events
{
	public class ArachnophobiaEvent : HullEvent
	{
		public override string ID()
		{
			return "Arachnophobia";
		}

		public override int GetWeight()
		{
			return 20;
		}

		public override string GetDescription()
		{
			return "Increased chance of spider spawning";
		}

		public override string GetMessage()
		{
			return "<color=white>Possible habitat of spiders</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>ARACHNOPHOBIA</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(SandSpiderAI), 256);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class BabkinPogrebEvent : HullEvent
	{
		public override string ID()
		{
			return "BabkinPogreb";
		}

		public override int GetWeight()
		{
			return 10;
		}

		public override string GetDescription()
		{
			return "Only jars of pickles spawn on the moon";
		}

		public override string GetMessage()
		{
			return "<color=white>On the this moon, something strange happened with scrap...</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>ITEM MYSTERY</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			try
			{
				if ((Object)(object)HullManager.Instance == (Object)null)
				{
					Plugin.Mls.LogError((object)"HullManager.Instance is null");
					return;
				}
				if ((Object)(object)level == (Object)null)
				{
					Plugin.Mls.LogError((object)"level is null");
					return;
				}
				level.spawnableScrap.RemoveAll((SpawnableItemWithRarity item) => item.spawnableItem.itemName != "Jar of pickles");
				if (level.spawnableScrap.Count == 0)
				{
					Plugin.Mls.LogError((object)"No jars of pickles found in spawnableScrap list!");
					DelayedReturnList(level);
					return;
				}
				foreach (SpawnableItemWithRarity item in level.spawnableScrap.Where((SpawnableItemWithRarity item) => item.spawnableItem.itemName == "Jar of pickles"))
				{
					item.rarity = 100;
				}
				HullManager.Instance.ExecuteAfterDelay(delegate
				{
					DelayedReturnList(level);
				}, 12f);
				HullManager.SendChatEventMessage(this);
			}
			catch (ArgumentOutOfRangeException ex)
			{
				Plugin.Mls.LogError((object)("ArgumentOutOfRangeException caught in BabkinPogrebEvent.Execute: " + ex.Message));
			}
		}

		private void DelayedReturnList(SelectableLevel level)
		{
			Plugin.Mls.LogInfo((object)"Resetting spawnable items...");
			level.spawnableScrap.Clear();
			foreach (SpawnableItemWithRarity item in Plugin.NotModifiedSpawnableItemsWithRarity)
			{
				level.spawnableScrap.Add(item);
			}
		}
	}
	public class BeeEvent : HullEvent
	{
		public override string ID()
		{
			return "Bee";
		}

		public override int GetWeight()
		{
			return 30;
		}

		public override string GetDescription()
		{
			return "Increased chance of bee hives spawning";
		}

		public override string GetMessage()
		{
			return "<color=white>Possibly a large amount of bee hives</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>ANNOYING BUZZING</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			using (IEnumerator<SpawnableEnemyWithRarity> enumerator = level.DaytimeEnemies.Where((SpawnableEnemyWithRarity unit) => (Object)(object)unit.enemyType.enemyPrefab.GetComponent<RedLocustBees>() != (Object)null).GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					SpawnableEnemyWithRarity current = enumerator.Current;
					current.rarity = 256;
				}
			}
			HullManager.SendChatEventMessage(this);
		}
	}
	public class CustomEvent : HullEvent
	{
		private string _id;

		private int _weight;

		private string _message;

		private string _shortMessage;

		public List<string> EnemySpawnList = new List<string>();

		public List<string> OutsideSpawnList = new List<string>();

		public int Rarity = 1;

		public override string ID()
		{
			return _id;
		}

		public void SetID(string value)
		{
			_id = value;
		}

		public void SetWeight(int value)
		{
			_weight = value;
		}

		public override int GetWeight()
		{
			return _weight;
		}

		public void SetMessage(string value)
		{
			_message = value;
		}

		public void SetShortMessage(string value)
		{
			_shortMessage = value;
		}

		public override string GetMessage()
		{
			return _message;
		}

		public override string GetShortMessage()
		{
			return _shortMessage;
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> componentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			foreach (string item in EnemySpawnList.TakeWhile((string enemy) => enemy != "off"))
			{
				componentRarity.Add(Plugin.EnemyBase[item], Rarity);
			}
			foreach (string item2 in OutsideSpawnList.TakeWhile((string enemy) => enemy != "off"))
			{
				outsideComponentRarity.Add(Plugin.EnemyBase[item2], Rarity);
			}
			HullManager.SendChatEventMessage(Plugin.UseShortChatMessages ? GetShortMessage() : GetMessage());
		}
	}
	public class DevochkaPizdecEvent : HullEvent
	{
		public override string ID()
		{
			return "DevochkaPizdec";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "Increased chance of phantom girl spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>A lot of workers are going crazy here</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>COTARD SYNDROME</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(DressGirlAI), 32);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class EnemyBountyEvent : HullEvent
	{
		public override string ID()
		{
			return "EnemyBounty";
		}

		public override int GetWeight()
		{
			return 50;
		}

		public override string GetDescription()
		{
			return "Company pays money for killing the enemies / 60 per enemy";
		}

		public override string GetMessage()
		{
			return "<color=white>Company pays money for killing the enemies!</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>ENEMY BOUNTY</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			Plugin.BountyIsActive = true;
			HullManager.SendChatEventMessage(this);
		}
	}
	public class FlowerManEvent : HullEvent
	{
		public override string ID()
		{
			return "FlowerMan";
		}

		public override int GetWeight()
		{
			return 20;
		}

		public override string GetDescription()
		{
			return "Increased chance of flowerman spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>So many eyes in the dark, carefully</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>WHITE EYES...</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(FlowermanAI), 256);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class HackedTurretsEvent : HullEvent
	{
		public override string ID()
		{
			return "HackedTurrets";
		}

		public override int GetWeight()
		{
			return 10;
		}

		public override string GetDescription()
		{
			return "Turrets dont work on the moon";
		}

		public override string GetMessage()
		{
			return "<color=white>The company's hackers have disabled all turrets on this moon, you can breathe easy</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>SYSTEM FAILURE</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			if ((Object)(object)HullManager.Instance == (Object)null)
			{
				Plugin.Mls.LogError((object)"HullManager.Instance is null");
				return;
			}
			if ((Object)(object)level == (Object)null)
			{
				Plugin.Mls.LogError((object)"level is null");
				return;
			}
			HullManager.Instance.ExecuteAfterDelay(delegate
			{
				HackTurrets();
			}, 16f);
			HullManager.SendChatEventMessage(this);
		}

		private void HackTurrets()
		{
			Turret[] array = Object.FindObjectsOfType<Turret>();
			Turret[] array2 = array;
			foreach (Turret val in array2)
			{
				val.ToggleTurretServerRpc(false);
			}
		}
	}
	public class HellEvent : HullEvent
	{
		public override string ID()
		{
			return "Hell";
		}

		public override int GetWeight()
		{
			return 1;
		}

		public override string GetDescription()
		{
			return "Increased chance of spawning Jester and more enemies";
		}

		public override string GetMessage()
		{
			return "<color=orange>It says here that there is total hell happening on the this moon</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>HELL</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(JesterAI), 64);
			HullManager.SendChatEventMessage(this);
			RoundManager.Instance.hourTimeBetweenEnemySpawnBatches = 1;
			HullManager.Instance.ExecuteAfterDelay(delegate
			{
				Hell();
			}, 16f);
		}

		private void Hell()
		{
			EnemyVent[] array = Object.FindObjectsOfType<EnemyVent>();
			for (int i = 0; i < 8; i++)
			{
				if (array.Length != 0)
				{
					EnemyVent val = array[Random.Range(0, array.Length)];
					RoundManager.Instance.SpawnEnemyFromVent(val);
				}
			}
		}
	}
	public class HoarderBugEvent : HullEvent
	{
		public override string ID()
		{
			return "HoarderBug";
		}

		public override int GetWeight()
		{
			return 50;
		}

		public override string GetDescription()
		{
			return "Increased chance of hoarder bug spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>Keep an eye on the loot, Hoarding Bugs nearby</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>BUG INVASION</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(HoarderBugAI), 512);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class HullBreakEvent : HullEvent
	{
		public override string ID()
		{
			return "HullBreak";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "Getting money for visiting this moon";
		}

		public override string GetMessage()
		{
			return "<color=green>Take a break, the company is sending money for visiting the moon</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>TAKE A BREAK</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			HullManager.Instance.AddMoney(120);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class LandMineEvent : HullEvent
	{
		public override string ID()
		{
			return "LandMine";
		}

		public override int GetWeight()
		{
			return 30;
		}

		public override string GetDescription()
		{
			return "Increased chance of landmines spawning";
		}

		public override string GetMessage()
		{
			return "<color=white>Watch your step, there are a lot of landmines</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>LANDMINE</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			Plugin.LevelUnits(level, turret: false, landmine: true);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class LizardsEvent : HullEvent
	{
		public override string ID()
		{
			return "Lizards";
		}

		public override int GetWeight()
		{
			return 15;
		}

		public override string GetDescription()
		{
			return "Increased chance of puffers spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>Horrible smell from toxic lizards</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>LIZARDSSS</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(PufferAI), 64);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class NothingEvent : HullEvent
	{
		public override string ID()
		{
			return "Nothing";
		}

		public override int GetWeight()
		{
			return 60;
		}

		public override string GetDescription()
		{
			return "Nothing happens";
		}

		public override string GetMessage()
		{
			return "<color=white>---</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>---</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			HullManager.SendChatEventMessage(this);
		}
	}
	public class NutcrackerEvent : HullEvent
	{
		public override string ID()
		{
			return "Nutcracker";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "Increased chance of NutCracker spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>NutCrackers detected in the area!</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=orange>NUTCRACKERS INCOMING</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(NutcrackerEnemyAI), 64);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class OnAPowderKegEvent : HullEvent
	{
		public override string ID()
		{
			return "OnAPowderKeg";
		}

		public override int GetWeight()
		{
			return 10;
		}

		public override string GetDescription()
		{
			return "Landmines can detonate at any time";
		}

		public override string GetMessage()
		{
			return "<color=red>CAUTION,</color> <color=white>landmines can detonate at any time</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=red>ON A POWDER KEG</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			HullManager.Instance.ExecuteAfterDelay(delegate
			{
				DetonateLandMine();
			}, Random.Range(30, 680));
			HullManager.SendChatEventMessage(this);
		}

		private void DetonateLandMine()
		{
			Landmine[] array = Object.FindObjectsOfType<Landmine>();
			Landmine[] array2 = array;
			foreach (Landmine val in array2)
			{
				val.ExplodeMineServerRpc();
			}
		}
	}
	public class OneForAllEvent : HullEvent
	{
		public override string ID()
		{
			return "OneForAll";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "The ship will fly into orbit in an hour if one of the workers dies";
		}

		public override string GetMessage()
		{
			return "<color=white>The ship will fly into orbit in an hour if one of the workers dies</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=red>ONE FOR ALL!</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			Plugin.OneForAllIsActive = true;
			HullManager.SendChatEventMessage(this);
		}
	}
	public class OpenTheNoorEvent : HullEvent
	{
		public override string ID()
		{
			return "OpenTheNoor";
		}

		public override int GetWeight()
		{
			return 25;
		}

		public override string GetDescription()
		{
			return "All big doors are locked in the level";
		}

		public override string GetMessage()
		{
			return "<color=white>All big doors are locked in the level</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>OPEN THE NOOR...</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			if ((Object)(object)HullManager.Instance == (Object)null)
			{
				Plugin.Mls.LogError((object)"HullManager.Instance is null");
				return;
			}
			if ((Object)(object)level == (Object)null)
			{
				Plugin.Mls.LogError((object)"level is null");
				return;
			}
			HullManager.Instance.ExecuteAfterDelay(delegate
			{
				CloseBigDoors();
			}, 16f);
			HullManager.SendChatEventMessage(this);
		}

		private void CloseBigDoors()
		{
			TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>();
			TerminalAccessibleObject[] array2 = array;
			foreach (TerminalAccessibleObject val in array2)
			{
				val.SetDoorOpenServerRpc(false);
			}
		}
	}
	public class OutSideEnemyDayEvent : HullEvent
	{
		public override string ID()
		{
			return "OutSideEnemyDay";
		}

		public override int GetWeight()
		{
			return 3;
		}

		public override string GetDescription()
		{
			return "Increased amount of enemies on the surface during the daytime";
		}

		public override string GetMessage()
		{
			return "<color=white>Increased amount of enemies on the surface during the daytime</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=red>SILENCE SEASON</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0028: Expected O, but got Unknown
			level.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
			{
				new Keyframe(0f, 512f)
			});
			HullManager.SendChatEventMessage(this);
		}
	}
	public class SlimeEvent : HullEvent
	{
		public override string ID()
		{
			return "Slime";
		}

		public override int GetWeight()
		{
			return 20;
		}

		public override string GetDescription()
		{
			return "Increased chance of slime spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>Inhabited with slime</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>SO SLIMY</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(BlobAI), 48);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class SpringManEvent : HullEvent
	{
		public override string ID()
		{
			return "SpringMan";
		}

		public override int GetWeight()
		{
			return 10;
		}

		public override string GetDescription()
		{
			return "Increased chance of spring man spawning (coil-head)";
		}

		public override string GetMessage()
		{
			return "<color=white>It's impossible not to look at them</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>SKULL COILS</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(SpringManAI), 128);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class TurretEvent : HullEvent
	{
		public override string ID()
		{
			return "Turret";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "Increased chance of turrets spawning";
		}

		public override string GetMessage()
		{
			return "<color=white>Alert, turrets detected</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>TURRETS</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			Plugin.LevelUnits(level, turret: true);
			HullManager.SendChatEventMessage(this);
		}
	}
}