Decompiled source of Isolation v1.0.2

Isolation.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dissonance;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Isolation")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("Isolation")]
[assembly: AssemblyTitle("Isolation")]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "Code generated with Anthropic Claude (Claude Opus 5.5 and other Claude models, via Claude Code); designed and tested by the author")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")]
[assembly: AssemblyVersion("1.0.2.0")]
namespace Isolation;

public static class Api
{
	public static int ApiVersion = 2;

	public static bool VoicePromptOpen => VoicePrompt.Showing;

	public static string VoiceSharing
	{
		get
		{
			try
			{
				return ShareRules.Describe(VoiceShare.Effective);
			}
			catch
			{
				return "";
			}
		}
	}

	public static bool Available
	{
		get
		{
			try
			{
				return (Object)(object)Runner.I != (Object)null && Runner.I.Available;
			}
			catch
			{
				return false;
			}
		}
	}

	public static float Level
	{
		get
		{
			try
			{
				return ((Object)(object)Runner.I != (Object)null) ? Runner.I.Meter.Level : 0f;
			}
			catch
			{
				return 0f;
			}
		}
	}

	public static int Tier => MeterMath.Tier(Level);

	public static string[] Effects()
	{
		string[] array = new string[EffectDefs.All.Length];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = EffectDefs.All[i].Id;
		}
		return array;
	}

	public static string Trigger(string effectId, bool force = true, bool ignoreDanger = false)
	{
		try
		{
			if ((Object)(object)Runner.I == (Object)null)
			{
				return "not loaded";
			}
			return Runner.I.Trigger(effectId, force, ignoreDanger);
		}
		catch (Exception ex)
		{
			Plugin.Warn("api-trigger", "Isolation.Api.Trigger failed: " + ex.Message);
			return "error";
		}
	}

	public static void AddLevel(float delta)
	{
		try
		{
			if ((Object)(object)Runner.I != (Object)null && Runner.I.DayActive)
			{
				Runner.I.Meter.Add(delta);
			}
		}
		catch
		{
		}
	}

	public static void Suppress(float seconds)
	{
		try
		{
			if ((Object)(object)Runner.I != (Object)null)
			{
				Runner.I.Suppress(seconds);
			}
		}
		catch
		{
		}
	}
}
public enum SoloModeOption
{
	Off,
	EnvironmentOnly
}
public enum FriendDeadModeOption
{
	EnvironmentOnly,
	All,
	Off
}
public enum MeterCornerOption
{
	TopLeft,
	TopRight,
	BottomLeft,
	BottomRight
}
internal static class Cfg
{
	internal static ConfigEntry<bool> Enabled;

	internal static ConfigEntry<bool> SurpriseMode;

	internal static ConfigEntry<bool> SilhouetteNameTag;

	internal static ConfigEntry<bool> MirageFallback;

	internal static ConfigEntry<bool> LogEffects;

	internal static ConfigEntry<ShareAnswer> ShareMyVoiceAnswer;

	internal static string MigratedOldShare;

	internal static ConfigEntry<MeterCornerOption> MeterCorner;

	internal static ConfigEntry<string> TriggerNow;

	internal static ConfigEntry<float> Intensity;

	internal static ConfigEntry<float> BuildPerMinute;

	internal static ConfigEntry<float> MinDistance;

	internal static ConfigEntry<float> DistanceBonusMax;

	internal static ConfigEntry<float> RegroupDistance;

	internal static ConfigEntry<float> VoiceRange;

	internal static ConfigEntry<float> DecayPerMinuteCompany;

	internal static ConfigEntry<float> DecayPerMinuteOutside;

	internal static ConfigEntry<float> GlobalGapStart;

	internal static ConfigEntry<float> GlobalGapEnd;

	internal static ConfigEntry<float> CooldownScale;

	internal static ConfigEntry<float> EnemyBlockRadius;

	internal static ConfigEntry<float> ChaseBlockRadius;

	internal static ConfigEntry<float> FearBlock;

	internal static ConfigEntry<float> QuietAfterDangerSeconds;

	internal static ConfigEntry<int> MaxPerDay;

	internal static ConfigEntry<SoloModeOption> SoloMode;

	internal static ConfigEntry<FriendDeadModeOption> FriendDeadMode;

	internal static readonly Dictionary<string, ConfigEntry<bool>> EffectOn = new Dictionary<string, ConfigEntry<bool>>();

	internal static readonly Dictionary<string, ConfigEntry<float>> EffectWeight = new Dictionary<string, ConfigEntry<float>>();

	internal static void Bind(ConfigFile c)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Expected O, but got Unknown
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Expected O, but got Unknown
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Expected O, but got Unknown
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Expected O, but got Unknown
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Expected O, but got Unknown
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Expected O, but got Unknown
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Expected O, but got Unknown
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Expected O, but got Unknown
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Expected O, but got Unknown
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Expected O, but got Unknown
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Expected O, but got Unknown
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Expected O, but got Unknown
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_043e: Expected O, but got Unknown
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0476: Expected O, but got Unknown
		//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Expected O, but got Unknown
		//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Expected O, but got Unknown
		//IL_0562: Unknown result type (might be due to invalid IL or missing references)
		//IL_056c: Expected O, but got Unknown
		Enabled = c.Bind<bool>("General", "Enabled", true, "Master switch.");
		SurpriseMode = c.Bind<bool>("General", "SurpriseMode", true, "No meter on screen and no Info logs during a round. With false, a thin meter shows (see MeterCorner).");
		MeterCorner = c.Bind<MeterCornerOption>("General", "MeterCorner", MeterCornerOption.TopLeft, "Where the meter bar goes when SurpriseMode is off. 120x6 px, 60% alpha, tier colour.");
		Intensity = c.Bind<float>("General", "Intensity", 1f, new ConfigDescription("Divides the gap between effects and multiplies the roll chance. Doesn't change volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 3f), Array.Empty<object>()));
		SoloMode = c.Bind<SoloModeOption>("General", "SoloMode", SoloModeOption.Off, "Off: nothing happens when nobody else has been in the game today. EnvironmentOnly: the meter counts all time inside as alone; only Door and LightFlicker fire.");
		FriendDeadMode = c.Bind<FriendDeadModeOption>("General", "FriendDeadMode", FriendDeadModeOption.EnvironmentOnly, "When every teammate is dead or has left. EnvironmentOnly: only Door and LightFlicker fire. All: everything fires. Off: the meter freezes and nothing fires.");
		BuildPerMinute = c.Bind<float>("Meter", "BuildPerMinute", 20f, new ConfigDescription("Points per minute while alone, before the distance factor.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 200f), Array.Empty<object>()));
		MinDistance = c.Bind<float>("Meter", "MinDistance", 25f, new ConfigDescription("Metres. Closer than this counts as company.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 100f), Array.Empty<object>()));
		DistanceBonusMax = c.Bind<float>("Meter", "DistanceBonusMax", 1.5f, new ConfigDescription("Build multiplier at 3 x MinDistance or more.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>()));
		RegroupDistance = c.Bind<float>("Meter", "RegroupDistance", 10f, new ConfigDescription("Metres with line of sight (5 m without) for 1.5 s resets the meter.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 40f), Array.Empty<object>()));
		VoiceRange = c.Bind<float>("Meter", "VoiceRange", 30f, new ConfigDescription("Metres within which hearing a teammate talk counts as company.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		DecayPerMinuteCompany = c.Bind<float>("Meter", "DecayPerMinuteCompany", 15f, new ConfigDescription("Decay while in company but not regrouped.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
		DecayPerMinuteOutside = c.Bind<float>("Meter", "DecayPerMinuteOutside", 30f, new ConfigDescription("Decay outside, in the ship or in the elevator.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
		GlobalGapStart = c.Bind<float>("Pacing", "GlobalGapStart", 90f, new ConfigDescription("Seconds between effects at level 25.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 900f), Array.Empty<object>()));
		GlobalGapEnd = c.Bind<float>("Pacing", "GlobalGapEnd", 35f, new ConfigDescription("Seconds between effects at level 100.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 900f), Array.Empty<object>()));
		CooldownScale = c.Bind<float>("Pacing", "CooldownScale", 1f, new ConfigDescription("Multiplies every per-effect cooldown.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		MaxPerDay = c.Bind<int>("Pacing", "MaxPerDay", 15, new ConfigDescription("Automatic effects per day. DNC triggers don't count.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
		EffectDef[] all = EffectDefs.All;
		foreach (EffectDef effectDef in all)
		{
			EffectOn[effectDef.Id] = c.Bind<bool>("Effects", effectDef.Id, true, effectDef.Description);
			EffectWeight[effectDef.Id] = c.Bind<float>("Effects", effectDef.Id + "Weight", effectDef.DefaultWeight, new ConfigDescription("Relative weight of " + effectDef.Id + ". 0 never picks it automatically.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
		}
		SilhouetteNameTag = c.Bind<bool>("Effects", "SilhouetteNameTag", false, "Show a name tag over the silhouette.");
		MirageFallback = c.Bind<bool>("Voice", "MirageFallback", true, "Use a teammate's Mirage recordings when Mimic+ has no name clip.");
		ShareMyVoiceAnswer = CfgMigration.BindShareAnswer(c, out MigratedOldShare);
		EnemyBlockRadius = c.Bind<float>("Safety", "EnemyBlockRadius", 20f, new ConfigDescription("Metres. Any living enemy this close blocks effects.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		ChaseBlockRadius = c.Bind<float>("Safety", "ChaseBlockRadius", 45f, new ConfigDescription("Metres. An enemy targeting me this close blocks effects.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
		FearBlock = c.Bind<float>("Safety", "FearBlock", 0.25f, new ConfigDescription("Block while the game's fear level is at or above this.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		QuietAfterDangerSeconds = c.Bind<float>("Safety", "QuietAfterDangerSeconds", 20f, new ConfigDescription("Seconds of calm needed after danger.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f), Array.Empty<object>()));
		LogEffects = c.Bind<bool>("Debug", "LogEffects", false, "Log meter tiers and effect fires at Debug level.");
		List<string> list = new List<string> { "None" };
		all = EffectDefs.All;
		foreach (EffectDef effectDef2 in all)
		{
			list.Add(effectDef2.Id);
		}
		TriggerNow = c.Bind<string>("Debug", "TriggerNow", "None", new ConfigDescription("Testing aid (pick it in LethalConfig during a round): fires that effect once on this PC, forced like a DNC trigger (danger checks still apply), then resets to None. The result is logged.", (AcceptableValueBase)(object)new AcceptableValueList<string>(list.ToArray()), Array.Empty<object>()));
	}

	internal static void FillMeter(MeterSettings m)
	{
		m.BuildPerMinute = BuildPerMinute.Value;
		m.MinDistance = MinDistance.Value;
		m.DistanceBonusMax = DistanceBonusMax.Value;
		m.DecayPerMinuteCompany = DecayPerMinuteCompany.Value;
		m.DecayPerMinuteOutside = DecayPerMinuteOutside.Value;
	}
}
internal sealed class EffectDef
{
	public string Id;

	public string Description;

	public int Tier;

	public int DayCap;

	public float DefaultWeight;

	public float Cooldown;

	public bool Environment;

	public bool NeedsTeammate;
}
internal static class EffectDefs
{
	public const string ItemDrop = "ItemDrop";

	public const string Door = "Door";

	public const string WalkieStatic = "WalkieStatic";

	public const string LightFlicker = "LightFlicker";

	public const string FootstepsBehind = "FootstepsBehind";

	public const string FootstepsAhead = "FootstepsAhead";

	public const string FriendItem = "FriendItem";

	public const string FlashlightStutter = "FlashlightStutter";

	public const string NameTag = "NameTag";

	public const string Silhouette = "Silhouette";

	public const string NameCall = "NameCall";

	public static readonly EffectDef[] All = new EffectDef[11]
	{
		new EffectDef
		{
			Id = "ItemDrop",
			Tier = 1,
			DefaultWeight = 3f,
			Cooldown = 120f,
			Description = "An item dropped somewhere out of sight."
		},
		new EffectDef
		{
			Id = "Door",
			Tier = 1,
			DefaultWeight = 3f,
			Cooldown = 150f,
			Environment = true,
			Description = "A door you can't see opens or closes (sound only; the door doesn't move)."
		},
		new EffectDef
		{
			Id = "WalkieStatic",
			Tier = 1,
			DefaultWeight = 2f,
			Cooldown = 180f,
			Description = "A short burst of static on your switched-on walkie."
		},
		new EffectDef
		{
			Id = "LightFlicker",
			Tier = 1,
			DefaultWeight = 2f,
			Cooldown = 240f,
			Environment = true,
			Description = "Nearby lights flicker (only on your screen)."
		},
		new EffectDef
		{
			Id = "FootstepsBehind",
			Tier = 2,
			DefaultWeight = 4f,
			Cooldown = 120f,
			NeedsTeammate = true,
			Description = "Your teammate's footsteps behind you."
		},
		new EffectDef
		{
			Id = "FootstepsAhead",
			Tier = 3,
			DefaultWeight = 2f,
			Cooldown = 180f,
			NeedsTeammate = true,
			Description = "Footsteps running away ahead of you."
		},
		new EffectDef
		{
			Id = "FriendItem",
			Tier = 2,
			DefaultWeight = 2f,
			Cooldown = 200f,
			NeedsTeammate = true,
			Description = "Your teammate swapping items round the corner."
		},
		new EffectDef
		{
			Id = "FlashlightStutter",
			Tier = 2,
			DefaultWeight = 2f,
			Cooldown = 240f,
			Description = "Your flashlight stutters for a moment (only on your screen)."
		},
		new EffectDef
		{
			Id = "NameTag",
			Tier = 2,
			DefaultWeight = 0.4f,
			Cooldown = 900f,
			DayCap = 1,
			NeedsTeammate = true,
			Description = "A glimpse of your teammate's name tag in the distance (very rare)."
		},
		new EffectDef
		{
			Id = "Silhouette",
			Tier = 3,
			DefaultWeight = 0.2f,
			Cooldown = 1500f,
			DayCap = 1,
			NeedsTeammate = true,
			Description = "A glimpse of your teammate standing in the distance (very rare)."
		},
		new EffectDef
		{
			Id = "NameCall",
			Tier = 3,
			DefaultWeight = 1f,
			Cooldown = 600f,
			DayCap = 2,
			NeedsTeammate = true,
			Description = "Your teammate's voice calling from far away."
		}
	};

	public static EffectDef Get(string id)
	{
		EffectDef[] all = All;
		foreach (EffectDef effectDef in all)
		{
			if (string.Equals(effectDef.Id, id, StringComparison.OrdinalIgnoreCase))
			{
				return effectDef;
			}
		}
		return null;
	}
}
internal static class CfgMigration
{
	internal const string Section = "Voice";

	internal const string OldKey = "ShareMyVoice";

	internal const string NewKey = "ShareMyVoiceAnswer";

	internal const string Description = "Let my PC send short clips of my voice (from my own Mirage recordings, at most 2.5 s, kept in memory only and deleted at the end of the day) for a teammate's name calls. Ask = not shared; you're asked once in orbit with another player. Yes / No = your answer. Replaces the old ShareMyVoice true/false (an old true is not taken as a yes).";

	internal static ConfigEntry<ShareAnswer> BindShareAnswer(ConfigFile c, out string oldValue)
	{
		bool flag = OrphanValue(c, "Voice", "ShareMyVoiceAnswer", remove: false) != null;
		oldValue = OrphanValue(c, "Voice", "ShareMyVoice", remove: true);
		ConfigEntry<ShareAnswer> val = c.Bind<ShareAnswer>("Voice", "ShareMyVoiceAnswer", ShareAnswer.Ask, "Let my PC send short clips of my voice (from my own Mirage recordings, at most 2.5 s, kept in memory only and deleted at the end of the day) for a teammate's name calls. Ask = not shared; you're asked once in orbit with another player. Yes / No = your answer. Replaces the old ShareMyVoice true/false (an old true is not taken as a yes).");
		if (oldValue != null)
		{
			if (!flag && ShareRules.MigrateOldBool(oldValue) == ShareAnswer.No)
			{
				val.Value = ShareAnswer.No;
			}
			try
			{
				c.Save();
			}
			catch
			{
			}
		}
		return val;
	}

	internal static string OrphanValue(ConfigFile c, string section, string key, bool remove)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		try
		{
			if (!(typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(c, null) is Dictionary<ConfigDefinition, string> dictionary))
			{
				return null;
			}
			ConfigDefinition key2 = new ConfigDefinition(section, key);
			if (!dictionary.TryGetValue(key2, out var value))
			{
				return null;
			}
			if (remove)
			{
				dictionary.Remove(key2);
			}
			return value ?? "";
		}
		catch
		{
			return null;
		}
	}
}
internal static class MimicBridge
{
	private static bool _looked;

	private static Func<bool> _playing;

	private static MethodInfo _nameClip;

	private static MethodInfo _keyOf;

	private static MethodInfo _myConsent;

	private static MethodInfo _consentStates;

	private static int _apiVersion;

	private static int _consentApi;

	private static bool _nameClipGated;

	private static Func<bool> _promptOpen;

	private static bool _promptBroken;

	private static bool _playingBroken;

	public static int ApiVersion
	{
		get
		{
			Look();
			return _apiVersion;
		}
	}

	public static bool Present
	{
		get
		{
			Look();
			if (_playing == null)
			{
				return _apiVersion > 0;
			}
			return true;
		}
	}

	public static bool HasGatedNameClip
	{
		get
		{
			Look();
			if (_nameClip != null && _nameClipGated && _consentApi >= 1)
			{
				return _consentStates != null;
			}
			return false;
		}
	}

	private static void Look()
	{
		if (_looked)
		{
			return;
		}
		_looked = true;
		try
		{
			_playing = StaticBoolGetter("MimicPlus.RadioState", "Playing") ?? StaticBoolGetter("MimicPlus.RadioPlayer", "Playing");
			Type type = QuietTypes.Find("MimicPlus.Debug");
			if (type != null)
			{
				FieldInfo field = type.GetField("ApiVersion", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null && (field.IsLiteral ? field.GetRawConstantValue() : field.GetValue(null)) is int apiVersion)
				{
					_apiVersion = apiVersion;
				}
				if (_apiVersion >= 2)
				{
					_nameClip = type.GetMethod("NameClip", BindingFlags.Static | BindingFlags.Public, null, new Type[3]
					{
						typeof(string),
						typeof(string),
						typeof(bool)
					}, null);
				}
				if (_nameClip != null && _nameClip.ReturnType != typeof(byte[]))
				{
					_nameClip = null;
				}
				_consentApi = StaticInt(type, "ConsentApiVersion");
				_nameClipGated = StaticBool(type, "NameClipConsentGated");
				if (_consentApi >= 1)
				{
					_myConsent = type.GetMethod("MyConsent", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null);
					if (_myConsent != null && _myConsent.ReturnType != typeof(string))
					{
						_myConsent = null;
					}
					_consentStates = type.GetMethod("ConsentStates", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null);
					if (_consentStates != null && _consentStates.ReturnType != typeof(string[]))
					{
						_consentStates = null;
					}
				}
				_promptOpen = StaticBoolGetter("MimicPlus.Debug", "ConsentPromptOpen");
			}
			if (_promptOpen == null)
			{
				_promptOpen = StaticBoolGetter("MimicPlus.ConsentUi", "Showing");
			}
			Type type2 = QuietTypes.Find("MimicPlus.Session");
			if (type2 != null)
			{
				_keyOf = type2.GetMethod("KeyOf", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(PlayerControllerB) }, null);
			}
			if (_keyOf != null && _keyOf.ReturnType != typeof(string))
			{
				_keyOf = null;
			}
		}
		catch (Exception ex)
		{
			Plugin.Warn("mimic-lookup", "Mimic+ lookup failed, treating it as missing: " + ex.Message);
		}
	}

	private static Func<bool> StaticBoolGetter(string typeName, string prop)
	{
		Type type = QuietTypes.Find(typeName);
		if (type == null)
		{
			return null;
		}
		MethodInfo methodInfo = type.GetProperty(prop, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetGetMethod(nonPublic: true);
		if (methodInfo != null && methodInfo.ReturnType == typeof(bool))
		{
			return (Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), methodInfo);
		}
		FieldInfo f = type.GetField(prop, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
		if (f != null && f.FieldType == typeof(bool))
		{
			return () => (bool)f.GetValue(null);
		}
		return null;
	}

	private static object StaticValue(Type t, string name)
	{
		FieldInfo field = t.GetField(name, BindingFlags.Static | BindingFlags.Public);
		if (field != null)
		{
			if (!field.IsLiteral)
			{
				return field.GetValue(null);
			}
			return field.GetRawConstantValue();
		}
		return t.GetProperty(name, BindingFlags.Static | BindingFlags.Public)?.GetGetMethod()?.Invoke(null, null);
	}

	private static int StaticInt(Type t, string name)
	{
		try
		{
			return (StaticValue(t, name) is int num) ? num : 0;
		}
		catch
		{
			return 0;
		}
	}

	private static bool StaticBool(Type t, string name)
	{
		try
		{
			object obj = StaticValue(t, name);
			bool flag = default(bool);
			int num;
			if (obj is bool)
			{
				flag = (bool)obj;
				num = 1;
			}
			else
			{
				num = 0;
			}
			return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
		}
		catch
		{
			return false;
		}
	}

	public static bool? ConsentPromptOpen()
	{
		Look();
		if (!Present)
		{
			return false;
		}
		if (_promptOpen == null || _promptBroken)
		{
			return null;
		}
		try
		{
			return _promptOpen();
		}
		catch (Exception ex)
		{
			_promptBroken = true;
			Plugin.Warn("mimic-prompt", "Couldn't read Mimic+'s prompt state; waiting longer instead: " + ex.Message);
			return null;
		}
	}

	public static string MyConsent()
	{
		Look();
		if (_myConsent == null)
		{
			return "";
		}
		try
		{
			return (_myConsent.Invoke(null, null) as string) ?? "";
		}
		catch
		{
			return "";
		}
	}

	public static int SpeakerConsent(string key)
	{
		Look();
		if (_consentStates == null || string.IsNullOrEmpty(key))
		{
			return 0;
		}
		try
		{
			return ShareRules.MimicLevelFor(_consentStates.Invoke(null, null) as string[], key);
		}
		catch (Exception ex)
		{
			Plugin.Warn("mimic-consent", "Couldn't read Mimic+ consent states; not using Mimic+ name clips: " + (ex.InnerException ?? ex).Message);
		}
		return 0;
	}

	public static bool RadioPlaying()
	{
		Look();
		if (_playing == null || _playingBroken)
		{
			return false;
		}
		try
		{
			return _playing();
		}
		catch (Exception ex)
		{
			_playingBroken = true;
			Plugin.Warn("mimic-playing", "Couldn't read Mimic+ radio state; ignoring it from now on: " + ex.Message);
			return false;
		}
	}

	public static string KeyOf(PlayerControllerB pc)
	{
		if ((Object)(object)pc == (Object)null)
		{
			return "";
		}
		Look();
		if (_keyOf != null)
		{
			try
			{
				return ((string)_keyOf.Invoke(null, new object[1] { pc })) ?? "";
			}
			catch
			{
			}
		}
		if (pc.playerSteamId != 0L)
		{
			return pc.playerSteamId.ToString();
		}
		return "lan_" + (pc.playerUsername ?? "").ToLowerInvariant().Trim().Replace(' ', '_');
	}

	public static byte[] NameClip(string speakerKey, string targetKey)
	{
		Look();
		if (!HasGatedNameClip)
		{
			return null;
		}
		int num = SpeakerConsent(speakerKey);
		if (num <= 0)
		{
			Plugin.Debug("Voice: no Mimic+ name clip (the speaker hasn't allowed Mimic+ recording on this host)");
			return null;
		}
		try
		{
			return _nameClip.Invoke(null, new object[3]
			{
				speakerKey,
				targetKey,
				num >= 2
			}) as byte[];
		}
		catch (Exception ex)
		{
			Plugin.Warn("mimic-nameclip", "Mimic+ NameClip failed: " + (ex.InnerException ?? ex).Message);
			return null;
		}
	}
}
internal static class DncBridge
{
	private static bool _looked;

	private static bool _broken;

	private static FieldInfo _running;

	public static bool LocalEffectRunning()
	{
		if (!_looked)
		{
			_looked = true;
			try
			{
				_running = QuietTypes.Find("DefinitelyNotCheats.FxRunner")?.GetField("Running", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			}
			catch
			{
				_running = null;
			}
		}
		if (_running == null || _broken)
		{
			return false;
		}
		try
		{
			return _running.GetValue(null) is ICollection collection && collection.Count > 0;
		}
		catch
		{
			_broken = true;
			return false;
		}
	}
}
internal static class MirageBridge
{
	public static string RecordingDirectory()
	{
		try
		{
			if ((QuietTypes.Find("Mirage.Domain.Directory")?.GetProperty("recordingDirectory", BindingFlags.Static | BindingFlags.Public))?.GetValue(null) is string { Length: >0 } text)
			{
				return text;
			}
		}
		catch
		{
		}
		try
		{
			return Path.Combine(Path.Combine(Path.GetDirectoryName(Application.dataPath), "Mirage"), "Recording");
		}
		catch
		{
			return null;
		}
	}
}
internal sealed class Ctx
{
	public PlayerControllerB Local;

	public Camera Cam;

	public PlayerControllerB Copy;

	public AudioSource MixerFallback
	{
		get
		{
			if (!((Object)(object)Local != (Object)null))
			{
				return null;
			}
			return Local.movementAudio;
		}
	}
}
internal abstract class Effect
{
	public EffectDef Def;

	protected Ctx C;

	protected float T;

	public bool Done { get; protected set; }

	public virtual string Precheck(Ctx c)
	{
		return "";
	}

	public abstract string Start(Ctx c);

	public abstract void Frame(float dt);

	public virtual void LateFrame()
	{
	}

	public abstract void Stop(float fade);

	public abstract void Cleanup();

	protected static bool Usable(PlayerControllerB p)
	{
		if ((Object)(object)p != (Object)null)
		{
			return ((Behaviour)p).isActiveAndEnabled;
		}
		return false;
	}
}
internal abstract class OneShotEffect : Effect
{
	protected FakeSource Src;

	private float _len;

	protected bool Play(Vector3 pos, AudioSource template, AudioClip clip, float volume)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		Src = Fx.Acquire(pos, template, C.MixerFallback);
		if (Src == null)
		{
			return false;
		}
		Src.Src.PlayOneShot(clip, volume);
		_len = clip.length / Mathf.Max(0.1f, Mathf.Abs(Src.Src.pitch)) + 0.25f;
		return true;
	}

	public override void Frame(float dt)
	{
		T += dt;
		if (Src == null || T >= _len || (!Src.Fading && (Object)(object)Src.Src != (Object)null && Src.Src.volume <= 0f))
		{
			Cleanup();
			base.Done = true;
		}
	}

	public override void Stop(float fade)
	{
		if (Src == null)
		{
			base.Done = true;
			return;
		}
		Src.FadeOut(fade);
		_len = Mathf.Min(_len, T + fade + 0.05f);
	}

	public override void Cleanup()
	{
		Fx.Release(Src);
		Src = null;
	}
}
internal sealed class ItemDropEffect : OneShotEffect
{
	public override string Start(Ctx c)
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		C = c;
		if (!PickClip(c, out var clip, out var template))
		{
			return "no drop sound";
		}
		Fx.Query q = new Fx.Query
		{
			MinDist = 8f,
			MaxDist = 18f,
			Hidden = true,
			SightHeight = 0.3f
		};
		if (!Fx.TryNodePoint(c.Local, c.Cam, q, out var point))
		{
			return "no hidden spot";
		}
		if (!Play(point, template, clip, 1f))
		{
			return "no audio source";
		}
		return "";
	}

	private static bool PickClip(Ctx c, out AudioClip clip, out AudioSource template)
	{
		clip = null;
		template = null;
		List<GrabbableObject> list = new List<GrabbableObject>();
		if ((Object)(object)c.Copy != (Object)null && c.Copy.ItemSlots != null)
		{
			GrabbableObject[] itemSlots = c.Copy.ItemSlots;
			foreach (GrabbableObject val in itemSlots)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val.itemProperties != (Object)null && (Object)(object)val.itemProperties.dropSFX != (Object)null)
				{
					list.Add(val);
				}
			}
		}
		if (list.Count == 0)
		{
			list.AddRange(LevelCache.ScrapWithDrop);
		}
		list.RemoveAll((GrabbableObject o) => (Object)(object)o == (Object)null);
		if (list.Count > 0)
		{
			GrabbableObject val2 = list[Fx.Rng.Next(list.Count)];
			clip = val2.itemProperties.dropSFX;
			template = ((Component)val2).GetComponent<AudioSource>();
		}
		else
		{
			List<Item> list2 = LevelCache.ItemsWithDrop();
			if (list2.Count == 0)
			{
				return false;
			}
			Item val3 = list2[Fx.Rng.Next(list2.Count)];
			clip = val3.dropSFX;
			template = (((Object)(object)val3.spawnPrefab != (Object)null) ? val3.spawnPrefab.GetComponent<AudioSource>() : null);
		}
		if ((Object)(object)template == (Object)null)
		{
			template = LevelCache.TypicalScrapSource();
		}
		return (Object)(object)clip != (Object)null;
	}
}
internal sealed class FriendItemEffect : OneShotEffect
{
	private static GrabbableObject PickItem(PlayerControllerB p)
	{
		if ((Object)(object)p == (Object)null || p.ItemSlots == null)
		{
			return null;
		}
		List<GrabbableObject> list = new List<GrabbableObject>();
		GrabbableObject[] itemSlots = p.ItemSlots;
		foreach (GrabbableObject val in itemSlots)
		{
			if ((Object)(object)val != (Object)null && (Object)(object)val.itemProperties != (Object)null && ((Object)(object)val.itemProperties.pocketSFX != (Object)null || (Object)(object)val.itemProperties.grabSFX != (Object)null))
			{
				list.Add(val);
			}
		}
		if (list.Count != 0)
		{
			return list[Fx.Rng.Next(list.Count)];
		}
		return null;
	}

	public override string Precheck(Ctx c)
	{
		if (!((Object)(object)PickItem(c.Copy) == (Object)null))
		{
			return "";
		}
		return "teammate carries nothing";
	}

	public override string Start(Ctx c)
	{
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		C = c;
		GrabbableObject val = PickItem(c.Copy);
		if ((Object)(object)val == (Object)null)
		{
			return "teammate carries nothing";
		}
		AudioClip clip = (((Object)(object)val.itemProperties.pocketSFX != (Object)null) ? val.itemProperties.pocketSFX : val.itemProperties.grabSFX);
		Fx.Query q = new Fx.Query
		{
			MinDist = 10f,
			MaxDist = 20f,
			Hidden = true,
			SightHeight = 1f
		};
		if (!Fx.TryNodePoint(c.Local, c.Cam, q, out var point))
		{
			return "no hidden spot";
		}
		if (!Play(point + Vector3.up * 1.1f, ((Component)val).GetComponent<AudioSource>(), clip, 1f))
		{
			return "no audio source";
		}
		return "";
	}
}
internal sealed class DoorEffect : OneShotEffect
{
	public override string Precheck(Ctx c)
	{
		if (LevelCache.Doors.Count != 0)
		{
			return "";
		}
		return "no doors";
	}

	public override string Start(Ctx c)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: 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_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		C = c;
		Vector3 position = ((Component)c.Local).transform.position;
		List<DoorLock> list = new List<DoorLock>();
		foreach (DoorLock door in LevelCache.Doors)
		{
			if (!((Object)(object)door == (Object)null) && ((Behaviour)door).isActiveAndEnabled && !door.isLocked && !LevelCache.IsHaunted(door))
			{
				float num = Vector3.Distance(((Component)door).transform.position, position);
				if (num >= 8f && num <= 20f)
				{
					list.Add(door);
				}
			}
		}
		Vector3 position2 = ((Component)c.Cam).transform.position;
		RaycastHit val4 = default(RaycastHit);
		for (int i = 0; i < 12; i++)
		{
			if (list.Count <= 0)
			{
				break;
			}
			int index = Fx.Rng.Next(list.Count);
			DoorLock val = list[index];
			list.RemoveAt(index);
			AnimatedObjectTrigger component = ((Component)val).GetComponent<AnimatedObjectTrigger>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.thisAudioSource == (Object)null)
			{
				continue;
			}
			AudioClip[] array = (component.boolValue ? component.boolFalseAudios : component.boolTrueAudios);
			if (array == null || array.Length == 0)
			{
				continue;
			}
			AudioClip val2 = array[Fx.Rng.Next(array.Length)];
			if ((Object)(object)val2 == (Object)null)
			{
				continue;
			}
			Vector3 position3 = ((Component)val).transform.position;
			if (Mathf.Abs(position3.y - position.y) > 4f || !Fx.PassesCommonRules(position3, c.Local, allowOtherFloor: false))
			{
				continue;
			}
			Vector3 val3 = position3 + Vector3.up * 1f;
			if (Physics.Linecast(position2, val3, ref val4, Fx.SightMask(), (QueryTriggerInteraction)1) && !(Vector3.Distance(((RaycastHit)(ref val4)).point, val3) < 1.5f))
			{
				if (!Play(((Component)component.thisAudioSource).transform.position, component.thisAudioSource, val2, 1f))
				{
					return "no audio source";
				}
				return "";
			}
		}
		return "no hidden door";
	}
}
internal sealed class WalkieStaticEffect : Effect
{
	private WalkieTalkie _w;

	private FakeSource _s;

	private int _phase;

	private float _phaseEnd;

	private float _stopLen;

	internal static WalkieTalkie FindOnWalkie(PlayerControllerB p)
	{
		if ((Object)(object)p == (Object)null || p.ItemSlots == null)
		{
			return null;
		}
		GrabbableObject[] itemSlots = p.ItemSlots;
		foreach (GrabbableObject obj in itemSlots)
		{
			WalkieTalkie val = (WalkieTalkie)(object)((obj is WalkieTalkie) ? obj : null);
			if (!((Object)(object)val == (Object)null) && ((GrabbableObject)val).isBeingUsed && (((GrabbableObject)val).insertedBattery == null || (!((GrabbableObject)val).insertedBattery.empty && !(((GrabbableObject)val).insertedBattery.charge <= 0f))))
			{
				return val;
			}
		}
		return null;
	}

	internal static bool RealTransmission()
	{
		List<WalkieTalkie> allWalkieTalkies = WalkieTalkie.allWalkieTalkies;
		if (allWalkieTalkies == null)
		{
			return false;
		}
		for (int i = 0; i < allWalkieTalkies.Count; i++)
		{
			if ((Object)(object)allWalkieTalkies[i] != (Object)null && allWalkieTalkies[i].clientIsHoldingAndSpeakingIntoThis)
			{
				return true;
			}
		}
		return false;
	}

	public override string Precheck(Ctx c)
	{
		if ((Object)(object)FindOnWalkie(c.Local) == (Object)null)
		{
			return "no switched-on walkie";
		}
		if (RealTransmission())
		{
			return "real transmission";
		}
		return "";
	}

	public override string Start(Ctx c)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		C = c;
		_w = FindOnWalkie(c.Local);
		if ((Object)(object)_w == (Object)null)
		{
			return "no switched-on walkie";
		}
		if (RealTransmission())
		{
			return "real transmission";
		}
		_s = Fx.Acquire(Pos(), _w.thisAudio, c.MixerFallback);
		if (_s == null)
		{
			return "no audio source";
		}
		AudioClip val = Pick(_w.startTransmissionSFX);
		if ((Object)(object)val != (Object)null)
		{
			_s.Src.PlayOneShot(val, 1f);
		}
		_phase = 0;
		_phaseEnd = (((Object)(object)val != (Object)null) ? Mathf.Min(val.length, 0.6f) : 0.05f);
		return "";
	}

	private static AudioClip Pick(AudioClip[] a)
	{
		if (a != null && a.Length != 0)
		{
			return a[Fx.Rng.Next(a.Length)];
		}
		return null;
	}

	private Vector3 Pos()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_w != (Object)null && ((GrabbableObject)_w).isHeld && !((GrabbableObject)_w).isPocketed)
		{
			return ((Component)_w).transform.position;
		}
		return ((Component)C.Local).transform.position + Vector3.up * 1.2f;
	}

	public override void Frame(float dt)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		T += dt;
		if (_s == null || (Object)(object)_s.Go == (Object)null)
		{
			Cleanup();
			base.Done = true;
			return;
		}
		_s.Go.transform.position = Pos();
		if (_phase < 2 && ((Object)(object)_w == (Object)null || !((GrabbableObject)_w).isBeingUsed || RealTransmission()))
		{
			Stop(0.1f);
		}
		if (T < _phaseEnd)
		{
			return;
		}
		switch (_phase)
		{
		case 0:
			_s.Src.clip = Fx.StaticClip();
			_s.Src.loop = true;
			_s.Src.volume = _s.BaseVolume * 0.55f;
			_s.Src.Play();
			_s.Src.time = Fx.R(0f, 0.3f);
			_phase = 1;
			_phaseEnd = T + Fx.R(0.6f, 1.4f);
			break;
		case 1:
		{
			_s.Src.Stop();
			_s.Src.loop = false;
			_s.Src.clip = null;
			_s.Src.volume = _s.BaseVolume;
			AudioClip val = Pick(((Object)(object)_w != (Object)null) ? _w.stopTransmissionSFX : null);
			if ((Object)(object)val != (Object)null)
			{
				_s.Src.PlayOneShot(val, 1f);
			}
			_phase = 2;
			_stopLen = (((Object)(object)val != (Object)null) ? val.length : 0f);
			_phaseEnd = T + _stopLen + 0.1f;
			break;
		}
		default:
			Cleanup();
			base.Done = true;
			break;
		}
	}

	public override void Stop(float fade)
	{
		if (_s == null)
		{
			base.Done = true;
			return;
		}
		_s.FadeOut(fade);
		_phase = 2;
		_phaseEnd = T + fade + 0.05f;
	}

	public override void Cleanup()
	{
		Fx.Release(_s);
		_s = null;
	}
}
internal sealed class LightFlickerEffect : Effect
{
	private readonly List<Animator> _anims = new List<Animator>();

	private readonly List<float> _at = new List<float>();

	private static readonly int FlickerHash = Animator.StringToHash("Flicker");

	internal static bool PowerOn()
	{
		RoundManager instance = RoundManager.Instance;
		if ((Object)(object)instance == (Object)null || instance.powerOffPermanently)
		{
			return false;
		}
		BreakerBox breaker = LevelCache.Breaker;
		if (!((Object)(object)breaker == (Object)null))
		{
			return breaker.isPowerOn;
		}
		return true;
	}

	private static void Collect(Vector3 lp, List<Animator> into)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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)
		into.Clear();
		RoundManager instance = RoundManager.Instance;
		if ((Object)(object)instance == (Object)null || instance.allPoweredLightsAnimators == null)
		{
			return;
		}
		foreach (Animator allPoweredLightsAnimator in instance.allPoweredLightsAnimators)
		{
			if (!((Object)(object)allPoweredLightsAnimator == (Object)null) && ((Behaviour)allPoweredLightsAnimator).isActiveAndEnabled)
			{
				Vector3 val = ((Component)allPoweredLightsAnimator).transform.position - lp;
				if (!(((Vector3)(ref val)).sqrMagnitude > 144f) && LevelCache.CanFlicker(allPoweredLightsAnimator))
				{
					into.Add(allPoweredLightsAnimator);
				}
			}
		}
	}

	public override string Precheck(Ctx c)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		if (!PowerOn())
		{
			return "power off";
		}
		Collect(((Component)c.Local).transform.position, _anims);
		if (_anims.Count != 0)
		{
			return "";
		}
		return "no lights nearby";
	}

	public override string Start(Ctx c)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		C = c;
		if (!PowerOn())
		{
			return "power off";
		}
		Collect(((Component)c.Local).transform.position, _anims);
		if (_anims.Count == 0)
		{
			return "no lights nearby";
		}
		while (_anims.Count > 6)
		{
			_anims.RemoveAt(Fx.Rng.Next(_anims.Count));
		}
		_at.Clear();
		foreach (Animator anim in _anims)
		{
			_ = anim;
			_at.Add(Fx.R(0f, 0.15f));
		}
		return "";
	}

	public override void Frame(float dt)
	{
		T += dt;
		for (int i = 0; i < _anims.Count; i++)
		{
			if (!(_at[i] < 0f) && !(T < _at[i]))
			{
				_at[i] = -1f;
				if ((Object)(object)_anims[i] != (Object)null && ((Behaviour)_anims[i]).isActiveAndEnabled)
				{
					_anims[i].SetTrigger(FlickerHash);
				}
			}
		}
		if (T >= 1.5f)
		{
			base.Done = true;
		}
	}

	public override void Stop(float fade)
	{
		for (int i = 0; i < _at.Count; i++)
		{
			_at[i] = -1f;
		}
		base.Done = true;
	}

	public override void Cleanup()
	{
		_anims.Clear();
		_at.Clear();
	}
}
internal abstract class FootstepsBase : Effect
{
	protected FakeSource S;

	protected Vector3 Pos;

	protected int StepsLeft;

	protected float NextStepAt;

	protected float Volume;

	protected bool Sprint;

	private int _prevClip = -1;

	private float _tailUntil;

	protected bool Ending;

	public override string Precheck(Ctx c)
	{
		if ((Object)(object)c.Copy == (Object)null || (Object)(object)c.Copy.movementAudio == (Object)null)
		{
			return "no teammate to copy";
		}
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance == (Object)null || instance.footstepSurfaces == null || instance.footstepSurfaces.Length == 0)
		{
			return "no footstep sounds";
		}
		return "";
	}

	protected bool Begin(Vector3 p)
	{
		//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)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		Pos = p;
		S = Fx.Acquire(p, C.Copy.movementAudio, C.MixerFallback);
		if (S == null)
		{
			return false;
		}
		NextStepAt = 0f;
		return true;
	}

	protected void Step()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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)
		StartOfRound instance = StartOfRound.Instance;
		int fallback = (((Object)(object)C.Local != (Object)null) ? C.Local.currentFootstepSurfaceIndex : 0);
		int num = Fx.SurfaceIndexAt(Pos, fallback);
		if (num < 0 || num >= instance.footstepSurfaces.Length)
		{
			num = 0;
		}
		AudioClip[] clips = instance.footstepSurfaces[num].clips;
		if (clips != null && clips.Length != 0)
		{
			int num2 = Fx.Rng.Next(clips.Length);
			if (num2 == _prevClip)
			{
				num2 = (num2 + 1) % clips.Length;
			}
			_prevClip = num2;
			S.Go.transform.position = Pos + Vector3.up * 0.1f;
			S.Src.pitch = Fx.R(0.93f, 1.07f);
			S.Src.PlayOneShot(clips[num2], Volume);
			_tailUntil = T + clips[num2].length + 0.1f;
		}
	}

	protected abstract bool Advance();

	public override void Frame(float dt)
	{
		T += dt;
		if (S == null || (Object)(object)S.Go == (Object)null)
		{
			Cleanup();
			base.Done = true;
			return;
		}
		if (!Ending && ShouldStopNow())
		{
			Ending = true;
		}
		if (!Ending && T >= NextStepAt)
		{
			if (StepsLeft <= 0)
			{
				Ending = true;
			}
			else
			{
				Step();
				StepsLeft--;
				NextStepAt = T + (Sprint ? 0.3f : Fx.R(0.45f, 0.55f));
				if (StepsLeft > 0 && !Advance())
				{
					Ending = true;
				}
			}
		}
		if (Ending && T >= _tailUntil && !S.Fading)
		{
			Cleanup();
			base.Done = true;
		}
	}

	protected virtual bool ShouldStopNow()
	{
		return false;
	}

	public override void Stop(float fade)
	{
		Ending = true;
		if (S != null)
		{
			S.FadeOut(fade);
		}
		_tailUntil = Mathf.Min(_tailUntil, T + fade);
	}

	public override void Cleanup()
	{
		Fx.Release(S);
		S = null;
	}
}
internal sealed class FootstepsBehindEffect : FootstepsBase
{
	private Vector3 _lastPlayer;

	public override string Start(Ctx c)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: 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)
		C = c;
		if (!Fx.TryAround(c.Local, c.Cam, 120f, 240f, 4f, 8f, out var point))
		{
			return "no spot behind";
		}
		if (!Begin(point))
		{
			return "no audio source";
		}
		StepsLeft = 3 + Fx.Rng.Next(5);
		Sprint = Fx.Rng.Next(4) == 0;
		Volume = (Sprint ? 0.9f : 0.6f);
		_lastPlayer = ((Component)c.Local).transform.position;
		return "";
	}

	protected override bool Advance()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//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)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((Component)C.Local).transform.position - Pos;
		val.y = 0f;
		if (((Vector3)(ref val)).magnitude > 3.5f)
		{
			Pos += ((Vector3)(ref val)).normalized * 0.5f;
		}
		if (Fx.Snap(Pos, out var snapped))
		{
			Pos = snapped;
		}
		return true;
	}

	protected override bool ShouldStopNow()
	{
		//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_002b: 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_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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_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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: 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)
		Vector3 position = ((Component)C.Local).transform.position;
		float deltaTime = Time.deltaTime;
		Vector3 val = ((deltaTime > 0f) ? ((position - _lastPlayer) / deltaTime) : Vector3.zero);
		_lastPlayer = position;
		if (Fx.AngleFromView(C.Cam, Pos + Vector3.up) <= 70f)
		{
			return true;
		}
		Vector3 val2 = Pos - position;
		val2.y = 0f;
		val.y = 0f;
		if (((Vector3)(ref val2)).sqrMagnitude > 0.01f)
		{
			return Vector3.Dot(val, ((Vector3)(ref val2)).normalized) > 1f;
		}
		return false;
	}
}
internal sealed class FootstepsAheadEffect : FootstepsBase
{
	private readonly List<Vector3> _path = new List<Vector3>();

	private int _seg;

	public override string Start(Ctx c)
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		C = c;
		Fx.Query q = new Fx.Query
		{
			MinDist = 10f,
			MaxDist = 16f,
			MinAngle = 0f,
			MaxAngle = 50f,
			Hidden = true,
			SightHeight = 1f
		};
		if (!Fx.TryNodePoint(c.Local, c.Cam, q, out var point))
		{
			return "no hidden spot ahead";
		}
		if (!BuildPath(c, point))
		{
			return "no path away";
		}
		if (!Begin(point))
		{
			return "no audio source";
		}
		StepsLeft = 4 + Fx.Rng.Next(3);
		Sprint = true;
		Volume = 0.9f;
		return "";
	}

	private bool BuildPath(Ctx c, Vector3 start)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: 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_00d3: Invalid comparison between Unknown and I4
		_path.Clear();
		_seg = 0;
		RoundManager instance = RoundManager.Instance;
		if ((Object)(object)instance == (Object)null || instance.insideAINodes == null)
		{
			return false;
		}
		Vector3 position = ((Component)c.Local).transform.position;
		float num = Vector3.Distance(position, start);
		NavMeshPath val = new NavMeshPath();
		for (int i = 0; i < 12; i++)
		{
			GameObject val2 = instance.insideAINodes[Fx.Rng.Next(instance.insideAINodes.Length)];
			if (!((Object)(object)val2 == (Object)null))
			{
				Vector3 position2 = val2.transform.position;
				float num2 = Vector3.Distance(position2, start);
				if (!(num2 < 8f) && !(num2 > 35f) && !(Vector3.Distance(position2, position) < num + 3f) && Fx.Snap(position2, out var snapped) && NavMesh.CalculatePath(start, snapped, -1, val) && (int)val.status != 2 && val.corners != null && val.corners.Length >= 2)
				{
					_path.AddRange(val.corners);
					return true;
				}
			}
		}
		return false;
	}

	protected override bool Advance()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		float num = 1.7f;
		while (num > 0f && _seg < _path.Count - 1)
		{
			Vector3 pos = Pos;
			Vector3 val = _path[_seg + 1];
			float num2 = Vector3.Distance(pos, val);
			if (num2 <= num)
			{
				Pos = val;
				num -= num2;
				_seg++;
			}
			else
			{
				Pos = pos + (val - pos) * (num / num2);
				num = 0f;
			}
		}
		if (!(num <= 0f))
		{
			return _seg < _path.Count - 1;
		}
		return true;
	}

	protected override bool ShouldStopNow()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((Component)C.Local).transform.position - Pos;
		return ((Vector3)(ref val)).sqrMagnitude < 36f;
	}
}
internal sealed class FlashlightStutterEffect : Effect
{
	private FlashlightItem _f;

	private Light _bulb;

	private Light _glow;

	private float _bulbI;

	private float _glowI;

	private DipPlan _plan;

	internal static FlashlightItem Held(PlayerControllerB p)
	{
		FlashlightItem val = (FlashlightItem)(((Object)(object)p != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
		if ((Object)(object)val == (Object)null || !((GrabbableObject)val).isBeingUsed || (Object)(object)val.flashlightBulb == (Object)null || !((Behaviour)val.flashlightBulb).enabled)
		{
			return null;
		}
		if (val.flashlightInterferenceLevel != 0 || FlashlightItem.globalFlashlightInterferenceLevel != 0)
		{
			return null;
		}
		return val;
	}

	public override string Precheck(Ctx c)
	{
		if (!((Object)(object)Held(c.Local) == (Object)null))
		{
			return "";
		}
		return "no switched-on flashlight in hand";
	}

	public override string Start(Ctx c)
	{
		C = c;
		_f = Held(c.Local);
		if ((Object)(object)_f == (Object)null)
		{
			return "no switched-on flashlight in hand";
		}
		_bulb = _f.flashlightBulb;
		_glow = _f.flashlightBulbGlow;
		_bulbI = _bulb.intensity;
		_glowI = (((Object)(object)_glow != (Object)null) ? _glow.intensity : 0f);
		_plan = new DipPlan(Fx.Rng);
		if ((Object)(object)_f.flashlightAudio != (Object)null && (Object)(object)_f.flashlightFlicker != (Object)null)
		{
			_f.flashlightAudio.PlayOneShot(_f.flashlightFlicker);
		}
		return "";
	}

	public override void Frame(float dt)
	{
		T += dt;
		if ((Object)(object)_f == (Object)null || (Object)(object)Held(C.Local) != (Object)(object)_f)
		{
			Restore();
			base.Done = true;
		}
		else if (T >= _plan.Total)
		{
			Restore();
			base.Done = true;
		}
	}

	public override void LateFrame()
	{
		if (!base.Done && !((Object)(object)_bulb == (Object)null) && _plan != null)
		{
			float num = _plan.At(T);
			_bulb.intensity = _bulbI * num;
			if ((Object)(object)_glow != (Object)null)
			{
				_glow.intensity = _glowI * num;
			}
		}
	}

	private void Restore()
	{
		if ((Object)(object)_bulb != (Object)null)
		{
			_bulb.intensity = _bulbI;
		}
		if ((Object)(object)_glow != (Object)null)
		{
			_glow.intensity = _glowI;
		}
		_bulb = null;
		_glow = null;
	}

	public override void Stop(float fade)
	{
		Restore();
		base.Done = true;
	}

	public override void Cleanup()
	{
		Restore();
	}
}
internal sealed class NameTagEffect : Effect
{
	private GameObject _tag;

	private Visuals.Fader _fade;

	private float _hold;

	private float _outAt;

	private bool _vanishing;

	public override string Precheck(Ctx c)
	{
		if (!((Object)(object)c.Copy == (Object)null))
		{
			return "";
		}
		return "no teammate to copy";
	}

	public override string Start(Ctx c)
	{
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		C = c;
		float num = Visuals.HeadHeight(c.Copy);
		Fx.Query q = new Fx.Query
		{
			MinDist = 15f,
			MaxDist = 25f,
			MinAngle = 35f,
			MaxAngle = 60f,
			Visible = true,
			SightHeight = num
		};
		if (!Fx.TryNodePoint(c.Local, c.Cam, q, out var point))
		{
			return "no visible spot";
		}
		_tag = Visuals.BuildNameTag(c.Copy, out _fade);
		if ((Object)(object)_tag == (Object)null)
		{
			return "couldn't build name tag";
		}
		_tag.transform.position = point + Vector3.up * num;
		_fade.Set(0f);
		_hold = Fx.R(0.8f, 1.5f);
		_outAt = 0.2f + _hold;
		Face();
		return "";
	}

	private void Face()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_tag == (Object)null) && !((Object)(object)C.Cam == (Object)null))
		{
			Vector3 val = _tag.transform.position - ((Component)C.Cam).transform.position;
			if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
			{
				_tag.transform.rotation = Quaternion.LookRotation(val);
			}
		}
	}

	public override void Frame(float dt)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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)
		T += dt;
		if ((Object)(object)_tag == (Object)null)
		{
			base.Done = true;
			return;
		}
		Face();
		Vector3 position = _tag.transform.position;
		if (!_vanishing && (Fx.AngleFromView(C.Cam, position) <= 15f || Vector3.Distance(((Component)C.Cam).transform.position, position) <= 10f))
		{
			_vanishing = true;
			_outAt = T;
			_hold = -1f;
		}
		float num = (_vanishing ? Mathf.Clamp01(_fade.Alpha - dt / 0.1f) : ((T < 0.2f) ? (T / 0.2f) : ((!(T < _outAt)) ? Mathf.Clamp01(1f - (T - _outAt) / 0.4f) : 1f)));
		_fade.Set(num);
		if ((_vanishing || T >= _outAt) && num <= 0f)
		{
			Cleanup();
			base.Done = true;
		}
	}

	public override void Stop(float fade)
	{
		if ((Object)(object)_tag == (Object)null)
		{
			base.Done = true;
		}
		else
		{
			_vanishing = true;
		}
	}

	public override void Cleanup()
	{
		if ((Object)(object)_tag != (Object)null)
		{
			Object.Destroy((Object)(object)_tag);
		}
		_tag = null;
	}
}
internal sealed class SilhouetteEffect : Effect
{
	private GameObject _body;

	private GameObject _tag;

	private Visuals.Fader _tagFade;

	private float _visible;

	private Vector3 _chest;

	public override string Precheck(Ctx c)
	{
		if (!((Object)(object)c.Copy == (Object)null))
		{
			return "";
		}
		return "no teammate to copy";
	}

	public override string Start(Ctx c)
	{
		//IL_0092: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		C = c;
		Visuals.Bake bake = Visuals.GetBake(c.Copy);
		if (bake == null)
		{
			return "no usable pose to copy";
		}
		Fx.Query q = new Fx.Query
		{
			MinDist = 14f,
			MaxDist = 30f,
			MinAngle = 30f,
			MaxAngle = 55f,
			Visible = true,
			SightHeight = 1.2f
		};
		if (!Fx.TryNodePoint(c.Local, c.Cam, q, out var point))
		{
			return "no visible spot";
		}
		Vector3 val = ((Component)c.Cam).transform.position - point;
		val.y = 0f;
		Quaternion yaw = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? (Quaternion.LookRotation(val) * Quaternion.Euler(0f, Fx.R(-30f, 30f), 0f)) : Quaternion.identity);
		_body = Visuals.BuildSilhouette(bake, point, yaw);
		if ((Object)(object)_body == (Object)null)
		{
			return "couldn't build silhouette";
		}
		_chest = point + Vector3.up * 1.2f;
		if (Cfg.SilhouetteNameTag.Value)
		{
			_tag = Visuals.BuildNameTag(c.Copy, out _tagFade);
			if ((Object)(object)_tag != (Object)null)
			{
				_tag.transform.position = point + Vector3.up * Visuals.HeadHeight(c.Copy);
				_tagFade.Set(1f);
			}
		}
		_visible = Fx.R(0.4f, 1f);
		return "";
	}

	public override void Frame(float dt)
	{
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: 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)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		T += dt;
		if ((Object)(object)_body == (Object)null)
		{
			Cleanup();
			base.Done = true;
			return;
		}
		if ((Object)(object)_tag != (Object)null)
		{
			Vector3 val = _tag.transform.position - ((Component)C.Cam).transform.position;
			if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
			{
				_tag.transform.rotation = Quaternion.LookRotation(val);
			}
		}
		Vector3 position = ((Component)C.Cam).transform.position;
		if (T >= _visible || Fx.AngleFromView(C.Cam, _chest) <= 12f || Vector3.Distance(position, _chest) <= 10f || !Fx.Clear(position, _chest))
		{
			Cleanup();
			base.Done = true;
		}
	}

	public override void Stop(float fade)
	{
		Cleanup();
		base.Done = true;
	}

	public override void Cleanup()
	{
		if ((Object)(object)_body != (Object)null)
		{
			Object.Destroy((Object)(object)_body);
		}
		if ((Object)(object)_tag != (Object)null)
		{
			Object.Destroy((Object)(object)_tag);
		}
		_body = null;
		_tag = null;
	}
}
internal sealed class NameCallEffect : OneShotEffect
{
	public override string Precheck(Ctx c)
	{
		if ((Object)(object)c.Copy == (Object)null)
		{
			return "no teammate to copy";
		}
		if ((Object)(object)Voice.ClipFor(c.Copy) == (Object)null)
		{
			return "no voice clip";
		}
		if (Time.time - Runner.MimicEndedAt < 60f)
		{
			return "Mimic+ radio just played";
		}
		return "";
	}

	public override string Start(Ctx c)
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		C = c;
		AudioClip val = Voice.ClipFor(c.Copy);
		if ((Object)(object)val == (Object)null)
		{
			return "no voice clip";
		}
		Fx.Query q = new Fx.Query
		{
			MinDist = 20f,
			MaxDist = 35f,
			Hidden = true,
			SightHeight = 1.6f
		};
		if (!Fx.TryNodePoint(c.Local, c.Cam, q, out var point))
		{
			return "no hidden spot";
		}
		if (!Play(point + Vector3.up * 1.6f, c.Copy.currentVoiceChatAudioSource, val, 1f))
		{
			return "no audio source";
		}
		Src.Src.volume = Mathf.Clamp(Mathf.Max(Src.Src.volume, 0.8f), 0f, 1f);
		if (Src.Src.maxDistance < 40f)
		{
			Src.Src.maxDistance = 40f;
		}
		if ((Object)(object)Src.Occ != (Object)null)
		{
			Src.Occ.overridingLowPass = true;
			Src.Occ.lowPassOverride = 2500f;
			Src.Occ.useReverb = true;
		}
		Voice.ClipUsed(c.Copy);
		return "";
	}
}
internal sealed class FakeSource
{
	public GameObject Go;

	public AudioSource Src;

	public OccludeAudio Occ;

	public bool InUse;

	public float BaseVolume = 1f;

	private float _fadeFrom;

	private float _fadeLeft;

	private float _fadeTotal;

	public bool Fading => _fadeLeft > 0f;

	public void FadeOut(float seconds)
	{
		if (!((Object)(object)Src == (Object)null))
		{
			if (seconds <= 0f)
			{
				Src.Stop();
				return;
			}
			_fadeFrom = Src.volume;
			_fadeTotal = seconds;
			_fadeLeft = seconds;
		}
	}

	public void Tick(float dt)
	{
		if (!(_fadeLeft <= 0f) && !((Object)(object)Src == (Object)null))
		{
			_fadeLeft -= dt;
			if (_fadeLeft <= 0f)
			{
				Src.volume = 0f;
				Src.Stop();
			}
			else
			{
				Src.volume = _fadeFrom * (_fadeLeft / _fadeTotal);
			}
		}
	}

	public void ClearFade()
	{
		_fadeLeft = 0f;
	}
}
internal static class Fx
{
	public struct Query
	{
		public float MinDist;

		public float MaxDist;

		public float MinAngle;

		public float MaxAngle;

		public bool Hidden;

		public bool Visible;

		public float SightHeight;
	}

	private const int PoolMax = 6;

	private static readonly List<FakeSource> Pool = new List<FakeSource>();

	internal static readonly Random Rng = new Random();

	private static AudioClip _static;

	private static readonly List<Vector3> Candidates = new List<Vector3>(256);

	public static float R(float a, float b)
	{
		return a + (b - a) * (float)Rng.NextDouble();
	}

	public static FakeSource Acquire(Vector3 pos, AudioSource template, AudioSource mixerFallback)
	{
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		FakeSource fakeSource = null;
		for (int i = 0; i < Pool.Count; i++)
		{
			if ((Object)(object)Pool[i].Go == (Object)null)
			{
				Pool.RemoveAt(i);
				i--;
			}
			else if (!Pool[i].InUse)
			{
				fakeSource = Pool[i];
				break;
			}
		}
		if (fakeSource == null)
		{
			if (Pool.Count >= 6)
			{
				return null;
			}
			fakeSource = new FakeSource();
			fakeSource.Go = new GameObject("IsolationFx");
			fakeSource.Src = fakeSource.Go.AddComponent<AudioSource>();
			fakeSource.Src.playOnAwake = false;
			fakeSource.Occ = fakeSource.Go.AddComponent<OccludeAudio>();
			Pool.Add(fakeSource);
		}
		fakeSource.InUse = true;
		fakeSource.ClearFade();
		fakeSource.Go.transform.position = pos;
		fakeSource.Go.SetActive(true);
		fakeSource.Src.Stop();
		fakeSource.Src.clip = null;
		fakeSource.Src.loop = false;
		fakeSource.Src.pitch = 1f;
		fakeSource.Src.time = 0f;
		if ((Object)(object)fakeSource.Occ != (Object)null)
		{
			fakeSource.Occ.overridingLowPass = false;
			fakeSource.Occ.useReverb = false;
		}
		CopySource(template, fakeSource.Src, mixerFallback);
		fakeSource.BaseVolume = fakeSource.Src.volume;
		return fakeSource;
	}

	public static void Release(FakeSource fs)
	{
		if (fs == null)
		{
			return;
		}
		try
		{
			fs.ClearFade();
			if ((Object)(object)fs.Src != (Object)null)
			{
				fs.Src.Stop();
				fs.Src.clip = null;
			}
			if ((Object)(object)fs.Go != (Object)null)
			{
				fs.Go.SetActive(false);
			}
		}
		catch
		{
		}
		fs.InUse = false;
	}

	public static void TickPool(float dt)
	{
		for (int i = 0; i < Pool.Count; i++)
		{
			if (Pool[i].InUse)
			{
				Pool[i].Tick(dt);
			}
		}
	}

	public static void DestroyAll()
	{
		foreach (FakeSource item in Pool)
		{
			try
			{
				if ((Object)(object)item.Go != (Object)null)
				{
					Object.Destroy((Object)(object)item.Go);
				}
			}
			catch
			{
			}
		}
		Pool.Clear();
	}

	public static void CopySource(AudioSource from, AudioSource to, AudioSource mixerFallback)
	{
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Invalid comparison between Unknown and I4
		to.playOnAwake = false;
		to.loop = false;
		if ((Object)(object)from == (Object)null)
		{
			to.outputAudioMixerGroup = (((Object)(object)mixerFallback != (Object)null) ? mixerFallback.outputAudioMixerGroup : null);
			to.spatialBlend = 1f;
			to.volume = 1f;
			to.rolloffMode = (AudioRolloffMode)0;
			to.minDistance = 1f;
			to.maxDistance = 40f;
			to.dopplerLevel = 0f;
			to.spread = 0f;
			to.priority = 128;
			return;
		}
		to.outputAudioMixerGroup = (((Object)(object)from.outputAudioMixerGroup != (Object)null) ? from.outputAudioMixerGroup : (((Object)(object)mixerFallback != (Object)null) ? mixerFallback.outputAudioMixerGroup : null));
		to.spatialBlend = from.spatialBlend;
		to.volume = from.volume;
		to.rolloffMode = from.rolloffMode;
		to.minDistance = from.minDistance;
		to.maxDistance = from.maxDistance;
		to.dopplerLevel = from.dopplerLevel;
		to.spread = from.spread;
		to.priority = from.priority;
		to.reverbZoneMix = from.reverbZoneMix;
		to.spatialize = from.spatialize;
		to.bypassEffects = from.bypassEffects;
		to.bypassListenerEffects = from.bypassListenerEffects;
		to.bypassReverbZones = from.bypassReverbZones;
		if ((int)from.rolloffMode == 2)
		{
			try
			{
				to.SetCustomCurve((AudioSourceCurveType)0, from.GetCustomCurve((AudioSourceCurveType)0));
			}
			catch
			{
			}
		}
		try
		{
			to.SetCustomCurve((AudioSourceCurveType)1, from.GetCustomCurve((AudioSourceCurveType)1));
		}
		catch
		{
		}
		try
		{
			to.SetCustomCurve((AudioSourceCurveType)3, from.GetCustomCurve((AudioSourceCurveType)3));
		}
		catch
		{
		}
	}

	public static AudioClip StaticClip()
	{
		if ((Object)(object)_static != (Object)null)
		{
			return _static;
		}
		float[] array = StaticNoise.Generate(44100, 1.6f, 81);
		_static = AudioClip.Create("IsolationStatic", array.Length, 1, 44100, false);
		_static.SetData(array, 0);
		((Object)_static).hideFlags = (HideFlags)32;
		return _static;
	}

	public static int SightMask()
	{
		StartOfRound instance = StartOfRound.Instance;
		if (!((Object)(object)instance != (Object)null))
		{
			return -1;
		}
		return instance.collidersAndRoomMask;
	}

	public static bool Clear(Vector3 a, Vector3 b)
	{
		//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)
		return !Physics.Linecast(a, b, SightMask(), (QueryTriggerInteraction)1);
	}

	public static float AngleFromView(Camera cam, Vector3 p)
	{
		//IL_0000: 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)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = p - ((Component)cam).transform.position;
		if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
		{
			return 0f;
		}
		return Vector3.Angle(((Component)cam).transform.forward, val);
	}

	public static int SurfaceIndexAt(Vector3 p, int fallback)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || instance.footstepSurfaces == null)
			{
				return fallback;
			}
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(new Ray(p + Vector3.up, Vector3.down), ref val, 6f, instance.walkableSurfacesMask, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val)).collider != (Object)null)
			{
				for (int i = 0; i < instance.footstepSurfaces.Length; i++)
				{
					FootstepSurface val2 = instance.footstepSurfaces[i];
					if (val2 != null && !string.IsNullOrEmpty(val2.surfaceTag) && ((Component)((RaycastHit)(ref val)).collider).CompareTag(val2.surfaceTag))
					{
						return i;
					}
				}
			}
		}
		catch
		{
		}
		return fallback;
	}

	public static bool Snap(Vector3 p, out Vector3 snapped)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		NavMeshHit val = default(NavMeshHit);
		if (NavMesh.SamplePosition(p, ref val, 2f, -1))
		{
			snapped = ((NavMeshHit)(ref val)).position;
			return true;
		}
		snapped = p;
		return false;
	}

	public static bool PassesCommonRules(Vector3 p, PlayerControllerB local, bool allowOtherFloor)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: 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_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)local).transform.position;
		if (!allowOtherFloor && Mathf.Abs(p.y - position.y) > 4f)
		{
			return false;
		}
		StartOfRound instance = StartOfRound.Instance;
		Vector3 val2;
		if ((Object)(object)instance != (Object)null && instance.allPlayerScripts != null)
		{
			PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)local || !val.isPlayerControlled || val.isPlayerDead)
				{
					continue;
				}
				Vector3 position2 = ((Component)val).transform.position;
				val2 = position2 - p;
				if (((Vector3)(ref val2)).sqrMagnitude < 225f)
				{
					return false;
				}
				if (val.isInsideFactory == local.isInsideFactory)
				{
					Vector3 val3 = p - position;
					Vector3 val4 = position2 - position;
					val3.y = 0f;
					val4.y = 0f;
					if (((Vector3)(ref val3)).sqrMagnitude > 0.01f && ((Vector3)(ref val4)).sqrMagnitude > 0.01f && Vector3.Angle(val3, val4) <= 25f)
					{
						return false;
					}
				}
			}
		}
		RoundManager instance2 = RoundManager.Instance;
		if ((Object)(object)instance2 != (Object)null && instance2.SpawnedEnemies != null)
		{
			foreach (EnemyAI spawnedEnemy in instance2.SpawnedEnemies)
			{
				if (!((Object)(object)spawnedEnemy == (Object)null) && !spawnedEnemy.isEnemyDead)
				{
					val2 = ((Component)spawnedEnemy).transform.position - p;
					if (((Vector3)(ref val2)).sqrMagnitude < 64f)
					{
						return false;
					}
				}
			}
		}
		return true;
	}

	public static bool TryNodePoint(PlayerControllerB local, Camera cam, Query q, out Vector3 point)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_0095: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		point = Vector3.zero;
		RoundManager instance = RoundManager.Instance;
		if ((Object)(object)instance == (Object)null || instance.insideAINodes == null || instance.insideAINodes.Length == 0 || (Object)(object)cam == (Object)null)
		{
			return false;
		}
		Vector3 position = ((Component)local).transform.position;
		Candidates.Clear();
		float num = Mathf.Max(0f, q.MinDist - 2f);
		float num2 = q.MaxDist + 2f;
		GameObject[] insideAINodes = instance.insideAINodes;
		foreach (GameObject val in insideAINodes)
		{
			if (!((Object)(object)val == (Object)null))
			{
				Vector3 position2 = val.transform.position;
				float num3 = Vector3.Distance(position2, position);
				if (num3 >= num && num3 <= num2)
				{
					Candidates.Add(position2);
				}
			}
		}
		for (int j = 0; j < 12; j++)
		{
			if (Candidates.Count <= 0)
			{
				break;
			}
			int index = Rng.Next(Candidates.Count);
			Vector3 p = Candidates[index];
			Candidates.RemoveAt(index);
			if (Snap(p, out var snapped) && Check(local, cam, q, snapped))
			{
				point = snapped;
				return true;
			}
		}
		return false;
	}

	public static bool Check(PlayerControllerB local, Camera cam, Query q, Vector3 p)
	{
		//IL_0000: 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)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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_0086: 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_008c: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		float num = Vector3.Distance(p, ((Component)local).transform.position);
		if (num < q.MinDist || num > q.MaxDist)
		{
			return false;
		}
		if (q.MaxAngle > 0f)
		{
			float num2 = AngleFromView(cam, p + Vector3.up * q.SightHeight);
			if (num2 < q.MinAngle || num2 > q.MaxAngle)
			{
				return false;
			}
		}
		if (!PassesCommonRules(p, local, allowOtherFloor: false))
		{
			return false;
		}
		if (q.Hidden || q.Visible)
		{
			bool flag = Clear(((Component)cam).transform.position, p + Vector3.up * q.SightHeight);
			if (q.Hidden && flag)
			{
				return false;
			}
			if (q.Visible && !flag)
			{
				return false;
			}
		}
		return true;
	}

	public static bool TryAround(PlayerControllerB local, Camera cam, float minBearing, float maxBearing, float minR, float maxR, out Vector3 point)
	{
		//IL_0002: 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)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		point = Vector3.zero;
		Vector3 forward = ((Component)cam).transform.forward;
		forward.y = 0f;
		if (((Vector3)(ref forward)).sqrMagnitude < 0.001f)
		{
			forward = ((Component)local).transform.forward;
		}
		((Vector3)(ref forward)).Normalize();
		Vector3 position = ((Component)local).transform.position;
		for (int i = 0; i < 12; i++)
		{
			Vector3 val = Quaternion.AngleAxis(R(minBearing, maxBearing), Vector3.up) * forward;
			if (Snap(position + val * R(minR, maxR), out var snapped))
			{
				float num = Vector3.Distance(snapped, position);
				if (!(num < minR * 0.75f) && !(num > maxR * 1.25f) && PassesCommonRules(snapped, local, allowOtherFloor: false))
				{
					point = snapped;
					return true;
				}
			}
		}
		return false;
	}
}
internal static class LevelCache
{
	public static readonly List<DoorLock> Doors = new List<DoorLock>();

	public static readonly List<GrabbableObject> ScrapWithDrop = new List<GrabbableObject>();

	public static BreakerBox Breaker;

	private static FieldRef<DoorLock, bool> _haunted;

	private static bool _hauntedLooked;

	private static readonly Dictionary<Animator, int> Params = new Dictionary<Animator, int>();

	private static List<Item> _itemsWithDrop;

	private static AudioSource _typicalScrap;

	private static bool _typicalLooked;

	public static bool Built { get; private set; }

	public static void Clear()
	{
		Doors.Clear();
		ScrapWithDrop.Clear();
		Breaker = null;
		Params.Clear();
		Built = false;
	}

	public static void TryBuild()
	{
		if (Built)
		{
			return;
		}
		RoundManager instance = RoundManager.Instance;
		if ((Object)(object)instance == (Object)null || !instance.dungeonCompletedGenerating)
		{
			return;
		}
		Built = true;
		try
		{
			DoorLock[] array = Object.FindObjectsOfType<DoorLock>();
			foreach (DoorLock val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					Doors.Add(val);
				}
			}
			GrabbableObject[] array2 = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val2 in array2)
			{
				if ((Object)(object)val2 != (Object)null && (Object)(object)val2.itemProperties != (Object)null && val2.itemProperties.isScrap && (Object)(object)val2.itemProperties.dropSFX != (Object)null && !val2.isInShipRoom)
				{
					ScrapWithDrop.Add(val2);
				}
			}
			Breaker = Object.FindObjectOfType<BreakerBox>();
			Plugin.Debug("Level cached: " + Doors.Count + " doors, " + ScrapWithDrop.Count + " scrap with drop sounds, breaker " + ((Object)(object)Breaker != (Object)null));
		}
		catch (Exception ex)
		{
			Plugin.Warn("levelcache", "Couldn't cache level objects: " + ex.Message);
		}
	}

	public static bool IsHaunted(DoorLock d)
	{
		if (!_hauntedLooked)
		{
			_hauntedLooked = true;
			try
			{
				_haunted = AccessTools.FieldRefAccess<DoorLock, bool>("hauntedDoor");
			}
			catch
			{
				_haunted = null;
			}
		}
		if (_haunted == null)
		{
			return false;
		}
		try
		{
			return _haunted.Invoke(d);
		}
		catch
		{
			return false;
		}
	}

	public static bool CanFlicker(Animator a)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Invalid comparison between Unknown and I4
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Invalid comparison between Unknown and I4
		if (!Params.TryGetValue(a, out var value))
		{
			value = 0;
			try
			{
				AnimatorControllerParameter[] parameters = a.parameters;
				foreach (AnimatorControllerParameter val in parameters)
				{
					if ((int)val.type == 9 && val.name == "Flicker")
					{
						value |= 1;
					}
					if ((int)val.type == 4 && val.name == "on")
					{
						value |= 2;
					}
				}
			}
			catch
			{
			}
			Params[a] = value;
		}
		if ((value & 1) == 0)
		{
			return false;
		}
		if ((value & 2) == 0)
		{
			return true;
		}
		try
		{
			return a.GetBool("on");
		}
		catch
		{
			return false;
		}
	}

	public static List<Item> ItemsWithDrop()
	{
		if (_itemsWithDrop != null && _itemsWithDrop.Count > 0)
		{
			return _itemsWithDrop;
		}
		_itemsWithDrop = new List<Item>();
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance != (Object)null && (Object)(object)instance.allItemsList != (Object)null && instance.allItemsList.itemsList != null)
		{
			foreach (Item items in instance.allItemsList.itemsList)
			{
				if ((Object)(object)items != (Object)null && (Object)(object)items.dropSFX != (Object)null)
				{
					_itemsWithDrop.Add(items);
				}
			}
		}
		return _itemsWithDrop;
	}

	public static AudioSource TypicalScrapSource()
	{
		if (_typicalLooked && (Object)(object)_typicalScrap != (Object)null)
		{
			return _typicalScrap;
		}
		_typicalLooked = true;
		foreach (Item item in ItemsWithDrop())
		{
			if (item.isScrap && !((Object)(object)item.spawnPrefab == (Object)null))
			{
				AudioSource component = item.spawnPrefab.GetComponent<AudioSource>();
				if ((Object)(object)component != (Object)null)
				{
					_typicalScrap = component;
					break;
				}
			}
		}
		return _typicalScrap;
	}
}
internal enum Situation
{
	Inactive,
	Outside,
	Alone,
	Company,
	Regrouped,
	Frozen
}
internal sealed class MeterSettings
{
	public float BuildPerMinute = 20f;

	public float MinDistance = 25f;

	public float DistanceBonusMax = 1.5f;

	public float DecayPerMinuteCompany = 15f;

	public float DecayPerMinuteOutside = 30f;
}
internal static class MeterMath
{
	public const float Max = 100f;

	public const float RegroupDrainSeconds = 3f;

	public static float DistanceFactor(float nearest, float minDistance, float bonusMax)
	{
		if (bonusMax < 1f)
		{
			bonusMax = 1f;
		}
		if (float.IsNaN(nearest) || float.IsInfinity(nearest))
		{
			return bonusMax;
		}
		if (minDistance <= 0.01f)
		{
			return bonusMax;
		}
		if (nearest <= minDistance)
		{
			return 1f;
		}
		float num = (nearest - minDistance) / (2f * minDistance);
		if (num >= 1f)
		{
			return bonusMax;
		}
		return 1f + (bonusMax - 1f) * num;
	}

	public static int Tier(float level)
	{
		if (level >= 75f)
		{
			return 3;
		}
		if (level >= 50f)
		{
			return 2;
		}
		if (level >= 25f)
		{
			return 1;
		}
		return 0;
	}

	public static float Clamp(float v)
	{
		if (!(v < 0f))
		{
			if (!(v > 100f))
			{
				return v;
			}
			return 100f;
		}
		return 0f;
	}
}
internal sealed class Meter
{
	public float Level;

	private float _drainRate;

	public bool Draining { get; private set; }

	public void Reset()
	{
		Level = 0f;
		Draining = false;
		_drainRate = 0f;
	}

	public void StartRegroupDrain()
	{
		if (Level <= 0f)
		{
			Level = 0f;
			Draining = false;
		}
		else
		{
			_drainRate = Level / 3f;
			Draining = true;
		}
	}

	public void Add(float delta)
	{
		Level = MeterMath.Clamp(Level + delta);
	}

	public void Step(Situation s, float dt, float nearestDistance, MeterSettings m)
	{
		if (dt <= 0f)
		{
			return;
		}
		if (s == Situation.Inactive)
		{
			Reset();
			return;
		}
		if (Draining)
		{
			Level -= _drainRate * dt;
			if (Level <= 0f)
			{
				Level = 0f;
				Draining = false;
			}
			return;
		}
		switch (s)
		{
		case Situation.Alone:
		{
			float num = MeterMath.DistanceFactor(nearestDistance, m.MinDistance, m.DistanceBonusMax);
			Level = MeterMath.Clamp(Level + m.BuildPerMinute / 60f * num * dt);
			break;
		}
		case Situation.Company:
			Level = MeterMath.Clamp(Level - m.DecayPerMinuteCompany / 60f * dt);
			break;
		case Situation.Outside:
			Level = MeterMath.Clamp(Level - m.DecayPerMinuteOutside / 60f * dt);
			break;
		case Situation.Regrouped:
			Level = 0f;
			break;
		case Situation.Frozen:
			break;
		}
	}
}
internal static class PacingMath
{
	public static float BaseGap(float level, float gapStart, float gapEnd)
	{
		float num = (level - 25f) / 75f;
		if (num < 0f)
		{
			num = 0f;
		}
		else if (num > 1f)
		{
			num = 1f;
		}
		return gapStart + (gapEnd - gapStart) * num;
	}

	public static float Gap(float level, float gapStart, float gapEnd, float intensity, double u01)
	{
		if (intensity < 0.05f)
		{
			intensity = 0.05f;
		}
		return (float)((double)(BaseGap(level, gapStart, gapEnd) / intensity) * (0.7 + 0.6 * u01));
	}

	public static float RollChance(float intensity)
	{
		float num = 0.15f * intensity;
		if (!(num < 0f))
		{
			if (!(num > 1f))
			{
				return num;
			}
			return 1f;
		}
		return 0f;
	}

	public static int PickWeighted(IList<float> weights, double u01)
	{
		double num = 0.0;
		for (int i = 0; i < weights.Count; i++)
		{
			if (weights[i] > 0f)
			{
				num += (double)weights[i];
			}
		}
		if (num <= 0.0)
		{
			return -1;
		}
		double num2 = u01 * num;
		int result = -1;
		for (int j = 0; j < weights.Count; j++)
		{
			if (!(weights[j] <= 0f))
			{
				result = j;
				if (num2 < (double)weights[j])
				{
					return j;
				}
				num2 -= (double)weights[j];
			}
		}
		return result;
	}
}
internal sealed class Grace
{
	public const float AfterLanding = 90f;

	public const float AfterEntering = 60f;

	public const float AfterRegroup = 20f;

	public float LandedAt = float.NegativeInfinity;

	public float EnteredAt = float.NegativeInfinity;

	public float RegroupAt = float.NegativeInfinity;

	public void Reset(float now)
	{
		LandedAt = now;
		EnteredAt = float.NegativeInfinity;
		RegroupAt = float.NegativeInfinity;
	}

	public bool Passed(float now)
	{
		if (now - LandedAt >= 90f && now - EnteredAt >= 60f)
		{
			return now - RegroupAt >= 20f;
		}
		return false;
	}
}
internal sealed class Scheduler
{
	public const float RollInterval = 2f;

	public float NextAllowedAt = float.NegativeInfinity;

	public float NextRollAt = float.NegativeInfinity;

	public void Reset()
	{
		NextAllowedAt = float.NegativeInfinity;
		NextRollAt = float.NegativeInfinity;
	}

	public bool RollDue(float now)
	{
		if (now < NextAllowedAt || now < NextRollAt)
		{
			return false;
		}
		NextRollAt = now + 2f;
		return true;
	}

	public void OnEffectEnded(float now, float gap)
	{
		NextAllowedAt = now + gap;
	}
}
internal sealed class EffectBook
{
	private readonly Dictionary<string, float> _last = new Dictionary<string, float>();

	private readonly Dictionary<string, int> _today = new Dictionary<string, int>();

	private readonly HashSet<string> _broken = new HashSet<string>();

	public int AutoToday;

	public void ResetDay()
	{
		_last.Clear();
		_today.Clear();
		_broken.Clear();
		AutoToday = 0;
	}

	public bool CooldownPassed(string id, float now, float cooldown)
	{
		if (_last.TryGetValue(id, out var value))
		{
			return now - value >= cooldown;
		}
		return true;
	}

	public int CountToday(string id)
	{
		if (!_today.TryGetValue(id, out var value))
		{
			return 0;
		}
		return value;
	}

	public void Fired(string id, float now, bool automatic)
	{
		_last[id] = now;
		_today[id] = CountToday(id) + 1;
		if (automatic)
		{
			AutoToday++;
		}
	}

	public void MarkBroken(string id)
	{
		_broken.Add(id);
	}

	public bool IsBroken(string id)
	{
		return _broken.Contains(id);
	}
}
internal static class OggInfo
{
	public static double OpusSeconds(byte[] data)
	{
		if (data == null || data.Length < 47)
		{
			return -1.0;
		}
		if (!IsCapture(data, 0))
		{
			return -1.0;
		}
		int num = FindAscii(data, "OpusHead", 0, Math.Min(data.Length, 200));
		if (num < 0 || num + 12 > data.Length)
		{
			return -1.0;
		}
		int num2 = data[num + 10] | (data[num + 11] << 8);
		for (int num3 = data.Length - 27; num3 >= 0; num3--)
		{
			if (IsCapture(data, num3))
			{
				long num4 = BitConverter.ToInt64(data, num3 + 6);
				if (num4 <= 0)
				{
					return -1.0;
				}
				return (double)(num4 - num2) / 48000.0;
			}
		}
		return -1.0;
	}

	private static bool IsCapture(byte[] d, int i)
	{
		if (i + 27 <= d.Length && d[i] == 79 && d[i + 1] == 103 && d[i + 2] == 103)
		{
			return d[i + 3] == 83;
		}
		return false;
	}

	private static int FindAscii(byte[] d, string s, int from, int to)
	{
		for (int i = from; i + s.Length <= to; i++)
		{
			bool flag = true;
			for (int j = 0; j < s.Length; j++)
			{
				if (d[i + j] != (byte)s[j])
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				return i;
			}
		}
		return -1;
	}
}
internal static class StaticNoise
{
	internal sealed class Biquad
	{
		private readonly float b0;

		private readonly float b1;

		private readonly float b2;

		private readonly float a1;

		private readonly float a2;

		private float x1;

		private float x2;

		private float y1;

		private float y2;

		private Biquad(float b0, float b1, float b2, float a0, float a1, float a2)
		{
			this.b0 = b0 / a0;
			this.b1 = b1 / a0;
			this.b2 = b2 / a0;
			this.a1 = a1 / a0;
			this.a2 = a2 / a0;
		}

		public static Biquad LowPass(float rate, float f, float q)
		{
			double num = Math.PI * 2.0 * (double)f / (double)rate;
			double num2 = Math.Cos(num);
			double num3 = Math.Sin(num) / (double)(2f * q);
			return new Biquad((float)((1.0 - num2) / 2.0), (float)(1.0 - num2), (float)((1.0 - num2) / 2.0), (float)(1.0 + num3), (float)(-2.0 * num2), (float)(1.0 - num3));
		}

		public static Biquad HighPass(float rate, float f, float q)
		{
			double num = Math.PI * 2.0 * (double)f / (double)rate;
			double num2 = Math.Cos(num);
			double num3 = Math.Sin(num) / (double)(2f * q);
			return new Biquad((float)((1.0 + num2) / 2.0), (float)(0.0 - (1.0 + num2)), (float)((1.0 + num2) / 2.0), (float)(1.0 + num3), (float)(-2.0 * num2), (float)(1.0 - num3));
		}

		public float Process(float x)
		{
			float result = b0 * x + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2;
			x2 = x1;
			x1 = x;
			y2 = y1;
			y1 = result;
			return result;
		}
	}

	public static float[] Generate(int sampleRate, float seconds, int seed)
	{