Decompiled source of KikisFog v0.14.3

plugins/KikisFog.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak;
using Peak.Afflictions;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;

[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("KikisFog")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.14.3.0")]
[assembly: AssemblyInformationalVersion("0.14.3")]
[assembly: AssemblyProduct("KikisFog")]
[assembly: AssemblyTitle("KikisFog")]
[assembly: AssemblyVersion("0.14.3.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace KFOG
{
	[BepInPlugin("kikisfog.peak.kfog", "Kikis Fog", "0.14.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "kikisfog.peak.kfog";

		public const string NAME = "Kikis Fog";

		public const string VERSION = "0.14.3";

		internal static Plugin I;

		internal static ManualLogSource L;

		private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;

		internal static ConfigEntry<float> FogDelay;

		internal static ConfigEntry<float> FogSpeed;

		internal static ConfigEntry<bool> DeadlyFog;

		internal static ConfigEntry<float> FogTolerance;

		internal static ConfigEntry<float> CampfireSafeRadius;

		internal static ConfigEntry<float> GloomDelay;

		internal static ConfigEntry<float> GloomSpeed;

		internal static ConfigEntry<bool> DeadlyGloom;

		internal static ConfigEntry<float> GloomTolerance;

		internal static ConfigEntry<float> LavaDelay;

		internal static ConfigEntry<float> LavaSpeed;

		internal static ConfigEntry<bool> CalderaNeverLowers;

		internal static ConfigEntry<float> SoulsDelay;

		internal static ConfigEntry<float> SoulsSpeed;

		internal static ConfigEntry<bool> AutoRevive;

		internal static ConfigEntry<float> WaitRevive;

		internal static ConfigEntry<float> ForcedRevive;

		internal static ConfigEntry<float> DayLength;

		internal static ConfigEntry<float> NightLength;

		internal static ConfigEntry<bool> EternalNight;

		private const float SYNC_INTERVAL = 0.18f;

		private const float SYNC_MIN_DELTA = 0.35f;

		private const float PAUSED_SYNC_INTERVAL = 0.5f;

		private const float QUIET_AFTER_ORIGIN = 3f;

		private const float QUIET_AFTER_JOIN = 8f;

		private const float TRANSITION_TIMEOUT = 90f;

		private const float KILL_RESEND = 10f;

		private const float STATUE_SKIP_WINDOW = 2f;

		private const float HEALTHY_WINDOW = 2f;

		private const float STALL_RESUME = 3f;

		private const float PAUSE_HOLD = 0.5f;

		private const float REVIVE_TICK = 0.25f;

		private const float REVIVE_RESEND = 5f;

		private const float REVIVE_HEIGHT = 2.5f;

		private const float REVIVE_GROUND_RAY = 8f;

		private const float REVIVE_FOG_MARGIN = 5f;

		private const float REVIVE_LEAD = 15f;

		private const float REVIVE_GROUND_HOLD = 1f;

		private const float LAVA_CLEAR = 3f;

		private const float LAVA_SCAN = 2f;

		private const float VOID_Y = 4000f;

		private const float VOID_REWARP_AFTER = 2f;

		private const float VOID_REWARP_EVERY = 3f;

		private const int VOID_REWARP_MAX = 3;

		private const float VOID_GUARD_MAX = 15f;

		private const float VOID_TARGET_KEEP = 30f;

		private const float VOID_LOG_MIN = 0.5f;

		private const float TRANSIT_ARRIVED = 3f;

		private const float TRANSIT_MAX = 10f;

		private const float TRANSIT_HOLD = 1f;

		private static readonly float[] SpotRadii = new float[3] { 1.1f, 1.6f, 2.2f };

		private const int SPOT_DIRECTIONS = 12;

		private const float SPOT_CHEST_UP = 0.2f;

		private const float SPOT_PROBE_RADIUS = 0.3f;

		private const float SPOT_BODY_RADIUS = 0.35f;

		private const float SPOT_EDGE = 0.7f;

		private const float SPOT_MAX_STEP = 0.6f;

		private const float SPOT_SLOPE_PER_UNIT = 0.4f;

		private const float SPOT_BODY_FLOOR = 0.35f;

		private const float SPOT_MIN_NORMAL_Y = 0.77f;

		private const float SPOT_HEAD_EXTRA = 0.4f;

		private const float SPOT_LIFT = 0.25f;

		private const float SPOT_PERSON_GAP = 0.9f;

		internal static bool InTransition;

		private static float _transitionStartedAt;

		private float _quietUntil;

		private OrbFogHandler _fog;

		private FogSphere _sphere;

		private static OrbFogHandler _originsOwner;

		private static FogSphereOrigin[] _origins;

		private bool _stageControlled;

		private float _lastHealthyTick = -999f;

		private int _stageId = -1;

		private float _delayElapsed;

		private bool _delayDone;

		private float _stalledSince = -1f;

		private bool _paused;

		private bool _campfireResolved;

		private bool _campfireFound;

		private Vector3 _campfirePos;

		private float _nextCampfireTry;

		private float _nextSync;

		private float _nextPausedSync;

		private float _lastSentSize = float.NaN;

		private bool _lastSentMoving;

		private int _lastPlayerCount;

		private readonly Dictionary<int, float> _insideSince = new Dictionary<int, float>();

		private readonly Dictionary<int, float> _killSentAt = new Dictionary<int, float>();

		private readonly Dictionary<int, float> _flagNotedAt = new Dictionary<int, float>();

		private readonly Dictionary<int, float> _petrifySentAt = new Dictionary<int, float>();

		private readonly List<Character> _victims = new List<Character>();

		private float _nextDeadly;

		private readonly Dictionary<int, Vector3> _transitTarget = new Dictionary<int, Vector3>();

		private readonly Dictionary<int, float> _transitSince = new Dictionary<int, float>();

		private readonly HashSet<int> _transitNoted = new HashSet<int>();

		private readonly Dictionary<int, float> _transitHoldSince = new Dictionary<int, float>();

		private const float GSPEED_WINDOW = 10f;

		private const float GSPEED_MIN_SPAN = 6f;

		private const float GSPEED_GAP = 1f;

		private readonly Queue<Vector2> _gSamples = new Queue<Vector2>();

		private int _gOrigin = int.MinValue;

		private float _gLastSample = -999f;

		private RectTransform _hudRoot;

		private TextMeshProUGUI _hudText;

		private string _hudLast;

		private float _nextHud;

		private readonly Dictionary<int, float> _deadSince = new Dictionary<int, float>();

		private readonly Dictionary<int, Vector3> _lastAlivePos = new Dictionary<int, Vector3>();

		private readonly Dictionary<int, float> _reviveSentAt = new Dictionary<int, float>();

		private readonly Dictionary<int, float> _noAnchorNotedAt = new Dictionary<int, float>();

		private readonly Dictionary<int, float> _groundedSince = new Dictionary<int, float>();

		private readonly List<Character> _toRevive = new List<Character>();

		private float _nextRevive;

		private int _spreadIndex;

		private float _spreadResetAt;

		private int _spotAngleIndex;

		private readonly List<Vector3> _recentSpots = new List<Vector3>();

		private static readonly List<Lava> _lavas = new List<Lava>();

		private static float _nextLavaScan;

		private static MethodInfo _lavaOutside;

		private static readonly object[] _lavaArg = new object[1];

		private int _spotsOverLava;

		private readonly Dictionary<int, float> _voidSince = new Dictionary<int, float>();

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

		private readonly Dictionary<int, float> _voidNextRewarp = new Dictionary<int, float>();

		private readonly HashSet<int> _voidGaveUp = new HashSet<int>();

		private readonly Dictionary<int, Vector3> _reviveTarget = new Dictionary<int, Vector3>();

		private float _nextVoid;

		private readonly Dictionary<string, float> _errLogged = new Dictionary<string, float>();

		private readonly Dictionary<LavaRising, float> _riserNextSync = new Dictionary<LavaRising, float>();

		private readonly Dictionary<LavaRising, StatusFieldGloom[]> _gloomFields = new Dictionary<LavaRising, StatusFieldGloom[]>();

		private readonly HashSet<LavaRising> _riserStartLogged = new HashSet<LavaRising>();

		private readonly Dictionary<int, float> _gloomInsideSince = new Dictionary<int, float>();

		private float _nextDeadlyGloom;

		private const float CALDERA_TOP = 0.7f;

		private readonly List<Animator> _calderaAnims = new List<Animator>();

		private readonly List<PhotonView> _calderaViews = new List<PhotonView>();

		private float _nextCalderaScan;

		private float _nextCalderaSync;

		private bool _calderaLogged;

		internal static bool IsAuthority
		{
			get
			{
				if (PhotonNetwork.InRoom)
				{
					return PhotonNetwork.IsMasterClient;
				}
				return true;
			}
		}

		private void Awake()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Expected O, but got Unknown
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Expected O, but got Unknown
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Expected O, but got Unknown
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Expected O, but got Unknown
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Expected O, but got Unknown
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Expected O, but got Unknown
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: 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_04ab: Unknown result type (might be due to invalid IL or missing references)
			I = this;
			L = ((BaseUnityPlugin)this).Logger;
			FogDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Fog", "Fog Delay (s)", 360f, new ConfigDescription("Seconds the fog waits in each fog stage before it starts rising.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1800f), Array.Empty<object>()));
			FogSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Fog", "Fog Speed", 1f, new ConfigDescription("How fast the fog rises.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
			DeadlyFog = ((BaseUnityPlugin)this).Config.Bind<bool>("Fog", "Deadly Fog", false, "Whoever stands in the fog dies.");
			FogTolerance = ((BaseUnityPlugin)this).Config.Bind<float>("Fog", "Deadly Fog Tolerance (s)", 1f, new ConfigDescription("How long someone can stand in the fog before it kills.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			CampfireSafeRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Fog", "Campfire Safe Radius (m)", 50f, new ConfigDescription("The fog stops this far away from the campfire.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
			GloomDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Gloom", "Gloom Delay (s)", 150f, new ConfigDescription("Seconds the gloom in the Citadel waits before it starts rising.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1800f), Array.Empty<object>()));
			GloomSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Gloom", "Gloom Speed", 1f, new ConfigDescription("How fast the gloom rises. 1 = normal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
			DeadlyGloom = ((BaseUnityPlugin)this).Config.Bind<bool>("Gloom", "Deadly Gloom", false, "Whoever stands in the rising gloom dies. Lit candles and fires still protect.");
			GloomTolerance = ((BaseUnityPlugin)this).Config.Bind<float>("Gloom", "Deadly Gloom Tolerance (s)", 1f, new ConfigDescription("How long someone can stand in the gloom before it kills.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			LavaDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Lava", "Kiln Lava Delay (s)", 180f, new ConfigDescription("Seconds the lava in the Kiln waits before it starts rising.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1800f), Array.Empty<object>()));
			LavaSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Lava", "Kiln Lava Speed", 1f, new ConfigDescription("How fast the lava in the Kiln rises. 1 = normal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
			CalderaNeverLowers = ((BaseUnityPlugin)this).Config.Bind<bool>("Lava", "Caldera Lava Never Lowers", false, "The lava in the Caldera stays up.");
			SoulsDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Nadir", "Souls Delay (s)", 0f, new ConfigDescription("Seconds the rising souls wait after a soul was freed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1800f), Array.Empty<object>()));
			SoulsSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Nadir", "Souls Speed", 1f, new ConfigDescription("How fast the souls rise. 1 = normal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
			AutoRevive = ((BaseUnityPlugin)this).Config.Bind<bool>("Auto Revive", "Auto Revive", false, "Dead players come back to life next to a teammate.");
			WaitRevive = ((BaseUnityPlugin)this).Config.Bind<float>("Auto Revive", "Wait Revive (s)", 30f, new ConfigDescription("Seconds a player stays dead before coming back.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 500f), Array.Empty<object>()));
			ForcedRevive = ((BaseUnityPlugin)this).Config.Bind<float>("Auto Revive", "Forced Revive (s)", 60f, new ConfigDescription("Seconds a player stays dead before coming back even without a safe spot. Never below Wait Revive.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 500f), Array.Empty<object>()));
			KeepForcedAtLeastWait();
			WaitRevive.SettingChanged += delegate
			{
				KeepForcedAtLeastWait();
			};
			ForcedRevive.SettingChanged += delegate
			{
				KeepForcedAtLeastWait();
			};
			DayLength = ((BaseUnityPlugin)this).Config.Bind<float>("Day & Night", "Day Length (x)", 1f, new ConfigDescription("How long the day lasts. 2 = twice as long, 0.5 = half as long.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 10f), Array.Empty<object>()));
			NightLength = ((BaseUnityPlugin)this).Config.Bind<float>("Day & Night", "Night Length (x)", 1f, new ConfigDescription("How long the night lasts. 2 = twice as long, 0.5 = half as long.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 10f), Array.Empty<object>()));
			EternalNight = ((BaseUnityPlugin)this).Config.Bind<bool>("Day & Night", "Eternal Night", false, "After midnight it stays deep night.");
			Weather.Bind(((BaseUnityPlugin)this).Config);
			try
			{
				new Harmony("kikisfog.peak.kfog").PatchAll(typeof(Plugin).Assembly);
				int ok = 0;
				List<string> list = new List<string>();
				Check(AccessTools.Method(typeof(OrbFogHandler), "WaitToMove", (Type[])null, (Type[])null), prefix: true, "OrbFogHandler.WaitToMove", ref ok, list);
				Check(AccessTools.Method(typeof(OrbFogHandler), "Start", (Type[])null, (Type[])null), prefix: false, "OrbFogHandler.Start", ref ok, list);
				Check(AccessTools.Method(typeof(OrbFogHandler), "SetFogOrigin", (Type[])null, (Type[])null), prefix: false, "OrbFogHandler.SetFogOrigin", ref ok, list);
				Check(AccessTools.Method(typeof(MapHandler), "GoToSegment", (Type[])null, (Type[])null), prefix: true, "MapHandler.GoToSegment", ref ok, list);
				Check(AccessTools.Method(typeof(Character), "SpawnStatue", (Type[])null, (Type[])null), prefix: true, "Character.SpawnStatue", ref ok, list);
				Check(AccessTools.Method(typeof(DayNightManager), "Update", (Type[])null, (Type[])null), prefix: true, "DayNightManager.Update", ref ok, list);
				Check(AccessTools.Method(typeof(WindChillZone), "HandleTime", (Type[])null, (Type[])null), prefix: true, "WindChillZone.HandleTime", ref ok, list);
				Check(AccessTools.Method(typeof(Character), "RPCA_ReviveAtPosition", (Type[])null, (Type[])null), prefix: true, "Character.RPCA_ReviveAtPosition", ref ok, list);
				Check(AccessTools.Method(typeof(Character), "WarpPlayerRPC", (Type[])null, (Type[])null), prefix: false, "Character.WarpPlayerRPC", ref ok, list);
				_lavaOutside = AccessTools.Method(typeof(Lava), "OutsideBounds", new Type[1] { typeof(Vector3) }, (Type[])null);
				string text = " | Fog: delay " + FogDelay.Value.ToString("0", Inv) + "s, speed " + FogSpeed.Value.ToString("0.00", Inv) + ", deadly " + (DeadlyFog.Value ? "ON" : "OFF") + " (tolerance " + FogTolerance.Value.ToString("0.0", Inv) + "s), death by RPCA_Die from the host (no statue), campfire safe radius " + CampfireSafeRadius.Value.ToString("0", Inv) + " m | Gloom: delay " + GloomDelay.Value.ToString("0", Inv) + "s, speed x" + GloomSpeed.Value.ToString("0.00", Inv) + ", deadly " + (DeadlyGloom.Value ? "ON" : "OFF") + " (tolerance " + GloomTolerance.Value.ToString("0.0", Inv) + "s) | Lava: delay " + LavaDelay.Value.ToString("0", Inv) + "s, speed x" + LavaSpeed.Value.ToString("0.00", Inv) + ", caldera never lowers " + (CalderaNeverLowers.Value ? "ON" : "OFF") + " | Nadir: souls delay " + SoulsDelay.Value.ToString("0", Inv) + "s, speed x" + SoulsSpeed.Value.ToString("0.00", Inv) + " | Auto Revive: " + (AutoRevive.Value ? "ON" : "OFF") + " (wait " + WaitRevive.Value.ToString("0", Inv) + "s, forced " + ForcedRevive.Value.ToString("0", Inv) + "s, next to the scout furthest from the campfire (else the lowest) " + 15f.ToString("0", Inv) + "s ahead of fog/gloom, " + ((_lavaOutside != null) ? (3f.ToString("0", Inv) + " units clear of lava") : "lava check OFF (Lava.OutsideBounds not found)") + ", void guard " + 15f.ToString("0", Inv) + "s) | Day & Night: day x" + DayLength.Value.ToString("0.00", Inv) + ", night x" + NightLength.Value.ToString("0.00", Inv) + ", eternal night " + (EternalNight.Value ? "ON" : "OFF") + " | " + Weather.Describe();
				if (list.Count == 0)
				{
					L.LogInfo((object)("[KFOG] Kikis Fog 0.14.3 loaded - " + ok + " of 9 hooks ok" + text));
					return;
				}
				L.LogError((object)("[KFOG] Kikis Fog 0.14.3 loaded - hook MISSING: " + string.Join(", ", list.ToArray()) + " - " + ok + " of 9 ok" + text));
			}
			catch (Exception ex)
			{
				L.LogError((object)("[KFOG] Kikis Fog 0.14.3 failed to patch: " + ex.Message));
			}
		}

		private static void KeepForcedAtLeastWait()
		{
			try
			{
				if (ForcedRevive != null && WaitRevive != null && ForcedRevive.Value < WaitRevive.Value)
				{
					ForcedRevive.Value = WaitRevive.Value;
				}
			}
			catch
			{
			}
		}

		private static void Check(MethodBase m, bool prefix, string name, ref int ok, List<string> missing)
		{
			bool flag = false;
			if (m != null)
			{
				Patches patchInfo = Harmony.GetPatchInfo(m);
				if (patchInfo != null)
				{
					IList<Patch> list;
					if (!prefix)
					{
						IList<Patch> postfixes = patchInfo.Postfixes;
						list = postfixes;
					}
					else
					{
						IList<Patch> postfixes = patchInfo.Prefixes;
						list = postfixes;
					}
					foreach (Patch item in list)
					{
						if (item.owner == "kikisfog.peak.kfog")
						{
							flag = true;
							break;
						}
					}
				}
			}
			if (flag)
			{
				ok++;
			}
			else
			{
				missing.Add(name);
			}
		}

		internal static bool DayNightActive()
		{
			//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)
			if (DayLength == null || !IsAuthority)
			{
				return false;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Airport")
			{
				return false;
			}
			if (!(Mathf.Abs(DayLength.Value - 1f) > 0.001f) && !(Mathf.Abs(NightLength.Value - 1f) > 0.001f))
			{
				return EternalNight.Value;
			}
			return true;
		}

		internal static void DayNightStep(DayNightManager dn)
		{
			if (!((Object)(object)dn == (Object)null) && DayNightActive())
			{
				float num = 1f / (dn.dayLengthInMinutes * 60f) * Time.deltaTime * 24f;
				float num2 = Mathf.Max(0.01f, (dn.isDay > 0.5f) ? DayLength.Value : NightLength.Value);
				float num3 = dn.timeOfDay + num / num2 - num;
				if (EternalNight.Value && num3 + num < 2f)
				{
					num3 = 1f - num;
				}
				dn.timeOfDay = Mathf.Max(0f, num3);
				if (dn.syncTimer >= 1f)
				{
					dn.syncTimer = 5.01f;
				}
			}
		}

		private void Update()
		{
			float unscaledTime = Time.unscaledTime;
			OrbFogHandler val = null;
			try
			{
				val = Singleton<OrbFogHandler>.Instance;
				if ((Object)(object)val != (Object)(object)_fog)
				{
					ResetForHandler(val);
				}
				if (InTransition && unscaledTime - _transitionStartedAt > 90f)
				{
					InTransition = false;
				}
				if ((Object)(object)val != (Object)null && IsAuthority)
				{
					FogAuthority(val, unscaledTime);
					SyncGuests(val, unscaledTime);
					DeadlyFogTick(val, unscaledTime);
					_lastHealthyTick = unscaledTime;
				}
				else
				{
					_stageControlled = false;
				}
			}
			catch (Exception e)
			{
				LogErr("update", e);
			}
			try
			{
				if (IsAuthority)
				{
					RiserAuthority(unscaledTime);
					CalderaAuthority(unscaledTime);
					DeadlyGloomTick(unscaledTime);
				}
			}
			catch (Exception e2)
			{
				LogErr("hazards", e2);
			}
			try
			{
				if (IsAuthority)
				{
					AutoReviveTick(val, unscaledTime);
				}
			}
			catch (Exception e3)
			{
				LogErr("revive", e3);
			}
			try
			{
				if (IsAuthority)
				{
					VoidTick(unscaledTime);
				}
			}
			catch (Exception e4)
			{
				LogErr("void", e4);
			}
			try
			{
				Weather.Tick();
			}
			catch (Exception e5)
			{
				LogErr("weather", e5);
			}
			try
			{
				HudTick(val, unscaledTime);
			}
			catch (Exception e6)
			{
				LogErr("hud", e6);
			}
		}

		private void ResetForHandler(OrbFogHandler fog)
		{
			_fog = fog;
			_sphere = null;
			_stageControlled = false;
			_stageId = -1;
			_delayDone = false;
			_delayElapsed = 0f;
			_paused = false;
			_campfireResolved = false;
			_campfireFound = false;
			_lastSentSize = float.NaN;
			_lastPlayerCount = 0;
			InTransition = false;
			_insideSince.Clear();
			_killSentAt.Clear();
			_flagNotedAt.Clear();
			_transitTarget.Clear();
			_transitSince.Clear();
			_transitNoted.Clear();
			_transitHoldSince.Clear();
		}

		private static bool StageActive(OrbFogHandler fog)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			if ((Object)(object)fog == (Object)null || InTransition || LoadingScreenHandler.loading)
			{
				return false;
			}
			if (!Ascents.fogEnabled)
			{
				return false;
			}
			MapHandler instance = Singleton<MapHandler>.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return false;
			}
			if ((int)instance.GetCurrentSegment() >= 4)
			{
				return false;
			}
			FogSphereOrigin[] array = OriginsFor(fog);
			int currentID = fog.currentID;
			if (array == null || currentID < 0 || currentID >= array.Length || (Object)(object)array[currentID] == (Object)null)
			{
				return false;
			}
			return !array[currentID].disableFog;
		}

		internal static void CacheOrigins(OrbFogHandler fog)
		{
			_originsOwner = fog;
			_origins = (((Object)(object)fog != (Object)null) ? ((Component)((Component)fog).transform.root).GetComponentsInChildren<FogSphereOrigin>() : null);
		}

		private static FogSphereOrigin[] OriginsFor(OrbFogHandler fog)
		{
			if ((Object)(object)_originsOwner != (Object)(object)fog || _origins == null)
			{
				CacheOrigins(fog);
			}
			return _origins;
		}

		private FogSphere SphereFor(OrbFogHandler fog)
		{
			if ((Object)(object)_sphere == (Object)null && (Object)(object)fog != (Object)null)
			{
				_sphere = ((Component)fog).GetComponentInChildren<FogSphere>(true);
			}
			return _sphere;
		}

		private void FogAuthority(OrbFogHandler fog, float now)
		{
			if (!(_stageControlled = StageActive(fog)))
			{
				_paused = false;
				_insideSince.Clear();
				return;
			}
			if (fog.currentID != _stageId)
			{
				BeginStage(fog);
			}
			if (!_delayDone)
			{
				if (fog.isMoving || fog.hasArrived)
				{
					_delayDone = true;
					L.LogWarning((object)("[KFOG] fog stage " + StageName(fog.currentID) + " was started by something else after " + _delayElapsed.ToString("0", Inv) + "s of " + FogDelay.Value.ToString("0", Inv) + "s"));
				}
				else
				{
					_delayElapsed += Time.deltaTime;
					if (_delayElapsed >= FogDelay.Value)
					{
						StartFog(fog);
					}
				}
			}
			else if (!fog.isMoving && !fog.hasArrived)
			{
				if (_stalledSince < 0f)
				{
					_stalledSince = now;
				}
				else if (now - _stalledSince > 3f)
				{
					_stalledSince = -1f;
					L.LogWarning((object)("[KFOG] fog stage " + StageName(fog.currentID) + ": fog was stopped from outside - started again"));
					StartFog(fog);
				}
			}
			else
			{
				_stalledSince = -1f;
			}
			float value = FogSpeed.Value;
			float num = MinSizeForCampfire(fog, now);
			if (!float.IsNaN(num) && fog.isMoving && (_paused ? (fog.currentSize <= num + 0.5f) : (fog.currentSize - value * Time.deltaTime * 1.5f <= num)))
			{
				if (!_paused)
				{
					_paused = true;
					_nextPausedSync = 0f;
					L.LogInfo((object)("[KFOG] fog stage " + StageName(fog.currentID) + ": fog stopped " + CampfireSafeRadius.Value.ToString("0", Inv) + " m before the campfire"));
				}
				if (fog.speed != 0f)
				{
					fog.speed = 0f;
				}
				if (fog.currentSize != num)
				{
					fog.currentSize = num;
				}
			}
			else
			{
				if (_paused && fog.isMoving)
				{
					L.LogInfo((object)("[KFOG] fog stage " + StageName(fog.currentID) + ": campfire safe radius lowered - fog moves on"));
				}
				_paused = false;
				if (fog.speed != value)
				{
					fog.speed = value;
				}
			}
		}

		private void BeginStage(OrbFogHandler fog)
		{
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			_stageId = fog.currentID;
			_delayElapsed = 0f;
			_stalledSince = -1f;
			_delayDone = fog.isMoving || fog.hasArrived;
			_paused = false;
			_campfireResolved = false;
			_campfireFound = false;
			_nextCampfireTry = 0f;
			_insideSince.Clear();
			string text = "[KFOG] fog stage " + StageName(_stageId) + ": " + (_delayDone ? "already rising, no delay" : ("waiting " + FogDelay.Value.ToString("0", Inv) + "s")) + ", speed " + FogSpeed.Value.ToString("0.00", Inv) + ", deadly " + (DeadlyFog.Value ? "ON" : "OFF");
			ResolveCampfire(fog);
			float unitsToMeters = CharacterStats.unitsToMeters;
			Vector3 val = FogCentre(fog);
			if (_campfireFound)
			{
				float num = Vector3.Distance(val, _campfirePos);
				float num2 = num + CampfireSafeRadius.Value / unitsToMeters;
				text = text + " | campfire " + (num * unitsToMeters).ToString("0", Inv) + " m from the fog centre, fog stops at " + (num2 * unitsToMeters).ToString("0", Inv) + " m, starts at " + (fog.currentSize * unitsToMeters).ToString("0", Inv) + " m";
				if (num2 >= fog.currentSize)
				{
					text += " - ⚠ safe radius covers the whole stage, the fog will not move";
				}
			}
			else
			{
				text += " | ⚠ campfire not found yet - no safe radius until it is";
			}
			L.LogInfo((object)text);
		}

		private void StartFog(OrbFogHandler fog)
		{
			_delayDone = true;
			fog.speed = FogSpeed.Value;
			PhotonView component = ((Component)fog).GetComponent<PhotonView>();
			if ((Object)(object)component != (Object)null && PhotonNetwork.InRoom)
			{
				component.RPC("StartMovingRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				fog.StartMovingRPC();
			}
			_lastSentSize = float.NaN;
			L.LogInfo((object)("[KFOG] fog stage " + StageName(fog.currentID) + ": waited " + FogDelay.Value.ToString("0", Inv) + "s - the fog rises now (speed " + FogSpeed.Value.ToString("0.00", Inv) + ")"));
		}

		private void ResolveCampfire(OrbFogHandler fog)
		{
			//IL_003e: 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)
			_campfireResolved = true;
			_campfireFound = false;
			try
			{
				GameObject campfireRoot = MapHandler.GetCampfireRoot(fog.currentID);
				Campfire val = (((Object)(object)campfireRoot != (Object)null) ? campfireRoot.GetComponentInChildren<Campfire>(true) : null);
				if ((Object)(object)val != (Object)null)
				{
					_campfirePos = ((Component)val).transform.position;
					_campfireFound = true;
				}
			}
			catch (Exception e)
			{
				LogErr("campfire", e);
			}
		}

		private Vector3 FogCentre(OrbFogHandler fog)
		{
			//IL_004c: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			FogSphereOrigin[] array = OriginsFor(fog);
			int currentID = fog.currentID;
			if (array != null && currentID >= 0 && currentID < array.Length && (Object)(object)array[currentID] != (Object)null)
			{
				return ((Component)array[currentID]).transform.position;
			}
			FogSphere val = SphereFor(fog);
			if (!((Object)(object)val != (Object)null))
			{
				return Vector3.zero;
			}
			return val.fogPoint;
		}

		private float MinSizeForCampfire(OrbFogHandler fog, float now)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (!_campfireFound)
			{
				if (_campfireResolved && now < _nextCampfireTry)
				{
					return float.NaN;
				}
				_nextCampfireTry = now + 1f;
				ResolveCampfire(fog);
				if (!_campfireFound)
				{
					return float.NaN;
				}
				L.LogInfo((object)("[KFOG] fog stage " + StageName(fog.currentID) + ": campfire found - safe radius active"));
			}
			float num = Mathf.Max(0f, CampfireSafeRadius.Value) / CharacterStats.unitsToMeters;
			if (num <= 0f)
			{
				return float.NaN;
			}
			return Vector3.Distance(FogCentre(fog), _campfirePos) + num;
		}

		private void SyncGuests(OrbFogHandler fog, float now)
		{
			if (!PhotonNetwork.InRoom || PhotonNetwork.OfflineMode || !PhotonNetwork.IsMasterClient || PhotonNetwork.CurrentRoom == null)
			{
				return;
			}
			int playerCount = PhotonNetwork.CurrentRoom.PlayerCount;
			if (playerCount > _lastPlayerCount)
			{
				_quietUntil = Mathf.Max(_quietUntil, now + 8f);
			}
			_lastPlayerCount = playerCount;
			if (playerCount <= 1 || !_stageControlled)
			{
				_lastSentSize = float.NaN;
			}
			else
			{
				if (now < _quietUntil || now < _nextSync)
				{
					return;
				}
				_nextSync = now + 0.18f;
				if (!float.IsNaN(_lastSentSize) && fog.isMoving == _lastSentMoving && !(Mathf.Abs(fog.currentSize - _lastSentSize) >= 0.35f) && (!_paused || !(now >= _nextPausedSync)))
				{
					return;
				}
				PhotonView component = ((Component)fog).GetComponent<PhotonView>();
				if (!((Object)(object)component == (Object)null))
				{
					component.RPC("RPCA_SyncFog", (RpcTarget)1, new object[2] { fog.currentSize, fog.isMoving });
					_lastSentSize = fog.currentSize;
					_lastSentMoving = fog.isMoving;
					if (_paused)
					{
						_nextPausedSync = now + 0.5f;
					}
				}
			}
		}

		private void DeadlyFogTick(OrbFogHandler fog, float now)
		{
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if (!DeadlyFog.Value || !_stageControlled)
			{
				_insideSince.Clear();
			}
			else
			{
				if (now < _nextDeadly)
				{
					return;
				}
				_nextDeadly = now + 0.1f;
				FogSphere val = SphereFor(fog);
				if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy || !Mathf.Approximately(val.ENABLE, 1f))
				{
					_insideSince.Clear();
					return;
				}
				float num = Mathf.Max(0f, FogTolerance.Value);
				_victims.Clear();
				List<Character> allCharacters = Character.AllCharacters;
				for (int i = 0; i < allCharacters.Count; i++)
				{
					Character val2 = allCharacters[i];
					try
					{
						if ((Object)(object)val2 == (Object)null || (Object)(object)val2.data == (Object)null || !val2.IsPlayerControlled || (Object)(object)((MonoBehaviourPun)val2).photonView == (Object)null)
						{
							continue;
						}
						int viewID = ((MonoBehaviourPun)val2).photonView.ViewID;
						if (val2.data.dead)
						{
							_insideSince.Remove(viewID);
							continue;
						}
						bool flag = InTransit(val2, viewID, now);
						if (VoidProtected(val2, viewID, now))
						{
							_insideSince.Remove(viewID);
							continue;
						}
						if (!(Vector3.Distance(val.fogPoint, val2.Center) > val.currentSize))
						{
							_insideSince.Remove(viewID);
							continue;
						}
						if (flag)
						{
							NoteTransit(val2, viewID, "fog");
							_insideSince.Remove(viewID);
							continue;
						}
						if (!_insideSince.TryGetValue(viewID, out var value))
						{
							value = now;
							_insideSince[viewID] = now;
						}
						if (!(now - value < num) && (!_killSentAt.TryGetValue(viewID, out var value2) || !(now - value2 < 10f)))
						{
							_victims.Add(val2);
						}
					}
					catch (Exception e)
					{
						LogErr("deadly-check", e);
					}
				}
				for (int j = 0; j < _victims.Count; j++)
				{
					Character val3 = _victims[j];
					try
					{
						int viewID2 = ((MonoBehaviourPun)val3).photonView.ViewID;
						if (Petrify(val3, "fog", now - _insideSince[viewID2], now))
						{
							_insideSince.Remove(viewID2);
						}
					}
					catch (Exception e2)
					{
						LogErr("deadly-kill", e2);
					}
				}
				_victims.Clear();
			}
		}

		internal static void OnMovedByRpc(Character c, Vector3 target)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)I == (Object)null) && !((Object)(object)c == (Object)null) && !((Object)(object)((MonoBehaviourPun)c).photonView == (Object)null) && IsAuthority)
				{
					int viewID = ((MonoBehaviourPun)c).photonView.ViewID;
					I._transitTarget[viewID] = target;
					I._transitSince[viewID] = Time.unscaledTime;
					I._transitNoted.Remove(viewID);
					I._transitHoldSince.Remove(viewID);
				}
			}
			catch
			{
			}
		}

		private bool InTransit(Character c, int id, float now)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (!_transitTarget.TryGetValue(id, out var value))
			{
				return false;
			}
			if (InVoid(c))
			{
				_transitSince[id] = now;
				_transitHoldSince.Remove(id);
				return false;
			}
			if (!_transitSince.TryGetValue(id, out var value2))
			{
				value2 = now;
			}
			if (now - value2 > 10f)
			{
				EndTransit(id);
				return false;
			}
			if (c.warping || !(Vector3.Distance(c.Center, value) <= 3f))
			{
				_transitHoldSince.Remove(id);
				return true;
			}
			if (!_transitHoldSince.TryGetValue(id, out var value3))
			{
				_transitHoldSince[id] = now;
				return true;
			}
			if (now - value3 < 1f)
			{
				return true;
			}
			EndTransit(id);
			return false;
		}

		private void EndTransit(int id)
		{
			_transitTarget.Remove(id);
			_transitSince.Remove(id);
			_transitNoted.Remove(id);
			_transitHoldSince.Remove(id);
		}

		private void NoteTransit(Character c, int id, string what)
		{
			//IL_0028: 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)
			if (!_transitNoted.Add(id))
			{
				return;
			}
			try
			{
				Vector3 value;
				float num = (_transitTarget.TryGetValue(id, out value) ? (Vector3.Distance(c.Center, value) * CharacterStats.unitsToMeters) : (-1f));
				L.LogInfo((object)("[KFOG] deadly " + what + ": '" + Who(c) + "' was just revived/warped and is still on the way on the host (" + num.ToString("0", Inv) + " m from the spot) - not judged until they arrive"));
			}
			catch
			{
			}
		}

		private bool Petrify(Character c, string what, float stood, float now)
		{
			int viewID = ((MonoBehaviourPun)c).photonView.ViewID;
			if (HasCheckpointFlag(c))
			{
				if (!_flagNotedAt.TryGetValue(viewID, out var value) || now - value > 30f)
				{
					_flagNotedAt[viewID] = now;
					L.LogInfo((object)("[KFOG] deadly " + what + ": '" + Who(c) + "' is in the " + what + " but has a checkpoint flag - not killed, the game decides"));
				}
				return false;
			}
			_petrifySentAt[viewID] = now;
			((MonoBehaviourPun)c).photonView.RPC("RPCA_Die", (RpcTarget)0, Array.Empty<object>());
			_killSentAt[viewID] = now;
			L.LogWarning((object)("[KFOG] deadly " + what + ": '" + Who(c) + "' stood in the " + what + " for " + stood.ToString("0.0", Inv) + "s - killed (RPCA_Die from the host)"));
			return true;
		}

		internal static bool SkipStatue(Character c, bool killedByDagger)
		{
			if ((Object)(object)I == (Object)null)
			{
				return false;
			}
			if (killedByDagger || (Object)(object)c == (Object)null || (Object)(object)((MonoBehaviourPun)c).photonView == (Object)null || !PhotonNetwork.IsMasterClient)
			{
				return false;
			}
			if (!I._petrifySentAt.TryGetValue(((MonoBehaviourPun)c).photonView.ViewID, out var value))
			{
				return false;
			}
			if (Time.unscaledTime - value > 2f)
			{
				return false;
			}
			L.LogInfo((object)("[KFOG] no statue for '" + Who(c) + "' (killed by us)"));
			return true;
		}

		private static bool IsHandledRiser(LavaRising r)
		{
			return (Object)(object)r != (Object)null;
		}

		private static float RiserDelay(LavaRising r)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			RisingFieldType risingFieldType = r.risingFieldType;
			if ((int)risingFieldType != 1)
			{
				if ((int)risingFieldType == 2)
				{
					return SoulsDelay.Value;
				}
				return LavaDelay.Value;
			}
			return GloomDelay.Value;
		}

		private static float RiserSpeed(LavaRising r)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			RisingFieldType risingFieldType = r.risingFieldType;
			if ((int)risingFieldType != 1)
			{
				if ((int)risingFieldType == 2)
				{
					return SoulsSpeed.Value;
				}
				return LavaSpeed.Value;
			}
			return GloomSpeed.Value;
		}

		private static LavaRising CurrentRiser()
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			List<LavaRising> aLL_LAVA = LavaRising.ALL_LAVA;
			MapHandler instance = Singleton<MapHandler>.Instance;
			if (aLL_LAVA == null || (Object)(object)instance == (Object)null)
			{
				return null;
			}
			Segment currentSegment = instance.GetCurrentSegment();
			for (int i = 0; i < aLL_LAVA.Count; i++)
			{
				LavaRising val = aLL_LAVA[i];
				if (IsHandledRiser(val) && val.requiredSegment == currentSegment)
				{
					return val;
				}
			}
			return null;
		}

		private void RiserAuthority(float now)
		{
			List<LavaRising> aLL_LAVA = LavaRising.ALL_LAVA;
			if (aLL_LAVA == null || aLL_LAVA.Count == 0)
			{
				return;
			}
			LavaRising val = CurrentRiser();
			bool flag = PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode && PhotonNetwork.CurrentRoom != null && PhotonNetwork.CurrentRoom.PlayerCount > 1;
			for (int i = 0; i < aLL_LAVA.Count; i++)
			{
				LavaRising val2 = aLL_LAVA[i];
				if (!IsHandledRiser(val2))
				{
					continue;
				}
				float num = RiserDelay(val2);
				if (val2.initialWaitTime != num)
				{
					val2.initialWaitTime = num;
				}
				if ((Object)(object)val2 != (Object)(object)val || !val2.started || val2.ended)
				{
					continue;
				}
				if (_riserStartLogged.Add(val2))
				{
					L.LogInfo((object)("[KFOG] " + RiserName(val2) + " rises now (waited " + val2.secondsWaitedToStart.ToString("0", Inv) + "s, speed x" + RiserSpeed(val2).ToString("0.00", Inv) + ")"));
				}
				float num2 = RiserSpeed(val2);
				if (!Mathf.Approximately(num2, 1f))
				{
					float num3 = val2.timeTraveled + Time.deltaTime * (num2 - 1f);
					val2.timeTraveled = Mathf.Max(0f, num3);
					if (flag && (!_riserNextSync.TryGetValue(val2, out var value) || !(now < value)))
					{
						_riserNextSync[val2] = now + 0.25f;
						((MonoBehaviourPun)val2).photonView.RPC("RPC_SyncLava", (RpcTarget)1, new object[4] { val2.started, val2.ended, val2.timeTraveled, val2.secondsWaitedToStart });
					}
				}
			}
		}

		private static string RiserName(LavaRising r)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			RisingFieldType risingFieldType = r.risingFieldType;
			if ((int)risingFieldType != 1)
			{
				if ((int)risingFieldType == 2)
				{
					return "souls (Nadir)";
				}
				return "lava (Kiln)";
			}
			return "gloom (Citadel)";
		}

		private StatusFieldGloom[] GloomFieldsOf(LavaRising r)
		{
			if (!_gloomFields.TryGetValue(r, out var value) || value == null)
			{
				value = ((Component)r).GetComponentsInChildren<StatusFieldGloom>(true);
				_gloomFields[r] = value;
			}
			return value;
		}

		private bool InRisingGloom(Character c, Vector3 point)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			LavaRising val = CurrentRiser();
			if ((Object)(object)val == (Object)null || (int)val.risingFieldType != 1 || !val.started)
			{
				return false;
			}
			StatusFieldGloom[] array = GloomFieldsOf(val);
			for (int i = 0; i < array.Length; i++)
			{
				if ((Object)(object)array[i] != (Object)null && ((Component)array[i]).gameObject.activeInHierarchy && ((StatusFieldBounds)array[i]).PointInField(point))
				{
					return true;
				}
			}
			return false;
		}

		private static float GloomRiseIn(LavaRising r, float seconds)
		{
			//IL_004f: 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)
			if ((Object)(object)r == (Object)null || !r.started || r.ended || (Object)(object)r.lava == (Object)null || (Object)(object)r.topTransform == (Object)null)
			{
				return 0f;
			}
			float num = r.travelTime - r.timeTraveled;
			float num2 = r.topTransform.position.y - ((Component)r.lava).transform.position.y;
			if (num <= 0.05f || num2 <= 0f)
			{
				return 0f;
			}
			return Mathf.Min(num2, num2 / num * Mathf.Max(0f, RiserSpeed(r)) * seconds);
		}

		private void DeadlyGloomTick(float now)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			if (!DeadlyGloom.Value)
			{
				_gloomInsideSince.Clear();
			}
			else
			{
				if (now < _nextDeadlyGloom)
				{
					return;
				}
				_nextDeadlyGloom = now + 0.1f;
				LavaRising val = CurrentRiser();
				if ((Object)(object)val == (Object)null || (int)val.risingFieldType != 1 || !val.started)
				{
					_gloomInsideSince.Clear();
					return;
				}
				float num = Mathf.Max(0f, GloomTolerance.Value);
				_victims.Clear();
				List<Character> allCharacters = Character.AllCharacters;
				for (int i = 0; i < allCharacters.Count; i++)
				{
					Character val2 = allCharacters[i];
					try
					{
						if ((Object)(object)val2 == (Object)null || (Object)(object)val2.data == (Object)null || !val2.IsPlayerControlled || (Object)(object)((MonoBehaviourPun)val2).photonView == (Object)null)
						{
							continue;
						}
						int viewID = ((MonoBehaviourPun)val2).photonView.ViewID;
						if (val2.data.dead)
						{
							_gloomInsideSince.Remove(viewID);
							continue;
						}
						bool flag = InTransit(val2, viewID, now);
						if (!InRisingGloom(val2, val2.Head))
						{
							_gloomInsideSince.Remove(viewID);
							continue;
						}
						if (flag)
						{
							NoteTransit(val2, viewID, "gloom");
							_gloomInsideSince.Remove(viewID);
							continue;
						}
						if (!_gloomInsideSince.TryGetValue(viewID, out var value))
						{
							value = now;
							_gloomInsideSince[viewID] = now;
						}
						if (!(now - value < num) && (!_killSentAt.TryGetValue(viewID, out var value2) || !(now - value2 < 10f)))
						{
							_victims.Add(val2);
						}
					}
					catch (Exception e)
					{
						LogErr("gloom-check", e);
					}
				}
				for (int j = 0; j < _victims.Count; j++)
				{
					Character val3 = _victims[j];
					try
					{
						int viewID2 = ((MonoBehaviourPun)val3).photonView.ViewID;
						if (Petrify(val3, "gloom", now - _gloomInsideSince[viewID2], now))
						{
							_gloomInsideSince.Remove(viewID2);
						}
					}
					catch (Exception e2)
					{
						LogErr("gloom-kill", e2);
					}
				}
				_victims.Clear();
			}
		}

		private static bool BelowRisingLava(Character c)
		{
			//IL_0010: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			LavaRising val = CurrentRiser();
			if ((Object)(object)val == (Object)null || (int)val.risingFieldType != 0 || !val.started || (Object)(object)val.lava == (Object)null)
			{
				return false;
			}
			return c.Center.y < ((Component)val.lava).transform.position.y + 3f;
		}

		private static bool AtLava(Vector3 p)
		{
			//IL_0091: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (_lavaOutside == null)
			{
				return false;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime >= _nextLavaScan)
			{
				_nextLavaScan = unscaledTime + 2f;
				_lavas.Clear();
				Lava[] array = Object.FindObjectsByType<Lava>((FindObjectsSortMode)0);
				for (int i = 0; i < array.Length; i++)
				{
					if ((Object)(object)array[i] != (Object)null && !array[i].isKiln)
					{
						_lavas.Add(array[i]);
					}
				}
			}
			for (int j = 0; j < _lavas.Count; j++)
			{
				try
				{
					Lava val = _lavas[j];
					if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && !(p.y >= ((Component)val).transform.position.y + 3f))
					{
						_lavaArg[0] = p;
						if (!(bool)_lavaOutside.Invoke(val, _lavaArg))
						{
							return true;
						}
					}
				}
				catch
				{
				}
			}
			return false;
		}

		private void CalderaAuthority(float now)
		{
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			if (!CalderaNeverLowers.Value)
			{
				_calderaLogged = false;
				return;
			}
			float num = 0.7f;
			if (now >= _nextCalderaScan)
			{
				_nextCalderaScan = now + 2f;
				_calderaAnims.Clear();
				_calderaViews.Clear();
				SyncedAnimation[] array = Object.FindObjectsByType<SyncedAnimation>((FindObjectsSortMode)0);
				for (int i = 0; i < array.Length; i++)
				{
					if (!((Object)(object)array[i] == (Object)null))
					{
						Lava component = ((Component)array[i]).GetComponent<Lava>();
						Animator component2 = ((Component)array[i]).GetComponent<Animator>();
						if (!((Object)(object)component == (Object)null) && !component.isKiln && !((Object)(object)component2 == (Object)null))
						{
							_calderaAnims.Add(component2);
							_calderaViews.Add(((Component)array[i]).GetComponent<PhotonView>());
						}
					}
				}
			}
			if (_calderaAnims.Count == 0)
			{
				return;
			}
			if (!_calderaLogged)
			{
				_calderaLogged = true;
				L.LogInfo((object)("[KFOG] caldera lava: held at the top (" + _calderaAnims.Count + " lava animator(s))"));
			}
			for (int j = 0; j < _calderaAnims.Count; j++)
			{
				Animator val = _calderaAnims[j];
				if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled)
				{
					AnimatorStateInfo currentAnimatorStateInfo = val.GetCurrentAnimatorStateInfo(0);
					val.Play(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash, 0, num);
				}
			}
			if (!PhotonNetwork.InRoom || PhotonNetwork.OfflineMode || now < _nextCalderaSync || PhotonNetwork.CurrentRoom == null || PhotonNetwork.CurrentRoom.PlayerCount <= 1)
			{
				return;
			}
			_nextCalderaSync = now + 0.5f;
			for (int k = 0; k < _calderaViews.Count; k++)
			{
				PhotonView val2 = _calderaViews[k];
				if ((Object)(object)val2 != (Object)null && (Object)(object)_calderaAnims[k] != (Object)null && ((Behaviour)_calderaAnims[k]).isActiveAndEnabled)
				{
					val2.RPC("RPCA_SyncAnim", (RpcTarget)1, new object[1] { num });
				}
			}
		}

		private static bool HasCheckpointFlag(Character c)
		{
			int ownerActorNr = ((MonoBehaviourPun)c).photonView.OwnerActorNr;
			CheckpointFlag[] array = Object.FindObjectsByType<CheckpointFlag>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				if (!((Object)(object)array[i] == (Object)null))
				{
					PhotonView component = ((Component)array[i]).GetComponent<PhotonView>();
					if ((Object)(object)component != (Object)null && component.OwnerActorNr == ownerActorNr)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static string Who(Character c)
		{
			try
			{
				string text = ((((MonoBehaviourPun)c).photonView.Owner != null) ? ((MonoBehaviourPun)c).photonView.Owner.NickName : null);
				return string.IsNullOrEmpty(text) ? c.characterName : text;
			}
			catch
			{
				return "?";
			}
		}

		private void AutoReviveTick(OrbFogHandler fog, float now)
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			if (now < _nextRevive)
			{
				return;
			}
			_nextRevive = now + 0.25f;
			Character localCharacter = Character.localCharacter;
			if (!AutoRevive.Value || !((Object)(object)localCharacter != (Object)null) || LoadingScreenHandler.loading || localCharacter.inAirport || localCharacter.gameOver)
			{
				_deadSince.Clear();
				return;
			}
			_toRevive.Clear();
			List<Character> allCharacters = Character.AllCharacters;
			for (int i = 0; i < allCharacters.Count; i++)
			{
				Character val = allCharacters[i];
				try
				{
					if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null || !val.IsPlayerControlled || (Object)(object)((MonoBehaviourPun)val).photonView == (Object)null)
					{
						continue;
					}
					int viewID = ((MonoBehaviourPun)val).photonView.ViewID;
					if (!val.data.dead)
					{
						_deadSince.Remove(viewID);
						if (!val.data.fullyPassedOut && (Object)(object)val.Ghost == (Object)null)
						{
							_lastAlivePos[viewID] = val.Center;
						}
						if (OnSolidGround(val))
						{
							if (!_groundedSince.ContainsKey(viewID))
							{
								_groundedSince[viewID] = now;
							}
						}
						else
						{
							_groundedSince.Remove(viewID);
						}
					}
					else
					{
						_groundedSince.Remove(viewID);
						float value2;
						if (!_deadSince.TryGetValue(viewID, out var value))
						{
							_deadSince[viewID] = now;
						}
						else if (!(now - value < WaitRevive.Value) && (!_reviveSentAt.TryGetValue(viewID, out value2) || !(now - value2 < 5f)))
						{
							_toRevive.Add(val);
						}
					}
				}
				catch (Exception e)
				{
					LogErr("revive-check", e);
				}
			}
			for (int j = 0; j < _toRevive.Count; j++)
			{
				try
				{
					TryAutoRevive(_toRevive[j], fog, now);
				}
				catch (Exception e2)
				{
					LogErr("revive-send", e2);
				}
			}
			_toRevive.Clear();
		}

		private void TryAutoRevive(Character dead, OrbFogHandler fog, float now)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			int viewID = ((MonoBehaviourPun)dead).photonView.ViewID;
			Vector3 value;
			bool flag = _lastAlivePos.TryGetValue(viewID, out value);
			Vector3 pos;
			bool flag2 = CampfireAhead(out pos);
			Character val = null;
			float num = float.MinValue;
			Character val2 = null;
			float num2 = float.MinValue;
			List<Character> allCharacters = Character.AllCharacters;
			for (int i = 0; i < allCharacters.Count; i++)
			{
				Character val3 = allCharacters[i];
				if (!IsAnchorCandidate(val3, dead, fog))
				{
					continue;
				}
				float num3 = (flag2 ? Vector3.Distance(pos, val3.Center) : (0f - val3.Center.y));
				if (AtLava(val3.Center))
				{
					if ((Object)(object)val2 == (Object)null || num3 > num2)
					{
						val2 = val3;
						num2 = num3;
					}
				}
				else if (!((Object)(object)val != (Object)null) || !(num3 <= num))
				{
					val = val3;
					num = num3;
				}
			}
			if ((Object)(object)val2 != (Object)null && (Object)(object)val != (Object)null && num2 <= num)
			{
				val2 = null;
			}
			float num4 = (((Object)(object)val != (Object)null && flag) ? Vector3.Distance(value, val.Center) : 0f);
			float num5 = now - _deadSince[viewID];
			if ((Object)(object)val == (Object)null)
			{
				NoteWaiting(viewID, now, ((Object)(object)val2 != (Object)null) ? ("[KFOG] auto revive: '" + Who(dead) + "' is dead for " + num5.ToString("0", Inv) + "s, but '" + Who(val2) + "' is in or right above the lava and nobody else can be the anchor - trying again") : ("[KFOG] auto revive: '" + Who(dead) + "' is dead for " + num5.ToString("0", Inv) + "s, but no teammate is alive, awake and at least " + 15f.ToString("0", Inv) + "s ahead of the fog/gloom right now - trying again"));
				return;
			}
			if (!_groundedSince.TryGetValue(((MonoBehaviourPun)val).photonView.ViewID, out var value2) || !(now - value2 >= 1f) || !Physics.Raycast(val.Center + Vector3.up * 2.5f, Vector3.down, 8f, LayerMask.op_Implicit(HelperFunctions.AllPhysicalExceptCharacter)))
			{
				NoteWaiting(viewID, now, "[KFOG] auto revive: '" + Who(dead) + "' is ready, waiting for '" + Who(val) + "' to stand on solid ground for " + 1f.ToString("0", Inv) + "s");
				return;
			}
			if (now > _spreadResetAt)
			{
				_spreadIndex = 0;
				_recentSpots.Clear();
			}
			bool flag3 = false;
			if (!FindReviveSpot(val, dead, out var pos2))
			{
				float num6 = Mathf.Max(WaitRevive.Value, ForcedRevive.Value);
				if (num5 < num6)
				{
					NoteWaiting(viewID, now, "[KFOG] auto revive: '" + Who(dead) + "' is ready, but there is no safe spot next to '" + Who(val) + "'" + ((_spotsOverLava > 0) ? (" (" + _spotsOverLava + " over the lava)") : "") + " - trying again, forced revive at " + num6.ToString("0", Inv) + "s dead");
					return;
				}
				pos2 = ForcedSpot(val);
				flag3 = true;
			}
			_spreadResetAt = now + 3f;
			_recentSpots.Add(pos2);
			((MonoBehaviourPun)dead).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { pos2, false, -1 });
			_reviveSentAt[viewID] = now;
			_reviveTarget[viewID] = pos2;
			_deadSince.Remove(viewID);
			_noAnchorNotedAt.Remove(viewID);
			L.LogInfo((object)("[KFOG] auto revive: '" + Who(dead) + "' was dead for " + num5.ToString("0", Inv) + "s - revived next to '" + Who(val) + "' (" + (flag2 ? ("the scout furthest from the campfire, " + (num * CharacterStats.unitsToMeters).ToString("0", Inv) + " m") : "the lowest scout, no campfire ahead") + ")" + (flag3 ? " - FORCED, no safe spot found (above them, under any ceiling)" : " on a free spot") + ((_spotsOverLava > 0) ? (" (" + _spotsOverLava + " spot(s) over the lava skipped)") : "") + (flag ? (" (" + (num4 * CharacterStats.unitsToMeters).ToString("0", Inv) + " m from where they last stood)") : "") + (((Object)(object)val2 != (Object)null) ? (" - '" + Who(val2) + "' is further back but in or right above the lava") : "")));
		}

		private bool FindReviveSpot(Character anchor, Character dead, out Vector3 pos)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			pos = Vector3.zero;
			_spotsOverLava = 0;
			int num = LayerMask.op_Implicit(HelperFunctions.AllPhysicalExceptCharacter);
			Vector3 center = anchor.Center;
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(center, Vector3.down, ref val, 8f, num, (QueryTriggerInteraction)1))
			{
				return false;
			}
			float y = ((RaycastHit)(ref val)).point.y;
			float num2 = Mathf.Clamp(center.y - y, 0.5f, 2.5f);
			float num3 = Mathf.Clamp(anchor.Head.y - y, num2 + 0.2f, 3.5f) + 0.4f;
			Vector3 val2 = center + Vector3.up * 0.2f;
			bool flag = !Physics.CheckSphere(val2, 0.3f, num, (QueryTriggerInteraction)1);
			float num4 = MathF.PI / 6f;
			float num5 = (float)_spotAngleIndex++ * 2.3999631f;
			Vector3 val3 = default(Vector3);
			RaycastHit val4 = default(RaycastHit);
			for (int i = 0; i < SpotRadii.Length; i++)
			{
				float num6 = SpotRadii[i];
				for (int j = 0; j < 12; j++)
				{
					float num7 = num5 + (float)j * num4;
					((Vector3)(ref val3))..ctor(Mathf.Cos(num7), 0f, Mathf.Sin(num7));
					float num8 = num6 + 0.7f;
					if (Physics.Raycast(val2, val3, num8, num, (QueryTriggerInteraction)1) || (flag && Physics.SphereCast(val2, 0.3f, val3, ref val4, num8, num, (QueryTriggerInteraction)1)) || !GroundAt(val2 + val3 * num6, y, num2, num6, out var hit) || !GroundAt(val2 + val3 * num8, y, num2, num8, out var _))
					{
						continue;
					}
					Vector3 point = ((RaycastHit)(ref hit)).point;
					if (Physics.Raycast(point + Vector3.up * 0.1f, Vector3.up, num3, num, (QueryTriggerInteraction)1))
					{
						continue;
					}
					Vector3 val5 = point + Vector3.up * 0.7f;
					Vector3 val6 = point + Vector3.up * Mathf.Max(num3 - 0.35f, 0.8f);
					if (!Physics.CheckCapsule(val5, val6, 0.35f, num, (QueryTriggerInteraction)1))
					{
						Vector3 val7 = point + Vector3.up * (num2 + 0.25f);
						if (AtLava(val7))
						{
							_spotsOverLava++;
						}
						else if (!Occupied(val7, dead))
						{
							pos = val7;
							return true;
						}
					}
				}
			}
			return false;
		}

		private static bool GroundAt(Vector3 top, float groundY, float torsoH, float dist, out RaycastHit hit)
		{
			//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_0027: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.6f + dist * 0.4f;
			float num2 = torsoH + 0.2f + num + 0.3f;
			if (!Physics.Raycast(top, Vector3.down, ref hit, num2, LayerMask.op_Implicit(HelperFunctions.AllPhysicalExceptCharacter), (QueryTriggerInteraction)1))
			{
				return false;
			}
			if (Mathf.Abs(((RaycastHit)(ref hit)).point.y - groundY) > num)
			{
				return false;
			}
			return ((RaycastHit)(ref hit)).normal.y >= 0.77f;
		}

		private bool Occupied(Vector3 target, Character dead)
		{
			//IL_0077: 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_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)
			List<Character> allCharacters = Character.AllCharacters;
			for (int i = 0; i < allCharacters.Count; i++)
			{
				Character val = allCharacters[i];
				try
				{
					if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)dead || (Object)(object)val.data == (Object)null || val.data.dead || !(Vector3.Distance(val.Center, target) < 0.9f))
					{
						continue;
					}
					return true;
				}
				catch
				{
				}
			}
			for (int j = 0; j < _recentSpots.Count; j++)
			{
				if (Vector3.Distance(_recentSpots[j], target) < 0.9f)
				{
					return true;
				}
			}
			return false;
		}

		private Vector3 ForcedSpot(Character anchor)
		{
			//IL_0000: 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_0013: 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_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_007d: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			int num = LayerMask.op_Implicit(HelperFunctions.AllPhysicalExceptCharacter);
			Vector3 center = anchor.Center;
			float num2 = Mathf.Max(anchor.Head.y - center.y, 0.3f) + 0.4f;
			float num3 = 2.5f;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(anchor.Head, Vector3.up, ref val, 2.5f + num2, num, (QueryTriggerInteraction)1))
			{
				num3 = Mathf.Clamp(((RaycastHit)(ref val)).point.y - num2 - center.y, 0f, 2.5f);
			}
			Vector3 val2 = center + Vector3.up * num3;
			Vector3 val3 = SpreadOffset();
			if (val3 != Vector3.zero && !Physics.Raycast(val2, ((Vector3)(ref val3)).normalized, ((Vector3)(ref val3)).magnitude + 0.3f, num, (QueryTriggerInteraction)1))
			{
				float num4 = num3 + 8f;
				RaycastHit val4 = default(RaycastHit);
				if (!(Physics.Raycast(val2 + val3, Vector3.down, ref val4, num4, num, (QueryTriggerInteraction)1) ? AtLava(((RaycastHit)(ref val4)).point + Vector3.up) : AtLava(val2 + val3 + Vector3.down * num4)))
				{
					val2 += val3;
				}
			}
			return val2;
		}

		private static bool CampfireAhead(out Vector3 pos)
		{
			//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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected I4, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			pos = Vector3.zero;
			try
			{
				MapHandler instance = Singleton<MapHandler>.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return false;
				}
				Segment currentSegment = instance.GetCurrentSegment();
				if ((int)currentSegment == 6)
				{
					return false;
				}
				GameObject campfireRoot = MapHandler.GetCampfireRoot((int)currentSegment);
				Campfire val = (((Object)(object)campfireRoot != (Object)null) ? campfireRoot.GetComponentInChildren<Campfire>(true) : null);
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				pos = ((Component)val).transform.position;
				return true;
			}
			catch
			{
				return false;
			}
		}

		private bool IsAnchorCandidate(Character a, Character dead, OrbFogHandler fog)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)a == (Object)null || (Object)(object)a == (Object)(object)dead || (Object)(object)a.data == (Object)null || !a.IsPlayerControlled || (Object)(object)((MonoBehaviourPun)a).photonView == (Object)null)
				{
					return false;
				}
				if (a.data.dead || a.data.passedOut || a.data.fullyPassedOut || (Object)(object)a.Ghost != (Object)null)
				{
					return false;
				}
				if (a.warping || InVoid(a))
				{
					return false;
				}
				if (InFogNow(a, fog))
				{
					return false;
				}
				if (InRisingGloom(a, a.Head) || InRisingGloom(a, a.Head + Vector3.up * 2f))
				{
					return false;
				}
				float num = GloomRiseIn(CurrentRiser(), 15f);
				if (num > 0f && InRisingGloom(a, a.Head - Vector3.up * num))
				{
					return false;
				}
				return !BelowRisingLava(a);
			}
			catch
			{
				return false;
			}
		}

		private static bool OnSolidGround(Character c)
		{
			CharacterData data = c.data;
			if (data.isGrounded && !data.isClimbing && !data.isRopeClimbing && !data.isVineClimbing)
			{
				return !data.isCarried;
			}
			return false;
		}

		private void NoteWaiting(int id, float now, string line)
		{
			if (!_noAnchorNotedAt.TryGetValue(id, out var value) || !(now - value <= 30f))
			{
				_noAnchorNotedAt[id] = now;
				L.LogInfo((object)line);
			}
		}

		private bool InFogNow(Character a, OrbFogHandler fog)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fog == (Object)null || !StageActive(fog))
			{
				return false;
			}
			FogSphere val = SphereFor(fog);
			if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy || val.ENABLE < 0.5f)
			{
				return false;
			}
			float num = 5f;
			if (fog.isMoving && fog.speed > 0f)
			{
				num = Mathf.Max(num, fog.speed * 15f);
			}
			return Vector3.Distance(val.fogPoint, a.Center) > val.currentSize - num;
		}

		private Vector3 SpreadOffset()
		{
			//IL_0035: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			int num = _spreadIndex++;
			if (num == 0)
			{
				return Vector3.zero;
			}
			float num2 = (float)num * 2.3999631f;
			return new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * 1.2f;
		}

		private static bool InVoid(Character c)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return c.Center.y > 4000f;
		}

		private bool VoidProtected(Character c, int id, float now)
		{
			if (!InVoid(c))
			{
				return false;
			}
			if (!_voidSince.TryGetValue(id, out var value))
			{
				value = now;
				_voidSince[id] = now;
			}
			return now - value < 15f;
		}

		private void VoidTick(float now)
		{
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			if (now < _nextVoid)
			{
				return;
			}
			_nextVoid = now + 0.25f;
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null || LoadingScreenHandler.loading || localCharacter.inAirport)
			{
				_voidSince.Clear();
				_voidRewarps.Clear();
				_voidNextRewarp.Clear();
				_voidGaveUp.Clear();
				return;
			}
			List<Character> allCharacters = Character.AllCharacters;
			for (int i = 0; i < allCharacters.Count; i++)
			{
				Character val = allCharacters[i];
				try
				{
					if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null || !val.IsPlayerControlled || (Object)(object)((MonoBehaviourPun)val).photonView == (Object)null)
					{
						continue;
					}
					int viewID = ((MonoBehaviourPun)val).photonView.ViewID;
					float value;
					bool flag = _voidSince.TryGetValue(viewID, out value);
					if (val.data.dead || !InVoid(val))
					{
						if (flag)
						{
							float num = now - value;
							_voidRewarps.TryGetValue(viewID, out var value2);
							if (!val.data.dead && num >= 0.5f)
							{
								L.LogInfo((object)("[KFOG] void: '" + Who(val) + "' arrived after " + num.ToString("0.0", Inv) + "s in the void" + ((value2 > 0) ? (" (warped again " + value2 + "x)") : "")));
							}
							_voidSince.Remove(viewID);
							_voidRewarps.Remove(viewID);
							_voidNextRewarp.Remove(viewID);
							_voidGaveUp.Remove(viewID);
						}
						continue;
					}
					if (!flag)
					{
						_voidSince[viewID] = now;
						continue;
					}
					float num2 = now - value;
					_voidRewarps.TryGetValue(viewID, out var value3);
					if (num2 >= 2f && value3 < 3 && !val.warping && _reviveSentAt.TryGetValue(viewID, out var value4) && now - value4 < 30f && _reviveTarget.TryGetValue(viewID, out var value5) && (!_voidNextRewarp.TryGetValue(viewID, out var value6) || now >= value6))
					{
						((MonoBehaviourPun)val).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { value5, true });
						_voidRewarps[viewID] = value3 + 1;
						_voidNextRewarp[viewID] = now + 3f;
						L.LogInfo((object)("[KFOG] void: '" + Who(val) + "' still hangs in the void " + num2.ToString("0.0", Inv) + "s after coming back - warped to their spot again (#" + (value3 + 1) + ")"));
					}
					if (num2 >= 15f && _voidGaveUp.Add(viewID))
					{
						L.LogWarning((object)("[KFOG] void: '" + Who(val) + "' is still in the void after " + 15f.ToString("0", Inv) + "s - the fog judges them normally again"));
					}
				}
				catch (Exception e)
				{
					LogErr("void-check", e);
				}
			}
		}

		internal static void OnTransitionStart()
		{
			InTransition = true;
			_transitionStartedAt = Time.unscaledTime;
			if ((Object)(object)I != (Object)null)
			{
				I._paused = false;
				I._stageControlled = false;
				I._insideSince.Clear();
			}
		}

		internal static void OnOriginSet(OrbFogHandler fog, int id)
		{
			InTransition = false;
			if ((Object)(object)I == (Object)null || (Object)(object)fog == (Object)null)
			{
				return;
			}
			I._quietUntil = Mathf.Max(I._quietUntil, Time.unscaledTime + 3f);
			I._stageId = -1;
			I._lastSentSize = float.NaN;
			if (!IsAuthority || !Ascents.fogEnabled)
			{
				return;
			}
			FogSphereOrigin[] array = OriginsFor(fog);
			if (array != null && id >= 0 && id < array.Length && !((Object)(object)array[id] == (Object)null) && !array[id].disableFog)
			{
				if (fog.isMoving)
				{
					fog.isMoving = false;
					L.LogInfo((object)("[KFOG] fog stage " + StageName(id) + ": the game carried 'moving' over from the last stage - reset, the delay counts"));
				}
				fog.currentWaitTime = 0f;
			}
		}

		internal static bool HoldsVanillaWait(OrbFogHandler fog)
		{
			if ((Object)(object)I != (Object)null && IsAuthority && Time.unscaledTime - I._lastHealthyTick < 2f)
			{
				return StageActive(fog);
			}
			return false;
		}

		private void HudTick(OrbFogHandler fog, float now)
		{
			if (now < _nextHud)
			{
				return;
			}
			_nextHud = now + 0.25f;
			GUIManager instance = GUIManager.instance;
			Canvas val = (((Object)(object)instance != (Object)null) ? instance.hudCanvas : null);
			bool flag = !IsAuthority;
			if (!((Object)(object)val != (Object)null) || !((Behaviour)val).isActiveAndEnabled || !((Object)(object)fog != (Object)null) || LoadingScreenHandler.loading || !((Object)(object)Character.localCharacter != (Object)null))
			{
				if ((Object)(object)_hudRoot != (Object)null && ((Component)_hudRoot).gameObject.activeSelf)
				{
					((Component)_hudRoot).gameObject.SetActive(false);
				}
				return;
			}
			if ((Object)(object)_hudRoot == (Object)null || (Object)(object)_hudText == (Object)null || (Object)(object)((Transform)_hudRoot).parent != (Object)(object)((Component)val).transform)
			{
				BuildHud(val, instance);
			}
			if (!((Object)(object)_hudRoot == (Object)null))
			{
				if (!((Component)_hudRoot).gameObject.activeSelf)
				{
					((Component)_hudRoot).gameObject.SetActive(true);
				}
				string text = (flag ? GuestHudLine(fog, now) : HudLine(fog));
				if (!string.Equals(text, _hudLast, StringComparison.Ordinal))
				{
					_hudLast = text;
					((TMP_Text)_hudText).text = text;
				}
			}
		}

		private void BuildHud(Canvas canvas, GUIManager g)
		{
			//IL_004b: 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_006f: 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_008f: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_hudRoot != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_hudRoot).gameObject);
			}
			_hudRoot = null;
			_hudText = null;
			_hudLast = null;
			RectTransform component = new GameObject("KikisFogHUD", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
			((Transform)component).SetParent(((Component)canvas).transform, false);
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			component.pivot = Vector2.zero;
			component.sizeDelta = new Vector2(1180f, 38f);
			((Transform)component).localScale = Vector3.one * 0.9f;
			component.anchoredPosition = new Vector2(60f, 0f);
			((Transform)component).SetAsLastSibling();
			GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			RectTransform component2 = val.GetComponent<RectTransform>();
			((Transform)component2).SetParent((Transform)(object)component, false);
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			TextMeshProUGUI val3 = StyleSource(g);
			if ((Object)(object)val3 != (Object)null)
			{
				((TMP_Text)val2).font = ((TMP_Text)val3).font;
				((TMP_Text)val2).fontSharedMaterial = ((TMP_Text)val3).fontSharedMaterial;
			}
			((Graphic)val2).raycastTarget = false;
			((TMP_Text)val2).richText = true;
			((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)val2).margin = new Vector4(10f, 0f, 10f, 0f);
			((TMP_Text)val2).fontSize = 16f;
			((TMP_Text)val2).fontWeight = (FontWeight)700;
			((Graphic)val2).color = Color.white;
			((TMP_Text)val2).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)220);
			((TMP_Text)val2).outlineWidth = 0.045f;
			_hudRoot = component;
			_hudText = val2;
		}

		private static TextMeshProUGUI StyleSource(GUIManager g)
		{
			if ((Object)(object)g == (Object)null)
			{
				return null;
			}
			if ((Object)(object)g.itemPromptMain != (Object)null && (Object)(object)((TMP_Text)g.itemPromptMain).font != (Object)null)
			{
				return g.itemPromptMain;
			}
			if ((Object)(object)g.interactNameText != (Object)null && (Object)(object)((TMP_Text)g.interactNameText).font != (Object)null)
			{
				return g.interactNameText;
			}
			if ((Object)(object)g.interactPromptText != (Object)null && (Object)(object)((TMP_Text)g.interactPromptText).font != (Object)null)
			{
				return g.interactPromptText;
			}
			return null;
		}

		private string HudLine(OrbFogHandler fog)
		{
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Invalid comparison between Unknown and I4
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Invalid comparison between Unknown and I4
			StringBuilder stringBuilder = new StringBuilder(220);
			RunTimer(stringBuilder);
			if (_stageControlled)
			{
				string value;
				string color;
				if (_paused)
				{
					value = "PAUSED";
					color = "#FFA64D";
				}
				else if (fog.isMoving)
				{
					value = "RISING";
					color = "#B5FFB8";
				}
				else if (fog.hasArrived)
				{
					value = "STOPPED";
					color = "#7BD4FF";
				}
				else if (!_delayDone)
				{
					value = "WAITING " + Clock(FogDelay.Value - _delayElapsed);
					color = "#FFE08A";
				}
				else
				{
					value = "WAITING";
					color = "#FFE08A";
				}
				Badge(stringBuilder, "FOG", value, color);
				Badge(stringBuilder, "SPEED", FogSpeed.Value.ToString("0.00", Inv), "#D6F1FF");
				Badge(stringBuilder, "DELAY", FogDelay.Value.ToString("0", Inv) + "s", "#F2C75C");
				if (DeadlyFog.Value)
				{
					Badge(stringBuilder, null, "DEADLY", "#FF5A4D");
				}
			}
			else
			{
				LavaRising val = CurrentRiser();
				if ((Object)(object)val != (Object)null)
				{
					bool flag = (int)val.risingFieldType == 1;
					bool flag2 = (int)val.risingFieldType == 2;
					float num = RiserDelay(val);
					string value2;
					string color2;
					if (val.ended)
					{
						value2 = "TOP";
						color2 = "#7BD4FF";
					}
					else if (val.started)
					{
						value2 = "RISING";
						color2 = "#B5FFB8";
					}
					else if (val.secondsWaitedToStart > 0f)
					{
						value2 = "WAITING " + Clock(num - val.secondsWaitedToStart);
						color2 = "#FFE08A";
					}
					else
					{
						value2 = "WAITING";
						color2 = "#FFE08A";
					}
					Badge(stringBuilder, flag ? "GLOOM" : (flag2 ? "SOULS" : "LAVA"), value2, color2);
					Badge(stringBuilder, "SPEED", "x" + RiserSpeed(val).ToString("0.00", Inv), "#D6F1FF");
					Badge(stringBuilder, "DELAY", num.ToString("0", Inv) + "s", "#F2C75C");
					if (flag && DeadlyGloom.Value)
					{
						Badge(stringBuilder, null, "DEADLY", "#FF5A4D");
					}
				}
				else if (CalderaNeverLowers.Value && _calderaAnims.Count > 0)
				{
					Badge(stringBuilder, "LAVA", "NEVER LOWERS", "#FFA64D");
				}
			}
			DayNight(stringBuilder);
			return stringBuilder.ToString();
		}

		private string GuestHudLine(OrbFogHandler fog, float now)
		{
			StringBuilder stringBuilder = new StringBuilder(100);
			RunTimer(stringBuilder);
			if (GuestFogSpeed(fog, now, out var speed))
			{
				Badge(stringBuilder, "SPEED", "~" + (Mathf.Round(speed * 20f) / 20f).ToString("0.00", Inv), "#D6F1FF");
			}
			DayNight(stringBuilder);
			return stringBuilder.ToString();
		}

		private bool GuestFogSpeed(OrbFogHandler fog, float now, out float speed)
		{
			//IL_006a: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			speed = 0f;
			int num;
			if (fog.isMoving)
			{
				num = ((!fog.hasArrived) ? 1 : 0);
				if (num != 0 && fog.currentID == _gOrigin && !(now - _gLastSample > 1f))
				{
					goto IL_0052;
				}
			}
			else
			{
				num = 0;
			}
			_gSamples.Clear();
			_gOrigin = fog.currentID;
			goto IL_0052;
			IL_0052:
			_gLastSample = now;
			if (num == 0)
			{
				return false;
			}
			_gSamples.Enqueue(new Vector2(now, fog.currentSize));
			while (_gSamples.Count > 0 && now - _gSamples.Peek().x > 10f)
			{
				_gSamples.Dequeue();
			}
			if (_gSamples.Count < 2)
			{
				return false;
			}
			Vector2 val = _gSamples.Peek();
			float num2 = now - val.x;
			if (num2 < 6f)
			{
				return false;
			}
			speed = Mathf.Max(0f, (val.y - fog.currentSize) / num2);
			return true;
		}

		private static void RunTimer(StringBuilder sb)
		{
			RunManager instance = RunManager.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				float timeSinceRunStarted = instance.TimeSinceRunStarted;
				if (!(timeSinceRunStarted <= 0.05f))
				{
					int num = Mathf.FloorToInt(timeSinceRunStarted);
					Badge(sb, "RUN", (num / 60).ToString("00", Inv) + ":" + (num % 60).ToString("00", Inv), "#E2EAF3");
				}
			}
		}

		private static void DayNight(StringBuilder sb)
		{
			DayNightManager instance = DayNightManager.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				float num = (instance.timeOfDay % 24f + 24f) % 24f;
				float dayStart = instance.dayStart;
				float dayEnd = instance.dayEnd;
				float num2 = dayEnd - dayStart;
				if (!(num2 <= 0.01f) && !(num2 >= 23.99f))
				{
					bool flag = num >= dayStart && num < dayEnd;
					float num3 = (flag ? ((num - dayStart) / num2) : (((num - dayEnd) % 24f + 24f) % 24f / (24f - num2)));
					Badge(sb, flag ? "DAY" : "NIGHT", Mathf.RoundToInt(Mathf.Clamp01(num3) * 100f).ToString(Inv) + "%", flag ? "#FFE38A" : "#AFC6FF");
				}
			}
		}

		private static void Badge(StringBuilder sb, string label, string value, string color)
		{
			if (sb.Length > 0)
			{
				sb.Append("   ");
			}
			if (label != null)
			{
				sb.Append("<color=#9AA7B4>").Append(label).Append("</color> ");
			}
			sb.Append("<color=").Append(color).Append('>')
				.Append(value)
				.Append("</color>");
		}

		private static string Clock(float seconds)
		{
			int num = Mathf.CeilToInt(Mathf.Max(0f, seconds));
			return (num / 60).ToString(Inv) + ":" + (num % 60).ToString("00", Inv);
		}

		private static string StageName(int id)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return ((object)(Segment)(byte)id/*cast due to .constrained prefix*/).ToString() + " (" + id + ")";
			}
			catch
			{
				return id.ToString();
			}
		}

		private void LogErr(string where, Exception e)
		{
			float unscaledTime = Time.unscaledTime;
			if (!_errLogged.TryGetValue(where, out var value) || !(unscaledTime - value < 10f))
			{
				_errLogged[where] = unscaledTime;
				L.LogError((object)("[KFOG] " + where + " failed: " + e.GetType().Name + ": " + e.Message));
			}
		}
	}
	[HarmonyPatch(typeof(OrbFogHandler), "WaitToMove")]
	internal static class WaitToMovePatch
	{
		private static bool Prefix(OrbFogHandler __instance)
		{
			try
			{
				return !Plugin.HoldsVanillaWait(__instance);
			}
			catch
			{
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(OrbFogHandler), "Start")]
	internal static class FogStartPatch
	{
		private static void Postfix(OrbFogHandler __instance)
		{
			try
			{
				Plugin.CacheOrigins(__instance);
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(OrbFogHandler), "SetFogOrigin")]
	internal static class SetFogOriginPatch
	{
		private static void Postfix(OrbFogHandler __instance, int id)
		{
			try
			{
				Plugin.OnOriginSet(__instance, id);
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(Character), "SpawnStatue")]
	internal static class SpawnStatuePatch
	{
		private static bool Prefix(Character __instance, bool killedByDagger)
		{
			try
			{
				return !Plugin.SkipStatue(__instance, killedByDagger);
			}
			catch
			{
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(DayNightManager), "Update")]
	internal static class DayNightPatch
	{
		private static void Prefix(DayNightManager __instance)
		{
			try
			{
				Plugin.DayNightStep(__instance);
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(Character), "RPCA_ReviveAtPosition")]
	internal static class ReviveTransitPatch
	{
		private static void Prefix(Character __instance, out bool __state)
		{
			__state = false;
			try
			{
				__state = (Object)(object)__instance != (Object)null && (Object)(object)__instance.data != (Object)null && __instance.data.dead;
			}
			catch
			{
			}
		}

		private static void Postfix(Character __instance, Vector3 position, bool __state)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!__state)
			{
				return;
			}
			try
			{
				Plugin.OnMovedByRpc(__instance, position);
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(Character), "WarpPlayerRPC")]
	internal static class WarpTransitPatch
	{
		private static void Postfix(Character __instance, Vector3 position, PhotonMessageInfo info)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (info.Sender != null && info.Sender.IsMasterClient)
				{
					Plugin.OnMovedByRpc(__instance, position);
				}
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(MapHandler), "GoToSegment")]
	internal static class GoToSegmentPatch
	{
		private static void Prefix(MapHandler __instance, Segment s)
		{
			//IL_0000: 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)
			try
			{
				if (s > __instance.GetCurrentSegment())
				{
					Plugin.OnTransitionStart();
				}
			}
			catch
			{
			}
		}
	}
	internal static class Weather
	{
		private class Storm
		{
			public bool On;

			public float Since;

			public int Scouts;

			public int Pushes;

			public int Gusts;

			public int Status;
		}

		private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;

		internal static ConfigEntry<bool> WrEnabled;

		internal static ConfigEntry<bool> WrInfinite;

		internal static ConfigEntry<bool> WrAnyDir;

		internal static ConfigEntry<bool> WrGusts;

		internal static ConfigEntry<float> WrStrength;

		internal static ConfigEntry<float> WrLength;

		internal static ConfigEntry<float> WrGustPower;

		internal static ConfigEntry<float> WrGustChance;

		internal static ConfigEntry<float> WrGustFall;

		internal static ConfigEntry<float> WrStatusPerSec;

		internal static ConfigEntry<STATUSTYPE> WrStatus;

		internal static ConfigEntry<bool> WaEnabled;

		internal static ConfigEntry<bool> WaInfinite;

		internal static ConfigEntry<bool> WaAnyDir;

		internal static ConfigEntry<bool> WaGusts;

		internal static ConfigEntry<float> WaStrength;

		internal static ConfigEntry<float> WaCold;

		internal static ConfigEntry<float> WaLength;

		internal static ConfigEntry<float> WaGustPower;

		internal static ConfigEntry<float> WaGustChance;

		internal static ConfigEntry<float> WaGustFall;

		internal static ConfigEntry<float> WaStatusPerSec;

		internal static ConfigEntry<STATUSTYPE> WaStatus;

		internal static ConfigEntry<bool> WtEnabled;

		internal static ConfigEntry<bool> WtInfinite;

		internal static ConfigEntry<bool> WtPushDown;

		internal static ConfigEntry<float> WtLength;

		internal static ConfigEntry<float> WtPushPower;

		internal static ConfigEntry<float> WtStatusPerSec;

		internal static ConfigEntry<STATUSTYPE> WtStatus;

		internal static ConfigEntry<bool> WmEnabled;

		internal static ConfigEntry<float> WmSunHeat;

		internal static ConfigEntry<float> WmStatusPerSec;

		internal static ConfigEntry<STATUSTYPE> WmStatus;

		internal static readonly List<string> Missing = new List<string>();

		private static readonly FieldRef<WindChillZone, float> UntilSwitch = Field<float>("untilSwitch");

		private static readonly FieldRef<WindChillZone, Vector3> WindDir = Field<Vector3>("currentWindDirection");

		private static readonly FieldRef<WindChillZone, float> ActiveFor = Field<float>("hasBeenActiveFor");

		private static readonly FieldRef<WindChillZone, float> ForceMult = Field<float>("currentForceMult");

		private static readonly MethodInfo NextTime = Method("GetNextWindTime");

		private static readonly MethodInfo RandomDir = Method("RandomWindDirection");

		private static readonly MethodInfo IntensityAt = Method("GetWindIntensityAtPoint");

		private const float WIND_TICK = 0.125f;

		private const float SUN_TICK = 0.5f;

		private static float _windAt;

		private static float _sunAt;

		private static WindChillZone[] _zones = (WindChillZone[])(object)new WindChillZone[0];

		private static HotSun[] _suns = (HotSun[])(object)new HotSun[0];

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

		private static int _cacheSeg = -99;

		private static string _cacheScene;

		private static float _cacheUntil;

		private static readonly Dictionary<int, Storm> _storms = new Dictionary<int, Storm>();

		private const float MAX_DV = 45f;

		private const float STEP = 0.025f;

		private static readonly Dictionary<long, float> _acc = new Dictionary<long, float>();

		private static readonly Dictionary<string, float> _errAt = new Dictionary<string, float>();

		internal static bool Host
		{
			get
			{
				if (PhotonNetwork.InRoom)
				{
					return PhotonNetwork.IsMasterClient;
				}
				return false;
			}
		}

		private static ConfigDescription Rf(string text, float min, float max)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			return new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>());
		}

		internal static void Bind(ConfigFile c)
		{
			st