Decompiled source of VoidBreach v0.1.1

plugins/VoidBreach.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CG;
using CG.Client.Audio;
using CG.Client.Ship.Interactions;
using CG.Game;
using CG.Game.Missions;
using CG.Game.Player;
using CG.Game.Scenarios;
using CG.Game.Scenarios.Actions;
using CG.Game.Scenarios.Conditions;
using CG.Space;
using Client.Player.Interactions;
using FMOD;
using FMOD.Studio;
using FMODUnity;
using Gameplay.Atmosphere;
using Gameplay.Damage;
using Gameplay.Quests;
using Gameplay.SpacePlatforms;
using Gameplay.Utilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Opsive.UltimateCharacterController.Character;
using Photon.Pun;
using Photon.Realtime;
using ResourceAssets;
using RuntimeAssets;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using VoidBreach.Compat;
using VoidBreach.Hive;
using VoidBreach.Mission;
using VoidGuns;
using VoidManager;
using VoidManager.Chat.Router;
using VoidManager.MPModChecks;
using VoidManager.ModMessages;
using VoidManager.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("NeoLorem")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Board and fight through generated HOLLOW hive ships (Void Crew).")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1")]
[assembly: AssemblyProduct("VoidBreach")]
[assembly: AssemblyTitle("VoidBreach")]
[assembly: AssemblyVersion("0.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace VoidBreach
{
	public class BreachCommand : ChatCommand
	{
		public override string[] CommandAliases()
		{
			return new string[1] { "breach" };
		}

		public override string Description()
		{
			return "Void Breach: test, tp, warden, info, clear, mission";
		}

		public override string[] UsageExamples()
		{
			return new string[11]
			{
				"/breach test", "/breach test 1234", "/breach test basic", "/breach tp", "/breach tp out", "/breach tp core", "/breach warden", "/breach warden hp 20", "/breach info", "/breach clear",
				"/breach mission"
			};
		}

		public override void Execute(string arguments)
		{
			string[] array = (arguments ?? string.Empty).Trim().ToLowerInvariant().Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			string text = ((array.Length != 0) ? array[0] : string.Empty);
			if (!Plugin.TestCommands.Value && text != "info" && text != "mission")
			{
				Messaging.Echo("/breach " + text + ": test commands are off ([Debug] TestCommands); use info or mission", true);
				return;
			}
			Messaging.Echo("/breach " + text + ": " + text switch
			{
				"test" => TestHive.Build((array.Length > 1) ? array[1] : null), 
				"tp" => TestHive.Teleport((array.Length > 1) ? array[1] : null), 
				"warden" => (array.Length > 2 && array[1] == "hp" && float.TryParse(array[2].TrimEnd(new char[1] { '%' }), out var result)) ? TestHive.WardenHealth(result) : TestHive.Warden(), 
				"info" => TestHive.Info(), 
				"clear" => TestHive.Clear(), 
				"mission" => HiveMission.Status(), 
				_ => "use test, tp, warden, info, clear or mission", 
			}, true);
		}
	}
	internal static class ConfigUpgrade
	{
		public static void Raise<T>(ConfigEntry<T> entry, T earlierDefault)
		{
			if (EqualityComparer<T>.Default.Equals(entry.Value, earlierDefault) && !EqualityComparer<T>.Default.Equals(entry.Value, (T)((ConfigEntryBase)entry).DefaultValue))
			{
				entry.Value = (T)((ConfigEntryBase)entry).DefaultValue;
			}
		}
	}
	internal static class MyPluginInfo
	{
		public const string GUID = "VoidBreach";

		public const string Name = "Void Breach";

		public const string Version = "0.1.1";
	}
	[BepInPlugin("VoidBreach", "Void Breach", "0.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static Plugin Instance;

		internal static string PluginDir;

		internal static ConfigEntry<bool> HollowStyle;

		internal static ConfigEntry<Color> HullTint;

		internal static ConfigEntry<Color> GlowColor;

		internal static ConfigEntry<float> ScreenGlow;

		internal static ConfigEntry<float> LightLumens;

		internal static ConfigEntry<float> TestDistance;

		internal static ConfigEntry<bool> Breathable;

		internal static ConfigEntry<float> RackYaw;

		internal static ConfigEntry<string> BaseObjective;

		internal static ConfigEntry<int> MissionWeight;

		internal static ConfigEntry<float> MissionDistance;

		internal static ConfigEntry<int> Decks;

		internal static ConfigEntry<int> CellsPerDeck;

		internal static ConfigEntry<int> HiveRadius;

		internal static ConfigEntry<float> ShaftSwimSpeed;

		internal static ConfigEntry<float> SwimSpeed;

		internal static ConfigEntry<int> ZeroGSize;

		internal static ConfigEntry<int> Relays;

		internal static ConfigEntry<Key> RelayKey;

		internal static ConfigEntry<float> RelayHoldTime;

		internal static ConfigEntry<float> DoorRange;

		internal static ConfigEntry<bool> EnemiesEnabled;

		internal static ConfigEntry<int> RoomMin;

		internal static ConfigEntry<int> RoomMax;

		internal static ConfigEntry<float> HallChance;

		internal static ConfigEntry<int> WaveSize;

		internal static ConfigEntry<float> PerExtraPlayer;

		internal static ConfigEntry<float> WakeRange;

		internal static ConfigEntry<float> Amount;

		internal static ConfigEntry<int> Turrets;

		internal static ConfigEntry<float> WardenPerExtraPlayer;

		internal static ConfigEntry<float> WardenResetDelay;

		internal static ConfigEntry<float> MusicVolume;

		internal static ConfigEntry<float> MusicAmbientVolume;

		internal static ConfigEntry<float> MusicActionVolume;

		internal static ConfigEntry<float> MusicFadeTime;

		internal static ConfigEntry<float> SelfDestructTime;

		internal static ConfigEntry<float> CalamityBonus;

		internal static ConfigEntry<bool> TestCommands;

		internal static ConfigEntry<int> VaultAlloys;

		internal static ConfigEntry<int> VaultGuns;

		private void Update()
		{
			TestHive.Update();
			HiveSector.Update();
			DronesCompat.Update();
			HiveMusic.Update();
		}

		private void OnGUI()
		{
			HivePower.Draw();
			HiveArena.Draw();
			HiveSelfDestruct.Draw();
		}

		private void Awake()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Expected O, but got Unknown
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Expected O, but got Unknown
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Expected O, but got Unknown
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Expected O, but got Unknown
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Expected O, but got Unknown
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Expected O, but got Unknown
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Expected O, but got Unknown
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Expected O, but got Unknown
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Expected O, but got Unknown
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05df: Expected O, but got Unknown
			//IL_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_061c: Expected O, but got Unknown
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Expected O, but got Unknown
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Expected O, but got Unknown
			//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ce: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			HollowStyle = ((BaseUnityPlugin)this).Config.Bind<bool>("Look", "HollowStyle", true, "Hive interiors in the HOLLOW colours: dark walls, purple screens and lights (else the kit's own colours). Applies to hives built after the change.");
			HullTint = ((BaseUnityPlugin)this).Config.Bind<Color>("Look", "HullTint", new Color(0.32f, 0.3f, 0.36f, 1f), "Multiplies the walls' colours in the HOLLOW style (dark: black).");
			GlowColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Look", "GlowColor", new Color(0.62f, 0.16f, 1f, 1f), "The HOLLOW glow: screens and lights.");
			ScreenGlow = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "ScreenGlow", 1.6f, "Brightness of the glowing screens and light strips.");
			LightLumens = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "LightLumens", 2400f, "Brightness of each hall's light (lumens).");
			Breathable = ((BaseUnityPlugin)this).Config.Bind<bool>("Hive", "Breathable", true, "Hive rooms have air like the ship's: your suit stops using its tank and refills it. Applies to hives built after the change.");
			Decks = ((BaseUnityPlugin)this).Config.Bind<int>("Hive", "Decks", 3, new ConfigDescription("Decks in a generated hive (8 m apart, joined by zero-g ladder shafts). Everyone in a session needs the same value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
			CellsPerDeck = ((BaseUnityPlugin)this).Config.Bind<int>("Hive", "CellsPerDeck", 20, new ConfigDescription("About how many 8 m cells each deck grows to. Everyone in a session needs the same value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(6, 60), Array.Empty<object>()));
			HiveRadius = ((BaseUnityPlugin)this).Config.Bind<int>("Hive", "Radius", 4, new ConfigDescription("How far a deck may spread, in 8 m cells to each side (and twice that forward). Everyone in a session needs the same value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 10), Array.Empty<object>()));
			ShaftSwimSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Hive", "ShaftSwimSpeed", 8f, new ConfigDescription("Inside a hive without a jetpack, floating up and down (the ladder shafts) is this many times the game's zero-g speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			ConfigUpgrade.Raise(ShaftSwimSpeed, 4f);
			ZeroGSize = ((BaseUnityPlugin)this).Config.Bind<int>("Hive", "ZeroGSize", 6, new ConfigDescription("Pieces in the hive's damaged section, where the gravity is out until its relay is restored (0: none). Everyone in a session needs the same value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>()));
			SwimSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Hive", "SwimSpeed", 4f, new ConfigDescription("Inside a hive without a jetpack, floating in every other direction (forward, back, sideways) is this many times the game's zero-g speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			ConfigUpgrade.Raise(SwimSpeed, 2f);
			Relays = ((BaseUnityPlugin)this).Config.Bind<int>("Power", "Relays", 2, new ConfigDescription("Power relays in a hive: all of them must be restored before the core's door opens. Everyone in a session needs the same value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 6), Array.Empty<object>()));
			RelayKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Power", "Key", (Key)21, "Key held at a relay to restore its power.");
			RelayHoldTime = ((BaseUnityPlugin)this).Config.Bind<float>("Power", "HoldTime", 4f, "Seconds to hold the key at a relay.");
			EnemiesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Enabled", true, "Hives are defended by Void Guns' HOLLOW enemies (the host's setting decides).");
			RoomMin = ((BaseUnityPlugin)this).Config.Bind<int>("Enemies", "RoomMin", 1, new ConfigDescription("Fewest defenders in a room (solo).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 6), Array.Empty<object>()));
			RoomMax = ((BaseUnityPlugin)this).Config.Bind<int>("Enemies", "RoomMax", 3, new ConfigDescription("Most defenders in a room (solo).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()));
			HallChance = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "HallChance", 0.2f, new ConfigDescription("Chance a hall piece has a patrol of one.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			WaveSize = ((BaseUnityPlugin)this).Config.Bind<int>("Enemies", "WaveSize", 3, new ConfigDescription("Reinforcements when a relay is restored (solo).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
			PerExtraPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "PerExtraPlayer", 0.5f, "Extra share of enemies for each player after the first (0.5 = +50%).");
			Turrets = ((BaseUnityPlugin)this).Config.Bind<int>("Hull", "Turrets", 5, new ConfigDescription("HOLLOW turrets round a hive's hull. They shoot players on EVA, the ship and drones, and can be destroyed (no drops). Their stats are Void Guns' [HOLLOW Turret] settings. Applies to hives built after the change.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()));
			Amount = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "Amount", 0.85f, new ConfigDescription("All hive enemies (rooms, halls, waves) times this; not the core's guards. 0.85 = 15% fewer (user, 2026-10-29).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			WardenPerExtraPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Warden", "PerExtraPlayer", 0.5f, "The Warden's extra health for each player after the first (0.5 = +50%). Its base health is Void Guns' [HOLLOW Warden] Health.");
			WardenResetDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Warden", "ResetDelay", 5f, "With nobody alive left in the core this long (s), the fight resets: the door opens and the Warden heals.");
			CalamityBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Mission", "CalamityBonus", 0.5f, new ConfigDescription("In a HOLLOW Hive sector the calamity's countdown (the Void Sanction and the like) is this much longer (0.5 = +50%, user 2026-10-31).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			TestCommands = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "TestCommands", false, "The /breach test, tp and warden commands (test hives, teleports, spawning and setting the Warden's health). Off in release: only /breach info and /breach mission.");
			SelfDestructTime = ((BaseUnityPlugin)this).Config.Bind<float>("Mission", "SelfDestructTime", 120f, "Seconds from the Warden's death until the hive blows (user, 2026-10-31: 2 minutes). Anyone still inside dies; the mission is done either way.");
			VaultAlloys = ((BaseUnityPlugin)this).Config.Bind<int>("Mission", "VaultAlloys", 60, new ConfigDescription("Alloys in the core's vault (solo; +[Enemies] PerExtraPlayer for each player after the first).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
			VaultGuns = ((BaseUnityPlugin)this).Config.Bind<int>("Mission", "VaultGuns", 2, new ConfigDescription("Guns in the core's vault (rifles and snipers).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()));
			MusicVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Music", "Volume", 1f, new ConfigDescription("All of the hive's music (0: none).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			MusicAmbientVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Music", "AmbientVolume", 0.48f, new ConfigDescription("The ambient theme inside a hive.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			ConfigUpgrade.Raise(MusicAmbientVolume, 0.6f);
			MusicActionVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Music", "ActionVolume", 0.6f, new ConfigDescription("The action theme during the Warden's fight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			ConfigUpgrade.Raise(MusicActionVolume, 1f);
			MusicFadeTime = ((BaseUnityPlugin)this).Config.Bind<float>("Music", "FadeTime", 2f, "Seconds to fade between the themes.");
			WakeRange = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "WakeRange", 22f, "A room's defenders appear when a player comes this close (m), on its deck.");
			DoorRange = ((BaseUnityPlugin)this).Config.Bind<float>("Hive", "DoorRange", 4.5f, "A hive door opens when someone is this close (m).");
			RackYaw = ((BaseUnityPlugin)this).Config.Bind<float>("Hive", "RackYaw", 0f, "Extra turn (degrees) of the hive's jetpack rack, if it faces the wrong way. Applies to hives built after the change.");
			BaseObjective = ((BaseUnityPlugin)this).Config.Bind<string>("Mission", "BaseObjective", "", "The game objective the HOLLOW Hive mission copies its mission logic, rewards and encounters from (any part of its asset or shown name; the log lists them all). Empty: the first main objective. Applies on the next game start.");
			MissionWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Mission", "Weight", 1, new ConfigDescription("How often new runs offer the HOLLOW Hive: it's added this many times to the main objectives the game picks from (0: never). Applies to new runs.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>()));
			MissionDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Mission", "Distance", 700f, "How far ahead of the arriving ship the hive is built (m).");
			TestDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Debug", "TestDistance", 150f, "How far in front of you \"/breach test\" builds the test hive's entrance (m).");
			ConfigUpgrade.Raise(TestDistance, 60f);
			GiveWardenModel();
			HiveSelfDestruct.Hook();
			Harmony val = new Harmony("VoidBreach");
			int num = 0;
			int num2 = 0;
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(Plugin).Assembly);
			foreach (Type type in typesFromAssembly)
			{
				if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0)
				{
					try
					{
						val.CreateClassProcessor(type).Patch();
						num++;
					}
					catch (Exception ex)
					{
						num2++;
						Log.LogError((object)("Void Breach: patch " + type.FullName + " failed and was skipped: " + ex.GetBaseException().Message));
					}
				}
			}
			Log.LogInfo((object)string.Format("{0} {1} loaded ({2} patches{3})", "Void Breach", "0.1.1", num, (num2 > 0) ? $", {num2} FAILED" : ""));
		}

		private static void GiveWardenModel()
		{
			try
			{
				SetWardenModel();
			}
			catch (MissingMethodException)
			{
				Log.LogError((object)"Void Breach: this Void Guns is too old for the Warden (needs its API 3); update Void Guns");
			}
		}

		private static void SetWardenModel()
		{
			string text = Path.Combine(PluginDir, "Warden");
			if (!VoidGunsApi.SetWardenModel(text))
			{
				Log.LogWarning((object)("Void Breach: no Warden model in " + text));
			}
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)30;

		public override string Author => "NeoLorem";

		public override string Description => "Board and fight through generated HOLLOW hive ships.";
	}
}
namespace VoidBreach.Mission
{
	[HarmonyPatch(typeof(WaitDuration), "Run")]
	internal static class HiveCalamityPatch
	{
		private static readonly FieldRef<WaitDuration, int> CompleteTimeRef = AccessTools.FieldRefAccess<WaitDuration, int>("CompleteTime");

		private static readonly FieldRef<WaitDuration, int> StartTimeRef = AccessTools.FieldRefAccess<WaitDuration, int>("startTime");

		[HarmonyPriority(200)]
		private static void Postfix(WaitDuration __instance)
		{
			float value = Plugin.CalamityBonus.Value;
			if (value <= 0f || ((__instance != null) ? __instance.BehDisplayTypes : null) == null || !__instance.BehDisplayTypes.ThreatPanelDisplay)
			{
				return;
			}
			ClientGame current = ClientGame.Current;
			object sector;
			if (current == null)
			{
				sector = null;
			}
			else
			{
				PlayerControlledShip playerShip = current.PlayerShip;
				sector = ((playerShip != null) ? ((OrbitObject)playerShip).Sector : null);
			}
			if (HiveSector.IsHiveSector((GameSessionSector)sector))
			{
				int num = StartTimeRef.Invoke(__instance);
				int num2 = CompleteTimeRef.Invoke(__instance);
				if (num2 != num)
				{
					int num3 = (int)((float)(num2 - num) * value);
					CompleteTimeRef.Invoke(__instance) = num2 + num3;
					__instance.PreviousSecondsLeft = int.MaxValue;
					Plugin.Log.LogInfo((object)$"Void Breach: the calamity countdown is {(float)num3 / 1000f:0} s longer in the hive's sector");
				}
			}
		}
	}
	internal static class HiveCalamityStart
	{
		private static readonly MethodInfo Fire = AccessTools.Method(typeof(Classifier), "OnTriggerConditionChanged", (Type[])null, (Type[])null);

		private static int startedSector = int.MinValue;

		public static void Trigger()
		{
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			if ((!PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom) || Fire == null)
			{
				return;
			}
			ClientGame current = ClientGame.Current;
			object obj;
			if (current == null)
			{
				obj = null;
			}
			else
			{
				PlayerControlledShip playerShip = current.PlayerShip;
				obj = ((playerShip != null) ? ((OrbitObject)playerShip).Sector : null);
			}
			GameSessionSector val = (GameSessionSector)obj;
			if (val == (GameSessionSector)null || val.Id == startedSector || !HiveSector.IsHiveSector(val))
			{
				return;
			}
			startedSector = val.Id;
			Objective val2 = val.SectorObjective?.Objective;
			if (val2 == null)
			{
				return;
			}
			int num = 0;
			Classifier[] array = val2.Classifiers.ToArray();
			foreach (Classifier val3 in array)
			{
				string text = (((Object)(object)val3.ClassifierOwner != (Object)null) ? ((Object)val3.ClassifierOwner).name : val3.Id);
				if (val3.IsActive && !val3.HasBeenInvoked && text != null && text.Contains("OnAggro_StartCountdown"))
				{
					try
					{
						Fire.Invoke(val3, new object[3]
						{
							val3.TriggerCondition,
							true,
							(object)new ClassifierContext()
						});
						num++;
						Plugin.Log.LogInfo((object)("Void Breach: the turrets were shot: the calamity begins (" + text + ")"));
					}
					catch (Exception ex)
					{
						Plugin.Log.LogWarning((object)("Void Breach: couldn't start the calamity (" + text + "): " + ex.GetBaseException().Message));
					}
				}
			}
			if (num == 0)
			{
				Plugin.Log.LogInfo((object)"Void Breach: the turrets were shot, but no calamity countdown was waiting to start");
			}
		}
	}
	internal static class HiveHologram
	{
		private const float Radius = 45f;

		private const float Height = 30f;

		private static GameObject holder;

		public static void Apply(PreviewContextInfo info)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_00d6: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			FieldInfo fieldInfo = AccessTools.Field(typeof(PreviewContextInfo), "previewPrefab");
			object? obj = fieldInfo?.GetValue(info);
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Void Breach: the copied objective has no map hologram; the hive gets none");
				return;
			}
			if ((Object)(object)holder == (Object)null)
			{
				holder = new GameObject("VoidBreach_HologramHolder");
				holder.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)holder);
				((Object)holder).hideFlags = (HideFlags)61;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, holder.transform);
			((Object)val2).name = "VoidBreach_HiveHologram";
			Component val3 = FindTint(val2);
			MeshRenderer val4 = (MeshRenderer)(((Object)(object)val3 != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
			Material[] array = null;
			Bounds val5 = default(Bounds);
			bool flag = false;
			MeshFilter[] componentsInChildren = val2.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val6 in componentsInChildren)
			{
				MeshRenderer component = ((Component)val6).GetComponent<MeshRenderer>();
				if ((Object)(object)val6.sharedMesh == (Object)null || (Object)(object)component == (Object)null || (Object)(object)component == (Object)(object)val4)
				{
					continue;
				}
				if (array == null)
				{
					array = ((Renderer)component).sharedMaterials;
				}
				Matrix4x4 val7 = val2.transform.worldToLocalMatrix * ((Component)val6).transform.localToWorldMatrix;
				Vector3[] array2 = Corners(val6.sharedMesh.bounds);
				foreach (Vector3 val8 in array2)
				{
					Vector3 val9 = ((Matrix4x4)(ref val7)).MultiplyPoint3x4(val8);
					if (!flag)
					{
						((Bounds)(ref val5))..ctor(val9, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref val5)).Encapsulate(val9);
					}
				}
				Object.Destroy((Object)(object)component);
				Object.Destroy((Object)(object)val6);
			}
			SkinnedMeshRenderer[] componentsInChildren2 = val2.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val10 in componentsInChildren2)
			{
				if (array == null)
				{
					array = ((Renderer)val10).sharedMaterials;
				}
				Object.Destroy((Object)(object)val10);
			}
			if (array == null || array.Length == 0)
			{
				Plugin.Log.LogWarning((object)"Void Breach: the copied hologram has no material to borrow; the hive gets none");
				Object.Destroy((Object)(object)val2);
				return;
			}
			Material material = array[0];
			float num = (flag ? Mathf.Max(new float[3]
			{
				((Bounds)(ref val5)).size.x,
				((Bounds)(ref val5)).size.y,
				((Bounds)(ref val5)).size.z
			}) : 1f);
			Vector3 val11 = (flag ? ((Bounds)(ref val5)).center : Vector3.zero);
			Transform transform = new GameObject("Hive").transform;
			transform.SetParent(val2.transform, false);
			float num2 = num * 0.44f / 90f;
			transform.localPosition = val11 - Vector3.up * 15f * num2;
			transform.localScale = Vector3.one * num2;
			Part(transform, "Wall", Resources.GetBuiltinResource<Mesh>("Cylinder.fbx"), material, new Vector3(0f, 15f, 0f), new Vector3(90f, 15f, 90f));
			string path = Path.Combine(Plugin.PluginDir, "Hull");
			if (File.Exists(Path.Combine(path, "hull_top.mesh")))
			{
				float num3 = 4.8387094f;
				Part(transform, "TopCap", KitMeshFile.Read(Path.Combine(path, "hull_top.mesh")), material, new Vector3(0f, 30f - 3f * num3, 0f), Vector3.one * num3);
				Part(transform, "BottomCap", KitMeshFile.Read(Path.Combine(path, "hull_bottom.mesh")), material, new Vector3(0f, 3f * num3, 0f), Vector3.one * num3);
			}
			Bounds box = default(Bounds);
			((Bounds)(ref box))..ctor(transform.localPosition + Vector3.up * 15f * num2, new Vector3(90f, 30f, 90f) * num2);
			CoverWithColliders(val2.transform, box);
			if ((Object)(object)val3 != (Object)null)
			{
				AccessTools.Field(((object)val3).GetType(), "renderers")?.SetValue(val3, ((Component)transform).GetComponentsInChildren<MeshRenderer>(true));
			}
			fieldInfo.SetValue(info, val2);
			Plugin.Log.LogInfo((object)$"Void Breach: the hive's map hologram is in place (from {((Object)val).name}, {num:0.##} across)");
		}

		private static void CoverWithColliders(Transform root, Bounds box)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: 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_00f5: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			Collider[] componentsInChildren = ((Component)root).GetComponentsInChildren<Collider>(true);
			List<string> list = new List<string>();
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				Transform transform = ((Component)val).transform;
				Vector3 center = transform.InverseTransformPoint(root.TransformPoint(((Bounds)(ref box)).center));
				Vector3 val2 = transform.InverseTransformVector(root.TransformVector(((Bounds)(ref box)).size));
				((Vector3)(ref val2))..ctor(Mathf.Abs(val2.x), Mathf.Abs(val2.y), Mathf.Abs(val2.z));
				list.Add(((object)val).GetType().Name + " on " + ((Object)transform).name);
				BoxCollider val3 = (BoxCollider)(object)((val is BoxCollider) ? val : null);
				if (val3 == null)
				{
					SphereCollider val4 = (SphereCollider)(object)((val is SphereCollider) ? val : null);
					if (val4 == null)
					{
						CapsuleCollider val5 = (CapsuleCollider)(object)((val is CapsuleCollider) ? val : null);
						if (val5 != null)
						{
							val5.center = center;
							val5.radius = Mathf.Max(val2.x, val2.z) / 2f;
							val5.height = Mathf.Max(val2.y, val5.radius * 2f);
							val5.direction = 1;
						}
						else
						{
							val.enabled = false;
							BoxCollider obj = ((Component)val).gameObject.AddComponent<BoxCollider>();
							((Collider)obj).isTrigger = val.isTrigger;
							obj.center = center;
							obj.size = val2;
						}
					}
					else
					{
						val4.center = center;
						val4.radius = Mathf.Max(new float[3] { val2.x, val2.y, val2.z }) / 2f;
					}
				}
				else
				{
					val3.center = center;
					val3.size = val2;
				}
			}
			if (componentsInChildren.Length == 0)
			{
				BoxCollider obj2 = ((Component)root).gameObject.AddComponent<BoxCollider>();
				obj2.center = ((Bounds)(ref box)).center;
				obj2.size = ((Bounds)(ref box)).size;
				list.Add("none: a box added");
			}
			Plugin.Log.LogInfo((object)("Void Breach: hive hologram click area: " + string.Join(", ", list)));
		}

		private static Component FindTint(GameObject hologram)
		{
			Component[] componentsInChildren = hologram.GetComponentsInChildren<Component>(true);
			foreach (Component val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "AstralMapModelColorHandler")
				{
					return val;
				}
			}
			return null;
		}

		private static void Part(Transform parent, string name, Mesh mesh, Material material, Vector3 at, Vector3 scale)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0024: 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)
			if (!((Object)(object)mesh == (Object)null))
			{
				GameObject val = new GameObject(name);
				val.transform.SetParent(parent, false);
				val.transform.localPosition = at;
				val.transform.localScale = scale;
				val.AddComponent<MeshFilter>().sharedMesh = mesh;
				Material[] array = (Material[])(object)new Material[Mathf.Max(1, mesh.subMeshCount)];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = material;
				}
				((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterials = array;
			}
		}

		private static Vector3[] Corners(Bounds b)
		{
			//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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			Vector3 min = ((Bounds)(ref b)).min;
			Vector3 max = ((Bounds)(ref b)).max;
			return (Vector3[])(object)new Vector3[8]
			{
				new Vector3(min.x, min.y, min.z),
				new Vector3(max.x, min.y, min.z),
				new Vector3(min.x, max.y, min.z),
				new Vector3(min.x, min.y, max.z),
				new Vector3(max.x, max.y, min.z),
				new Vector3(max.x, min.y, max.z),
				new Vector3(min.x, max.y, max.z),
				new Vector3(max.x, max.y, max.z)
			};
		}
	}
	internal static class HiveMission
	{
		public static readonly GUIDUnion Guid = new GUIDUnion("7b1e0a5c3d9f4e2a8c6b5d4e3f2a1b0c");

		public const string DisplayName = "HOLLOW Hive";

		public const string Description = "A HOLLOW hive ship holds this sector. Breach it, fight through its decks, restore power to the core and destroy what waits there.";

		private static ObjectiveDataRef reference;

		public static string BaseName { get; private set; }

		public static bool Registered => (ResourceAssetRef)(object)reference != (ResourceAssetRef)null;

		public static void Register()
		{
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_0174: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			ObjectiveDataContainer instance = ResourceAssetContainer<ObjectiveDataContainer, ObjectiveData, ObjectiveDataDef>.Instance;
			HashSet<GUIDUnion> mains = MainObjectiveGuids();
			LogObjectives(instance, mains);
			ObjectiveDataDef val = PickBase(instance, mains);
			if ((Object)(object)((ResourceAssetDef<ObjectiveData>)(object)val)?.Asset == (Object)null)
			{
				Plugin.Log.LogError((object)"Void Breach: no objective to base the HOLLOW Hive on; it won't be offered");
				return;
			}
			BaseName = ((Object)((ResourceAssetDef<ObjectiveData>)(object)val).Asset).name;
			ObjectiveData val2 = Object.Instantiate<ObjectiveData>(((ResourceAssetDef<ObjectiveData>)(object)val).Asset);
			((Object)val2).name = "Objective_VoidBreach_Hive";
			((Object)val2).hideFlags = (HideFlags)32;
			val2.ContainerGuid = Guid;
			val2.mainMission = HiveObjective.Create();
			string text = VirtualResources.Add(Guid, (Object)(object)val2);
			PreviewContextInfo val3 = (((Object)(object)val.PreviewContextInfo != (Object)null) ? Object.Instantiate<PreviewContextInfo>(val.PreviewContextInfo) : null);
			if ((Object)(object)val3 != (Object)null)
			{
				((Object)val3).name = "ContextInfo_VoidBreach_Hive";
				((Object)val3).hideFlags = (HideFlags)32;
				SetText((ContextInfo)(object)val3, "headerTextDefaultable", "HOLLOW Hive");
				SetText((ContextInfo)(object)val3, "bodyTextDefaultable", "A HOLLOW hive ship holds this sector. Breach it, fight through its decks, restore power to the core and destroy what waits there.");
				try
				{
					HiveHologram.Apply(val3);
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Void Breach: the hive's map hologram couldn't be made (" + ex.Message + "); the copied one stays"));
				}
			}
			ObjectiveDataDef val4 = new ObjectiveDataDef(Guid, text)
			{
				ObjectiveType = val.ObjectiveType,
				EmphasizedUIPrefab = val.EmphasizedUIPrefab
			};
			if ((Object)(object)val3 != (Object)null)
			{
				val4.ContextInfo = (IResourceAssetContextInfo)(object)val3;
			}
			((ResourceAssetContainer<ObjectiveDataContainer, ObjectiveData, ObjectiveDataDef>)(object)instance).UpdateRuntimeAsset(Guid, val4);
			reference = new ObjectiveDataRef(Guid, text);
			ManualLogSource log = Plugin.Log;
			string[] obj = new string[5] { "Void Breach: the HOLLOW Hive objective is registered (based on ", BaseName, ", \"", null, null };
			PreviewContextInfo previewContextInfo = val.PreviewContextInfo;
			obj[3] = ((previewContextInfo != null) ? ((ContextInfo)previewContextInfo).HeaderText : null);
			obj[4] = "\")";
			log.LogInfo((object)string.Concat(obj));
		}

		private static void SetText(ContextInfo info, string field, string text)
		{
			//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_000d: Expected O, but got Unknown
			DefaultableLocalizedString value = new DefaultableLocalizedString
			{
				FallBackString = text
			};
			AccessTools.Field(typeof(ContextInfo), field).SetValue(info, value);
		}

		private static HashSet<GUIDUnion> MainObjectiveGuids()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			HashSet<GUIDUnion> hashSet = new HashSet<GUIDUnion>();
			foreach (QuestAssetDef assetDescription in ((ResourceAssetContainer<QuestAssetContainer, QuestAsset, QuestAssetDef>)(object)ResourceAssetContainer<QuestAssetContainer, QuestAsset, QuestAssetDef>.Instance).AssetDescriptions)
			{
				try
				{
					EndlessQuestConfiguration val = (((Object)(object)((ResourceAssetDef<QuestAsset>)(object)assetDescription)?.Asset != (Object)null) ? ((ResourceAssetDef<QuestAsset>)(object)assetDescription).Asset.EndlessQuestConfiguration : null);
					if (val?.MainObjectiveDefinitions == null)
					{
						continue;
					}
					foreach (ObjectiveDataRef mainObjectiveDefinition in val.MainObjectiveDefinitions)
					{
						hashSet.Add(((ResourceAssetRef)mainObjectiveDefinition).AssetGuid);
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Void Breach: couldn't read a quest's objectives (" + ex.Message + ")"));
				}
			}
			return hashSet;
		}

		private static void LogObjectives(ObjectiveDataContainer objectives, HashSet<GUIDUnion> mains)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			foreach (ObjectiveDataDef assetDescription in ((ResourceAssetContainer<ObjectiveDataContainer, ObjectiveData, ObjectiveDataDef>)(object)objectives).AssetDescriptions)
			{
				string text;
				try
				{
					text = (((Object)(object)((ResourceAssetDef<ObjectiveData>)(object)assetDescription)?.Asset != (Object)null) ? ((Object)((ResourceAssetDef<ObjectiveData>)(object)assetDescription).Asset).name : "(not loaded)");
				}
				catch
				{
					text = "(failed to load)";
				}
				object[] obj2 = new object[4]
				{
					mains.Contains(((ResourceAssetDef<ObjectiveData>)(object)assetDescription).AssetGuid) ? "MAIN " : "     ",
					text,
					null,
					null
				};
				PreviewContextInfo previewContextInfo = assetDescription.PreviewContextInfo;
				obj2[2] = ((previewContextInfo != null) ? ((ContextInfo)previewContextInfo).HeaderText : null);
				obj2[3] = assetDescription.ObjectiveType;
				list.Add(string.Format("  {0}{1} \"{2}\" ({3})", obj2));
			}
			Plugin.Log.LogInfo((object)($"Void Breach: the game's objectives ({list.Count}, MAIN = a main objective of an endless run):\n" + string.Join("\n", list)));
		}

		private static ObjectiveDataDef PickBase(ObjectiveDataContainer objectives, HashSet<GUIDUnion> mains)
		{
			string wanted = Plugin.BaseObjective.Value?.Trim();
			List<ObjectiveDataDef> source = ((ResourceAssetContainer<ObjectiveDataContainer, ObjectiveData, ObjectiveDataDef>)(object)objectives).AssetDescriptions.Where((ObjectiveDataDef d) => (Object)(object)((ResourceAssetDef<ObjectiveData>)(object)d)?.Asset != (Object)null).ToList();
			if (!string.IsNullOrEmpty(wanted))
			{
				ObjectiveDataDef val = ((IEnumerable<ObjectiveDataDef>)source).FirstOrDefault((Func<ObjectiveDataDef, bool>)delegate(ObjectiveDataDef d)
				{
					if (((Object)((ResourceAssetDef<ObjectiveData>)(object)d).Asset).name.IndexOf(wanted, StringComparison.OrdinalIgnoreCase) < 0)
					{
						PreviewContextInfo previewContextInfo = d.PreviewContextInfo;
						return (((previewContextInfo != null) ? ((ContextInfo)previewContextInfo).HeaderText : null) ?? "").IndexOf(wanted, StringComparison.OrdinalIgnoreCase) >= 0;
					}
					return true;
				});
				if (val != null)
				{
					return val;
				}
				Plugin.Log.LogWarning((object)("Void Breach: no objective matches [Mission] BaseObjective \"" + wanted + "\"; picking one"));
			}
			return ((IEnumerable<ObjectiveDataDef>)source).FirstOrDefault((Func<ObjectiveDataDef, bool>)((ObjectiveDataDef d) => mains.Contains(((ResourceAssetDef<ObjectiveData>)(object)d).AssetGuid) && ((Object)((ResourceAssetDef<ObjectiveData>)(object)d).Asset).name.IndexOf("Boss", StringComparison.OrdinalIgnoreCase) < 0));
		}

		internal static void AddTo(ref EndlessQuestGenerationParameters parameters)
		{
			int value = Plugin.MissionWeight.Value;
			if (!((ResourceAssetRef)(object)reference == (ResourceAssetRef)null) && value > 0 && parameters.MainObjectiveDefinitions != null)
			{
				List<ObjectiveDataRef> list = new List<ObjectiveDataRef>(parameters.MainObjectiveDefinitions);
				for (int i = 0; i < value; i++)
				{
					list.Add(reference);
				}
				parameters.MainObjectiveDefinitions = list;
				Plugin.Log.LogInfo((object)string.Format("Void Breach: the {0} is offered in this run ({1} in {2} main objectives)", "HOLLOW Hive", value, list.Count));
			}
		}

		public static string Status()
		{
			if (!Registered)
			{
				return "HOLLOW Hive not registered (see the log)";
			}
			return string.Format("{0} registered (based on {1}), offered {2}x in new runs; {3}", "HOLLOW Hive", BaseName, Plugin.MissionWeight.Value, HiveSector.Status());
		}
	}
	[HarmonyPatch(typeof(EndlessQuestConfiguration), "GenerateBaseParameters")]
	internal static class GenerateBaseParametersPatch
	{
		private static void Postfix(ref EndlessQuestGenerationParameters __result)
		{
			try
			{
				HiveMission.AddTo(ref __result);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Void Breach: couldn't add the hive to the run: {arg}");
			}
		}
	}
	[HarmonyPatch(typeof(RuntimeAssetLoadingService), "Initialize")]
	internal static class RuntimeAssetLoadingPatch
	{
		private static void Postfix(ref IEnumerator __result)
		{
			__result = RunThenRegister(__result);
		}

		private static IEnumerator RunThenRegister(IEnumerator original)
		{
			while (original.MoveNext())
			{
				yield return original.Current;
			}
			try
			{
				HiveMission.Register();
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)string.Format("Void Breach: registering the {0} failed: {1}", "HOLLOW Hive", arg));
			}
		}
	}
	internal static class HiveObjective
	{
		public static MissionData Data { get; private set; }

		public static MissionData Create()
		{
			if ((Object)(object)Data != (Object)null)
			{
				return Data;
			}
			Data = ScriptableObject.CreateInstance<MissionData>();
			((Object)Data).name = "Mission_VoidBreach_Hive";
			((Object)Data).hideFlags = (HideFlags)32;
			AccessTools.Field(typeof(MissionData), "missionTextDefaultable").SetValue(Data, Text("HOLLOW Hive"));
			Data.MissionBehaviours = new List<MissionBehaviour>
			{
				(MissionBehaviour)(object)new HiveStep
				{
					Step = 0
				},
				(MissionBehaviour)(object)new HiveStep
				{
					Step = 1
				},
				(MissionBehaviour)(object)new HiveStep
				{
					Step = 2
				},
				(MissionBehaviour)(object)new HiveStep
				{
					Step = 3
				}
			};
			return Data;
		}

		internal static DefaultableLocalizedString Text(string text)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0024: Expected O, but got Unknown
			DefaultableLocalizedString val = new DefaultableLocalizedString
			{
				FallBackString = text
			};
			Traverse.Create((object)val).Field("_string").SetValue((object)null);
			return val;
		}

		internal static void Rebuild(Objective objective)
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			ClassifierData start = objective.Asset.initializeClassifier;
			Classifier val = ((IEnumerable<Classifier>)objective.Classifiers).FirstOrDefault((Func<Classifier, bool>)((Classifier c) => (Object)(object)c.ClassifierOwner == (Object)(object)start));
			if (val == null || (Object)(object)Data == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Void Breach: the hive objective has no starting classifier; it keeps the copied objective's mission");
				return;
			}
			List<Mission> list = objective.ObjectiveMissions.Where((Mission m) => m.UnloadWithMainObjective).ToList();
			int num = ((list.Count > 0) ? list.Min((Mission m) => m.Id) : (objective.ObjectiveMissions.Select((Mission m) => m.Id).DefaultIfEmpty(0).Max() + 1));
			foreach (Mission item in list)
			{
				objective.ObjectiveMissions.Remove(item);
			}
			Mission val2 = new Mission(Text("HOLLOW Hive"), Data)
			{
				Id = num,
				UnloadWithMainObjective = true
			};
			objective.ObjectiveMissions.Insert(0, val2);
			foreach (Classifier item2 in objective.MainObjectiveClassifiers.ToList())
			{
				if (item2 != val)
				{
					objective.MainObjectiveClassifiers.Remove(item2);
					objective.Classifiers.Remove(item2);
				}
			}
			val.TriggerCondition = (AbstractScenarioClassifierCondition)new NullCondition();
			val.DeactivationCondition = null;
			val.Actions = (AbstractScenarioClassifierAction[])(object)new AbstractScenarioClassifierAction[1] { (AbstractScenarioClassifierAction)new MissionAction(val2, (MissionResult)0) };
			Plugin.Log.LogInfo((object)$"Void Breach: the hive objective runs its own mission ({num}); {list.Count} copied mission(s) taken out");
		}
	}
	[Serializable]
	public class HiveStep : MissionBehaviour
	{
		public const int Breach = 0;

		public const int Power = 1;

		public const int Warden = 2;

		public const int Escape = 3;

		public int Step;

		protected override float UpdateInterval => 0.5f;

		public override string ObjectiveText
		{
			get
			{
				HivePower power = HiveSector.Power;
				switch (Step)
				{
				case 0:
					return "Breach the hive's airlock";
				case 1:
					if (!((Object)(object)power != (Object)null) || power.RelayCount <= 0)
					{
						return "Restore power to the core";
					}
					return $"Restore power to the core ({power.OnCount}/{power.RelayCount})";
				case 2:
					return "Destroy the HOLLOW Warden";
				default:
				{
					float secondsLeft = HiveSelfDestruct.SecondsLeft;
					if (!(secondsLeft > 0f))
					{
						return "Escape the hive";
					}
					return $"Escape before the hive self-destructs ({(int)secondsLeft / 60}:{(int)secondsLeft % 60:00})";
				}
				}
			}
		}

		public override DefaultableLocalizedString DefaultableText
		{
			get
			{
				string name = Name;
				if (base.objectiveTextDefaultable == null || base.objectiveTextDefaultable.FallBackString != name)
				{
					base.objectiveTextDefaultable = HiveObjective.Text(name);
				}
				return base.objectiveTextDefaultable;
			}
		}

		private string Name
		{
			get
			{
				if (Step != 0)
				{
					if (Step != 1)
					{
						if (Step != 2)
						{
							return "Escape before the hive self-destructs";
						}
						return "Destroy the HOLLOW Warden";
					}
					return "Restore power to the core";
				}
				return "Breach the hive's airlock";
			}
		}

		public HiveStep()
		{
			base.objectiveTextDefaultable = HiveObjective.Text("HOLLOW Hive");
		}

		protected override void Run()
		{
		}

		protected override void CheckCompletionState()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			if (base.OwnerBehaviourState != null && (int)base.OwnerBehaviourState.Phase != 2 && Done())
			{
				base.OwnerBehaviourState.SetPhase((MissionPhase)2, false);
			}
		}

		private bool Done()
		{
			HivePower power = HiveSector.Power;
			HiveArena hiveArena = (((Object)(object)HiveSector.Root != (Object)null) ? ((Component)HiveSector.Root).GetComponent<HiveArena>() : null);
			switch (Step)
			{
			case 0:
				if ((Object)(object)power != (Object)null)
				{
					return power.Breached;
				}
				return false;
			case 1:
				if ((Object)(object)power != (Object)null && power.Breached)
				{
					return power.OnCount >= power.RelayCount;
				}
				return false;
			case 2:
				if ((Object)(object)hiveArena != (Object)null)
				{
					return hiveArena.Defeated;
				}
				return false;
			default:
				return HiveSelfDestruct.Escaped;
			}
		}

		protected override void UpdateFeedback()
		{
			base.InfoText = ((MissionBehaviour)this).ObjectiveText;
		}
	}
	[HarmonyPatch(typeof(QuestGeneratorUtils), "CreateObjectiveLogic")]
	internal static class HiveObjectiveLogicPatch
	{
		private static void Prefix(Objective obj)
		{
			//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)
			if ((Object)(object)obj?.Asset == (Object)null || obj.Asset.ContainerGuid != HiveMission.Guid)
			{
				return;
			}
			try
			{
				HiveObjective.Rebuild(obj);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Void Breach: couldn't give the hive objective its own mission: {arg}");
			}
		}
	}
	internal static class HiveSector
	{
		private const float ArrivalDelay = 6f;

		private static int lastSectorId = int.MinValue;

		private static float buildAt = -1f;

		private static int builtSectorId = int.MinValue;

		private static GameObject root;

		public static Transform Root
		{
			get
			{
				if (!((Object)(object)root != (Object)null))
				{
					return null;
				}
				return root.transform;
			}
		}

		public static HivePower Power
		{
			get
			{
				if (!((Object)(object)root != (Object)null))
				{
					return null;
				}
				return root.GetComponent<HivePower>();
			}
		}

		public static void Update()
		{
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_0141: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			ClientGame current = ClientGame.Current;
			PlayerControlledShip val = ((current != null) ? current.PlayerShip : null);
			GameSessionSector val2 = (((Object)(object)val != (Object)null) ? ((OrbitObject)val).Sector : null);
			int num = ((val2 != (GameSessionSector)null) ? val2.Id : int.MinValue);
			if (num != lastSectorId)
			{
				lastSectorId = num;
				buildAt = -1f;
				if ((Object)(object)root != (Object)null && builtSectorId != num)
				{
					Clear();
				}
				if (IsHiveSector(val2))
				{
					Plugin.Log.LogInfo((object)string.Format("Void Breach: arrived in a {0} sector ({1}, {2})", "HOLLOW Hive", val2.Name, num));
					if (PhotonNetwork.IsMasterClient || !PhotonNetwork.InRoom)
					{
						buildAt = Time.time + 6f;
					}
				}
			}
			if (buildAt > 0f && Time.time >= buildAt && (Object)(object)val != (Object)null)
			{
				buildAt = -1f;
				Vector3 val3 = Vector3.ProjectOnPlane(((Component)val).transform.forward, Vector3.up);
				if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
				{
					val3 = Vector3.forward;
				}
				((Vector3)(ref val3)).Normalize();
				Vector3 at = ((Component)val).transform.position + val3 * Plugin.MissionDistance.Value;
				Quaternion val4 = Quaternion.LookRotation(val3);
				float y = ((Quaternion)(ref val4)).eulerAngles.y;
				int seed = Random.Range(1, int.MaxValue);
				Build(num, at, y, seed);
				HiveSectorMessage.ToOthers(num, at, y, seed);
			}
		}

		public static bool IsHiveSector(GameSessionSector sector)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			ObjectiveData val = sector?.SectorObjective?.Objective?.Asset;
			if ((Object)(object)val != (Object)null)
			{
				return val.ContainerGuid == HiveMission.Guid;
			}
			return false;
		}

		public static void Build(int sectorId, Vector3 at, float yaw, int seed)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (KitCatalog.Load())
			{
				Clear();
				KitCatalog.ForgetMaterials();
				HiveLayout hiveLayout = HiveLayout.Generate(seed);
				Plugin.Log.LogInfo((object)("Void Breach: the sector's hive, " + hiveLayout.Summary()));
				root = HiveBuilder.Build("VoidBreach_Hive", hiveLayout.Placements, at, yaw, hiveLayout.ZeroGPlacements);
				HiveBuilder.Furnish(root, hiveLayout, networked: true);
				builtSectorId = sectorId;
				HiveSelfDestruct.Reset();
			}
		}

		public static void Clear()
		{
			if ((Object)(object)root != (Object)null)
			{
				Object.Destroy((Object)(object)root);
				Plugin.Log.LogInfo((object)"Void Breach: the hive was removed (left its sector)");
			}
			root = null;
			builtSectorId = int.MinValue;
		}

		public static string Status()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			ClientGame current = ClientGame.Current;
			object obj;
			if (current == null)
			{
				obj = null;
			}
			else
			{
				PlayerControlledShip playerShip = current.PlayerShip;
				obj = ((playerShip != null) ? ((OrbitObject)playerShip).Sector : null);
			}
			GameSessionSector val = (GameSessionSector)obj;
			object obj3;
			if (!(val == (GameSessionSector)null))
			{
				if (!IsHiveSector(val))
				{
					GameSessionSectorObjective sectorObjective = val.SectorObjective;
					object obj2;
					if (sectorObjective == null)
					{
						obj2 = null;
					}
					else
					{
						Objective objective = sectorObjective.Objective;
						if (objective == null)
						{
							obj2 = null;
						}
						else
						{
							ObjectiveData asset = objective.Asset;
							obj2 = ((asset != null) ? ((Object)asset).name : null);
						}
					}
					if (obj2 == null)
					{
						obj2 = "none";
					}
					obj3 = "this sector's objective is " + (string?)obj2;
				}
				else
				{
					obj3 = "this is a hive sector";
				}
			}
			else
			{
				obj3 = "no sector";
			}
			string text = (string)obj3;
			if (!((Object)(object)root != (Object)null))
			{
				return text;
			}
			return $"{text}; the hive is {Vector3.Distance(root.transform.position, ((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : Vector3.zero):0} m away";
		}
	}
	public class HiveSectorMessage : ModMessage
	{
		internal static void ToOthers(int sectorId, Vector3 at, float yaw, int seed)
		{
			//IL_0037: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.InRoom)
			{
				ModMessage.Send("VoidBreach", ModMessage.GetIdentifier(typeof(HiveSectorMessage)), (ReceiverGroup)0, new object[7] { 0, sectorId, at.x, at.y, at.z, yaw, seed }, true);
			}
		}

		public override void Handle(object[] arguments, Player sender)
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (arguments != null && arguments.Length >= 7)
			{
				object obj = arguments[0];
				if (obj is int && (int)obj == 0 && sender != null && sender.IsMasterClient && arguments[1] is int sectorId && arguments[2] is float num && arguments[3] is float num2 && arguments[4] is float num3 && arguments[5] is float yaw && arguments[6] is int seed)
				{
					HiveSector.Build(sectorId, new Vector3(num, num2, num3), yaw, seed);
				}
			}
		}
	}
	internal static class VirtualResources
	{
		private const string Prefix = "VoidBreach/";

		private static readonly Dictionary<string, Object> Assets = new Dictionary<string, Object>();

		public static string Add(GUIDUnion guid, Object asset)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			string text = "VoidBreach/" + asset.name;
			Assets[text] = asset;
			ResourcePaths.Instance.SetPath(guid, text);
			return text;
		}

		public static bool TryLoad(string path, Type type, out Object result)
		{
			result = null;
			if (path == null || !path.StartsWith("VoidBreach/", StringComparison.Ordinal) || !Assets.TryGetValue(path, out var value))
			{
				return false;
			}
			if (type == null || type.IsInstanceOfType(value))
			{
				result = value;
			}
			else
			{
				GameObject val = (GameObject)(object)((value is GameObject) ? value : null);
				if (val != null && typeof(Component).IsAssignableFrom(type))
				{
					result = (Object)(object)val.GetComponent(type);
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ResourcesAPI), "Load", new Type[]
	{
		typeof(string),
		typeof(Type)
	})]
	internal static class ResourcesLoadPatch
	{
		private static bool Prefix(string __0, Type __1, ref Object __result)
		{
			if (VirtualResources.TryLoad(__0, __1, out var result))
			{
				__result = result;
				return false;
			}
			return true;
		}
	}
}
namespace VoidBreach.Hive
{
	internal static class ExplosionFx
	{
		private sealed class Swell : MonoBehaviour
		{
			private float start;

			private float size;

			private Light light;

			public void Init(Light glow)
			{
				start = Time.time;
				size = Random.Range(5f, 9f);
				light = glow;
			}

			private void Update()
			{
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				float num = (Time.time - start) / 1.1f;
				if (num >= 1f)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
					return;
				}
				float num2 = size * Mathf.Sin(Mathf.Min(1f, num * 1.6f) * (float)Math.PI * 0.5f) * (1f - num * num);
				((Component)this).transform.localScale = Vector3.one * num2;
				if ((Object)(object)light != (Object)null)
				{
					HiveLight.Set(light, 80000f * (1f - num));
				}
			}
		}

		private const string ExplosionKeys = "enemyexplosion_large_generic;payload_projectile_nuke_explosion;defect_explosionnormal;explosion";

		private const string AlarmKeys = "alarm|ship;alarm;klaxon;warning";

		private static readonly Dictionary<string, (bool found, EventDescription description, bool loop)> found = new Dictionary<string, (bool, EventDescription, bool)>();

		private static Material fireball;

		private const string SirenKeys = "voidbomb|siren;void_bomb|siren;sanction|siren;voidbomb;void_bomb;voidsanction;void_sanction;sanction;calamity|siren;siren";

		private static bool sirenListed;

		public static void Play(Vector3 at, float volume)
		{
			//IL_0005: 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)
			PlayKeys("enemyexplosion_large_generic;payload_projectile_nuke_explosion;defect_explosionnormal;explosion", at, volume, 0f);
			Fireball(at);
		}

		public static void Alarm(Vector3 at)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			PlayKeys("alarm|ship;alarm;klaxon;warning", at, 0.8f, 1.2f);
		}

		public static void Siren(Vector3 at)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (!sirenListed)
			{
				sirenListed = true;
				LogCandidates(new string[5] { "siren", "sanction", "bomb", "calamity", "klaxon" });
			}
			PlayKeys("voidbomb|siren;void_bomb|siren;sanction|siren;voidbomb;void_bomb;voidsanction;void_sanction;sanction;calamity|siren;siren", at, 1f, 0f, 1.5f);
		}

		private static void LogCandidates(string[] words)
		{
			//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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			System studioSystem = RuntimeManager.StudioSystem;
			Bank[] array = default(Bank[]);
			if ((int)((System)(ref studioSystem)).getBankList(ref array) != 0)
			{
				return;
			}
			List<string> list = new List<string>();
			Bank[] array2 = array;
			EventDescription[] array3 = default(EventDescription[]);
			string path = default(string);
			for (int i = 0; i < array2.Length; i++)
			{
				Bank val = array2[i];
				if ((int)((Bank)(ref val)).getEventList(ref array3) != 0)
				{
					continue;
				}
				EventDescription[] array4 = array3;
				for (int j = 0; j < array4.Length; j++)
				{
					EventDescription val2 = array4[j];
					if ((int)((EventDescription)(ref val2)).getPath(ref path) == 0 && path != null && words.Any((string w) => path.ToLowerInvariant().Contains(w)))
					{
						list.Add(path);
					}
				}
			}
			Plugin.Log.LogInfo((object)("Void Breach: siren candidates: " + string.Join(", ", list)));
		}

		private static void PlayKeys(string keys, Vector3 at, float volume, float stopAfter, float pitch = 1f)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			if (!found.TryGetValue(keys, out (bool, EventDescription, bool) value))
			{
				value = Find(keys);
				found[keys] = value;
			}
			EventInstance instance = default(EventInstance);
			if (value.Item1 && (int)((EventDescription)(ref value.Item2)).createInstance(ref instance) == 0)
			{
				((EventInstance)(ref instance)).set3DAttributes(RuntimeUtils.To3DAttributes(at));
				((EventInstance)(ref instance)).setVolume(volume);
				((EventInstance)(ref instance)).setPitch(pitch);
				((EventInstance)(ref instance)).start();
				if (value.Item3 && stopAfter > 0f && (Object)(object)Plugin.Instance != (Object)null)
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(StopLater(instance, stopAfter));
				}
				else
				{
					((EventInstance)(ref instance)).release();
				}
			}
		}

		private static IEnumerator StopLater(EventInstance instance, float seconds)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(seconds);
			((EventInstance)(ref instance)).stop((STOP_MODE)0);
			((EventInstance)(ref instance)).release();
		}

		private static (bool, EventDescription, bool) Find(string keys)
		{
			//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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			System studioSystem = RuntimeManager.StudioSystem;
			Bank[] array = default(Bank[]);
			if ((int)((System)(ref studioSystem)).getBankList(ref array) != 0)
			{
				return (false, default(EventDescription), false);
			}
			List<(string, EventDescription)> list = new List<(string, EventDescription)>();
			Bank[] array2 = array;
			EventDescription[] array3 = default(EventDescription[]);
			string text = default(string);
			for (int i = 0; i < array2.Length; i++)
			{
				Bank val = array2[i];
				if ((int)((Bank)(ref val)).getEventList(ref array3) != 0)
				{
					continue;
				}
				EventDescription[] array4 = array3;
				for (int j = 0; j < array4.Length; j++)
				{
					EventDescription item = array4[j];
					if ((int)((EventDescription)(ref item)).getPath(ref text) == 0 && !string.IsNullOrEmpty(text))
					{
						list.Add((text.ToLowerInvariant(), item));
					}
				}
			}
			string[] array5 = keys.Split(new char[1] { ';' });
			bool flag = default(bool);
			foreach (string text2 in array5)
			{
				string[] words = text2.Split(new char[1] { '|' });
				List<(string, EventDescription)> list2 = list.Where<(string, EventDescription)>(((string path, EventDescription description) e) => words.All((string w) => e.path.Contains(w))).ToList();
				if (list2.Count != 0)
				{
					(string, EventDescription) tuple = list2.OrderBy<(string, EventDescription), int>(delegate((string path, EventDescription description) e)
					{
						//IL_0009: Unknown result type (might be due to invalid IL or missing references)
						bool flag2 = default(bool);
						((EventDescription)(ref e.description)).isOneshot(ref flag2);
						return (!flag2) ? 1 : 0;
					}).ThenBy<(string, EventDescription), int>(((string path, EventDescription description) e) => e.path.Length).First();
					((EventDescription)(ref tuple.Item2)).isOneshot(ref flag);
					Plugin.Log.LogInfo((object)("Void Breach: sound for \"" + text2 + "\": " + tuple.Item1));
					return (true, tuple.Item2, !flag);
				}
			}
			Plugin.Log.LogWarning((object)("Void Breach: no game sound for \"" + keys + "\""));
			return (false, default(EventDescription), false);
		}

		private static void Fireball(Vector3 at)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0049: 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_0063: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fireball == (Object)null)
			{
				Color value = Plugin.GlowColor.Value;
				fireball = new Material(Shader.Find("HDRP/Unlit"))
				{
					name = "VoidBreach_Fireball",
					hideFlags = (HideFlags)32
				};
				fireball.SetColor("_UnlitColor", Color.Lerp(value, new Color(1f, 0.6f, 0.3f), 0.5f));
				fireball.SetColor("_EmissiveColor", value * 20f);
			}
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			((Object)obj).name = "VoidBreach_Explosion";
			obj.transform.position = at;
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = fireball;
			((Renderer)obj.GetComponent<MeshRenderer>()).shadowCastingMode = (ShadowCastingMode)0;
			Light glow = HiveLight.Add(obj, Plugin.GlowColor.Value, 40f, 80000f);
			obj.AddComponent<Swell>().Init(glow);
		}
	}
	internal class HiveArena : MonoBehaviour
	{
		private enum Phase
		{
			Waiting,
			Fight,
			Won
		}

		public static readonly List<HiveArena> All = new List<HiveArena>();

		private int seed;

		private bool networked;

		private Transform core;

		private KitCatalog.PieceDef coreDef;

		private HiveDoor door;

		private Phase phase;

		private int wardenId = -1;

		private bool scaled;

		private float emptySince = -1f;

		private float nextCheck;

		private string notice;

		private float noticeUntil;

		private readonly List<(Light light, Color color)> lights = new List<(Light, Color)>();

		private static readonly Color FightLight = new Color(1f, 0.08f, 0.05f);

		private bool killedRaised;

		private static GUIStyle title;

		private static GUIStyle small;

		public int Seed => seed;

		public bool Defeated => phase == Phase.Won;

		public Vector3 CoreCentre
		{
			get
			{
				//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_0021: 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_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = Vector3.zero;
				foreach (int[] cell in coreDef.cells)
				{
					val += new Vector3((float)cell[0] * 8f, 0f, (float)cell[1] * 8f);
				}
				return core.TransformPoint(val / (float)Mathf.Max(1, coreDef.cells.Count));
			}
		}

		public static event Action<HiveArena> WardenKilled;

		public static HiveArena Add(GameObject root, HiveLayout layout, bool networked)
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			Transform val = root.transform.Find("Pieces");
			if (layout.CorePlacement < 0 || (Object)(object)val == (Object)null || layout.CorePlacement >= val.childCount)
			{
				return null;
			}
			HiveArena hiveArena = root.AddComponent<HiveArena>();
			hiveArena.seed = layout.Seed;
			hiveArena.networked = networked;
			hiveArena.core = val.GetChild(layout.CorePlacement);
			hiveArena.coreDef = layout.Placements[layout.CorePlacement].Piece;
			hiveArena.door = ((Component)hiveArena.core).GetComponentInChildren<HiveDoor>();
			if ((Object)(object)hiveArena.door != (Object)null)
			{
				hiveArena.door.PlayersOnly = true;
			}
			Light[] componentsInChildren = ((Component)hiveArena.core).GetComponentsInChildren<Light>(true);
			foreach (Light val2 in componentsInChildren)
			{
				if ((Object)(object)((Component)val2).GetComponentInParent<HiveDoor>() == (Object)null)
				{
					hiveArena.lights.Add((val2, val2.color));
				}
			}
			return hiveArena;
		}

		private void Light(bool fight)
		{
			//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)
			//IL_0032: 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)
			foreach (var (val, val2) in lights)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.color = (fight ? FightLight : val2);
				}
			}
		}

		private void OnEnable()
		{
			All.Add(this);
		}

		private void OnDisable()
		{
			All.Remove(this);
		}

		public bool Inside(Vector3 world)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = core.InverseTransformPoint(world);
			if (val.y < -1f || val.y > 8f)
			{
				return false;
			}
			foreach (int[] cell in coreDef.cells)
			{
				if (InCell(val, cell))
				{
					return true;
				}
			}
			return false;
		}

		public bool FightFor(Vector3 at)
		{
			//IL_001c: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)door != (Object)null && door.Locked)
			{
				if (!Inside(at))
				{
					return Vector3.Distance(at, core.position) < 40f;
				}
				return true;
			}
			return false;
		}

		private bool Has(int x, int z)
		{
			return coreDef.cells.Exists((int[] c) => c[0] == x && c[1] == z);
		}

		private bool InCell(Vector3 local, int[] c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			float num = local.x - (float)c[0] * 8f;
			float num2 = local.z - (float)c[1] * 8f;
			float num3 = Edge(c, 1, 0, "+x");
			float num4 = Edge(c, -1, 0, "-x");
			float num5 = Edge(c, 0, 1, "+z");
			float num6 = Edge(c, 0, -1, "-z");
			if (num <= num3 && num >= 0f - num4 && num2 <= num5)
			{
				return num2 >= 0f - num6;
			}
			return false;
		}

		private float Edge(int[] c, int sx, int sz, string dir)
		{
			float num = 4f;
			if (Has(c[0] + sx, c[1] + sz))
			{
				return num;
			}
			if (!coreDef.sockets.Exists((KitCatalog.SocketDef s) => s.doorway != null && s.cell[0] == c[0] && s.cell[1] == c[1] && s.dir == dir))
			{
				return num + 1f;
			}
			return num - 1.5f;
		}

		private int LivingInside()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (Player item in HivePlayers.Living)
			{
				if ((Object)(object)item != (Object)null && Inside(((Component)item).transform.position))
				{
					num++;
				}
			}
			return num;
		}

		private void Update()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if (!VoidGunsApi.IsHost || Time.time < nextCheck || phase == Phase.Won)
			{
				return;
			}
			nextCheck = Time.time + 0.25f;
			if (wardenId < 0 || !VoidGunsApi.IsAlive(wardenId))
			{
				if (phase == Phase.Fight && wardenId >= 0)
				{
					Won();
					return;
				}
				wardenId = -1;
				int num = VoidGunsApi.Find("warden");
				Vector3 world = default(Vector3);
				if (num >= 0 && VoidGunsApi.Position(num, ref world) && Inside(world))
				{
					wardenId = num;
				}
				if (wardenId < 0)
				{
					return;
				}
			}
			if (!scaled)
			{
				scaled = true;
				int num2 = Mathf.Max(1, HivePlayers.Living.Count);
				float num3 = default(float);
				float num4 = default(float);
				if (num2 > 1 && VoidGunsApi.Health(wardenId, ref num3, ref num4))
				{
					float num5 = num4 * (1f + Plugin.WardenPerExtraPlayer.Value * (float)(num2 - 1));
					VoidGunsApi.SetHealth(wardenId, num5, num5);
					Plugin.Log.LogInfo((object)$"Void Breach: the Warden's health {num4:0} -> {num5:0} for {num2} players");
				}
			}
			int num6 = LivingInside();
			if (phase == Phase.Waiting && num6 > 0)
			{
				phase = Phase.Fight;
				emptySince = -1f;
				SetLocked(locked: true);
				Plugin.Log.LogInfo((object)"Void Breach: the Warden's fight begins, the core is locked");
			}
			else if (phase == Phase.Fight)
			{
				if (num6 > 0)
				{
					emptySince = -1f;
				}
				else if (emptySince < 0f)
				{
					emptySince = Time.time;
				}
				else if (Time.time - emptySince >= Plugin.WardenResetDelay.Value)
				{
					Reset();
				}
			}
		}

		private void Reset()
		{
			phase = Phase.Waiting;
			emptySince = -1f;
			float num = default(float);
			float num2 = default(float);
			if (VoidGunsApi.Health(wardenId, ref num, ref num2))
			{
				VoidGunsApi.SetHealth(wardenId, num2, num2);
			}
			SetLocked(locked: false);
			Plugin.Log.LogInfo((object)"Void Breach: nobody left in the core: the Warden resets, the core opens");
		}

		private void Won()
		{
			phase = Phase.Won;
			SetLocked(locked: false);
			Plugin.Log.LogInfo((object)"Void Breach: the Warden is destroyed, the core opens");
			Show(locked: false, won: true);
			if (networked)
			{
				HiveArenaMessage.State(seed, 2);
			}
		}

		private void SetLocked(bool locked)
		{
			Show(locked, won: false);
			if (networked)
			{
				HiveArenaMessage.State(seed, locked ? 1 : 0);
			}
		}

		public void Show(bool locked, bool won)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			bool num = locked && (Object)(object)door != (Object)null && !door.Locked;
			if ((Object)(object)door != (Object)null)
			{
				door.Locked = locked;
			}
			Light(locked);
			LocalPlayer instance = LocalPlayer.Instance;
			if (num && (Object)(object)instance != (Object)null && !((Player)instance).IsDead && Inside(((Component)instance).transform.position))
			{
				VoidGunsApi.RefillPlayer();
			}
			if (won)
			{
				bool num2 = !killedRaised;
				killedRaised = true;
				phase = Phase.Won;
				Notice("THE WARDEN IS DESTROYED");
				if (num2)
				{
					HiveArena.WardenKilled?.Invoke(this);
				}
			}
			else
			{
				Notice(locked ? "THE CORE IS LOCKED:  DESTROY THE WARDEN" : "THE CORE OPENS");
			}
		}

		private void Notice(string text)
		{
			//IL_0015: 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)
			LocalPlayer instance = LocalPlayer.Instance;
			if ((Object)(object)instance != (Object)null && Vector3.Distance(((Component)instance).transform.position, core.position) < 40f)
			{
				notice = text;
				noticeUntil = Time.time + 4f;
			}
		}

		public static void Draw()
		{
			foreach (HiveArena item in All)
			{
				item.DrawBar();
			}
		}

		private void DrawBar()
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_00ce: 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_00b8: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			LocalPlayer instance = LocalPlayer.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				if (title == null)
				{
					title = new GUIStyle(GUI.skin.label)
					{
						alignment = (TextAnchor)4,
						fontSize = 16,
						fontStyle = (FontStyle)1
					};
					small = new GUIStyle(title)
					{
						fontSize = 20
					};
				}
				if (notice != null && Time.time < noticeUntil)
				{
					Shadowed(new Rect(0f, (float)Screen.height * 0.28f, (float)Screen.width, 30f), notice, (Color)((phase == Phase.Won) ? Plugin.GlowColor.Value : new Color(1f, 0.45f, 0.35f)), small);
				}
				bool num = Inside(((Component)instance).transform.position) || ((Object)(object)door != (Object)null && door.Locked && Vector3.Distance(((Component)instance).transform.position, core.position) < 40f);
				int num2 = VoidGunsApi.Find("warden");
				float num3 = default(float);
				float num4 = default(float);
				if (num && num2 >= 0 && VoidGunsApi.Health(num2, ref num3, ref num4) && !(num4 <= 0f))
				{
					float num5 = Mathf.Min(720f, (float)Screen.width * 0.5f);
					float num6 = 14f;
					float num7 = ((float)Screen.width - num5) / 2f;
					float num8 = 74f;
					Shadowed(new Rect(0f, num8 - 26f, (float)Screen.width, 22f), "HOLLOW WARDEN", Color.white, title);
					GUI.color = new Color(0f, 0f, 0f, 0.65f);
					GUI.DrawTexture(new Rect(num7 - 2f, num8 - 2f, num5 + 4f, num6 + 4f), (Texture)(object)Texture2D.whiteTexture);
					GUI.color = Plugin.GlowColor.Value;
					GUI.DrawTexture(new Rect(num7, num8, num5 * Mathf.Clamp01(num3 / num4), num6), (Texture)(object)Texture2D.whiteTexture);
					GUI.color = Color.white;
				}
			}
		}

		private static void Shadowed(Rect r, string text, Color color, GUIStyle s)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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.normal.textColor = new Color(0f, 0f, 0f, 0.8f);
			GUI.Label(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, s);
			s.normal.textColor = color;
			GUI.Label(r, text, s);
		}
	}
	public class HiveArenaMessage : ModMessage
	{
		internal static void State(int seed, int state)
		{
			if (PhotonNetwork.InRoom)
			{
				ModMessage.Send("VoidBreach", ModMessage.GetIdentifier(typeof(HiveArenaMessage)), (ReceiverGroup)0, new object[2] { seed, state }, true);
			}
		}

		public override void Handle(object[] arguments, Player sender)
		{
			if (arguments != null && arguments.Length >= 2 && arguments[0] is int num && arguments[1] is int num2 && sender != null && sender.IsMasterClient)
			{
				HiveArena hiveArena = (((Object)(object)HiveSector.Root != (Object)null) ? ((Component)HiveSector.Root).GetComponent<HiveArena>() : null);
				if ((Object)(object)hiveArena != (Object)null && hiveArena.Seed == num)
				{
					hiveArena.Show(num2 == 1, num2 == 2);
				}
			}
		}
	}
	internal static class HiveAtmosphere
	{
		public static Atmosphere Add(GameObject root)
		{
			if (!Plugin.Breathable.Value)
			{
				return null;
			}
			return root.AddComponent<Atmosphere>();
		}

		public static void Fill(Atmosphere atmosphere, RoomCollection rooms)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0069: 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)
			if (!((Object)(object)atmosphere == (Object)null))
			{
				string source;
				AtmosphereValues val = ShipAir(out source);
				atmosphere.RoomAtmospheres.Clear();
				Room[] rooms2 = rooms.Rooms;
				foreach (Room val2 in rooms2)
				{
					atmosphere.RoomAtmospheres.Add(val2, val);
				}
				Plugin.Log.LogInfo((object)$"Void Breach: hive air {source}: oxygen {val.Oxygen:0.##}, pressure {val.Pressure:0.##}, temperature {val.Temperature:0.#} in {rooms.Rooms.Length} rooms");
			}
		}

		private static AtmosphereValues ShipAir(out string source)
		{
			//IL_0124: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ClientGame current = ClientGame.Current;
				object obj;
				if (current == null)
				{
					obj = null;
				}
				else
				{
					PlayerControlledShip playerShip = current.PlayerShip;
					obj = ((playerShip != null) ? ((AbstractCloneStarObject)playerShip).GameObject : null);
				}
				GameObject val = (GameObject)obj;
				Atmosphere val2 = (((Object)(object)val != (Object)null) ? val.GetComponentInChildren<Atmosphere>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					AtmosphereValues val3 = default(AtmosphereValues);
					bool flag = false;
					for (int i = 0; i < val2.RoomAtmospheres.Count; i++)
					{
						Room keyAt = val2.RoomAtmospheres.GetKeyAt(i);
						AtmosphereValues elementAt = val2.RoomAtmospheres.GetElementAt(i);
						if ((Object)(object)keyAt != (Object)null && !keyAt.InSpace && (!flag || elementAt.Oxygen > val3.Oxygen))
						{
							val3 = elementAt;
							flag = true;
						}
					}
					if (flag && val3.Oxygen > 0f)
					{
						source = "copied from the ship";
						return new AtmosphereValues
						{
							Oxygen = val3.Oxygen,
							Pressure = val3.Pressure,
							Temperature = val3.Temperature
						};
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Void Breach: couldn't read the ship's air (" + ex.Message + ")"));
			}
			source = "from defaults (the ship's couldn't be read)";
			return new AtmosphereValues
			{
				Oxygen = 1f,
				Pressure = 1f,
				Temperature = 20f
			};
		}
	}
	internal class HiveMarker : MonoBehaviour
	{
		public static bool Is(SpacePlatform platform)
		{
			if ((Object)(object)platform != (Object)null)
			{
				return (Object)(object)((Component)platform).GetComponent<HiveMarker>() != (Object)null;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(SnapshotController), "OnPlatformSet")]
	internal static class HiveBoardingSoundPatch
	{
		private static void Prefix(ref SpacePlatform newPlatform)
		{
			if (HiveMarker.Is(newPlatform))
			{
				newPlatform = n