Decompiled source of SawTapes v2.0.0

SawTapes.dll

Decompiled 2 weeks 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 DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SawTapes.Behaviours;
using SawTapes.Behaviours.Items;
using SawTapes.Behaviours.Tapes;
using SawTapes.Files;
using SawTapes.Files.Values;
using SawTapes.Managers;
using SawTapes.NetcodePatcher;
using SawTapes.Patches;
using SawTapes.Values;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SawTapes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SawTapes")]
[assembly: AssemblyTitle("SawTapes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SawTapes
{
	public class Constants
	{
		public const string IMPOSSIBLE_ACTION = "Impossible Action";

		public const string INFORMATION = "Information";

		public const string MESSAGE_INFO_IMP_ACTION = "This action is unavailable while your trial is underway";

		public const string MESSAGE_IMPAC_KEY = "This key is needed by the tested player to survive";

		public const string MESSAGE_IMPAC_SAW = "This saw is needed by the tested players to survive";

		public const string MESSAGE_IMPAC_TESTED_PLAYER = "You are not a tested player, the game can't start";

		public const string MESSAGE_INFO_ERR_PATH_ESCAPE = "An error occurred while determining the path, the game has been cancelled";

		public const string GLOBAL = "_Global_";

		public const string HUD = "_HUD_";

		public const string SURVIVAL_GAME = "Survival Game";

		public const string HUNTING_GAME = "Hunting Game";

		public const string ESCAPE_GAME = "Escape Game";

		public const string SHOVEL = "Shovel";

		public const string PURSUER_EYE = "Pursuer Eye";

		public const string REVERSE_BEAR_TRAP = "Reverse Bear Trap";

		public const string SAW = "Saw";

		public const string SAW_TAPE = "Saw Tape";
	}
	public class ConfigManager
	{
		public static ConfigEntry<int> rarityIncrement;

		public static ConfigEntry<bool> isSawTheme;

		public static ConfigEntry<float> gassingDistance;

		public static ConfigEntry<bool> isSubtitles;

		public static ConfigEntry<float> chronoPosX;

		public static ConfigEntry<float> chronoPosY;

		public static ConfigEntry<float> eyeAuraHunting;

		public static ConfigEntry<float> eyeDistanceSurvival;

		public static ConfigEntry<int> reverseBearTrapValue;

		public static ConfigEntry<int> sawValue;

		public static ConfigEntry<int> sawMaxUse;

		public static ConfigEntry<int> sawTapeValue;

		public static ConfigEntry<int> survivalRarity;

		public static ConfigEntry<int> survivalMinPlayers;

		public static ConfigEntry<int> survivalMaxPlayers;

		public static ConfigEntry<int> survivalDuration;

		public static ConfigEntry<int> survivalBillyValue;

		public static ConfigEntry<string> survivalEnemies;

		public static ConfigEntry<string> survivalInteriorExclusions;

		public static ConfigEntry<int> huntingRarity;

		public static ConfigEntry<int> huntingMinPlayers;

		public static ConfigEntry<int> huntingMaxPlayers;

		public static ConfigEntry<int> huntingDuration;

		public static ConfigEntry<int> huntingBillyValue;

		public static ConfigEntry<float> huntingAura;

		public static ConfigEntry<string> huntingEnemies;

		public static ConfigEntry<string> huntingInteriorExclusions;

		public static ConfigEntry<int> escapeRarity;

		public static ConfigEntry<int> escapeDuration;

		public static ConfigEntry<int> escapeBillyValue;

		public static ConfigEntry<string> escapeHazards;

		public static ConfigEntry<float> escapeAuraDistance;

		public static ConfigEntry<string> escapeInteriorExclusions;

		public static int SurvivalRarity => survivalRarity.Value;

		public static int HuntingRarity => huntingRarity.Value;

		public static int EscapeRarity => escapeRarity.Value;

		public static void Load()
		{
			rarityIncrement = SawTapes.configFile.Bind<int>("_Global_", "Rarity increment", 10, "By how much does the chance of a Saw game appearing increase with each round if it hasn't appeared?");
			isSawTheme = SawTapes.configFile.Bind<bool>("_Global_", "Enable Saw theme", true, "Is Saw theme enabled?");
			gassingDistance = SawTapes.configFile.Bind<float>("_Global_", "Gassing distance", 30f, "Maximum distance between the player and the tape before he is gassed");
			isSubtitles = SawTapes.configFile.Bind<bool>("_HUD_", "Enable subtitles", false, "Is subtitles enabled?");
			chronoPosX = SawTapes.configFile.Bind<float>("_HUD_", "Chrono pos X", 106f, "X position of chrono on interface.");
			chronoPosY = SawTapes.configFile.Bind<float>("_HUD_", "Chrono pos Y", -50f, "Y position of chrono on interface.");
			eyeAuraHunting = SawTapes.configFile.Bind<float>("Pursuer Eye", "Aura duration - Hunting Game", 20f, "Duration for which the enemy's aura is visible through walls for the Hunting Game");
			eyeDistanceSurvival = SawTapes.configFile.Bind<float>("Pursuer Eye", "Activation range - Survival Game", 10f, "Maximum distance between player and enemy for activation for the Survival Game");
			reverseBearTrapValue = SawTapes.configFile.Bind<int>("Reverse Bear Trap", "Reverse Bear Trap value", 30, "Reverse Bear Trap value");
			sawValue = SawTapes.configFile.Bind<int>("Saw", "Saw value", 60, "Saw value");
			sawMaxUse = SawTapes.configFile.Bind<int>("Saw", "Saw max use", 3, "Maximum number of uses before the Saw breaks");
			sawTapeValue = SawTapes.configFile.Bind<int>("Saw Tape", "Saw Tape Tape value", 15, "Saw Tape value");
			survivalRarity = SawTapes.configFile.Bind<int>("Survival Game", "Rarity", 20, "Default probability of the Survival Game mini-game appearing");
			survivalMinPlayers = SawTapes.configFile.Bind<int>("Survival Game", "Min players", 2, "Minimum number of players for Survival Game - Set to -1 to limit it to the number of connected players who can participate");
			survivalMaxPlayers = SawTapes.configFile.Bind<int>("Survival Game", "Max players", -1, "Maximum number of players for Survival Game - Set to -1 to limit it to the number of connected players who can participate");
			survivalDuration = SawTapes.configFile.Bind<int>("Survival Game", "Duration", 120, "Duration of the Survival Game");
			survivalBillyValue = SawTapes.configFile.Bind<int>("Survival Game", "Billy value", 120, "Billy value for the Survival Game");
			survivalEnemies = SawTapes.configFile.Bind<string>("Survival Game", "Enemies list", "Blob,Crawler,Bunker Spider,Flowerman,Puffer,Hoarding bug,Spring,Clay Surgeon,Masked,Nutcracker,Butler", "List of creatures that will be selected by the Survival Game.\nYou can add enemies by separating them with a comma.");
			survivalInteriorExclusions = SawTapes.configFile.Bind<string>("Survival Game", "Interiors exclusion list", "", "List of interiors in which the Survival Game will not appear.");
			huntingRarity = SawTapes.configFile.Bind<int>("Hunting Game", "Rarity", 20, "Default probability of the Hunting Game mini-game appearing");
			huntingMinPlayers = SawTapes.configFile.Bind<int>("Hunting Game", "Min players", 2, "Minimum number of players for Hunting Game - Set to -1 to limit it to the number of connected players who can participate");
			huntingMaxPlayers = SawTapes.configFile.Bind<int>("Hunting Game", "Max players", -1, "Maximum number of players for Hunting Game - Set to -1 to limit it to the number of connected players who can participate");
			huntingDuration = SawTapes.configFile.Bind<int>("Hunting Game", "Duration", 150, "Duration of the Hunting Game");
			huntingBillyValue = SawTapes.configFile.Bind<int>("Hunting Game", "Billy value", 90, "Billy value for the Hunting Game");
			huntingAura = SawTapes.configFile.Bind<float>("Hunting Game", "Aura duration", 30f, "Duration for which the enemy's aura is visible through walls");
			huntingEnemies = SawTapes.configFile.Bind<string>("Hunting Game", "Enemies list", "Crawler,Bunker Spider,Flowerman,Hoarding bug,Masked,Nutcracker,Butler", "List of creatures that will be selected by the Hunting Game.\nYou can add enemies by separating them with a comma.");
			huntingInteriorExclusions = SawTapes.configFile.Bind<string>("Hunting Game", "Interiors exclusion list", "", "List of interiors in which the Hunting Game will not appear.");
			escapeRarity = SawTapes.configFile.Bind<int>("Escape Game", "Rarity", 20, "Default probability of the Escape Game mini-game appearing");
			escapeDuration = SawTapes.configFile.Bind<int>("Escape Game", "Duration", 150, "Duration of the Escape Game");
			escapeBillyValue = SawTapes.configFile.Bind<int>("Escape Game", "Billy value", 90, "Billy value for the Escape Game");
			escapeHazards = SawTapes.configFile.Bind<string>("Escape Game", "Hazards list", "Landmine:2:false:false:false:false,SpikeRoofTrapHazard:3:false:true:true:true,TurretContainer:1:true:false:false:false,LaserTurret:2:false:false:false:false,FanTrapAnimated:2:false:false:false:false,FunctionalMicrowave:1:false:false:false:false", "List of spawnable hazards for the Escape Game.\nThe format is 'HazardName:Weight:SpawnFacingAwayFromWall:SpawnFacingWall:SpawnWithBackToWall:SpawnWithBackFlushAgainstWall'.");
			escapeAuraDistance = SawTapes.configFile.Bind<float>("Hunting Game", "Aura distance", 25f, "Maximum distance between players and the Saw to see its aura through walls");
			escapeInteriorExclusions = SawTapes.configFile.Bind<string>("Escape Game", "Interiors exclusion list", "GrandArmoryFlow,Level3Flow,StorehouseFlow", "List of interiors in which the Escape Game will not appear.");
		}
	}
	[BepInPlugin("Lega.SawTapes", "Saw Tapes", "2.0.0")]
	public class SawTapes : BaseUnityPlugin
	{
		private const string modGUID = "Lega.SawTapes";

		private const string modName = "Saw Tapes";

		private const string modVersion = "2.0.0";

		private readonly Harmony harmony = new Harmony("Lega.SawTapes");

		private static readonly AssetBundle bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sawtapes"));

		internal static ManualLogSource mls;

		public static ConfigFile configFile;

		public static GameObject managerPrefab = NetworkPrefabs.CreateNetworkPrefab("SawTapesNetworkManager");

		public static List<SawTapeValue> sawTapeValues = new List<SawTapeValue>();

		public static GameObject billyPuppetObj;

		public static GameObject reverseBearTrapObj;

		public static Item sawKey;

		public static Item pursuerEye;

		public static Item sawItem;

		public static GameObject chainObj;

		public static GameObject sawTheme;

		public static GameObject sawRecordingSurvival;

		public static GameObject sawRecordingHunting;

		public static GameObject sawRecordingEscape;

		public static GameObject billyRecordingSurvival;

		public static GameObject steamAudio;

		public static GameObject spawnParticle;

		public static GameObject teleportParticle;

		public static GameObject despawnParticle;

		public static GameObject steamParticle;

		public static GameObject pathParticle;

		public static EnemyType billyEnemy;

		public static Material wallhackShader;

		public static HashSet<EnemyType> allEnemies = new HashSet<EnemyType>();

		public void Awake()
		{
			mls = Logger.CreateLogSource("SawTapes");
			configFile = ((BaseUnityPlugin)this).Config;
			ConfigManager.Load();
			LoadManager();
			NetcodePatcher();
			LoadItems();
			LoadEnemies();
			LoadParticles();
			LoadAudios();
			LoadShaders();
			harmony.PatchAll(typeof(HUDManagerPatch));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(ManualCameraRendererPatch));
			harmony.PatchAll(typeof(ShipTeleporterPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(EnemyAIPatch));
		}

		public static void LoadManager()
		{
			Utilities.FixMixerGroups(managerPrefab);
			managerPrefab.AddComponent<SawTapesNetworkManager>();
		}

		private static void NetcodePatcher()
		{
			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);
					}
				}
			}
		}

		public void LoadItems()
		{
			List<SawTapeValue> list = new List<SawTapeValue>();
			list.Add(new SawTapeValue(typeof(SurvivalTape), bundle.LoadAsset<Item>("Assets/SawTape/SurvivalTapeItem.asset"), ConfigManager.SurvivalRarity, ConfigManager.survivalMinPlayers.Value, ConfigManager.survivalMaxPlayers.Value, ConfigManager.survivalInteriorExclusions.Value));
			list.Add(new SawTapeValue(typeof(HuntingTape), bundle.LoadAsset<Item>("Assets/SawTape/HuntingTapeItem.asset"), ConfigManager.HuntingRarity, ConfigManager.huntingMinPlayers.Value, ConfigManager.huntingMaxPlayers.Value, ConfigManager.huntingInteriorExclusions.Value));
			list.Add(new SawTapeValue(typeof(EscapeTape), bundle.LoadAsset<Item>("Assets/SawTape/EscapeTapeItem.asset"), ConfigManager.EscapeRarity, 2, 2, ConfigManager.escapeInteriorExclusions.Value));
			sawTapeValues = list;
			foreach (SawTapeValue sawTapeValue in sawTapeValues)
			{
				RegisterItem(sawTapeValue.Type, sawTapeValue.Item);
			}
			billyPuppetObj = RegisterItem(typeof(BillyPuppet), bundle.LoadAsset<Item>("Assets/BillyPuppet/BillyPuppetItem.asset")).spawnPrefab;
			reverseBearTrapObj = RegisterItem(typeof(ReverseBearTrap), bundle.LoadAsset<Item>("Assets/ReverseBearTrap/ReverseBearTrapItem.asset")).spawnPrefab;
			sawKey = RegisterItem(typeof(SawKey), bundle.LoadAsset<Item>("Assets/SawKey/SawKeyItem.asset"));
			pursuerEye = RegisterItem(typeof(PursuerEye), bundle.LoadAsset<Item>("Assets/PursuerEye/PursuerEyeItem.asset"));
			sawItem = RegisterItem(typeof(Saw), bundle.LoadAsset<Item>("Assets/Saw/SawItem.asset"));
			chainObj = RegisterItem(typeof(Chain), bundle.LoadAsset<Item>("Assets/Chain/ChainItem.asset")).spawnPrefab;
		}

		public Item RegisterItem(Type type, Item item)
		{
			if ((Object)(object)item.spawnPrefab.GetComponent(type) == (Object)null)
			{
				Component obj = item.spawnPrefab.AddComponent(type);
				PhysicsProp val = (PhysicsProp)(object)((obj is PhysicsProp) ? obj : null);
				((GrabbableObject)val).grabbable = true;
				((GrabbableObject)val).grabbableToEnemies = true;
				((GrabbableObject)val).itemProperties = item;
			}
			NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab);
			Utilities.FixMixerGroups(item.spawnPrefab);
			Items.RegisterItem(item);
			return item;
		}

		public void LoadEnemies()
		{
			billyEnemy = bundle.LoadAsset<EnemyType>("Assets/BillyPuppet/BillyEnemy.asset");
			billyEnemy.enemyPrefab.AddComponent<Billy>();
			NetworkPrefabs.RegisterNetworkPrefab(billyEnemy.enemyPrefab);
		}

		public void LoadParticles()
		{
			HashSet<GameObject> hashSet = new HashSet<GameObject>
			{
				spawnParticle = bundle.LoadAsset<GameObject>("Assets/Particles/SpawnParticle.prefab"),
				teleportParticle = bundle.LoadAsset<GameObject>("Assets/Particles/TeleportParticle.prefab"),
				despawnParticle = bundle.LoadAsset<GameObject>("Assets/Particles/DespawnParticle.prefab"),
				steamParticle = bundle.LoadAsset<GameObject>("Assets/Particles/SteamParticle.prefab"),
				pathParticle = bundle.LoadAsset<GameObject>("Assets/Particles/PathParticle.prefab")
			};
			foreach (GameObject item in hashSet)
			{
				NetworkPrefabs.RegisterNetworkPrefab(item);
				Utilities.FixMixerGroups(item);
			}
		}

		public void LoadAudios()
		{
			HashSet<GameObject> hashSet = new HashSet<GameObject>
			{
				sawTheme = bundle.LoadAsset<GameObject>("Assets/Audios/SawTheme.prefab"),
				sawRecordingSurvival = bundle.LoadAsset<GameObject>("Assets/Audios/SawRecording_Survival.prefab"),
				sawRecordingHunting = bundle.LoadAsset<GameObject>("Assets/Audios/SawRecording_Hunting.prefab"),
				sawRecordingEscape = bundle.LoadAsset<GameObject>("Assets/Audios/SawRecording_Escape.prefab"),
				billyRecordingSurvival = bundle.LoadAsset<GameObject>("Assets/Audios/BillyRecording_Survival.prefab"),
				steamAudio = bundle.LoadAsset<GameObject>("Assets/Audios/SteamAudio.prefab")
			};
			foreach (GameObject item in hashSet)
			{
				NetworkPrefabs.RegisterNetworkPrefab(item);
				Utilities.FixMixerGroups(item);
			}
		}

		public static void LoadShaders()
		{
			wallhackShader = bundle.LoadAsset<Material>("Assets/Shaders/WallhackMaterial.mat");
		}
	}
	public class STUtilities
	{
		public static void Shuffle<T>(List<T> list)
		{
			for (int num = list.Count - 1; num > 0; num--)
			{
				int num2 = Random.Range(0, num + 1);
				int index = num2;
				int index2 = num;
				T value = list[num];
				T value2 = list[num2];
				list[index] = value;
				list[index2] = value2;
			}
		}

		public static Transform FindMainEntrancePoint()
		{
			return ((IEnumerable<EntranceTeleport>)Object.FindObjectsOfType<EntranceTeleport>()).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport e) => e.entranceId == 0 && !e.isEntranceToBuilding))?.entrancePoint;
		}

		public static Vector3[] GetFurthestPositions(Vector3 position, int amount)
		{
			//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)
			return (from n in RoundManager.Instance.insideAINodes
				select n.transform.position into p
				orderby Vector3.Distance(position, p) descending
				select p).Take(amount).ToArray();
		}

		public static Vector3 GetFurthestPositionScrapSpawn(Vector3 position, Item itemToSpawn)
		{
			//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)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00e8: 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)
			RandomScrapSpawn val = (from s in Object.FindObjectsOfType<RandomScrapSpawn>()
				where !s.spawnUsed
				orderby Vector3.Distance(position, ((Component)s).transform.position) descending
				select s).FirstOrDefault();
			if ((Object)(object)val == (Object)null)
			{
				val = (from p in Object.FindObjectsOfType<RandomScrapSpawn>()
					orderby Vector3.Distance(position, ((Component)p).transform.position) descending
					select p).FirstOrDefault();
			}
			if (val.spawnedItemsCopyPosition)
			{
				val.spawnUsed = true;
			}
			else
			{
				((Component)val).transform.position = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(((Component)val).transform.position, val.itemSpawnRange, RoundManager.Instance.navHit, RoundManager.Instance.AnomalyRandom, -1) + Vector3.up * itemToSpawn.verticalOffset;
			}
			return ((Component)val).transform.position + Vector3.up * 0.5f;
		}

		public static PlayerControllerB GetFurthestInGamePlayer(PlayerControllerB player)
		{
			return (from p in StartOfRound.Instance.allPlayerScripts.Where(delegate(PlayerControllerB p)
				{
					if (p.isPlayerControlled && !p.isPlayerDead)
					{
						PlayerSTBehaviour playerBehaviour = PlayerSTManager.GetPlayerBehaviour(p);
						if (playerBehaviour != null)
						{
							return playerBehaviour.isInGame;
						}
					}
					return false;
				})
				orderby Vector3.Distance(((Component)player).transform.position, ((Component)p).transform.position) descending
				select p).FirstOrDefault();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SawTapes";

		public const string PLUGIN_NAME = "SawTapes";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace SawTapes.Values
{
	public class EscapeHazard
	{
		public string HazardName { get; internal set; }

		public bool SpawnFacingAwayFromWall { get; internal set; }

		public bool SpawnFacingWall { get; internal set; }

		public bool SpawnWithBackToWall { get; internal set; }

		public bool SpawnWithBackFlushAgainstWall { get; internal set; }

		public EscapeHazard(string hazardName, bool spawnFacingAwayFromWall, bool spawnFacingWall, bool spawnWithBackToWall, bool spawnWithBackFlushAgainstWall)
		{
			HazardName = hazardName;
			SpawnFacingAwayFromWall = spawnFacingAwayFromWall;
			SpawnFacingWall = spawnFacingWall;
			SpawnWithBackToWall = spawnWithBackToWall;
			SpawnWithBackFlushAgainstWall = spawnWithBackFlushAgainstWall;
			base..ctor();
		}
	}
	public class SawTapeValue
	{
		public Type Type { get; internal set; }

		public Item Item { get; internal set; }

		public int DefaultRarity { get; internal set; }

		public int Rarity { get; internal set; }

		public int MinPlayers { get; internal set; }

		public int MaxPlayers { get; internal set; }

		public string InteriorsExclusion { get; internal set; }

		public SawTapeValue(Type type, Item item, int rarity, int minPlayers, int maxPlayers, string interiorsExclusion)
		{
			Type = type;
			Item = item;
			DefaultRarity = rarity;
			Rarity = rarity;
			MinPlayers = minPlayers;
			MaxPlayers = maxPlayers;
			InteriorsExclusion = interiorsExclusion;
			base..ctor();
		}
	}
}
namespace SawTapes.Patches
{
	internal class EnemyAIPatch
	{
		[HarmonyPatch(typeof(EnemyAI), "HitEnemy")]
		[HarmonyPostfix]
		private static void HitEnemy(ref EnemyAI __instance, int force = 1, PlayerControllerB playerWhoHit = null)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)playerWhoHit) && !__instance.isEnemyDead && !((float)(__instance.enemyHP - force) > 0f))
			{
				SawTape sawTapeFromPlayer = SawGameSTManager.GetSawTapeFromPlayer(playerWhoHit);
				if (!((Object)(object)sawTapeFromPlayer == (Object)null) && (sawTapeFromPlayer is HuntingTape || sawTapeFromPlayer is SurvivalTape))
				{
					SawTapesNetworkManager.Instance.SpawnPursuerEyeServerRpc(((Component)__instance).transform.position);
				}
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "KillEnemy")]
		[HarmonyPostfix]
		private static void KillEnemy(ref EnemyAI __instance)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (((NetworkBehaviour)localPlayerController).IsHost || ((NetworkBehaviour)localPlayerController).IsServer)
			{
				HuntingTape huntingTape = StartOfRound.Instance.allPlayerScripts.Select((PlayerControllerB p) => PlayerSTManager.GetPlayerBehaviour(p)?.sawTape as HuntingTape).FirstOrDefault((HuntingTape h) => (Object)(object)h != (Object)null);
				if (!((Object)(object)huntingTape == (Object)null) && huntingTape.spawnedEnemies.Contains(__instance.thisNetworkObject))
				{
					RoundManagerPatch.SpawnItem(SawTapes.sawKey.spawnPrefab, ((Component)__instance).transform.position);
				}
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "PlayerIsTargetable")]
		[HarmonyPrefix]
		private static bool IsPlayerTargetable(ref bool __result, PlayerControllerB playerScript)
		{
			PlayerSTBehaviour playerBehaviour = PlayerSTManager.GetPlayerBehaviour(playerScript);
			if ((Object)(object)playerBehaviour == (Object)null || playerBehaviour.isTargetable)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	internal class HUDManagerPatch
	{
		public static TextMeshProUGUI chronoText;

		public static TextMeshProUGUI subtitleText;

		public static bool isChronoEnded = false;

		public static Dictionary<EntranceTeleport, Tile> blockedEntrances = new Dictionary<EntranceTeleport, Tile>();

		public static bool isFlashFilterUsed = false;

		[HarmonyPatch(typeof(HUDManager), "Start")]
		[HarmonyPostfix]
		private static void StartHUDManager()
		{
			//IL_000f: 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_002d: 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)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00b1: 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)
			chronoText = HUDSTManager.CreateUIElement("ChronoUI", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(ConfigManager.chronoPosX.Value, ConfigManager.chronoPosY.Value), new Vector2(300f, 300f), (TextAlignmentOptions)257);
			if (ConfigManager.isSubtitles.Value)
			{
				subtitleText = HUDSTManager.CreateUIElement("SubtitleUI", new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -125f), new Vector2(600f, 200f), (TextAlignmentOptions)514);
			}
		}

		public static IEnumerator StartChronoCoroutine(int seconds)
		{
			while (!IsChronoEnded(seconds))
			{
				seconds--;
				yield return (object)new WaitForSecondsRealtime(1f);
			}
		}

		private static bool IsChronoEnded(int totalSeconds)
		{
			int num = (int)Math.Floor((double)totalSeconds / 60.0);
			int num2 = (int)Math.Floor((double)totalSeconds % 60.0);
			((TMP_Text)chronoText).text = $"{num:D2}:{num2:D2}";
			if (GameNetworkManager.Instance.localPlayerController.isPlayerDead || isChronoEnded || (num == 0 && num2 == 0))
			{
				((TMP_Text)chronoText).text = "";
				isChronoEnded = false;
				return true;
			}
			return false;
		}

		[HarmonyPatch(typeof(HUDManager), "HoldInteractionFill")]
		[HarmonyPostfix]
		private static void HoldInteraction(ref bool __result)
		{
			if (!__result)
			{
				return;
			}
			InteractTrigger hoveringOverTrigger = GameNetworkManager.Instance.localPlayerController.hoveringOverTrigger;
			if (!((Object)(object)hoveringOverTrigger == (Object)null))
			{
				EntranceTeleport component = ((Component)hoveringOverTrigger).GetComponent<EntranceTeleport>();
				if (!((Object)(object)component == (Object)null) && IsEntranceBlocked(component))
				{
					HUDManager.Instance.DisplayTip("Impossible Action", "This action is unavailable while your trial is underway", false, false, "LC_Tip1");
					__result = false;
				}
			}
		}

		public static bool IsEntranceBlocked(EntranceTeleport entranceTeleport)
		{
			return blockedEntrances.ContainsKey(entranceTeleport);
		}

		[HarmonyPatch(typeof(HUDManager), "SetScreenFilters")]
		[HarmonyPrefix]
		private static bool UpdateScreenFilters()
		{
			return !isFlashFilterUsed;
		}
	}
	internal class ManualCameraRendererPatch
	{
		[HarmonyPatch(typeof(ManualCameraRenderer), "updateMapTarget")]
		[HarmonyPostfix]
		private static void MapCameraText(ref ManualCameraRenderer __instance)
		{
			MapCameraSTManager.UpdateMapCamera(__instance);
		}
	}
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		private static void StartPlayerControllerB(ref PlayerControllerB __instance)
		{
			PlayerSTManager.AddPlayerBehaviour(__instance);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "TeleportPlayer")]
		[HarmonyPrefix]
		private static bool TeleportPlayer(ref PlayerControllerB __instance)
		{
			return !PlayerSTManager.PreventTeleportPlayer(__instance);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "spawnPlayerAnimTimer")]
		[HarmonyPrefix]
		private static void SpawnPlayerAnim(ref PlayerControllerB __instance)
		{
			PlayerSTBehaviour playerBehaviour = PlayerSTManager.GetPlayerBehaviour(__instance);
			if (!((Object)(object)playerBehaviour == (Object)null))
			{
				((MonoBehaviour)__instance).StartCoroutine(PlayerSTManager.SetUntargetablePlayerCoroutine(playerBehaviour, 4f));
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ItemSecondaryUse_performed")]
		[HarmonyPrefix]
		private static void SecondaryUsePerformed(ref PlayerControllerB __instance)
		{
			if (!((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				PlayerSTBehaviour playerBehaviour = PlayerSTManager.GetPlayerBehaviour(__instance);
				if (!((Object)(object)playerBehaviour == (Object)null))
				{
					(playerBehaviour.sawTape as EscapeTape)?.TeleportSawToPlayerServerRpc((int)__instance.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerClientRpc")]
		[HarmonyPostfix]
		private static void KillPlayerForClient(ref PlayerControllerB __instance, int playerId)
		{
			PlayerControllerB component = __instance.playersManager.allPlayerObjects[playerId].GetComponent<PlayerControllerB>();
			PlayerSTManager.ResetPlayerGame(component);
		}
	}
	internal class RoundManagerPatch
	{
		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPostfix]
		private static void SpawnItems()
		{
			AddNewItems();
		}

		public static void AddNewItems()
		{
			List<RandomScrapSpawn> list = (from s in Object.FindObjectsOfType<RandomScrapSpawn>()
				where !s.spawnUsed
				select s).ToList();
			SpawnTape(list[new Random().Next(0, list.Count)]);
		}

		public static void SpawnTape(RandomScrapSpawn randomScrapSpawn)
		{
			//IL_0036: 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)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0070: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if ((Object)(object)randomScrapSpawn == (Object)null)
			{
				return;
			}
			SawTapeValue sawTapeValue = GetSawTapeValue();
			if (sawTapeValue != null)
			{
				if (randomScrapSpawn.spawnedItemsCopyPosition)
				{
					randomScrapSpawn.spawnUsed = true;
				}
				else
				{
					((Component)randomScrapSpawn).transform.position = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(((Component)randomScrapSpawn).transform.position, randomScrapSpawn.itemSpawnRange, RoundManager.Instance.navHit, RoundManager.Instance.AnomalyRandom, -1) + Vector3.up * sawTapeValue.Item.verticalOffset;
				}
				SpawnItem(sawTapeValue.Item.spawnPrefab, ((Component)randomScrapSpawn).transform.position + Vector3.up * 0.5f);
			}
		}

		public static SawTapeValue GetSawTapeValue()
		{
			SawTapeValue sawTapeValue = null;
			STUtilities.Shuffle(SawTapes.sawTapeValues);
			foreach (SawTapeValue sawTapeValue2 in SawTapes.sawTapeValues)
			{
				if ((string.IsNullOrEmpty(sawTapeValue2.InteriorsExclusion) || !sawTapeValue2.InteriorsExclusion.Contains(((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name)) && sawTapeValue2.MinPlayers <= StartOfRound.Instance.connectedPlayersAmount + 1)
				{
					if (sawTapeValue == null && new Random().Next(1, 100) <= sawTapeValue2.Rarity)
					{
						sawTapeValue = sawTapeValue2;
						sawTapeValue2.Rarity = sawTapeValue2.DefaultRarity;
					}
					else
					{
						sawTapeValue2.Rarity = Mathf.Min(100, sawTapeValue2.Rarity + ConfigManager.rarityIncrement.Value);
					}
				}
			}
			return sawTapeValue;
		}

		public static GrabbableObject SpawnItem(GameObject spawnPrefab, Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return SpawnItem(spawnPrefab, position, Quaternion.identity);
		}

		public static GrabbableObject SpawnItem(GameObject spawnPrefab, Vector3 position, Quaternion rotation)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsServer && !((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsHost)
			{
				return null;
			}
			GrabbableObject val = null;
			try
			{
				GameObject val2 = Object.Instantiate<GameObject>(spawnPrefab, position, rotation, StartOfRound.Instance.propsContainer);
				val = val2.GetComponent<GrabbableObject>();
				val.fallTime = 0f;
				val2.GetComponent<NetworkObject>().Spawn(false);
			}
			catch (Exception arg)
			{
				SawTapes.mls.LogError((object)$"Error in SpawnItem: {arg}");
			}
			return val;
		}
	}
	internal class ShipTeleporterPatch
	{
		[HarmonyPatch(typeof(ShipTeleporter), "PressTeleportButtonOnLocalClient")]
		[HarmonyPrefix]
		private static bool PreventTeleport(ref ShipTeleporter __instance)
		{
			if (__instance.isInverseTeleporter || (Object)(object)StartOfRound.Instance.mapScreen.targetedPlayer == (Object)null)
			{
				return true;
			}
			PlayerSTBehaviour playerBehaviour = PlayerSTManager.GetPlayerBehaviour(StartOfRound.Instance.mapScreen.targetedPlayer);
			if ((Object)(object)playerBehaviour == (Object)null || !playerBehaviour.isInGame)
			{
				return true;
			}
			return false;
		}
	}
	internal class StartOfRoundPatch
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyBefore(new string[] { "evaisa.lethallib" })]
		[HarmonyPostfix]
		private static void StartRound(ref StartOfRound __instance)
		{
			if (NetworkManager.Singleton.IsHost && (Object)(object)SawTapesNetworkManager.Instance == (Object)null)
			{
				GameObject val = Object.Instantiate<GameObject>(SawTapes.managerPrefab, ((Component)__instance).transform.parent);
				val.GetComponent<NetworkObject>().Spawn(false);
				SawTapes.mls.LogInfo((object)"Spawning SawTapesNetworkManager");
			}
			AffectEnemiesForSawGames();
			SubtitleFile.LoadJSON();
		}

		public static void AffectEnemiesForSawGames()
		{
			SawTapes.allEnemies.Clear();
			EnemyAI val = default(EnemyAI);
			foreach (EnemyType item in Resources.FindObjectsOfTypeAll<EnemyType>().Distinct())
			{
				if (!((Object)(object)item == (Object)null) && !((Object)(object)item.enemyPrefab == (Object)null) && item.enemyPrefab.TryGetComponent<EnemyAI>(ref val) && (Object)(object)val != (Object)null)
				{
					SawTapes.allEnemies.Add(item);
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "OnDisable")]
		[HarmonyPostfix]
		public static void OnDisable()
		{
			SawTapesNetworkManager.Instance = null;
		}

		[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
		[HarmonyPostfix]
		private static void PlayerConnection(ref StartOfRound __instance)
		{
			PlayerControllerB[] allPlayerScripts = __instance.allPlayerScripts;
			foreach (PlayerControllerB player in allPlayerScripts)
			{
				PlayerSTManager.AddPlayerBehaviour(player);
			}
		}
	}
}
namespace SawTapes.Managers
{
	public class CustomPassManager : MonoBehaviour
	{
		public static WallhackCustomPass wallhackPass;

		public static CustomPassVolume customPassVolume;

		public static CustomPassVolume CustomPassVolume
		{
			get
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)customPassVolume == (Object)null)
				{
					customPassVolume = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).gameObject.AddComponent<CustomPassVolume>();
					if ((Object)(object)customPassVolume != (Object)null)
					{
						customPassVolume.targetCamera = GameNetworkManager.Instance.localPlayerController.gameplayCamera;
						customPassVolume.injectionPoint = (CustomPassInjectionPoint)1;
						customPassVolume.isGlobal = true;
						wallhackPass = new WallhackCustomPass();
						customPassVolume.customPasses.Add((CustomPass)(object)wallhackPass);
					}
				}
				return customPassVolume;
			}
		}

		public static void SetupCustomPassForObjects(GameObject[] objects)
		{
			//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)
			LayerMask wallhackLayer = LayerMask.op_Implicit(524288);
			List<Renderer> list = new List<Renderer>();
			EnemyAI val2 = default(EnemyAI);
			foreach (GameObject val in objects)
			{
				List<Renderer> list2 = val.GetComponentsInChildren<Renderer>().ToList();
				if (val.TryGetComponent<EnemyAI>(ref val2))
				{
					list2 = list2.Where((Renderer r) => (LayerMask.op_Implicit(wallhackLayer) & (1 << ((Component)r).gameObject.layer)) != 0).ToList();
					if (list2.Any((Renderer r) => ((Object)r).name.Contains("LOD")))
					{
						list2.RemoveAll((Renderer r) => !((Object)r).name.Contains("LOD"));
					}
				}
				if (list2.Count == 0)
				{
					SawTapes.mls.LogError((object)("No renderer could be found on " + ((Object)val).name + "."));
				}
				else
				{
					list.AddRange(list2);
				}
			}
			if (list.Count > 0)
			{
				SetupCustomPass(list.ToArray());
			}
		}

		public static void SetupCustomPass(Renderer[] renderers)
		{
			if ((Object)(object)CustomPassVolume == (Object)null)
			{
				SawTapes.mls.LogError((object)"CustomPassVolume is not assigned.");
				return;
			}
			wallhackPass = CustomPassVolume.customPasses.Find((CustomPass pass) => pass is WallhackCustomPass) as WallhackCustomPass;
			if (wallhackPass == null)
			{
				SawTapes.mls.LogError((object)"WallhackCustomPass could not be found in CustomPassVolume.");
			}
			else
			{
				wallhackPass.SetTargetRenderers(renderers, SawTapes.wallhackShader);
			}
		}

		public static void RemoveAura()
		{
			wallhackPass?.ClearTargetRenderers();
		}
	}
	public class EnemySTManager
	{
		public static NetworkObject SpawnEnemyForServer(EnemyType enemyType, Vector3 spawnPosition)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(enemyType.enemyPrefab, spawnPosition, Quaternion.identity);
			NetworkObject componentInChildren = val.GetComponentInChildren<NetworkObject>();
			componentInChildren.Spawn(true);
			return componentInChildren;
		}

		public static void DespawnEnemiesForServer(List<NetworkObject> spawnedEnemies)
		{
			foreach (NetworkObject spawnedEnemy in spawnedEnemies)
			{
				if (!((Object)(object)spawnedEnemy == (Object)null))
				{
					EnemyAI componentInChildren = ((Component)spawnedEnemy).GetComponentInChildren<EnemyAI>();
					if (!((Object)(object)componentInChildren?.thisNetworkObject == (Object)null) && componentInChildren.thisNetworkObject.IsSpawned && !componentInChildren.isEnemyDead)
					{
						DespawnEnemy(spawnedEnemy);
					}
				}
			}
		}

		public static void DespawnEnemy(NetworkObject spawnedEnemy)
		{
			//IL_0024: 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)
			EnemyAI componentInChildren = ((Component)spawnedEnemy).GetComponentInChildren<EnemyAI>();
			if (!((Object)(object)componentInChildren == (Object)null) && !componentInChildren.isEnemyDead)
			{
				SawTapesNetworkManager.Instance.PlayDespawnParticleClientRpc(((Component)spawnedEnemy).transform.position);
				NutcrackerEnemyAI val = (NutcrackerEnemyAI)(object)((componentInChildren is NutcrackerEnemyAI) ? componentInChildren : null);
				if (val != null && (Object)(object)val.gun != (Object)null)
				{
					SawTapesNetworkManager.Instance.DestroyObjectClientRpc(NetworkObjectReference.op_Implicit(((Component)val.gun).GetComponent<NetworkObject>()));
				}
				spawnedEnemy.Despawn(true);
			}
		}
	}
	public class HUDSTManager
	{
		public static TextMeshProUGUI CreateUIElement(string name, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 anchoredPosition, Vector2 sizeDelta, TextAlignmentOptions alignment)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001d: 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)
			//IL_003e: 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_004c: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = GameObject.Find("Systems/UI/Canvas/Panel/GameObject/PlayerScreen").transform;
			GameObject val = new GameObject(name);
			val.transform.localPosition = Vector3.zero;
			RectTransform val2 = val.AddComponent<RectTransform>();
			((Transform)val2).SetParent(transform, false);
			val2.anchorMin = anchorMin;
			val2.anchorMax = anchorMax;
			val2.pivot = pivot;
			val2.anchoredPosition = anchoredPosition;
			val2.sizeDelta = sizeDelta;
			TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val3).alignment = alignment;
			((TMP_Text)val3).font = ((TMP_Text)HUDManager.Instance.controlTipLines[0]).font;
			((TMP_Text)val3).fontSize = 14f;
			return val3;
		}
	}
	public class MapCameraSTManager
	{
		public static void UpdateMapCamera(ManualCameraRenderer mapScreen)
		{
			if (StartOfRound.Instance.shipHasLanded && !((Object)(object)mapScreen.targetedPlayer == (Object)null))
			{
				PlayerSTBehaviour playerBehaviour = PlayerSTManager.GetPlayerBehaviour(StartOfRound.Instance.mapScreen.targetedPlayer);
				if ((Object)(object)playerBehaviour == (Object)null || !playerBehaviour.isInGame)
				{
					((Behaviour)StartOfRound.Instance.mapScreenPlayerName).enabled = true;
					((Behaviour)StartOfRound.Instance.screenLevelDescription).enabled = false;
					((TMP_Text)StartOfRound.Instance.screenLevelDescription).text = "";
				}
				else
				{
					((Behaviour)StartOfRound.Instance.mapScreenPlayerName).enabled = false;
					((Behaviour)StartOfRound.Instance.screenLevelDescription).enabled = true;
					((TMP_Text)StartOfRound.Instance.screenLevelDescription).text = mapScreen.targetedPlayer.playerUsername + " is playing a game";
				}
			}
		}
	}
	public class ObjectSTManager
	{
		public static void ChangeObjectPosition(GrabbableObject grabbableObject, Vector3 position)
		{
			//IL_0016: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!grabbableObject.isHeld)
			{
				grabbableObject.EnableItemMeshes(false);
				((Component)grabbableObject).transform.localPosition = position;
				((Component)grabbableObject).transform.position = position;
				grabbableObject.startFallingPosition = position;
				grabbableObject.FallToGround(false);
				grabbableObject.hasHitGround = false;
				grabbableObject.EnableItemMeshes(true);
			}
		}

		public static void DestroyObjectOfTypeForServer<T>(T grabbableObject) where T : GrabbableObject
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)grabbableObject == (Object)null))
			{
				NetworkObject component = ((Component)(object)grabbableObject).GetComponent<NetworkObject>();
				if (!((Object)(object)component == (Object)null) && component.IsSpawned)
				{
					SawTapesNetworkManager.Instance.DestroyObjectClientRpc(NetworkObjectReference.op_Implicit(((Component)(object)grabbableObject).GetComponent<NetworkObject>()));
				}
			}
		}

		public static void DestroyObjectsOfTypeAllForServer<T>() where T : GrabbableObject
		{
			T[] array = Resources.FindObjectsOfTypeAll<T>();
			foreach (T grabbableObject in array)
			{
				DestroyObjectOfTypeForServer(grabbableObject);
			}
		}

		public static void DestroyReverseBearTrapForServer(PlayerControllerB player)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsHost && !((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsServer)
			{
				return;
			}
			PlayerSTBehaviour playerBehaviour = PlayerSTManager.GetPlayerBehaviour(player);
			if (!((Object)(object)playerBehaviour == (Object)null) && !((Object)(object)playerBehaviour.reverseBearTrap == (Object)null))
			{
				NetworkObject component = ((Component)playerBehaviour.reverseBearTrap).GetComponent<NetworkObject>();
				if (!((Object)(object)component == (Object)null) && component.IsSpawned)
				{
					SawTapesNetworkManager.Instance.DestroyObjectClientRpc(NetworkObjectReference.op_Implicit(component));
				}
			}
		}
	}
	public class PlayerSTManager
	{
		public static Dictionary<PlayerControllerB, PlayerSTBehaviour> playerBehavioursCache = new Dictionary<PlayerControllerB, PlayerSTBehaviour>();

		public static void AddPlayerBehaviour(PlayerControllerB player)
		{
			if (player.isPlayerControlled && !((Object)(object)((Component)player).GetComponent<PlayerSTBehaviour>() != (Object)null))
			{
				PlayerSTBehaviour playerSTBehaviour = ((Component)player).gameObject.AddComponent<PlayerSTBehaviour>();
				playerSTBehaviour.playerProperties = player;
			}
		}

		public static PlayerSTBehaviour GetPlayerBehaviour(PlayerControllerB player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			if (playerBehavioursCache.TryGetValue(player, out var value))
			{
				return value;
			}
			value = ((Component)player).GetComponent<PlayerSTBehaviour>();
			if ((Object)(object)value == (Object)null)
			{
				AddPlayerBehaviour(player);
				playerBehavioursCache.TryGetValue(player, out value);
				return value;
			}
			playerBehavioursCache[player] = value;
			return value;
		}

		public static IEnumerator SetUntargetablePlayerCoroutine(PlayerSTBehaviour playerBehaviour, float duration)
		{
			playerBehaviour.isTargetable = false;
			yield return (object)new WaitForSeconds(duration);
			playerBehaviour.isTargetable = true;
		}

		public static bool PreventTeleportPlayer(PlayerControllerB player)
		{
			PlayerSTBehaviour playerBehaviour = GetPlayerBehaviour(player);
			if ((Object)(object)playerBehaviour == (Object)null)
			{
				return false;
			}
			if (!playerBehaviour.isInGame || !playerBehaviour.hasBeenGassed)
			{
				return false;
			}
			if ((Object)(object)player != (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				return true;
			}
			HUDManager.Instance.DisplayTip("Information", "This action is unavailable while your trial is underway", false, false, "LC_Tip1");
			return true;
		}

		public static void ResetPlayerGame(PlayerControllerB player)
		{
			PlayerSTBehaviour playerBehaviour = GetPlayerBehaviour(player);
			if (!((Object)(object)playerBehaviour == (Object)null))
			{
				playerBehaviour.isTargetable = true;
				playerBehaviour.isInGame = false;
				playerBehaviour.hasBeenGassed = false;
				playerBehaviour.sawTape = null;
				ObjectSTManager.DestroyReverseBearTrapForServer(playerBehaviour.playerProperties);
				playerBehaviour.reverseBearTrap = null;
			}
		}
	}
	public class SawGameSTManager
	{
		public static SawTape GetSawTapeFromPlayer(PlayerControllerB player)
		{
			return PlayerSTManager.GetPlayerBehaviour(player)?.sawTape;
		}

		public static GrabbableObject SpawnItemFromNameForServer(string name, Vector3 position)
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = null;
			IEnumerable<NetworkPrefabsList> networkPrefabsLists = NetworkManager.Singleton.NetworkConfig.Prefabs.NetworkPrefabsLists;
			foreach (NetworkPrefabsList item in networkPrefabsLists ?? Enumerable.Empty<NetworkPrefabsList>())
			{
				IEnumerable<NetworkPrefab> prefabList = item.PrefabList;
				foreach (NetworkPrefab item2 in prefabList ?? Enumerable.Empty<NetworkPrefab>())
				{
					GrabbableObject component = item2.Prefab.GetComponent<GrabbableObject>();
					if (!((Object)(object)component == (Object)null) && !((Object)(object)component.itemProperties == (Object)null) && component.itemProperties.itemName.Equals(name))
					{
						val = item2.Prefab;
						if ((Object)(object)val != (Object)null)
						{
							break;
						}
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			return RoundManagerPatch.SpawnItem(val, position + Vector3.up * 0.5f);
		}

		public static void SpawnPathParticle(Vector3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0046: 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)
			//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_0070: 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_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)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(position + Vector3.up * 2f, Vector3.down, ref val, 10f))
			{
				position = ((RaycastHit)(ref val)).point;
			}
			GameObject val2 = Object.Instantiate<GameObject>(SawTapes.pathParticle, position, Quaternion.Euler(-90f, 0f, 0f));
			ParticleSystem component = val2.GetComponent<ParticleSystem>();
			MainModule main = component.main;
			float duration = ((MainModule)(ref main)).duration;
			main = component.main;
			MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
			Object.Destroy((Object)(object)val2, duration + ((MinMaxCurve)(ref startLifetime)).constantMax);
		}

		public static void DespawnHazard(GameObject hazard)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)hazard == (Object)null) && !((Object)(object)hazard.transform == (Object)null))
			{
				SawTapesNetworkManager.Instance.PlayDespawnParticleClientRpc(hazard.transform.position);
				hazard.GetComponent<NetworkObject>().Despawn(true);
			}
		}
	}
	public class SawTapesNetworkManager : NetworkBehaviour
	{
		public static SawTapesNetworkManager Instance;

		public void Awake()
		{
			Instance = this;
		}

		[ClientRpc]
		public void SetScrapValueClientRpc(NetworkObjectReference obj, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2854845142u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
					BytePacker.WriteValueBitPacked(val2, value);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2854845142u, val, (RpcDelivery)0);
				}
				NetworkObject val3 = default(NetworkObject);
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref obj)).TryGet(ref val3, (NetworkManager)null))
				{
					GrabbableObject componentInChildren = ((Component)val3).gameObject.GetComponentInChildren<GrabbableObject>();
					componentInChildren.SetScrapValue(value);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void ChangeObjectPositionServerRpc(NetworkObjectReference obj, Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(603606525u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 603606525u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ChangeObjectPositionClientRpc(obj, position);
				}
			}
		}

		[ClientRpc]
		public void ChangeObjectPositionClientRpc(NetworkObjectReference obj, Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2827975664u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2827975664u, val, (RpcDelivery)0);
				}
				NetworkObject val3 = default(NetworkObject);
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref obj)).TryGet(ref val3, (NetworkManager)null))
				{
					GrabbableObject componentInChildren = ((Component)val3).gameObject.GetComponentInChildren<GrabbableObject>();
					ObjectSTManager.ChangeObjectPosition(componentInChildren, position);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DestroyObjectServerRpc(NetworkObjectReference obj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3111254174u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3111254174u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					DestroyObjectClientRpc(obj);
				}
			}
		}

		[ClientRpc]
		public void DestroyObjectClientRpc(NetworkObjectReference obj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2084577577u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2084577577u, val, (RpcDelivery)0);
				}
				NetworkObject val3 = default(NetworkObject);
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref obj)).TryGet(ref val3, (NetworkManager)null))
				{
					GrabbableObject componentInChildren = ((Component)val3).gameObject.GetComponentInChildren<GrabbableObject>();
					componentInChildren.DestroyObjectInHand(componentInChildren.playerHeldBy);
				}
			}
		}

		[ClientRpc]
		public void KillPlayerClientRpc(int playerId, Vector3 velocity, bool spawnBody, int causeOfDeath)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00a6: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(998721621u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref velocity);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref spawnBody, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, causeOfDeath);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 998721621u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[playerId].GetComponent<PlayerControllerB>();
				if (!((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController))
				{
					component.KillPlayer(velocity, spawnBody, (CauseOfDeath)causeOfDeath, 0, default(Vector3));
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnPursuerEyeServerRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1100417780u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1100417780u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					RoundManagerPatch.SpawnItem(SawTapes.pursuerEye.spawnPrefab, position);
				}
			}
		}

		[ClientRpc]
		public void PlayDespawnParticleClientRpc(Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3869059331u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3869059331u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					GameObject val3 = Object.Instantiate<GameObject>(SawTapes.despawnParticle, position, Quaternion.identity);
					ParticleSystem component = val3.GetComponent<ParticleSystem>();
					MainModule main = component.main;
					float duration = ((MainModule)(ref main)).duration;
					main = component.main;
					MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
					Object.Destroy((Object)(object)val3, duration + ((MinMaxCurve)(ref startLifetime)).constantMax);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SawTapesNetworkManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2854845142u, new RpcReceiveHandler(__rpc_handler_2854845142));
			NetworkManager.__rpc_func_table.Add(603606525u, new RpcReceiveHandler(__rpc_handler_603606525));
			NetworkManager.__rpc_func_table.Add(2827975664u, new RpcReceiveHandler(__rpc_handler_2827975664));
			NetworkManager.__rpc_func_table.Add(3111254174u, new RpcReceiveHandler(__rpc_handler_3111254174));
			NetworkManager.__rpc_func_table.Add(2084577577u, new RpcReceiveHandler(__rpc_handler_2084577577));
			NetworkManager.__rpc_func_table.Add(998721621u, new RpcReceiveHandler(__rpc_handler_998721621));
			NetworkManager.__rpc_func_table.Add(1100417780u, new RpcReceiveHandler(__rpc_handler_1100417780));
			NetworkManager.__rpc_func_table.Add(3869059331u, new RpcReceiveHandler(__rpc_handler_3869059331));
		}

		private static void __rpc_handler_2854845142(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference obj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SawTapesNetworkManager)(object)target).SetScrapValueClientRpc(obj, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_603606525(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0060: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference obj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SawTapesNetworkManager)(object)target).ChangeObjectPositionServerRpc(obj, position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2827975664(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0060: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference obj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SawTapesNetworkManager)(object)target).ChangeObjectPositionClientRpc(obj, position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3111254174(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference obj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SawTapesNetworkManager)(object)target).DestroyObjectServerRpc(obj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2084577577(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference obj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref obj, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SawTapesNetworkManager)(object)target).DestroyObjectClientRpc(obj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_998721621(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_007a: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				Vector3 velocity = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref velocity);
				bool spawnBody = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref spawnBody, default(ForPrimitives));
				int causeOfDeath = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref causeOfDeath);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SawTapesNetworkManager)(object)target).KillPlayerClientRpc(playerId, velocity, spawnBody, causeOfDeath);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1100417780(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SawTapesNetworkManager)(object)target).SpawnPursuerEyeServerRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3869059331(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SawTapesNetworkManager)(object)target).PlayDespawnParticleClientRpc(position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "SawTapesNetworkManager";
		}
	}
}
namespace SawTapes.Files
{
	public class SubtitleFile
	{
		public static string FilePath = Path.Combine(Paths.ConfigPath, "ST.subtitles.json");

		public static HashSet<SubtitleMapping> survivalGameSubtitles;

		public static HashSet<SubtitleMapping> huntingGameSubtitles;

		public static HashSet<SubtitleMapping> escapeGameSubtitles;

		public static HashSet<SubtitleMapping> billySubtitles;

		public static string Get()
		{
			return "{\n  \"survival_game\": [\n    {\n      \"timestamp\": 0,\n      // Hello workers\n      \"text\": \"Bonjour travailleurs\"\n    },\n    {\n      \"timestamp\": 1.2,\n      // All your life, you have fled from responsibility\n      \"text\": \"Toute votre vie, vous avez fui toute responsabilité\"\n    },\n    {\n      \"timestamp\": 4.01,\n      // sacrificing others to ensure your own survival\n      \"text\": \"sacrifiant les autres pour assurer votre propre survie\"\n    },\n    {\n      \"timestamp\": 7.59,\n      // But today, there is no escape\n      \"text\": \"Mais aujourd’hui, il n’y a plus d’échappatoire\"\n    },\n    {\n      \"timestamp\": 9.94,\n      // You are being hunted and you will inevitably draw the attention of the creatures lurking here\n      \"text\": \"Vous êtes traqués et vous attirerez inévitablement l’attention des créatures qui rôdent ici\"\n    },\n    {\n      \"timestamp\": 15.11,\n      // A single eye may divert their gaze… but at the cost of another sacrifice\n      \"text\": \"Un œil peut détourner leur regard… mais au prix d’un autre sacrifice\"\n    },\n    {\n      \"timestamp\": 19.56,\n      // Let the game begin\n      \"text\": \"Que le jeu commence\"\n    }\n  ],\n  \"hunting_game\": [\n    {\n      \"timestamp\": 0,\n      // Hello workers\n      \"text\": \"Bonjour travailleurs\"\n    },\n    {\n      \"timestamp\": 1.25,\n      // All your life, you have spilled blood without consequences\n      \"text\": \"Toute votre vie, vous avez fait couler le sang sans conséquences\"\n    },\n    {\n      \"timestamp\": 4.91,\n      // finding pleasure in the pain of others\n      \"text\": \"trouvant du plaisir dans la douleur des autres\"\n    },\n    {\n      \"timestamp\": 7.44,\n      // Today, that brutality has become your only way out\n      \"text\": \"Aujourd’hui, cette brutalité est devenue votre seule issue\"\n    },\n    {\n      \"timestamp\": 11.41,\n      // A key is your salvation, but it lies within the guts of beasts you must hunt\n      \"text\": \"Une clé est votre salut, mais elle repose dans les entrailles de bêtes que vous devrez traquer\"\n    },\n    {\n      \"timestamp\": 16.63,\n      // Live or die, the choice is yours\n      \"text\": \"Vivre ou mourir, à vous de choisir\"\n    }\n  ],\n  \"escape_game\": [\n    {\n      \"timestamp\": 0,\n      // Hello workers.\n      \"text\": \"Bonjour travailleurs\"\n    },\n    {\n      \"timestamp\": 1.27,\n      // Until now\n      \"text\": \"Jusqu'à maintenant\"\n    },\n    {\n      \"timestamp\": 2.21,\n      // you have made decisions that impacted the lives of others without facing the consequences yourselves\n      \"text\": \"vous avez pris des décisions qui ont affecté la vie des autres sans en subir vous-même les conséquences\"\n    },\n    {\n      \"timestamp\": 8.43,\n      // But today, your lives are bound together\n      \"text\": \"Mais aujourd'hui, vos vies sont liées\"\n    },\n    {\n      \"timestamp\": 11.16,\n      // The chains that tether you represent your ability—or inability—to work as one\n      \"text\": \"Les chaînes qui vous attachent représentent votre capacité, ou votre incapacité, à travailler ensemble\"\n    },\n    {\n      \"timestamp\": 16.85,\n      // Path to freedom is littered with deadly traps\n      \"text\": \"Votre chemin vers la liberté est jonché de pièges mortels\"\n    },\n    {\n      \"timestamp\": 20.41,\n      // Reach the saw before it's too late, or prepare to perish together\n      \"text\": \"Atteignez la scie avant qu'il ne soit trop tard, ou préparez-vous à périr ensemble\"\n    },\n    {\n      \"timestamp\": 24.93,\n      // The choice is yours\n      \"text\": \"Le choix est à vous\"\n    }\n  ],\n  \"billy_announcement\": [\n    {\n      \"timestamp\": 0,\n      // Congratulations\n      \"text\": \"Félicitations\"\n    },\n    {\n      \"timestamp\": 1.37,\n      // you've survived\n      \"text\": \"vous avez survécu\"\n    },\n    {\n      \"timestamp\": 2.71,\n      // Today, you have emerged from this trial changed\n      \"text\": \"Aujourd'hui, vous êtes sorti de cette épreuve changé\"\n    },\n    {\n      \"timestamp\": 6.13,\n      // But remember... life is made of choices\n      \"text\": \"Mais rappelez-vous… la vie est faite de choix\"\n    }\n  ]\n}";
		}

		public static void LoadJSON()
		{
			string text = Path.Combine(Paths.ConfigPath, FilePath);
			if (File.Exists(text))
			{
				try
				{
					string text2 = File.ReadAllText(text);
					JObject parsedJson = JObject.Parse(text2);
					if (!ValidateJsonStructure(parsedJson))
					{
						RenameOldFile(text);
					}
				}
				catch (Exception)
				{
					RenameOldFile(text);
				}
			}
			else
			{
				File.WriteAllText(text, Get());
			}
			using (new StreamReader(Path.Combine(Paths.ConfigPath, FilePath)))
			{
				survivalGameSubtitles = LoadSurvivalGameSubtitles();
				huntingGameSubtitles = LoadHuntingGameSubtitles();
				escapeGameSubtitles = LoadEscapeGameSubtitles();
				billySubtitles = LoadBillyAnnouncementSubtitles();
			}
		}

		public static bool ValidateJsonStructure(JObject parsedJson)
		{
			List<string> list = new List<string> { "survival_game", "hunting_game", "escape_game", "billy_announcement" };
			foreach (string item in list)
			{
				if (parsedJson[item] == null)
				{
					return false;
				}
				JToken obj = parsedJson[item];
				JArray val = (JArray)(object)((obj is JArray) ? obj : null);
				if (val == null)
				{
					continue;
				}
				foreach (JToken item2 in val)
				{
					if (item2[(object)"timestamp"] == null || item2[(object)"text"] == null)
					{
						return false;
					}
				}
			}
			return true;
		}

		public static void RenameOldFile(string filePath)
		{
			string text = filePath + ".old";
			if (File.Exists(text))
			{
				File.Delete(text);
			}
			File.Move(filePath, text);
			File.WriteAllText(filePath, Get());
		}

		public static HashSet<SubtitleMapping> LoadSurvivalGameSubtitles()
		{
			string text = File.ReadAllText(FilePath);
			return JObject.Parse(text)["survival_game"].ToObject<HashSet<SubtitleMapping>>();
		}

		public static HashSet<SubtitleMapping> LoadHuntingGameSubtitles()
		{
			string text = File.ReadAllText(FilePath);
			return JObject.Parse(text)["hunting_game"].ToObject<HashSet<SubtitleMapping>>();
		}

		public static HashSet<SubtitleMapping> LoadEscapeGameSubtitles()
		{
			string text = File.ReadAllText(FilePath);
			return JObject.Parse(text)["escape_game"].ToObject<HashSet<SubtitleMapping>>();
		}

		public static HashSet<SubtitleMapping> LoadBillyAnnouncementSubtitles()
		{
			string text = File.ReadAllText(FilePath);
			return JObject.Parse(text)["billy_announcement"].ToObject<HashSet<SubtitleMapping>>();
		}
	}
}
namespace SawTapes.Files.Values
{
	public class SubtitleMapping
	{
		public string GameName { get; internal set; }

		[JsonProperty("timestamp")]
		public float Timestamp { get; internal set; }

		[JsonProperty("text")]
		public string Text { get; internal set; }
	}
}
namespace SawTapes.Behaviours
{
	public class Billy : EnemyAI
	{
		public bool isMoving;

		public BillyPuppet billyPuppet;

		public int billyValue;

		public AudioSource bikeSqueek;

		public AudioSource billyRecording;

		public override void Start()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			base.enemyType = SawTapes.billyEnemy;
			((EnemyAI)this).Start();
			if ((Object)(object)bikeSqueek == (Object)null)
			{
				bikeSqueek = ((Component)this).GetComponent<AudioSource>();
			}
			if ((Object)(object)bikeSqueek == (Object)null)
			{
				SawTapes.mls.LogError((object)"bikeSqueek is not assigned and could not be found.");
			}
			GameObject val = Object.Instantiate<GameObject>(SawTapes.billyRecordingSurvival, ((Component)this).transform.position, Quaternion.identity);
			billyRecording = val.GetComponent<AudioSource>();
			val.transform.SetParent(((Component)this).transform);
			base.syncMovementSpeed = 0f;
			base.updatePositionThreshold = 99999f;
		}

		public void StartFollowingPlayer()
		{
			isMoving = true;
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			if (((NetworkBehaviour)this).IsServer && isMoving && (Object)(object)base.targetPlayer != (Object)null)
			{
				MoveTowardPlayer();
			}
		}

		public void MoveTowardPlayer()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			StartMovingClientRpc();
			if (Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position) <= 4f)
			{
				isMoving = false;
				StopMovingClientRpc();
				((MonoBehaviour)this).StartCoroutine(BillyAnnouncementCoroutine());
			}
		}

		[ClientRpc]
		public void StartMovingClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(583599021u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 583599021u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayMovementSound();
				Animator creatureAnimator = base.creatureAnimator;
				if (creatureAnimator != null)
				{
					creatureAnimator.SetBool("isMoving", true);
				}
				((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
			}
		}

		[ClientRpc]
		public void StopMovingClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2088207619u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2088207619u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.moveTowardsDestination = false;
				base.movingTowardsTargetPlayer = false;
				base.targetPlayer = null;
				base.agent.speed = 0f;
				bikeSqueek.Stop();
				Animator creatureAnimator = base.creatureAnimator;
				if (creatureAnimator != null)
				{
					creatureAnimator.SetBool("isMoving", false);
				}
			}
		}

		public void PlayMovementSound()
		{
			if (!((Object)(object)bikeSqueek == (Object)null) && !bikeSqueek.isPlaying)
			{
				RoundManager.PlayRandomClip(bikeSqueek, (AudioClip[])(object)new AudioClip[1] { bikeSqueek.clip }, true, 1f, 0, 1000);
			}
		}

		public IEnumerator BillyAnnouncementCoroutine()
		{
			BillyAnnouncementClientRpc();
			yield return (object)new WaitUntil((Func<bool>)(() => billyRecording.isPlaying));
			yield return (object)new WaitWhile((Func<bool>)(() => billyRecording.isPlaying));
			if ((Object)(object)billyPuppet == (Object)null)
			{
				Vector3 position = ((Component)this).transform.position;
				billyPuppet = RoundManagerPatch.SpawnItem(SawTapes.billyPuppetObj, position) as BillyPuppet;
				SpawnBillyClientRpc(NetworkObjectReference.op_Implicit(((Component)billyPuppet).GetComponent<NetworkObject>()));
			}
		}

		[ClientRpc]
		public void BillyAnnouncementClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1491505320u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1491505320u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				billyRecording.Play();
				if (ConfigManager.isSubtitles.Value)
				{
					((MonoBehaviour)this).StartCoroutine(ShowSubtitlesCoroutine());
				}
			}
		}

		[ClientRpc]
		public void SpawnBillyClientRpc(NetworkObjectReference obj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4056799847u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref obj, default(