Decompiled source of MoreEvents v1.0.4

plugins/MoreEvents.dll

Decompiled 3 minutes 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.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MoreEvents")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c7ddb9d4c9be99586d3a7cd3c513ea1adf62f05c")]
[assembly: AssemblyProduct("MoreEvents")]
[assembly: AssemblyTitle("MoreEvents")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 MoreEvents
{
	internal static class Director
	{
		private static RunEvent active;

		private static float nextAt = -1f;

		private static IntPtr runPtr;

		private static float nextPublish;

		private static readonly HashSet<string> failedToStart = new HashSet<string>();

		internal static bool Running => active != null;

		internal static void Reset()
		{
			active = null;
			nextAt = -1f;
			runPtr = IntPtr.Zero;
			failedToStart.Clear();
		}

		private static List<RunEvent> All()
		{
			return new List<RunEvent>
			{
				new BountyEvent(),
				new HillEvent(),
				new SwarmEvent(),
				new EscortEvent(),
				new CursedEvent(),
				new GauntletEvent()
			};
		}

		internal static void Tick()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			if (!Game.IsServer)
			{
				return;
			}
			RunManager run = Game.Run;
			if ((Object)(object)run == (Object)null)
			{
				if (active != null)
				{
					Reset();
				}
				return;
			}
			if (((Il2CppObjectBase)run).Pointer != runPtr)
			{
				Reset();
				runPtr = ((Il2CppObjectBase)run).Pointer;
			}
			bool runHasStarted;
			float currentRunTimeInSeconds;
			try
			{
				runHasStarted = run.runHasStarted;
				currentRunTimeInSeconds = run.currentRunTimeInSeconds;
			}
			catch
			{
				return;
			}
			if (!runHasStarted)
			{
				return;
			}
			if (nextAt < 0f)
			{
				nextAt = Mathf.Max(currentRunTimeInSeconds, 0f) + Mathf.Max(10f, Plugin.FirstEventAfter.Value);
			}
			if (active != null)
			{
				bool? flag;
				try
				{
					flag = active.Tick(Time.deltaTime);
				}
				catch (Exception ex)
				{
					ManualLogSource log = Plugin.Log;
					bool flag2 = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(2, 2, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(active.Title);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					log.LogError(val);
					flag = false;
				}
				if (!flag.HasValue)
				{
					if (Time.unscaledTime >= nextPublish)
					{
						nextPublish = Time.unscaledTime + 0.25f;
						Publish(0, "");
					}
				}
				else
				{
					Finish(flag.Value, currentRunTimeInSeconds);
				}
			}
			else if (Pressed(Plugin.StartKey.Value) || (Plugin.Enabled.Value && !(currentRunTimeInSeconds < nextAt) && !(Time.timeScale <= 0.01f) && (!Plugin.SkipDuringObjectives.Value || !ObjectiveActive())))
			{
				StartRandom(currentRunTimeInSeconds);
			}
		}

		private static bool ObjectiveActive()
		{
			try
			{
				ObjectiveDirector objectives = Game.Objectives;
				return (Object)(object)objectives != (Object)null && objectives.ActiveObjective != null;
			}
			catch
			{
				return false;
			}
		}

		private static void StartRandom(float runTime)
		{
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			List<RunEvent> list = All().FindAll((RunEvent e) => e.Weight > 0 && !failedToStart.Contains(e.Key));
			if (list.Count == 0)
			{
				nextAt = runTime + 30f;
				failedToStart.Clear();
				return;
			}
			int num = 0;
			foreach (RunEvent item in list)
			{
				num += item.Weight;
			}
			int num2 = Random.Range(0, num);
			RunEvent runEvent = list[0];
			foreach (RunEvent item2 in list)
			{
				if (num2 < item2.Weight)
				{
					runEvent = item2;
					break;
				}
				num2 -= item2.Weight;
			}
			bool flag;
			bool flag2 = default(bool);
			try
			{
				flag = runEvent.Start();
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(11, 2, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Starting ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(runEvent.Title);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
				flag = false;
			}
			if (!flag)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(48, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(runEvent.Title);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" couldn't start here; trying another event soon.");
				}
				log2.LogWarning(val2);
				failedToStart.Add(runEvent.Key);
				nextAt = runTime + 5f;
				return;
			}
			failedToStart.Clear();
			active = runEvent;
			ManualLogSource log3 = Plugin.Log;
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Event started: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(runEvent.Title);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
			}
			log3.LogInfo(val3);
			Publish(0, "");
		}

		private static void Finish(bool success, float runTime)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			RunEvent runEvent = active;
			string text;
			bool flag = default(bool);
			try
			{
				text = runEvent.Finish(success);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(10, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(runEvent.Title);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" rewards: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
				text = "";
			}
			Publish(success ? 1 : 2, text);
			ManualLogSource log2 = Plugin.Log;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(10, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Event ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(success ? "won" : "lost");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(runEvent.Title);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(". ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
			}
			log2.LogInfo(val2);
			active = null;
			nextAt = runTime + Mathf.Max(20f, Plugin.SecondsBetween.Value) + Random.Range(0f, Mathf.Max(0f, Plugin.RandomExtra.Value));
		}

		private static void Publish(int phase, string result)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			RunEvent runEvent = active;
			if (runEvent == null)
			{
				return;
			}
			EventState s = new EventState
			{
				Key = runEvent.Key,
				Title = runEvent.Title,
				Accent = runEvent.Accent,
				Phase = phase,
				Result = result
			};
			try
			{
				if (phase == 0)
				{
					runEvent.Fill(s);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(8, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(runEvent.Title);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" state: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogError(val);
			}
			Net.Publish(s);
		}

		private static bool Pressed(string keyName)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Keyboard current = Keyboard.current;
				if (current == null || string.IsNullOrEmpty(keyName))
				{
					return false;
				}
				if (!Enum.TryParse<Key>(keyName, ignoreCase: true, out Key result) || (int)result == 0)
				{
					return false;
				}
				KeyControl val = current[result];
				return val != null && ((ButtonControl)val).wasPressedThisFrame;
			}
			catch
			{
				return false;
			}
		}
	}
	internal abstract class RunEvent
	{
		protected float Started;

		protected static readonly Color Gold = new Color(1f, 0.82f, 0.25f);

		protected static readonly Color Red = new Color(1f, 0.3f, 0.25f);

		protected static readonly Color Green = new Color(0.45f, 1f, 0.45f);

		protected static readonly Color Purple = new Color(0.75f, 0.35f, 1f);

		protected static readonly Color Orange = new Color(1f, 0.6f, 0.2f);

		protected static readonly Color White = new Color(0.95f, 0.95f, 0.95f);

		public abstract string Key { get; }

		public abstract string Title { get; }

		public abstract Color Accent { get; }

		public abstract int Weight { get; }

		protected float Elapsed => Time.time - Started;

		public bool Start()
		{
			Started = Time.time;
			return Begin();
		}

		protected abstract bool Begin();

		public abstract bool? Tick(float dt);

		public abstract void Fill(EventState s);

		public abstract string Finish(bool success);

		protected static string Pretty(string id)
		{
			if (string.IsNullOrEmpty(id))
			{
				return "?";
			}
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < id.Length; i++)
			{
				char c = id[i];
				if (c == '_')
				{
					stringBuilder.Append(' ');
					continue;
				}
				if (i > 0 && char.IsUpper(c) && !char.IsUpper(id[i - 1]) && id[i - 1] != '_')
				{
					stringBuilder.Append(' ');
				}
				stringBuilder.Append(c);
			}
			return stringBuilder.ToString();
		}
	}
	internal sealed class BountyEvent : RunEvent
	{
		private Game.Tracked target;

		private string name = "";

		public override string Key => "bounty";

		public override string Title => "Bounty";

		public override Color Accent => RunEvent.Red;

		public override int Weight => Plugin.BountyWeight.Value;

		private float Limit => Mathf.Max(10f, Plugin.BountyTime.Value);

		protected override bool Begin()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			EnemyType? val = null;
			foreach (var item in Game.EliteLists())
			{
				val = Game.RandomEliteFrom(item.elites);
				if (val.HasValue)
				{
					break;
				}
			}
			if (!val.HasValue && Game.CanSpawn((EnemyType)7))
			{
				val = (EnemyType)7;
			}
			if (!val.HasValue)
			{
				return false;
			}
			Game.SpawnTracked(val.Value, Game.PointInRing(Game.PartyCentre(), 14f, 22f), out target);
			name = RunEvent.Pretty(((object)val.Value/*cast due to .constrained prefix*/).ToString());
			return target != null;
		}

		public override bool? Tick(float dt)
		{
			switch (Game.FateOf(target))
			{
			case Game.Fate.Killed:
				return true;
			case Game.Fate.Gone:
				return false;
			default:
				if (base.Elapsed >= Limit)
				{
					Game.Despawn(target.Obj);
					return false;
				}
				return null;
			}
		}

		public override void Fill(EventState s)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			s.Line = "Kill the marked " + name + " before it escapes!";
			s.Timer = Mathf.Max(0f, Limit - base.Elapsed);
			if (!target.Dead && Game.Alive((Object)(object)target.Obj))
			{
				s.Markers.Add(new Marker
				{
					Kind = MarkerKind.Follow,
					NetId = target.Obj.NetworkObjectId,
					Icon = "skull",
					Color = RunEvent.Red,
					Radius = 2.2f
				});
			}
		}

		public override string Finish(bool success)
		{
			if (success)
			{
				return Game.GiveShop((StoreType)0);
			}
			float num = Mathf.Max(0f, Plugin.BountyEscapeBuff.Value);
			if (num <= 0f)
			{
				return "It got away.";
			}
			WaveBuff.Arm(num);
			return $"It got away: next wave's enemies have +{num:0}% health";
		}
	}
	internal sealed class HillEvent : RunEvent
	{
		private Vector3 zone;

		private float progress;

		private float nextSpawn;

		private int inside;

		private int spawned;

		public override string Key => "hill";

		public override string Title => "King of the Hill";

		public override Color Accent => RunEvent.Gold;

		public override int Weight => Plugin.HillWeight.Value;

		private float Limit => Mathf.Max(15f, Plugin.HillTime.Value);

		private float Radius => Mathf.Clamp(Plugin.HillRadius.Value, 2f, 20f);

		protected override bool Begin()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			zone = Game.ObjectivePoint(Game.PartyCentre(), 14f, 35f);
			return true;
		}

		public override bool? Tick(float dt)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			inside = 0;
			foreach (Vector3 item in Game.LivingPlayerPositions())
			{
				if (Game.FlatDistance(item, zone) <= Radius)
				{
					inside++;
				}
			}
			float num = Mathf.Max(3f, Plugin.HillCapture.Value);
			if (inside > 0)
			{
				progress += dt * (1f + 0.5f * (float)(inside - 1)) / num;
			}
			else
			{
				progress -= dt / (num * 1.6f);
			}
			progress = Mathf.Clamp01(progress);
			if (base.Elapsed >= nextSpawn && spawned < 20)
			{
				nextSpawn = base.Elapsed + 2.5f;
				Game.SpawnWaveEnemy(Game.PointInRing(zone, Radius + 6f, Radius + 12f));
				spawned++;
			}
			if (progress >= 1f)
			{
				return true;
			}
			if (base.Elapsed >= Limit)
			{
				return false;
			}
			return null;
		}

		public override void Fill(EventState s)
		{
			//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_00b0: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			s.Line = ((inside > 0) ? $"Holding the zone ({inside} inside)" : "Stand in the zone to claim it!");
			s.Timer = Mathf.Max(0f, Limit - base.Elapsed);
			s.Progress = progress;
			s.Markers.Add(new Marker
			{
				Kind = MarkerKind.Ring,
				Pos = zone,
				Radius = Radius,
				Color = ((inside > 0) ? RunEvent.Gold : RunEvent.White),
				Icon = "crown"
			});
		}

		public override string Finish(bool success)
		{
			if (!success)
			{
				return "The zone was lost.";
			}
			return Game.GiveShop((StoreType)0);
		}
	}
	internal sealed class SwarmEvent : RunEvent
	{
		private readonly List<Game.Tracked> crabs = new List<Game.Tracked>();

		private readonly List<bool> done = new List<bool>();

		private int caught;

		private int total;

		public override string Key => "swarm";

		public override string Title => "Golden Swarm";

		public override Color Accent => RunEvent.Gold;

		public override int Weight => Plugin.SwarmWeight.Value;

		private float Limit => Mathf.Max(10f, Plugin.SwarmTime.Value);

		protected override bool Begin()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			EnemyType type;
			if (Game.CanSpawn((EnemyType)39))
			{
				type = (EnemyType)39;
			}
			else
			{
				if (!Game.CanSpawn((EnemyType)12))
				{
					return false;
				}
				type = (EnemyType)12;
			}
			Vector3 centre = Game.PartyCentre();
			int num = Mathf.Clamp(Plugin.SwarmCount.Value, 1, 20);
			for (int i = 0; i < num; i++)
			{
				Game.SpawnTracked(type, Game.PointInRing(centre, 8f, 28f), out var tracked);
				if (tracked != null)
				{
					crabs.Add(tracked);
					done.Add(item: false);
				}
			}
			total = crabs.Count;
			return total > 0;
		}

		public override bool? Tick(float dt)
		{
			int num = 0;
			for (int i = 0; i < crabs.Count; i++)
			{
				if (!done[i])
				{
					switch (Game.FateOf(crabs[i]))
					{
					case Game.Fate.Killed:
						done[i] = true;
						caught++;
						Game.GiveXp(Mathf.Max(0f, Plugin.SwarmXp.Value));
						EndCrab(crabs[i]);
						break;
					case Game.Fate.Gone:
						done[i] = true;
						break;
					default:
						num++;
						break;
					}
				}
			}
			if (num == 0)
			{
				return caught == total;
			}
			if (base.Elapsed >= Limit)
			{
				for (int j = 0; j < crabs.Count; j++)
				{
					if (!done[j])
					{
						done[j] = true;
						EndCrab(crabs[j]);
					}
				}
				return caught == total;
			}
			return null;
		}

		private static void EndCrab(Game.Tracked c)
		{
			try
			{
				HuntTarget val = (Game.Alive((Object)(object)c.Obj) ? ((Component)c.Obj).GetComponentInChildren<HuntTarget>(true) : null);
				if ((Object)(object)val != (Object)null)
				{
					val.EndLifetime();
					return;
				}
			}
			catch
			{
			}
			Game.Despawn(c.Obj);
		}

		public override void Fill(EventState s)
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			s.Line = $"Catch the golden crabs! {caught}/{total}";
			s.Timer = Mathf.Max(0f, Limit - base.Elapsed);
			s.Progress = ((total > 0) ? ((float)caught / (float)total) : 0f);
			for (int i = 0; i < crabs.Count; i++)
			{
				if (!done[i] && Game.Alive((Object)(object)crabs[i].Obj))
				{
					s.Markers.Add(new Marker
					{
						Kind = MarkerKind.Follow,
						NetId = crabs[i].Obj.NetworkObjectId,
						Icon = "crab",
						Color = RunEvent.Gold,
						Radius = 0f
					});
				}
			}
		}

		public override string Finish(bool success)
		{
			string text = $"{caught}/{total} caught (+{Plugin.SwarmXp.Value * (float)caught:0}% XP)";
			if (!success)
			{
				return text;
			}
			return text + ". " + Game.GiveShop((StoreType)3);
		}
	}
	internal sealed class EscortEvent : RunEvent
	{
		private Vector3 pos;

		private Vector3 start;

		private Vector3 dest;

		private float health;

		private float maxHealth;

		private float nextScan;

		private float nextSpawn;

		private int escorts;

		private int attackers;

		private int spawned;

		private List<Vector3> enemies = new List<Vector3>();

		private const float EscortRange = 7f;

		private const float AttackRange = 4.5f;

		private const float Speed = 2.2f;

		public override string Key => "escort";

		public override string Title => "Escort the Fungus";

		public override Color Accent => RunEvent.Green;

		public override int Weight => Plugin.EscortWeight.Value;

		private float Limit => Mathf.Max(20f, Plugin.EscortTime.Value);

		protected override bool Begin()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0020: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 centre = Game.PartyCentre();
			start = (pos = Game.PointInRing(centre, 4f, 8f));
			float num = Mathf.Max(15f, Plugin.EscortDistance.Value);
			dest = Game.ObjectivePoint(start, num * 0.8f, num * 1.3f);
			if (Game.FlatDistance(dest, start) < num * 0.5f)
			{
				dest = Game.PointInRing(start, num * 0.8f, num * 1.1f);
			}
			maxHealth = (health = Mathf.Max(10f, Plugin.EscortHealth.Value));
			return true;
		}

		public override bool? Tick(float dt)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
			if (base.Elapsed >= nextScan)
			{
				nextScan = base.Elapsed + 0.4f;
				enemies = Game.EnemyPositions();
				escorts = 0;
				foreach (Vector3 item in Game.LivingPlayerPositions())
				{
					if (Game.FlatDistance(item, pos) <= 7f)
					{
						escorts++;
					}
				}
			}
			attackers = 0;
			foreach (Vector3 enemy in enemies)
			{
				if (Game.FlatDistance(enemy, pos) <= 4.5f)
				{
					attackers++;
				}
			}
			health -= (float)Mathf.Min(attackers, 8) * 5f * dt;
			if (escorts > 0)
			{
				Vector3 val = dest - pos;
				val.y = 0f;
				float num = 2.2f * (1f + 0.15f * (float)(escorts - 1)) * dt;
				if (((Vector3)(ref val)).magnitude <= num)
				{
					pos = new Vector3(dest.x, pos.y, dest.z);
				}
				else
				{
					pos += ((Vector3)(ref val)).normalized * num;
				}
			}
			if (base.Elapsed >= nextSpawn && spawned < 16)
			{
				nextSpawn = base.Elapsed + 5f;
				for (int i = 0; i < 2; i++)
				{
					Game.SpawnWaveEnemy(Game.PointInRing(pos, 10f, 14f));
					spawned++;
				}
			}
			if (Game.FlatDistance(pos, dest) < 1.5f)
			{
				return true;
			}
			if (health <= 0f)
			{
				return false;
			}
			if (base.Elapsed >= Limit)
			{
				return false;
			}
			return null;
		}

		public override void Fill(EventState s)
		{
			//IL_00a7: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: 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_0180: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			int value = Mathf.CeilToInt(Mathf.Max(0f, health) / maxHealth * 100f);
			s.Line = ((escorts > 0) ? "Escorting the fungus" : "The fungus waits for you") + $"  -  health {value}%" + ((attackers > 0) ? "  (under attack!)" : "");
			s.Timer = Mathf.Max(0f, Limit - base.Elapsed);
			float num = Game.FlatDistance(start, dest);
			s.Progress = ((num > 0.1f) ? Mathf.Clamp01(1f - Game.FlatDistance(pos, dest) / num) : 1f);
			Color color = ((attackers > 0) ? RunEvent.Red : ((escorts > 0) ? RunEvent.Green : RunEvent.White));
			s.Markers.Add(new Marker
			{
				Kind = MarkerKind.Ring,
				Pos = pos,
				Radius = 7f,
				Color = color,
				Icon = "mushroom"
			});
			s.Markers.Add(new Marker
			{
				Kind = MarkerKind.Ring,
				Pos = dest,
				Radius = 2.5f,
				Color = RunEvent.Green,
				Icon = "flag"
			});
		}

		public override string Finish(bool success)
		{
			if (!success)
			{
				if (!(health <= 0f))
				{
					return "Out of time.";
				}
				return "The fungus was eaten.";
			}
			return Game.GiveShop((StoreType)3);
		}
	}
	internal sealed class CursedEvent : RunEvent
	{
		private Vector3 from;

		private Vector3 to;

		public override string Key => "cursed";

		public override string Title => "Cursed Ground";

		public override Color Accent => RunEvent.Purple;

		public override int Weight => Plugin.CursedWeight.Value;

		private float Duration => Mathf.Max(10f, Plugin.CursedTime.Value);

		private float T => Mathf.Clamp01(base.Elapsed / Duration);

		private Vector3 Centre => Vector3.Lerp(from, to, T);

		private float Radius => Mathf.Lerp(Mathf.Max(4f, Plugin.CursedStartRadius.Value), Mathf.Max(2f, Plugin.CursedEndRadius.Value), Mathf.SmoothStep(0f, 1f, T));

		protected override bool Begin()
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			from = Game.PartyCentre();
			to = Game.PointInRing(from, 6f, 16f);
			return true;
		}

		public override bool? Tick(float dt)
		{
			if (!(base.Elapsed >= Duration))
			{
				return null;
			}
			return true;
		}

		public override void Fill(EventState s)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			s.Line = "The ground is cursed! Stay inside the circle.";
			s.Timer = Mathf.Max(0f, Duration - base.Elapsed);
			s.Progress = T;
			s.Markers.Add(new Marker
			{
				Kind = MarkerKind.Safe,
				Pos = Centre,
				Radius = Radius,
				Color = RunEvent.Purple,
				Dps = Mathf.Max(0f, Plugin.CursedDamage.Value)
			});
		}

		public override string Finish(bool success)
		{
			return "Survived the curse: " + Game.GiveXp(50f);
		}
	}
	internal sealed class GauntletEvent : RunEvent
	{
		private readonly List<(EnemyType type, int world)> stages = new List<(EnemyType, int)>();

		private int stage;

		private Game.Tracked current;

		private float spawnAt = -1f;

		private readonly List<string> rewards = new List<string>();

		public override string Key => "gauntlet";

		public override string Title => "Elite Gauntlet";

		public override Color Accent => RunEvent.Orange;

		public override int Weight => Plugin.GauntletWeight.Value;

		private float Limit => Mathf.Max(30f, Plugin.GauntletTime.Value);

		protected override bool Begin()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			List<(int, List<EliteEnemyConfiguration>)> list = Game.EliteLists();
			if (list.Count == 0)
			{
				return false;
			}
			List<(int, List<EliteEnemyConfiguration>)> list2 = new List<(int, List<EliteEnemyConfiguration>)>(list);
			for (int num = list2.Count - 1; num > 0; num--)
			{
				int num2 = Random.Range(0, num + 1);
				List<(int, List<EliteEnemyConfiguration>)> list3 = list2;
				int index = num;
				int index2 = num2;
				(int, List<EliteEnemyConfiguration>) value = list2[num2];
				(int, List<EliteEnemyConfiguration>) value2 = list2[num];
				list3[index] = value;
				list2[index2] = value2;
			}
			int num3 = Mathf.Clamp(Plugin.GauntletElites.Value, 1, 8);
			int num4 = 0;
			while (stages.Count < num3 && num4 < num3 * 4)
			{
				(int, List<EliteEnemyConfiguration>) tuple = list2[num4 % list2.Count];
				int item = tuple.Item1;
				EnemyType? val = Game.RandomEliteFrom(tuple.Item2);
				if (val.HasValue)
				{
					stages.Add((val.Value, item));
				}
				num4++;
			}
			if (stages.Count == 0)
			{
				return false;
			}
			return SpawnStage();
		}

		private bool SpawnStage()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Game.SpawnTracked(stages[stage].type, Game.PointInRing(Game.PartyCentre(), 14f, 22f), out current);
			spawnAt = -1f;
			return current != null;
		}

		public override bool? Tick(float dt)
		{
			if (base.Elapsed >= Limit)
			{
				return false;
			}
			if (spawnAt >= 0f)
			{
				if (base.Elapsed >= spawnAt && !SpawnStage())
				{
					stage++;
					if (stage >= stages.Count)
					{
						return true;
					}
					spawnAt = base.Elapsed + 1f;
				}
				return null;
			}
			switch (Game.FateOf(current))
			{
			case Game.Fate.Alive:
				return null;
			case Game.Fate.Killed:
				rewards.Add(Game.GiveRevive());
				break;
			}
			stage++;
			if (stage >= stages.Count)
			{
				return true;
			}
			spawnAt = base.Elapsed + 2f;
			return null;
		}

		public unsafe override void Fill(EventState s)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Min(stage, stages.Count - 1);
			(EnemyType type, int world) tuple = stages[num];
			EnemyType item = tuple.type;
			int item2 = tuple.world;
			s.Line = $"Elite {num + 1}/{stages.Count}: {RunEvent.Pretty(((object)(*(EnemyType*)(&item))/*cast due to .constrained prefix*/).ToString())} from {Game.RealmNames[Mathf.Clamp(item2, 0, 3)]}";
			s.Timer = Mathf.Max(0f, Limit - base.Elapsed);
			s.Progress = (float)stage / (float)stages.Count;
			if (spawnAt < 0f && current != null && !current.Dead && Game.Alive((Object)(object)current.Obj))
			{
				s.Markers.Add(new Marker
				{
					Kind = MarkerKind.Follow,
					NetId = current.Obj.NetworkObjectId,
					Icon = "sword",
					Color = RunEvent.Orange,
					Radius = 2.2f
				});
			}
		}

		public override string Finish(bool success)
		{
			int count = rewards.FindAll((string r) => r.StartsWith("+1 Revive")).Count;
			string text = ((count > 0) ? $"+{count} revive{((count > 1) ? "s" : "")}" : ((rewards.Count > 0) ? string.Join(", ", rewards) : "no rewards"));
			if (!success)
			{
				return $"Gauntlet failed ({stage}/{stages.Count}): {text}";
			}
			return "Gauntlet cleared: " + text;
		}
	}
	[HarmonyPatch]
	internal static class WaveBuff
	{
		private static int wave = -1;

		private static float multiplier = 1f;

		internal static void Arm(float percent)
		{
			try
			{
				RunManager run = Game.Run;
				if (((run != null) ? run.CurrentWave : null) != null)
				{
					wave = run.CurrentWave.Value + 1;
					multiplier = 1f + percent / 100f;
				}
			}
			catch
			{
			}
		}

		internal static void Reset()
		{
			wave = -1;
			multiplier = 1f;
		}

		[HarmonyPatch(typeof(EnemyHealthContainer), "CalculateMaxHealth")]
		[HarmonyPostfix]
		private static void MaxHealth_Postfix(EnemyHealthContainer __instance, ref float __result)
		{
			if (wave < 0)
			{
				return;
			}
			try
			{
				if (__instance.IsBoss)
				{
					return;
				}
				RunManager run = Game.Run;
				if (((run != null) ? run.CurrentWave : null) != null)
				{
					int value = run.CurrentWave.Value;
					if (value > wave)
					{
						Reset();
					}
					else if (value == wave)
					{
						__result *= multiplier;
					}
				}
			}
			catch
			{
			}
		}

		[HarmonyPatch(typeof(RunManager), "OnDestroy")]
		[HarmonyPostfix]
		private static void RunEnded()
		{
			Reset();
			Director.Reset();
		}
	}
	internal static class Game
	{
		internal sealed class Tracked
		{
			public NetworkObject Obj;

			public EnemyHealthContainer Health;

			public bool Dead;
		}

		internal enum Fate
		{
			Alive,
			Killed,
			Gone
		}

		private static RunManager run;

		private static EnemySpawner spawner;

		private static PartyLevelManager party;

		private static ReviveManager revives;

		private static StoreManager store;

		private static ObjectiveDirector objectives;

		private static readonly Dictionary<Type, float> nextLookup = new Dictionary<Type, float>();

		private static List<GameplayPlayer> players = new List<GameplayPlayer>();

		private static float nextPlayerScan;

		internal static readonly string[] RealmNames = new string[4] { "Verdant Meadows", "Frozen Ancients", "Pyrestorm Pit", "Astral Planes" };

		internal static RunManager Run => Find<RunManager>(ref run);

		internal static EnemySpawner Spawner => Find<EnemySpawner>(ref spawner);

		internal static PartyLevelManager Party => Find<PartyLevelManager>(ref party);

		internal static ReviveManager Revives => Find<ReviveManager>(ref revives);

		internal static StoreManager Store => Find<StoreManager>(ref store);

		internal static ObjectiveDirector Objectives => Find<ObjectiveDirector>(ref objectives);

		internal static bool IsServer
		{
			get
			{
				try
				{
					NetworkManager singleton = NetworkManager.Singleton;
					return (Object)(object)singleton != (Object)null && singleton.IsListening && singleton.IsServer;
				}
				catch
				{
					return false;
				}
			}
		}

		internal static bool Listening
		{
			get
			{
				try
				{
					NetworkManager singleton = NetworkManager.Singleton;
					return (Object)(object)singleton != (Object)null && singleton.IsListening;
				}
				catch
				{
					return false;
				}
			}
		}

		internal static bool Alive(Object o)
		{
			if (o != null && !((Il2CppObjectBase)o).WasCollected)
			{
				return o != (Object)null;
			}
			return false;
		}

		private static T Find<T>(ref T cache) where T : Object
		{
			if (Alive((Object)(object)cache))
			{
				return cache;
			}
			if (nextLookup.TryGetValue(typeof(T), out var value) && Time.unscaledTime < value)
			{
				return default(T);
			}
			cache = Object.FindObjectOfType<T>();
			if (!Alive((Object)(object)cache))
			{
				cache = default(T);
				nextLookup[typeof(T)] = Time.unscaledTime + 1f;
			}
			return cache;
		}

		internal static List<GameplayPlayer> Players()
		{
			if (Time.unscaledTime >= nextPlayerScan)
			{
				nextPlayerScan = Time.unscaledTime + 0.5f;
				List<GameplayPlayer> list = new List<GameplayPlayer>();
				foreach (GameplayPlayer item in Object.FindObjectsOfType<GameplayPlayer>())
				{
					if ((Object)(object)item != (Object)null && ((NetworkBehaviour)item).IsSpawned)
					{
						list.Add(item);
					}
				}
				players = list;
			}
			players.RemoveAll((GameplayPlayer p) => !Alive((Object)(object)p));
			return players;
		}

		internal static PlayerHealthContainer HealthOf(GameplayPlayer p)
		{
			try
			{
				PlayerHealthContainer val = p.HealthContainer;
				if (!Alive((Object)(object)val))
				{
					val = ((Component)p).GetComponentInChildren<PlayerHealthContainer>(true);
				}
				return Alive((Object)(object)val) ? val : null;
			}
			catch
			{
				return null;
			}
		}

		internal static Vector3 PositionOf(GameplayPlayer p)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return p.GetPosition();
			}
			catch
			{
				return ((Component)p).transform.position;
			}
		}

		internal static bool IsAlive(GameplayPlayer p)
		{
			try
			{
				if (!((Component)p).gameObject.activeInHierarchy)
				{
					return false;
				}
				PlayerHealthContainer val = HealthOf(p);
				return (Object)(object)val == (Object)null || !((HealthContainer)val).IsHealthZero();
			}
			catch
			{
				return false;
			}
		}

		internal static List<Vector3> LivingPlayerPositions()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			foreach (GameplayPlayer item in Players())
			{
				if (IsAlive(item))
				{
					list.Add(PositionOf(item));
				}
			}
			return list;
		}

		internal static Vector3 PartyCentre()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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)
			List<Vector3> list = LivingPlayerPositions();
			if (list.Count == 0)
			{
				foreach (GameplayPlayer item in Players())
				{
					list.Add(PositionOf(item));
				}
			}
			if (list.Count == 0)
			{
				return Vector3.zero;
			}
			Vector3 val = Vector3.zero;
			foreach (Vector3 item2 in list)
			{
				val += item2;
			}
			return val / (float)list.Count;
		}

		internal static GameplayPlayer LocalPlayer()
		{
			foreach (GameplayPlayer item in Players())
			{
				if (((NetworkBehaviour)item).IsOwner)
				{
					return item;
				}
			}
			return null;
		}

		internal static float FlatDistance(Vector3 a, Vector3 b)
		{
			//IL_0000: 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_000d: 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_001a: 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)
			Vector2 val = new Vector2(a.x - b.x, a.z - b.z);
			return ((Vector2)(ref val)).magnitude;
		}

		internal static Vector3 Snap(Vector3 p, float range = 12f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				NavMeshHit val = default(NavMeshHit);
				if (NavMesh.SamplePosition(p, ref val, range, -1))
				{
					return ((NavMeshHit)(ref val)).position;
				}
			}
			catch
			{
			}
			return p;
		}

		internal static bool OnNavMesh(Vector3 p, float range, out Vector3 snapped)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			snapped = p;
			try
			{
				NavMeshHit val = default(NavMeshHit);
				if (NavMesh.SamplePosition(p, ref val, range, -1))
				{
					snapped = ((NavMeshHit)(ref val)).position;
					return true;
				}
			}
			catch
			{
				return true;
			}
			return false;
		}

		internal static Vector3 PointInRing(Vector3 centre, float min, float max)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 12; i++)
			{
				float num = Random.Range(0f, (float)Math.PI * 2f);
				float num2 = Random.Range(min, max);
				if (OnNavMesh(centre + new Vector3(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2), 4f, out var snapped))
				{
					return snapped;
				}
			}
			return Snap(centre + new Vector3(min, 0f, 0f));
		}

		internal static Vector3 ObjectivePoint(Vector3 centre, float min, float max)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			try
			{
				List<Vector3> list = new List<Vector3>();
				foreach (ObjectiveSpawnPoint item in Object.FindObjectsOfType<ObjectiveSpawnPoint>())
				{
					if (!((Object)(object)item == (Object)null))
					{
						float num = FlatDistance(((Component)item).transform.position, centre);
						if (num >= min && num <= max)
						{
							list.Add(((Component)item).transform.position);
						}
					}
				}
				if (list.Count > 0)
				{
					return Snap(list[Random.Range(0, list.Count)]);
				}
			}
			catch
			{
			}
			return PointInRing(centre, min, max);
		}

		internal static NetworkObject Spawn(EnemyType type, Vector3 position)
		{
			//IL_001c: 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_003b: 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)
			EnemySpawner val = Spawner;
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Dictionary<EnemyType, NetworkObject> enemyTypeToPrefab = val.enemyTypeToPrefab;
			if (enemyTypeToPrefab == null || !enemyTypeToPrefab.ContainsKey(type))
			{
				return null;
			}
			NetworkObject val2 = enemyTypeToPrefab[type];
			if ((Object)(object)val2 == (Object)null)
			{
				return null;
			}
			return val.SpawnEnemy(val2, Snap(position), (EnemySpawnRotation)0);
		}

		internal static bool CanSpawn(EnemyType type)
		{
			//IL_0016: 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)
			try
			{
				EnemySpawner obj = Spawner;
				Dictionary<EnemyType, NetworkObject> val = ((obj != null) ? obj.enemyTypeToPrefab : null);
				return val != null && val.ContainsKey(type) && (Object)(object)val[type] != (Object)null;
			}
			catch
			{
				return false;
			}
		}

		internal static void SpawnWaveEnemy(Vector3 position)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EnemySpawner val = Spawner;
				WaveConfiguration val2 = ((val != null) ? val.currentWave : null);
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
				{
					val.SpawnRandomEnemy(val2, Snap(position));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Spawning a wave enemy: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val3);
			}
		}

		internal static Tracked Track(NetworkObject o)
		{
			if ((Object)(object)o == (Object)null)
			{
				return null;
			}
			Tracked tracked = new Tracked
			{
				Obj = o
			};
			try
			{
				tracked.Health = ((Component)o).GetComponentInChildren<EnemyHealthContainer>(true);
			}
			catch
			{
			}
			try
			{
				Enemy componentInChildren = ((Component)o).GetComponentInChildren<Enemy>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.SetOverrideImmuneToDespawning(true);
				}
			}
			catch
			{
			}
			return tracked;
		}

		internal static NetworkObject SpawnTracked(EnemyType type, Vector3 position, out Tracked tracked)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject val = Spawn(type, position);
			tracked = Track(val);
			return val;
		}

		internal static Fate FateOf(Tracked t)
		{
			if (t == null)
			{
				return Fate.Gone;
			}
			if (t.Dead)
			{
				return Fate.Killed;
			}
			try
			{
				if (Alive((Object)(object)t.Health) && ((HealthContainer)t.Health).IsHealthZero())
				{
					t.Dead = true;
					return Fate.Killed;
				}
				if (!Alive((Object)(object)t.Obj) || !t.Obj.IsSpawned)
				{
					return Fate.Gone;
				}
				if (!((Component)t.Obj).gameObject.activeInHierarchy)
				{
					return Fate.Gone;
				}
			}
			catch
			{
				return Fate.Gone;
			}
			return Fate.Alive;
		}

		internal static void Despawn(NetworkObject o)
		{
			try
			{
				if (Alive((Object)(object)o) && o.IsSpawned)
				{
					o.Despawn(true);
				}
			}
			catch
			{
			}
		}

		internal static List<Vector3> EnemyPositions()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			foreach (EnemyHealthContainer item in Object.FindObjectsOfType<EnemyHealthContainer>())
			{
				try
				{
					if ((Object)(object)item != (Object)null && ((Component)item).gameObject.activeInHierarchy && !((HealthContainer)item).IsHealthZero())
					{
						list.Add(((Component)item).transform.position);
					}
				}
				catch
				{
				}
			}
			return list;
		}

		internal static RunConfiguration ConfigFor(RunManager rm, int world)
		{
			return (RunConfiguration)(world switch
			{
				0 => rm.verdantMeadowsConfiguration, 
				1 => rm.frozenAncientsConfiguration, 
				2 => rm.pyrestormPitConfiguration, 
				3 => rm.astralPlanesConfiguration, 
				_ => null, 
			});
		}

		internal static List<(int world, List<EliteEnemyConfiguration> elites)> EliteLists()
		{
			List<(int, List<EliteEnemyConfiguration>)> list = new List<(int, List<EliteEnemyConfiguration>)>();
			RunManager val = Run;
			if ((Object)(object)val == (Object)null)
			{
				return list;
			}
			IntPtr intPtr = IntPtr.Zero;
			try
			{
				RunConfiguration configuration = val.Configuration;
				intPtr = ((configuration != null) ? ((Il2CppObjectBase)configuration).Pointer : IntPtr.Zero);
			}
			catch
			{
			}
			for (int i = 0; i < 4; i++)
			{
				RunConfiguration val2 = ConfigFor(val, i);
				if (((val2 != null) ? val2.EliteEnemies : null) != null && val2.EliteEnemies.Count != 0)
				{
					if (((Il2CppObjectBase)val2).Pointer == intPtr)
					{
						list.Insert(0, (i, val2.EliteEnemies));
					}
					else
					{
						list.Add((i, val2.EliteEnemies));
					}
				}
			}
			return list;
		}

		internal static EnemyType? RandomEliteFrom(List<EliteEnemyConfiguration> list)
		{
			//IL_0021: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 6; i++)
			{
				if (list.Count <= 0)
				{
					break;
				}
				EliteEnemyConfiguration val = list[Random.Range(0, list.Count)];
				if (!((Object)(object)val == (Object)null))
				{
					EnemyType randomEnemy = val.GetRandomEnemy();
					if (CanSpawn(randomEnemy))
					{
						return randomEnemy;
					}
				}
			}
			return null;
		}

		internal static string GiveXp(float percentOfLevel)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//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_0026: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PartyLevelManager val = Party;
				if ((Object)(object)val == (Object)null)
				{
					return "";
				}
				PartyLevelState state = val.GetState();
				float num = Mathf.Max(1f, state.RequiredExperience * percentOfLevel / 100f);
				val.TryAddExperience(num);
				return $"+{Mathf.RoundToInt(percentOfLevel)}% XP";
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(11, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("XP reward: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val2);
				return "";
			}
		}

		internal static string GiveShop(StoreType type)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			try
			{
				StoreManager val = Store;
				if ((Object)(object)val == (Object)null)
				{
					return "";
				}
				val.OfferStoreToAllPlayers(type);
				return ((int)type == 3) ? "Bonus artifact for everyone" : "Bonus upgrade for everyone";
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(13, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Shop reward: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val2);
				return "";
			}
		}

		internal static string GiveRevive()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			try
			{
				ReviveManager val = Revives;
				if (((val != null) ? val.CurrentRevives : null) == null)
				{
					return GiveXp(20f);
				}
				int num = val.CalculateTotalRevives();
				if (num > 0 && val.CurrentRevives.Value >= num)
				{
					return GiveXp(20f) + " (revives full)";
				}
				val.CurrentRevives.Value = val.CurrentRevives.Value + 1;
				return "+1 Revive";
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(15, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Revive reward: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val2);
				return "";
			}
		}
	}
	internal static class HostConfig
	{
		private static ConfigFile cfg;

		private static string messageName;

		private static string[] personal;

		private static Dictionary<string, string> whenHostLacksMod;

		private static Func<bool> active;

		private static HandleNamedMessageDelegate handler;

		private static IntPtr registeredOn;

		private static float nextSend;

		private static float joinedAt;

		private static string lastSent;

		private static string lastApplied;

		private static bool overriding;

		private static bool heardFromHost;

		private static bool warnedMissing;

		private static bool savedFlag;

		private static bool savingPersonal;

		private static readonly Dictionary<ConfigEntryBase, string> originals = new Dictionary<ConfigEntryBase, string>();

		internal static bool FromHost
		{
			get
			{
				if (overriding)
				{
					return heardFromHost;
				}
				return false;
			}
		}

		internal static void Init(BasePlugin plugin, string guid, string[] personalKeys, Dictionary<string, string> offWithoutHost, Func<bool> isActive = null)
		{
			cfg = plugin.Config;
			messageName = guid + ".HostConfig";
			personal = personalKeys ?? Array.Empty<string>();
			whenHostLacksMod = offWithoutHost ?? new Dictionary<string, string>();
			active = isActive;
			cfg.SettingChanged += OnSettingChanged;
			plugin.AddComponent<HostConfigRunner>();
		}

		private static void OnSettingChanged(object sender, SettingChangedEventArgs e)
		{
			try
			{
				if (overriding && !savingPersonal && IsPersonal(e.ChangedSetting.Definition))
				{
					SavePersonal();
				}
			}
			catch
			{
			}
		}

		private static string Id(ConfigDefinition d)
		{
			return d.Section + "." + d.Key;
		}

		private static bool IsPersonal(ConfigDefinition d)
		{
			string[] array = personal;
			foreach (string text in array)
			{
				if (text.EndsWith(".*") ? (d.Section == text.Substring(0, text.Length - 2)) : (Id(d) == text))
				{
					return true;
				}
			}
			return false;
		}

		internal static void Tick()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			try
			{
				NetworkManager singleton = NetworkManager.Singleton;
				bool flag = (Object)(object)singleton != (Object)null && singleton.IsListening;
				if (!flag || singleton.IsServer || (active != null && !active()))
				{
					if (overriding)
					{
						Restore();
					}
					if (flag && singleton.IsServer)
					{
						HostTick(singleton);
					}
					if (!flag)
					{
						registeredOn = IntPtr.Zero;
					}
				}
				else
				{
					ClientTick(singleton);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag2 = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(15, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Host settings: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogError(val);
			}
		}

		private static void HostTick(NetworkManager nm)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime < nextSend || nm.CustomMessagingManager == null)
			{
				return;
			}
			nextSend = Time.unscaledTime + 1.5f;
			List<string> list = new List<string>();
			foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in cfg)
			{
				if (!IsPersonal(item.Key))
				{
					list.Add(item.Key.Section + "\u001f" + item.Key.Key + "\u001f" + item.Value.GetSerializedValue());
				}
			}
			string text = string.Join("\u001e", list);
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(text.Length * 2 + 64, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
				nm.CustomMessagingManager.SendNamedMessageToAll(messageName, val, (NetworkDelivery)4);
			}
			finally
			{
				((FastBufferWriter)(ref val)).Dispose();
			}
			if (text != lastSent)
			{
				lastSent = text;
				Plugin.Log.LogInfo((object)"Sending this game's settings to all players.");
			}
		}

		private static void ClientTick(NetworkManager nm)
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			CustomMessagingManager customMessagingManager = nm.CustomMessagingManager;
			if (customMessagingManager != null && registeredOn != ((Il2CppObjectBase)customMessagingManager).Pointer)
			{
				if (handler == null)
				{
					handler = DelegateSupport.ConvertDelegate<HandleNamedMessageDelegate>((Delegate)new Action<ulong, FastBufferReader>(OnReceived));
				}
				customMessagingManager.RegisterNamedMessageHandler(messageName, handler);
				registeredOn = ((Il2CppObjectBase)customMessagingManager).Pointer;
			}
			if (!overriding)
			{
				Begin();
				joinedAt = Time.unscaledTime;
				foreach (KeyValuePair<string, string> item in whenHostLacksMod)
				{
					Set(item.Key, item.Value);
				}
			}
			if (!heardFromHost && !warnedMissing && Time.unscaledTime - joinedAt > 15f)
			{
				warnedMissing = true;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(88, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No settings from the host: the host doesn't seem to have ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MoreEvents");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", so it stays off in this game.");
				}
				log.LogWarning(val);
			}
		}

		private static void OnReceived(ulong sender, FastBufferReader reader)
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				string text = default(string);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
				if (!overriding)
				{
					Begin();
				}
				heardFromHost = true;
				if (text == lastApplied)
				{
					return;
				}
				lastApplied = text;
				int num = 0;
				string[] array = text.Split('\u001e');
				for (int i = 0; i < array.Length; i++)
				{
					string[] array2 = array[i].Split('\u001f');
					if (array2.Length == 3)
					{
						ConfigDefinition d = new ConfigDefinition(array2[0], array2[1]);
						if (!IsPersonal(d) && Set(Id(d), array2[2]))
						{
							num++;
						}
					}
				}
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Using the host's settings (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" values).");
				}
				log.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Host settings (receive): ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log2.LogError(val2);
			}
		}

		private static void Begin()
		{
			overriding = true;
			heardFromHost = false;
			warnedMissing = false;
			lastApplied = null;
			savedFlag = cfg.SaveOnConfigSet;
			cfg.SaveOnConfigSet = false;
		}

		private static bool Set(string id, string value)
		{
			foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in cfg)
			{
				if (!(Id(item.Key) != id))
				{
					ConfigEntryBase value2 = item.Value;
					if (!originals.ContainsKey(value2))
					{
						originals[value2] = value2.GetSerializedValue();
					}
					if (value2.GetSerializedValue() != value)
					{
						value2.SetSerializedValue(value);
					}
					return true;
				}
			}
			return false;
		}

		private static void SavePersonal()
		{
			savingPersonal = true;
			Dictionary<ConfigEntryBase, string> dictionary = new Dictionary<ConfigEntryBase, string>();
			try
			{
				foreach (KeyValuePair<ConfigEntryBase, string> original in originals)
				{
					dictionary[original.Key] = original.Key.GetSerializedValue();
					original.Key.SetSerializedValue(original.Value);
				}
				cfg.Save();
			}
			finally
			{
				foreach (KeyValuePair<ConfigEntryBase, string> item in dictionary)
				{
					try
					{
						item.Key.SetSerializedValue(item.Value);
					}
					catch
					{
					}
				}
				savingPersonal = false;
			}
		}

		private static void Restore()
		{
			foreach (KeyValuePair<ConfigEntryBase, string> original in originals)
			{
				try
				{
					original.Key.SetSerializedValue(original.Value);
				}
				catch
				{
				}
			}
			originals.Clear();
			overriding = false;
			heardFromHost = false;
			lastApplied = null;
			cfg.SaveOnConfigSet = savedFlag;
			try
			{
				cfg.Save();
			}
			catch
			{
			}
			Plugin.Log.LogInfo((object)"Left the game; back to this computer's own settings.");
		}
	}
	public class HostConfigRunner : MonoBehaviour
	{
		public HostConfigRunner(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Update()
		{
			HostConfig.Tick();
		}
	}
	public class Hud : MonoBehaviour
	{
		private const float BannerWidth = 600f;

		private const float ResultSeconds = 6f;

		private const float StaleSeconds = 3f;

		private GameObject bannerCanvas;

		private GameObject worldCanvas;

		private GameObject panel;

		private RectTransform panelRt;

		private RectTransform barBg;

		private RectTransform barFill;

		private TextMeshProUGUI title;

		private TextMeshProUGUI timer;

		private TextMeshProUGUI line;

		private Image accentLine;

		private readonly List<Image> segments = new List<Image>();

		private readonly List<Image> icons = new List<Image>();

		private int segUsed;

		private int iconUsed;

		private int segShown;

		private int iconShown;

		private float nextDamage;

		private float nextErrorLog;

		private bool outsideSafe;

		private const int CircleSteps = 48;

		private readonly Vector3[] pts = (Vector3[])(object)new Vector3[49];

		public Hud(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Update()
		{
			try
			{
				Net.Tick();
				Director.Tick();
				CursedDamage();
			}
			catch (Exception ex)
			{
				LogOnce(ex);
			}
		}

		private void LateUpdate()
		{
			try
			{
				Draw();
			}
			catch (Exception ex)
			{
				LogOnce(ex);
			}
		}

		private void LogOnce(Exception ex)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			if (!(Time.unscaledTime < nextErrorLog))
			{
				nextErrorLog = Time.unscaledTime + 10f;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(8, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Events: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private static EventState Visible()
		{
			EventState current = Net.Current;
			if (current == null || !Game.Listening)
			{
				return null;
			}
			float num = Time.unscaledTime - Net.ReceivedAt;
			if (current.Phase == 0 && num > 3f)
			{
				return null;
			}
			if (current.Phase != 0 && num > 6f)
			{
				return null;
			}
			return current;
		}

		private void CursedDamage()
		{
			//IL_0089: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			outsideSafe = false;
			EventState eventState = Visible();
			if (eventState == null || eventState.Phase != 0)
			{
				return;
			}
			Marker marker = null;
			foreach (Marker marker2 in eventState.Markers)
			{
				if (marker2.Kind == MarkerKind.Safe)
				{
					marker = marker2;
					break;
				}
			}
			if (marker == null)
			{
				return;
			}
			GameplayPlayer val = Game.LocalPlayer();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			PlayerHealthContainer val2 = Game.HealthOf(val);
			if ((Object)(object)val2 == (Object)null || ((HealthContainer)val2).IsHealthZero() || Game.FlatDistance(Game.PositionOf(val), marker.Pos) <= marker.Radius)
			{
				return;
			}
			outsideSafe = true;
			if (Time.time < nextDamage)
			{
				return;
			}
			nextDamage = Time.time + 0.5f;
			float num = ((HealthContainer)val2).MaxHealth * marker.Dps / 100f * 0.5f;
			if (!(num <= 0f))
			{
				TakeDamageOnLevelUpCurseDamageInfo val3 = new TakeDamageOnLevelUpCurseDamageInfo();
				try
				{
					((DamageInfo)val3).Damage = num;
				}
				catch
				{
				}
				((HealthContainer)val2).RemoveHealth(num, (DamageInfo)(object)val3, false);
			}
		}

		private void Draw()
		{
			segUsed = (iconUsed = 0);
			EventState eventState = Visible();
			if (eventState == null)
			{
				if ((Object)(object)panel != (Object)null && panel.activeSelf)
				{
					panel.SetActive(false);
				}
				HideUnused();
			}
			else if (Build())
			{
				DrawBanner(eventState);
				Camera main = Camera.main;
				if ((Object)(object)main != (Object)null && eventState.Phase == 0)
				{
					DrawMarkers(eventState, main);
				}
				HideUnused();
			}
		}

		private void DrawBanner(EventState s)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: 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_0244: Unknown result type (might be due to invalid IL or missing references)
			if (!panel.activeSelf)
			{
				panel.SetActive(true);
			}
			Color color = (Color)((s.Phase == 1) ? new Color(0.45f, 1f, 0.45f) : ((s.Phase == 2) ? new Color(1f, 0.35f, 0.3f) : s.Accent));
			((Graphic)title).color = color;
			((Graphic)accentLine).color = color;
			if (s.Phase == 0)
			{
				((TMP_Text)title).text = s.Title.ToUpperInvariant();
				((TMP_Text)line).text = (outsideSafe ? "<color=#FF6060>Outside the safe circle! Get back in!</color>" : s.Line);
				((TMP_Text)timer).text = ((s.Timer >= 0f) ? $"{(int)(s.Timer / 60f)}:{(int)(s.Timer % 60f):00}" : "");
				((Graphic)timer).color = (Color)((s.Timer >= 0f && s.Timer < 10f) ? new Color(1f, 0.4f, 0.35f) : Color.white);
			}
			else
			{
				((TMP_Text)title).text = s.Title.ToUpperInvariant() + ((s.Phase == 1) ? "  COMPLETE!" : "  FAILED");
				((TMP_Text)line).text = s.Result;
				((TMP_Text)timer).text = "";
			}
			bool flag = s.Phase == 0 && s.Progress >= 0f;
			((Component)barBg).gameObject.SetActive(flag);
			if (flag)
			{
				barFill.sizeDelta = new Vector2((barBg.sizeDelta.x - 4f) * Mathf.Clamp01(s.Progress), barBg.sizeDelta.y - 4f);
			}
			panelRt.sizeDelta = new Vector2(600f, flag ? 104f : 84f);
		}

		private void DrawMarkers(EventState s, Camera cam)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(0.6f, (float)Screen.height / 1080f);
			Dictionary<ulong, NetworkObject> val = null;
			bool flag = false;
			foreach (Marker marker in s.Markers)
			{
				NetworkObject val2;
				switch (marker.Kind)
				{
				case MarkerKind.Ring:
					Circle(cam, marker.Pos, marker.Radius, marker.Color, 3f * num);
					if (!string.IsNullOrEmpty(marker.Icon))
					{
						Icon(cam, marker.Pos + Vector3.up * 2.5f, marker.Icon, marker.Color, num);
					}
					break;
				case MarkerKind.Safe:
					Circle(cam, marker.Pos, marker.Radius, marker.Color, 5f * num);
					Circle(cam, marker.Pos, marker.Radius + 0.6f, new Color(marker.Color.r, marker.Color.g, marker.Color.b, 0.35f), 3f * num);
					break;
				case MarkerKind.Icon:
					Icon(cam, marker.Pos, marker.Icon, marker.Color, num);
					break;
				case MarkerKind.Follow:
					{
						if (!flag)
						{
							flag = true;
							try
							{
								NetworkManager singleton = NetworkManager.Singleton;
								object obj;
								if (singleton == null)
								{
									obj = null;
								}
								else
								{
									NetworkSpawnManager spawnManager = singleton.SpawnManager;
									obj = ((spawnManager != null) ? spawnManager.SpawnedObjects : null);
								}
								val = (Dictionary<ulong, NetworkObject>)obj;
							}
							catch
							{
							}
						}
						val2 = null;
						try
						{
							if (val == null || !val.TryGetValue(marker.NetId, ref val2))
							{
								break;
							}
							goto IL_01a4;
						}
						catch
						{
						}
						break;
					}
					IL_01a4:
					if (Game.Alive((Object)(object)val2))
					{
						Vector3 position = ((Component)val2).transform.position;
						if (marker.Radius > 0f)
						{
							Circle(cam, position, marker.Radius, marker.Color, 3f * num);
						}
						Icon(cam, position + Vector3.up * 3.2f, marker.Icon, marker.Color, num);
					}
					break;
				}
			}
		}

		private void Circle(Camera cam, Vector3 centre, float radius, Color color, float thickness)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: 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)
			Vector3 val = cam.WorldToScreenPoint(centre);
			Vector3 val2 = cam.WorldToScreenPoint(centre + new Vector3(radius, 0f, 0f));
			Vector2 val3 = new Vector2(val2.x - val.x, val2.y - val.y);
			int num = Mathf.Clamp(Mathf.RoundToInt(((Vector2)(ref val3)).magnitude * (float)Math.PI * 2f / 18f), 12, 48);
			for (int i = 0; i <= num; i++)
			{
				float num2 = (float)i * (float)Math.PI * 2f / (float)num;
				pts[i] = cam.WorldToScreenPoint(centre + new Vector3(Mathf.Cos(num2) * radius, 0.15f, Mathf.Sin(num2) * radius));
			}
			Vector2 val6 = default(Vector2);
			for (int j = 0; j < num; j++)
			{
				Vector3 val4 = pts[j];
				Vector3 val5 = pts[j + 1];
				if (!(val4.z <= 0f) && !(val5.z <= 0f) && (!Offscreen(val4) || !Offscreen(val5)))
				{
					Image obj = Segment();
					RectTransform rectTransform = ((Graphic)obj).rectTransform;
					((Vector2)(ref val6))..ctor(val5.x - val4.x, val5.y - val4.y);
					rectTransform.anchoredPosition = new Vector2((val4.x + val5.x) * 0.5f, (val4.y + val5.y) * 0.5f);
					rectTransform.sizeDelta = new Vector2(((Vector2)(ref val6)).magnitude + thickness * 0.5f, thickness);
					((Transform)rectTransform).localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(val6.y, val6.x) * 57.29578f);
					((Graphic)obj).color = color;
				}
			}
		}

		private static bool Offscreen(Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			if (!(p.x < -50f) && !(p.y < -50f) && !(p.x > (float)Screen.width + 50f))
			{
				return p.y > (float)Screen.height + 50f;
			}
			return true;
		}

		private void Icon(Camera cam, Vector3 world, string name, Color color, float ui)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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)
			Sprite val = Icons.Get(name);
			if (!((Object)(object)val == (Object)null))
			{
				Vector3 val2 = cam.WorldToScreenPoint(world);
				bool num = val2.z < 0f;
				if (num)
				{
					val2.x = (float)Screen.width - val2.x;
					val2.y = (float)Screen.height - val2.y;
				}
				float num2 = 40f * ui;
				bool flag = num || val2.x < num2 || val2.y < num2 || val2.x > (float)Screen.width - num2 || val2.y > (float)Screen.height - num2;
				val2.x = Mathf.Clamp(val2.x, num2, (float)Screen.width - num2);
				val2.y = Mathf.Clamp(val2.y, num2, (float)Screen.height - num2);
				Image obj = IconImage();
				obj.sprite = val;
				((Graphic)obj).color = (Color)(flag ? new Color(color.r, color.g, color.b, 0.75f) : color);
				RectTransform rectTransform = ((Graphic)obj).rectTransform;
				rectTransform.anchoredPosition = new Vector2(val2.x, val2.y);
				float num3 = (flag ? 30f : 38f) * ui;
				Rect rect = val.rect;
				float num4 = num3 * ((Rect)(ref rect)).height;
				rect = val.rect;
				rectTransform.sizeDelta = new Vector2(num3, num4 / ((Rect)(ref rect)).width);
			}
		}

		private Image Segment()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_008b: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			if (segUsed < segments.Count)
			{
				Image val = segments[segUsed];
				if (segUsed >= segShown)
				{
					((Component)val).gameObject.SetActive(true);
				}
				segUsed++;
				return val;
			}
			GameObject val2 = new GameObject("Seg");
			val2.transform.SetParent(worldCanvas.transform, false);
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).raycastTarget = false;
			RectTransform rectTransform = ((Graphic)val3).rectTransform;
			Vector2 anchorMin = (rectTransform.anchorMax = Vector2.zero);
			rectTransform.anchorMin = anchorMin;
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			segments.Add(val3);
			segUsed++;
			return val3;
		}

		private Image IconImage()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			if (iconUsed < icons.Count)
			{
				Image val = icons[iconUsed];
				if (iconUsed >= iconShown)
				{
					((Component)val).gameObject.SetActive(true);
				}
				iconUsed++;
				((Component)val).transform.SetAsLastSibling();
				return val;
			}
			GameObject val2 = new GameObject("Icon");
			val2.transform.SetParent(worldCanvas.transform, false);
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).raycastTarget = false;
			val3.preserveAspect = true;
			RectTransform rectTransform = ((Graphic)val3).rectTransform;
			Vector2 anchorMin = (rectTransform.anchorMax = Vector2.zero);
			rectTransform.anchorMin = anchorMin;
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			icons.Add(val3);
			iconUsed++;
			return val3;
		}

		private void HideUnused()
		{
			for (int i = segUsed; i < segShown && i < segments.Count; i++)
			{
				if ((Object)(object)segments[i] != (Object)null)
				{
					((Component)segments[i]).gameObject.SetActive(false);
				}
			}
			for (int j = iconUsed; j < iconShown && j < icons.Count; j++)
			{
				if ((Object)(object)icons[j] != (Object)null)
				{
					((Component)icons[j]).gameObject.SetActive(false);
				}
			}
			segShown = segUsed;
			iconShown = iconUsed;
		}

		private bool Build()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: 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_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			if (Game.Alive((Object)(object)panel) && Game.Alive((Object)(object)worldCanvas))
			{
				return true;
			}
			TMP_FontAsset val = null;
			try
			{
				TextMeshProUGUI val2 = Object.FindObjectOfType<TextMeshProUGUI>();
				if ((Object)(object)val2 != (Object)null)
				{
					val = ((TMP_Text)val2).font;
				}
				if ((Object)(object)val == (Object)null)
				{
					val = TMP_Settings.defaultFontAsset;
				}
			}
			catch
			{
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			segments.Clear();
			icons.Clear();
			segShown = (iconShown = 0);
			worldCanvas = new GameObject("MoreEvents_World");
			Object.DontDestroyOnLoad((Object)(object)worldCanvas);
			Canvas obj2 = worldCanvas.AddComponent<Canvas>();
			obj2.renderMode = (RenderMode)0;
			obj2.sortingOrder = -1;
			bannerCanvas = new GameObject("MoreEvents_Banner");
			Object.DontDestroyOnLoad((Object)(object)bannerCanvas);
			Canvas obj3 = bannerCanvas.AddComponent<Canvas>();
			obj3.renderMode = (RenderMode)0;
			obj3.sortingOrder = 450;
			CanvasScaler obj4 = bannerCanvas.AddComponent<CanvasScaler>();
			obj4.uiScaleMode = (ScaleMode)1;
			obj4.referenceResolution = new Vector2(1920f, 1080f);
			obj4.matchWidthOrHeight = 0.5f;
			panel = new GameObject("Panel");
			panelRt = panel.AddComponent<RectTransform>();
			panel.transform.SetParent(bannerCanvas.transform, false);
			RectTransform obj5 = panelRt;
			RectTransform obj6 = panelRt;
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(0.5f, 1f);
			obj6.anchorMax = val3;
			obj5.anchorMin = val3;
			panelRt.pivot = new Vector2(0.5f, 1f);
			panelRt.anchoredPosition = new Vector2(0f, -200f);
			panelRt.sizeDelta = new Vector2(600f, 104f);
			Image obj7 = panel.AddComponent<Image>();
			((Graphic)obj7).color = new Color(0.06f, 0.04f, 0.12f, 0.78f);
			((Graphic)obj7).raycastTarget = false;
			accentLine = Child<Image>("Accent", panel.transform, new Vector2(0f, 0f), new Vector2(600f, 3f), new Vector2(0.5f, 1f));
			((Graphic)accentLine).raycastTarget = false;
			title = Text("Title", val, 26f, (FontStyles)1, new Vector2(0f, -8f), new Vector2(480f, 34f), (TextAlignmentOptions)514);
			timer = Text("Timer", val, 24f, (FontStyles)1, new Vector2(250f, -9f), new Vector2(90f, 32f), (TextAlignmentOptions)516);
			line = Text("Line", val, 18f, (FontStyles)0, new Vector2(0f, -44f), new Vector2(570f, 26f), (TextAlignmentOptions)514);
			barBg = ((Graphic)Child<Image>("Bar", panel.transform, new Vector2(0f, -76f), new Vector2(460f, 14f), new Vector2(0.5f, 1f))).rectTransform;
			((Graphic)((Component)barBg).GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.6f);
			Image val4 = Child<Image>("Fill", (Transform)(object)barBg, new Vector2(2f, -2f), new Vector2(0f, 10f), new Vector2(0f, 1f));
			((Graphic)val4).color = new Color(1f, 0.85f, 0.35f, 0.95f);
			barFill = ((Graphic)val4).rectTransform;
			RectTransform obj8 = barFill;
			RectTransform obj9 = barFill;
			((Vector2)(ref val3))..ctor(0f, 1f);
			obj9.anchorMax = val3;
			obj8.anchorMin = val3;
			panel.SetActive(false);
			return true;
		}

		private static T Child<T>(string name, Transform parent, Vector2 pos, Vector2 size, Vector2 anchor) where T : Component
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val.transform.SetParent(parent, false);
			Vector2 anchorMin = (val2.anchorMax = anchor);
			val2.anchorMin = anchorMin;
			val2.pivot = new Vector2(anchor.x, 1f);
			val2.anchoredPosition = pos;
			val2.sizeDelta = size;
			T val4 = val.AddComponent<T>();
			object obj = val4;
			Graphic val5 = (Graphic)((obj is Graphic) ? obj : null);
			if (val5 != null)
			{
				val5.raycastTarget = false;
			}
			return val4;
		}

		private TextMeshProUGUI Text(string name, TMP_FontAsset font, float size, FontStyles style, Vector2 pos, Vector2 box, TextAlignmentOptions align)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = Child<TextMeshProUGUI>(name, panel.transform, pos, box, new Vector2(0.5f, 1f));
			((TMP_Text)obj).font = font;
			((TMP_Text)obj).fontSize = size;
			((TMP_Text)obj).fontStyle = style;
			((TMP_Text)obj).alignment = align;
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			((TMP_Text)obj).richText = true;
			((Graphic)obj).color = Color.white;
			((TMP_Text)obj).outlineWidth = 0.15f;
			((TMP_Text)obj).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)200);
			return obj;
		}
	}
	internal static class Icons
	{
		private static readonly Dictionary<string, string[]> Art = new Dictionary<string, string[]>
		{
			["skull"] = new string[11]
			{
				"..XXXXXXXX..", ".XXXXXXXXXX.", "XXXXXXXXXXXX", "XX..XXXX..XX", "XX..XXXX..XX", "XXXXXXXXXXXX", "XXXXX..XXXXX", ".XXXXXXXXXX.", "..XXXXXXXX..", "..X.X..X.X..",
				"..XXXXXXXX.."
			},
			["crown"] = new string[7] { "X....XX....X", "XX..XXXX..XX", "XXX.XXXX.XXX", "XXXXXXXXXXXX", "XXXXXXXXXXXX", ".XXXXXXXXXX.", ".XXXXXXXXXX." },
			["crab"] = new string[9] { "XX........XX", "X.X......X.X", ".XX......XX.", "..X.XXXX.X..", "...XXXXXX...", "..XXXXXXXX..", ".XXXXXXXXXX.", ".X.X.XX.X.X.", "X..X....X..X" },
			["mushroom"] = new string[9] { "...XXXXXX...", ".XXX..XXXXX.", "XXXXXXXX..XX", "XX..XXXXXXXX", "XXXXXXXXXXXX", "....XXXX....", "....XXXX....", "....XXXX....", "...XXXXXX..." },
			["flag"] = new string[9] { "XXXXXXXX....", "XXXXXXXXXX..", "XXXXXXXXXXXX", "XXXXXXXXXX..", "XXXXXXXX....", "X...........", "X...........", "X...........", "X..........." },
			["sword"] = new string[11]
			{
				"..........XX", ".........XXX", "........XXX.", ".......XXX..", "......XXX...", ".X...XXX....", "..X.XXX.....", "...XXX......", "...XX.......", "..X..X......",
				".X.........."
			}
		};

		private static readonly Dictionary<string, Sprite> cache = new Dictionary<string, Sprite>();

		internal static Sprite Get(string name)
		{
			//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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_018d: 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_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_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)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(name) || !Art.ContainsKey(name))
			{
				return null;
			}
			if (cache.TryGetValue(name, out var value) && (Object)(object)value != (Object)null && !((Il2CppObjectBase)value).WasCollected)
			{
				return value;
			}
			string[] rows = Art[name];
			int h = rows.Length;
			int w = rows[0].Length;
			int num = w + 2;
			int num2 = h + 2;
			Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.05f, 0.03f, 0.08f, 1f);
			for (int i = 0; i < num2; i++)
			{
				for (int j = 0; j < num; j++)
				{
					int num3 = j - 1;
					in