Decompiled source of ElowinyCompany v1.0.24

Elowiny.RandomMoonsTest.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Elowiny.RandomMoonsTest")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+15d6f9d5fbd32de9b1884f29ddec3be9133bd912")]
[assembly: AssemblyProduct("Elowiny.RandomMoonsTest")]
[assembly: AssemblyTitle("Elowiny.RandomMoonsTest")]
[assembly: AssemblyVersion("1.0.4.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 RandomMoonsTest
{
	internal static class DawnCompatibility
	{
		private static object zeroCost;

		private static FieldInfo moonsField;

		private static PropertyInfo purchaseProperty;

		private static PropertyInfo routeProperty;

		private static PropertyInfo receiptProperty;

		private static PropertyInfo levelProperty;

		private static PropertyInfo predicateProperty;

		private static MethodInfo costSetter;

		internal static void Initialize(Harmony harmony)
		{
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			Type type = AccessTools.TypeByName("Dawn.DawnMoonInfo");
			if (!(type == null))
			{
				zeroCost = Activator.CreateInstance(AccessTools.TypeByName("Dawn.SimpleProvider`1").MakeGenericType(typeof(int)), 0);
				moonsField = AccessTools.Field(AccessTools.TypeByName("Dawn.LethalContent"), "Moons");
				purchaseProperty = AccessTools.Property(type, "DawnPurchaseInfo");
				routeProperty = AccessTools.Property(type, "RouteNode");
				receiptProperty = AccessTools.Property(type, "ReceiptNode");
				levelProperty = AccessTools.Property(type, "Level");
				Type type2 = AccessTools.TypeByName("Dawn.DawnPurchaseInfo");
				costSetter = AccessTools.PropertySetter(type2, "Cost");
				predicateProperty = AccessTools.Property(type2, "PurchasePredicate");
				if (moonsField == null || costSetter == null || purchaseProperty == null)
				{
					throw new InvalidOperationException("Installed DawnLib moon-price API does not match the audited 0.9.25 API.");
				}
				harmony.Patch((MethodBase)AccessTools.Method("Dawn.MoonRegistrationHandler:UpdateMoonPrice", (Type[])null, (Type[])null), new HarmonyMethod(typeof(DawnCompatibility), "PrepareMoonPrice", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		private static IEnumerable Values()
		{
			object obj = moonsField?.GetValue(null);
			if (obj != null)
			{
				return AccessTools.Property(obj.GetType(), "Values")?.GetValue(obj) as IEnumerable;
			}
			return null;
		}

		internal static void Refresh()
		{
			IEnumerable enumerable = Values();
			if (enumerable == null)
			{
				return;
			}
			foreach (object item in enumerable)
			{
				PrepareMoonPrice(item);
			}
		}

		private static void PrepareMoonPrice(object moonInfo)
		{
			if (moonInfo != null && zeroCost != null)
			{
				object value = purchaseProperty.GetValue(moonInfo);
				costSetter.Invoke(value, new object[1] { zeroCost });
				object? value2 = routeProperty.GetValue(moonInfo);
				Plugin.FreeNode((TerminalNode)((value2 is TerminalNode) ? value2 : null));
				object? value3 = receiptProperty.GetValue(moonInfo);
				Plugin.FreeNode((TerminalNode)((value3 is TerminalNode) ? value3 : null));
			}
		}

		internal static bool CanRoute(SelectableLevel level)
		{
			IEnumerable enumerable = Values();
			if (enumerable == null)
			{
				return true;
			}
			foreach (object item in enumerable)
			{
				object? value = levelProperty.GetValue(item);
				if (!((Object)((value is SelectableLevel) ? value : null) != (Object)(object)level))
				{
					object value2 = purchaseProperty.GetValue(item);
					object value3 = predicateProperty.GetValue(value2);
					object obj = AccessTools.Method(value3.GetType(), "CanPurchase", (Type[])null, (Type[])null).Invoke(value3, null);
					if (obj == null)
					{
						return false;
					}
					string name = obj.GetType().Name;
					if (name == "SuccessPurchaseResult")
					{
						return true;
					}
					if (name == "HiddenPurchaseResult")
					{
						return AccessTools.Property(obj.GetType(), "IsFailure").GetValue(obj) is bool flag && !flag;
					}
					return false;
				}
			}
			return true;
		}

		private static object FindMoon(SelectableLevel level)
		{
			IEnumerable enumerable = Values();
			if (enumerable != null)
			{
				foreach (object item in enumerable)
				{
					object? value = levelProperty.GetValue(item);
					if ((Object)((value is SelectableLevel) ? value : null) == (Object)(object)level)
					{
						return item;
					}
				}
			}
			return null;
		}

		internal static TerminalNode Receipt(SelectableLevel level)
		{
			object obj = FindMoon(level);
			if (obj != null)
			{
				object? value = receiptProperty.GetValue(obj);
				return (TerminalNode)((value is TerminalNode) ? value : null);
			}
			return null;
		}

		internal static IEnumerable<string> Tags(SelectableLevel level)
		{
			object obj = FindMoon(level);
			IEnumerable enumerable = ((obj == null) ? null : (AccessTools.Method(obj.GetType(), "AllTags", (Type[])null, (Type[])null).Invoke(obj, null) as IEnumerable));
			if (enumerable == null)
			{
				yield break;
			}
			foreach (object item in enumerable)
			{
				yield return item.ToString();
			}
		}

		internal static bool IsVanilla(SelectableLevel level)
		{
			object obj = FindMoon(level);
			if (obj == null)
			{
				return false;
			}
			object value = AccessTools.Property(obj.GetType(), "Key").GetValue(obj);
			object obj2 = AccessTools.Method(value.GetType(), "IsVanilla", (Type[])null, (Type[])null).Invoke(value, null);
			bool flag = default(bool);
			int num;
			if (obj2 is bool)
			{
				flag = (bool)obj2;
				num = 1;
			}
			else
			{
				num = 0;
			}
			return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
		}
	}
	[BepInPlugin("elowiny.randommoonstest", "Random Moons Test", "1.0.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Bootstrap : BaseUnityPlugin
	{
		private void Awake()
		{
			new Plugin(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger);
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("BOOTSTRAP_DESTROYED runtime retained=" + (Plugin.Instance != null)));
		}
	}
	internal sealed class Plugin
	{
		[HarmonyPatch(typeof(StartOfRound), "Update")]
		private static class TickPatch
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				Instance?.Update();
			}
		}

		[HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")]
		private static class ParsePatch
		{
			[HarmonyPrefix]
			[HarmonyPriority(800)]
			private static bool Prefix(Terminal __instance, ref TerminalNode __result)
			{
				if (Instance == null)
				{
					return true;
				}
				try
				{
					TerminalNode result;
					bool num = Instance.Parse(__instance, out result);
					if (!num)
					{
						__result = result;
					}
					return num;
				}
				catch (Exception ex)
				{
					Instance.awaitingChoice = false;
					Instance.Logger.LogError((object)ex);
					__result = Instance.NewResponse("Random route failed safely. See BepInEx/LogOutput.log.\nType random to try again.\n");
					return false;
				}
			}
		}

		[HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")]
		private static class EnterPatch
		{
			[HarmonyPostfix]
			private static void Postfix(Terminal __instance)
			{
				Instance?.FreeRoutes();
				Instance?.RegisterNativeCommand(__instance);
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static class LobbyPatch
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				if (Instance != null)
				{
					Instance.history.Clear();
					Instance.landing.Reset();
					Instance.session = StartOfRound.Instance;
					Terminal val = Object.FindObjectOfType<Terminal>();
					if ((Object)(object)val != (Object)null)
					{
						Instance.RegisterNativeCommand(val);
					}
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")]
		private static class LandingPatch
		{
			[HarmonyPostfix]
			private static void Postfix(StartOfRound __instance)
			{
				if (Instance != null && !((Object)(object)__instance.currentLevel == (Object)null) && Instance.landing.Observe(landed: true))
				{
					string text = Identity(__instance.currentLevel);
					Instance.history.Land(text);
					Instance.Logger.LogInfo((object)$"LANDING_VISIT {text} count={Instance.history.Count(text)}");
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "StartGame")]
		private static class DescentPatch
		{
			[HarmonyPrefix]
			private static void Prefix(StartOfRound __instance)
			{
				if (Instance != null && __instance.inShipPhase)
				{
					Instance.landing.Reset();
				}
			}
		}

		[HarmonyPatch(typeof(Terminal), "QuitTerminal")]
		private static class ExitPatch
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				if (Instance != null)
				{
					Instance.awaitingChoice = false;
				}
			}
		}

		[HarmonyPatch(typeof(Terminal), "LoadNewNodeIfAffordable")]
		private static class PricePatch
		{
			[HarmonyPrefix]
			[HarmonyPriority(0)]
			private static void Prefix(TerminalNode node)
			{
				FreeNode(node);
			}
		}

		[HarmonyPatch(typeof(Terminal), "LoadNewNode")]
		private static class DisplayPatch
		{
			[HarmonyPrefix]
			[HarmonyPriority(800)]
			private static void Prefix(Terminal __instance, TerminalNode node)
			{
				if (Instance != null && (Object)(object)node == (Object)(object)Instance.nativeMenu)
				{
					Instance.RefreshNativeMenu(__instance);
				}
				FreeNode(node);
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static class LoaderPricePatch
		{
			[HarmonyPrefix]
			private static void Prefix(ref int value)
			{
				value = 0;
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static class LoaderPriceReadPatch
		{
			[HarmonyPrefix]
			private static void Prefix(ExtendedLevel __instance)
			{
				FreeNode(__instance.RouteNode);
				FreeNode(__instance.RouteConfirmNode);
			}

			[HarmonyPostfix]
			private static void Postfix(ref int __result)
			{
				__result = 0;
			}
		}

		public const string Guid = "elowiny.randommoonstest";

		internal static Plugin Instance;

		private readonly ConfigFile Config;

		private readonly ManualLogSource Logger;

		private Harmony harmony;

		private ConfigEntry<float> repeatWeight;

		private ConfigEntry<string> excludedScenes;

		private readonly LandingHistory history = new LandingHistory();

		private readonly LandingObserver landing = new LandingObserver();

		private readonly Random random = new Random();

		private StartOfRound session;

		private Terminal choiceTerminal;

		private TerminalNode response;

		private bool awaitingChoice;

		private bool updateReported;

		private Terminal eventTerminal;

		private UnityAction<string> textListener;

		private Terminal registeredTerminal;

		private TerminalKeyword nativeRandom;

		private TerminalNode nativeMenu;

		private string catalogueSignature;

		private readonly List<Object> nativeMenuObjects = new List<Object>();

		private static readonly Regex DollarPrice = new Regex("\\$\\d[\\d,]*", RegexOptions.Compiled);

		internal Plugin(ConfigFile config, ManualLogSource logger)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			Config = config;
			Logger = logger;
			Instance = this;
			SceneManager.sceneLoaded += SceneLoaded;
			repeatWeight = Config.Bind<float>("Selection", "RepeatWeight", 0.01f, new ConfigDescription("Weight of a more-visited moon relative to a least-visited moon. Positive: repeats remain possible.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1E-06f, 1f), Array.Empty<object>()));
			excludedScenes = Config.Bind<string>("Safety", "ExcludedScenes", "CompanyBuilding", "Comma-separated scene names always excluded from random. Manual routing is still available and free.");
			harmony = new Harmony("elowiny.randommoonstest");
			Type[] array = new Type[11]
			{
				typeof(ParsePatch),
				typeof(EnterPatch),
				typeof(ExitPatch),
				typeof(PricePatch),
				typeof(DisplayPatch),
				typeof(LoaderPricePatch),
				typeof(LoaderPriceReadPatch),
				typeof(LobbyPatch),
				typeof(LandingPatch),
				typeof(DescentPatch),
				typeof(TickPatch)
			};
			foreach (Type type in array)
			{
				harmony.CreateClassProcessor(type).Patch();
			}
			DawnCompatibility.Initialize(harmony);
			Patches patchInfo = Harmony.GetPatchInfo((MethodBase)AccessTools.Method(typeof(Terminal), "ParsePlayerSentence", (Type[])null, (Type[])null));
			if (patchInfo == null || !patchInfo.Prefixes.Any((Patch p) => p.owner == "elowiny.randommoonstest"))
			{
				throw new InvalidOperationException("Random terminal parser hook was not installed.");
			}
			Logger.LogInfo((object)"Random Moons Test 1.0.4 ready; automatic registered moon discovery; managed runtime survives bootstrap destruction.");
		}

		private void SceneLoaded(Scene scene, LoadSceneMode mode)
		{
			bool flag = Harmony.GetPatchInfo((MethodBase)AccessTools.Method(typeof(Terminal), "ParsePlayerSentence", (Type[])null, (Type[])null))?.Prefixes.Any((Patch p) => p.owner == "elowiny.randommoonstest") ?? false;
			Logger.LogInfo((object)$"SCENE_CALLBACK {((Scene)(ref scene)).name} parserRecorded={flag} instanceMatches={Instance == this} terminalAssembly={typeof(Terminal).Assembly.FullName}");
			BindTerminalEvents();
		}

		private void BindTerminalEvents()
		{
			Terminal terminal = Object.FindObjectOfType<Terminal>();
			if ((Object)(object)terminal == (Object)null || (Object)(object)terminal.screenText == (Object)null)
			{
				return;
			}
			RegisterNativeCommand(terminal);
			if ((Object)(object)eventTerminal == (Object)(object)terminal)
			{
				return;
			}
			if ((Object)(object)eventTerminal != (Object)null && textListener != null)
			{
				((UnityEvent<string>)(object)eventTerminal.screenText.onValueChanged).RemoveListener(textListener);
			}
			eventTerminal = terminal;
			textListener = delegate(string text)
			{
				RegisterNativeCommand(terminal);
				if (terminal.terminalInUse && terminal.textAdded > 0 && text.Substring(Math.Max(0, text.Length - terminal.textAdded)).Trim().ToLowerInvariant() == "random")
				{
					Logger.LogInfo((object)"INPUT_EVENT random");
					FreeRoutes();
					RefreshNativeMenu(terminal, activateChoice: false);
				}
			};
			((UnityEvent<string>)(object)terminal.screenText.onValueChanged).AddListener(textListener);
			RefreshNativeMenu(terminal, activateChoice: false);
			Logger.LogInfo((object)"TERMINAL_EVENTS_BOUND native keyword and menu ready");
		}

		private void Update()
		{
			if (!updateReported)
			{
				updateReported = true;
				Logger.LogInfo((object)"RUNTIME_TICK managed runtime active");
			}
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance != (Object)(object)session)
			{
				session = instance;
				history.Clear();
				landing.Reset();
				awaitingChoice = false;
			}
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			if ((Object)(object)eventTerminal == (Object)null)
			{
				BindTerminalEvents();
			}
			if ((Object)(object)registeredTerminal == (Object)null && PatchedContent.ExtendedLevels.Count > 0)
			{
				Terminal val = Object.FindObjectOfType<Terminal>();
				if ((Object)(object)val != (Object)null)
				{
					RegisterNativeCommand(val);
				}
			}
			if (landing.Observe(instance.shipHasLanded) && (Object)(object)instance.currentLevel != (Object)null)
			{
				string text = Identity(instance.currentLevel);
				history.Land(text);
				Logger.LogInfo((object)$"LANDING_VISIT {text} count={history.Count(text)}");
			}
		}

		internal static string Identity(SelectableLevel level)
		{
			if (!((Object)(object)level == (Object)null))
			{
				return ((Object)level).name + ":" + ((Object)level).GetInstanceID();
			}
			return "";
		}

		private static HashSet<string> SceneSet(string value)
		{
			return new HashSet<string>(from s in (value ?? "").Split(',')
				select s.Trim() into s
				where s.Length > 0
				select s, StringComparer.OrdinalIgnoreCase);
		}

		internal List<MoonChoice> Candidates()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			List<MoonChoice> list = new List<MoonChoice>();
			StartOfRound instance = StartOfRound.Instance;
			if (instance?.levels == null)
			{
				return list;
			}
			HashSet<string> hashSet = SceneSet(excludedScenes.Value);
			for (int i = 0; i < instance.levels.Length; i++)
			{
				SelectableLevel level = instance.levels[i];
				if (!((Object)(object)level == (Object)null))
				{
					ExtendedLevel val = ((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel e) => (Object)(object)e != (Object)null && (Object)(object)e.SelectableLevel == (Object)(object)level));
					string text = level.sceneName ?? "";
					string id = Identity(level);
					bool modded = (((Object)(object)val != (Object)null) ? ((int)((ExtendedContent)val).ContentType > 0) : (!DawnCompatibility.IsVanilla(level)));
					IEnumerable<string> first = ((val == null) ? null : (from t in ((ExtendedContent)val).ContentTags?.Where((ContentTag t) => (Object)(object)t != (Object)null)
						select t.contentTagName)) ?? Enumerable.Empty<string>();
					bool selling = SelectionRules.IsSellingDestination(text, first.Concat(DawnCompatibility.Tags(level)));
					if (SelectionRules.Eligible(text.Length > 0, selling, (Object)(object)val != (Object)null && val.IsRouteLocked, (Object)(object)val != (Object)null && val.IsRouteRemoved, (Object)(object)GameNetworkManager.Instance != (Object)null && GameNetworkManager.Instance.isDemo && level.lockedForDemo, level.spawnEnemiesAndScrap, level.planetHasTime, hashSet.Contains(text)) && !((Object)(object)ResolveRoute(level, i) == (Object)null) && DawnCompatibility.CanRoute(level))
					{
						list.Add(new MoonChoice
						{
							Id = id,
							Name = level.PlanetName,
							Modded = modded,
							Index = i
						});
					}
				}
			}
			string text2 = string.Join("|", list.Select((MoonChoice m) => m.Id + ":" + m.Modded));
			if (text2 != catalogueSignature)
			{
				catalogueSignature = text2;
				Logger.LogInfo((object)$"AUTO_MOONS_DISCOVERED registered={instance.levels.Length} eligible={list.Count} modded={list.Count((MoonChoice m) => m.Modded)} vanilla={list.Count((MoonChoice m) => !m.Modded)}");
			}
			return list;
		}

		private static TerminalNode ResolveRoute(SelectableLevel level, int index)
		{
			ExtendedLevel? obj = ((IEnumerable<ExtendedLevel>)PatchedContent.ExtendedLevels).FirstOrDefault((Func<ExtendedLevel, bool>)((ExtendedLevel e) => (Object)(object)e != (Object)null && (Object)(object)e.SelectableLevel == (Object)(object)level));
			TerminalNode val = ((obj != null) ? obj.RouteConfirmNode : null) ?? DawnCompatibility.Receipt(level);
			if ((Object)(object)val != (Object)null && !val.isConfirmationNode && val.buyRerouteToMoon == index)
			{
				return val;
			}
			return ((IEnumerable<TerminalNode>)Resources.FindObjectsOfTypeAll<TerminalNode>()).FirstOrDefault((Func<TerminalNode, bool>)((TerminalNode n) => (Object)(object)n != (Object)null && !n.isConfirmationNode && n.buyRerouteToMoon == index));
		}

		internal static bool IsRouteNode(TerminalNode node)
		{
			if ((Object)(object)node != (Object)null)
			{
				if (node.buyRerouteToMoon < 0 && node.buyRerouteToMoon != -2)
				{
					return node.displayPlanetInfo >= 0;
				}
				return true;
			}
			return false;
		}

		internal static void FreeNode(TerminalNode node)
		{
			if (IsRouteNode(node))
			{
				node.itemCost = 0;
				if (!string.IsNullOrEmpty(node.displayText))
				{
					node.displayText = DollarPrice.Replace(node.displayText, "$0");
				}
			}
		}

		internal void FreeRoutes()
		{
			DawnCompatibility.Refresh();
			foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
			{
				if (!((Object)(object)extendedLevel == (Object)null))
				{
					extendedLevel.RoutePrice = 0;
					FreeNode(extendedLevel.RouteNode);
					FreeNode(extendedLevel.RouteConfirmNode);
				}
			}
			TerminalNode[] array = Resources.FindObjectsOfTypeAll<TerminalNode>();
			for (int i = 0; i < array.Length; i++)
			{
				FreeNode(array[i]);
			}
		}

		internal bool Parse(Terminal terminal, out TerminalNode result)
		{
			result = null;
			FreeRoutes();
			RegisterNativeCommand(terminal);
			if ((Object)(object)terminal.screenText == (Object)null || terminal.textAdded <= 0)
			{
				return true;
			}
			string text = terminal.screenText.text;
			string text2 = text.Substring(Math.Max(0, text.Length - terminal.textAdded)).Trim().ToLowerInvariant();
			if (text2 == "random")
			{
				awaitingChoice = true;
				choiceTerminal = terminal;
				Logger.LogInfo((object)"COMMAND_RECEIVED random");
				result = NewResponse(Prompt());
				return false;
			}
			if (!awaitingChoice || (Object)(object)choiceTerminal != (Object)(object)terminal)
			{
				return true;
			}
			switch (text2)
			{
			case "cancel":
			case "back":
			case "deny":
				awaitingChoice = false;
				result = NewResponse("Random route cancelled.\n");
				return false;
			default:
			{
				if (text2 != "mod" && text2 != "vanilla" && text2 != "all")
				{
					awaitingChoice = false;
					if ((Object)(object)terminal.currentNode == (Object)(object)nativeMenu)
					{
						nativeMenu.overrideOptions = false;
					}
					return true;
				}
				List<MoonChoice> list = SelectionRules.Filter(Candidates(), text2);
				if (list.Count == 0)
				{
					result = NewResponse("No eligible " + text2 + " moons available.\n\n" + Prompt());
					return false;
				}
				StartOfRound instance = StartOfRound.Instance;
				if ((Object)(object)instance == (Object)null || !instance.inShipPhase || instance.travellingToNewLevel || instance.beganLoadingNewLevel || instance.shipIsLeaving || instance.isChallengeFile || (Object)(object)RoundManager.Instance == (Object)null || RoundManager.Instance.dungeonIsGenerating || terminal.useCreditsCooldown)
				{
					result = NewResponse("Wait until the ship is idle in orbit, then enter " + text2 + " again.\n");
					return false;
				}
				MoonChoice moonChoice = SelectionRules.Pick(list, history, Identity(instance.currentLevel), repeatWeight.Value, random.NextDouble);
				if ((Object)(object)instance.currentLevel == (Object)(object)instance.levels[moonChoice.Index])
				{
					awaitingChoice = false;
					result = NewResponse("Already orbiting " + moonChoice.Name + ", the only eligible moon.\nLand to visit it, or type random to choose again.\n");
					return false;
				}
				TerminalNode val = ResolveRoute(instance.levels[moonChoice.Index], moonChoice.Index);
				if ((Object)(object)val == (Object)null || val.isConfirmationNode || val.buyRerouteToMoon != moonChoice.Index)
				{
					throw new InvalidOperationException("Route confirmation node does not match the installed moon index: " + moonChoice.Id);
				}
				FreeNode(val);
				awaitingChoice = false;
				Logger.LogInfo((object)$"RANDOM_ROUTE category={text2} scene={instance.levels[moonChoice.Index].sceneName} identity={moonChoice.Id} landedCount={history.Count(moonChoice.Id)} credits={terminal.groupCredits}");
				result = val;
				return false;
			}
			}
		}

		private string Prompt()
		{
			bool flag = Candidates().Any((MoonChoice m) => m.Modded);
			return "RANDOM MOONS — all routes are free\n\n" + (flag ? "mod     — random modded moon\n" : "mod     — unavailable (no eligible modded moons)\n") + "vanilla — random vanilla moon\nall     — either kind\n\ncancel  — exit\n\nReroll with random. Only landing counts as a visit.\n";
		}

		private TerminalNode NewResponse(string text)
		{
			TerminalNode val = response;
			response = ScriptableObject.CreateInstance<TerminalNode>();
			((Object)response).name = "RandomMoonsResponse";
			response.displayText = text;
			response.clearPreviousText = true;
			response.maxCharactersToType = 80;
			response.buyItemIndex = (response.buyVehicleIndex = (response.buyRerouteToMoon = (response.shipUnlockableID = (response.displayPlanetInfo = -1))));
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
			return response;
		}

		internal void RegisterNativeCommand(Terminal terminal)
		{
			if (terminal.terminalNodes?.allKeywords != null && (!((Object)(object)registeredTerminal == (Object)(object)terminal) || !((Object)(object)nativeRandom != (Object)null) || !terminal.terminalNodes.allKeywords.Contains(nativeRandom)))
			{
				nativeMenu = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)nativeMenu).name = "RandomMoonsNativeMenu";
				nativeMenu.displayText = Prompt();
				nativeMenu.clearPreviousText = true;
				nativeMenu.maxCharactersToType = 80;
				nativeMenu.buyItemIndex = (nativeMenu.buyVehicleIndex = (nativeMenu.buyRerouteToMoon = (nativeMenu.shipUnlockableID = (nativeMenu.displayPlanetInfo = -1))));
				nativeRandom = ScriptableObject.CreateInstance<TerminalKeyword>();
				((Object)nativeRandom).name = "RandomMoonsKeyword";
				nativeRandom.word = "random";
				nativeRandom.specialKeywordResult = nativeMenu;
				terminal.terminalNodes.allKeywords = terminal.terminalNodes.allKeywords.Where((TerminalKeyword k) => (Object)(object)k != (Object)null && !string.Equals(k.word, "random", StringComparison.OrdinalIgnoreCase)).Concat((IEnumerable<TerminalKeyword>)(object)new TerminalKeyword[1] { nativeRandom }).ToArray();
				registeredTerminal = terminal;
				Logger.LogInfo((object)$"COMMAND_REGISTERED random keywords={terminal.terminalNodes.allKeywords.Length}");
			}
		}

		private void RefreshNativeMenu(Terminal terminal, bool activateChoice = true)
		{
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			foreach (Object nativeMenuObject in nativeMenuObjects)
			{
				if (nativeMenuObject != (Object)null)
				{
					Object.Destroy(nativeMenuObject);
				}
			}
			nativeMenuObjects.Clear();
			List<CompatibleNoun> list = new List<CompatibleNoun>();
			string[] array = new string[5] { "mod", "vanilla", "all", "cancel", "random" };
			foreach (string text in array)
			{
				TerminalKeyword val = ScriptableObject.CreateInstance<TerminalKeyword>();
				val.word = text;
				nativeMenuObjects.Add((Object)(object)val);
				TerminalNode val2 = nativeMenu;
				List<MoonChoice> list2 = SelectionRules.Filter(Candidates(), text);
				StartOfRound instance = StartOfRound.Instance;
				if (text != "random" && text != "cancel" && (Object)(object)instance != (Object)null && list2.Count > 0)
				{
					MoonChoice moonChoice = SelectionRules.Pick(list2, history, Identity(instance.currentLevel), repeatWeight.Value, random.NextDouble);
					val2 = ResolveRoute(instance.levels[moonChoice.Index], moonChoice.Index);
					FreeNode(val2);
				}
				else if (text != "random")
				{
					val2 = ScriptableObject.CreateInstance<TerminalNode>();
					val2.clearPreviousText = true;
					val2.displayText = ((text == "cancel") ? "Random route cancelled.\n" : ("No eligible " + text + " moons. Type random to choose again.\n"));
					val2.buyItemIndex = (val2.buyVehicleIndex = (val2.buyRerouteToMoon = (val2.shipUnlockableID = (val2.displayPlanetInfo = -1))));
					nativeMenuObjects.Add((Object)(object)val2);
				}
				list.Add(new CompatibleNoun(val, val2));
			}
			nativeMenu.displayText = Prompt();
			nativeMenu.overrideOptions = true;
			nativeMenu.terminalOptions = list.ToArray();
			if (activateChoice)
			{
				awaitingChoice = true;
				choiceTerminal = terminal;
			}
			Logger.LogInfo((object)"COMMAND_MENU_LOADED native fallback ready");
		}
	}
	public sealed class LandingHistory
	{
		private readonly Dictionary<string, int> counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

		public string LastLanded { get; private set; }

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

		public void Land(string id)
		{
			if (!string.IsNullOrEmpty(id))
			{
				counts[id] = Count(id) + 1;
				LastLanded = id;
			}
		}

		public void Clear()
		{
			counts.Clear();
			LastLanded = null;
		}
	}
	public sealed class LandingObserver
	{
		private bool wasLanded;

		public bool Observe(bool landed)
		{
			bool result = landed && !wasLanded;
			wasLanded = landed;
			return result;
		}

		public void Reset()
		{
			wasLanded = false;
		}
	}
	public sealed class MoonChoice
	{
		public string Id;

		public string Name;

		public bool Modded;

		public int Index;
	}
	public static class SelectionRules
	{
		public static List<MoonChoice> Filter(IEnumerable<MoonChoice> choices, string category)
		{
			if (category != "all" && category != "mod" && category != "vanilla")
			{
				return new List<MoonChoice>();
			}
			return (from g in choices.Where((MoonChoice m) => category == "all" || m.Modded == (category == "mod")).GroupBy<MoonChoice, string>((MoonChoice m) => m.Id, StringComparer.OrdinalIgnoreCase)
				select g.First()).ToList();
		}

		public static MoonChoice Pick(IReadOnlyList<MoonChoice> pool, LandingHistory history, string currentId, double repeatWeight, Func<double> draw)
		{
			if (pool.Count == 0)
			{
				return null;
			}
			if (pool.Count == 1)
			{
				return pool[0];
			}
			repeatWeight = Math.Max(1E-06, Math.Min(1.0, repeatWeight));
			int num = pool.Min((MoonChoice m) => history.Count(m.Id));
			double[] array = new double[pool.Count];
			for (int num2 = 0; num2 < pool.Count; num2++)
			{
				if (!string.Equals(pool[num2].Id, currentId, StringComparison.OrdinalIgnoreCase))
				{
					array[num2] = ((history.Count(pool[num2].Id) == num) ? 1.0 : repeatWeight);
					if (string.Equals(pool[num2].Id, history.LastLanded, StringComparison.OrdinalIgnoreCase))
					{
						array[num2] *= repeatWeight;
					}
				}
			}
			double num3 = array.Sum();
			if (num3 == 0.0)
			{
				return pool[0];
			}
			double num4 = Math.Max(0.0, Math.Min(0.9999999999999999, draw())) * num3;
			MoonChoice result = null;
			for (int num5 = 0; num5 < pool.Count; num5++)
			{
				if (!(array[num5] <= 0.0))
				{
					result = pool[num5];
					if (num4 < array[num5])
					{
						return pool[num5];
					}
					num4 -= array[num5];
				}
			}
			return result;
		}

		public static bool IsSellingDestination(string scene, IEnumerable<string> tags)
		{
			if (string.Equals(scene, "CompanyBuilding", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			using (IEnumerator<string> enumerator = (tags ?? Enumerable.Empty<string>()).GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					switch (new string((enumerator.Current ?? "").Split(':').Last().Where(char.IsLetterOrDigit)
						.ToArray()).ToLowerInvariant())
					{
					case "company":
					case "selling":
					case "companymoon":
					case "sellingmoon":
					case "companybuilding":
					case "sell":
					case "sellmoon":
					case "scrapselling":
					case "scrapsellingmoon":
					case "sellingdestination":
						return true;
					}
				}
			}
			return false;
		}

		public static bool Eligible(bool hasScene, bool selling, bool locked, bool removed, bool demoLocked, bool spawnsScrap, bool hasTime, bool excluded)
		{
			if (hasScene && !selling && !locked && !removed && !demoLocked && spawnsScrap && hasTime)
			{
				return !excluded;
			}
			return false;
		}
	}
}

ElowinyCharacters.dll

Decompiled an hour ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ElowinyCharacters")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d623f605e6bc56764110e8685f67aae2e66227e8")]
[assembly: AssemblyProduct("ElowinyCharacters")]
[assembly: AssemblyTitle("ElowinyCharacters")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ModelReplacement
{
	public class MRKAISERKATTAIL3D : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "KaiserKattail3D";
			return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
		}
	}
	[BepInPlugin("com.elowiny.ElowinyCompany", "ElowinyCharacters", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Assets.PopulateAssets();
			ModelReplacementAPI.RegisterSuitModelReplacement("Kattail3D", typeof(MRKAISERKATTAIL3D));
			Harmony val = new Harmony("com.elowiny.ElowinyCompany");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.elowiny.ElowinyCompany is loaded!");
		}
	}
	public static class Assets
	{
		public static string mainAssetBundleName = "elowinycharacters";

		public static AssetBundle MainAssetBundle = null;

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_");
		}

		public static void PopulateAssets()
		{
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				Console.WriteLine(GetAssemblyName() + "." + mainAssetBundleName);
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName);
				MainAssetBundle = AssetBundle.LoadFromStream(stream);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

ElowinyPan.Runtime.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ElowinyPan.Runtime")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0+15d6f9d5fbd32de9b1884f29ddec3be9133bd912")]
[assembly: AssemblyProduct("ElowinyPan.Runtime")]
[assembly: AssemblyTitle("ElowinyPan.Runtime")]
[assembly: AssemblyVersion("0.3.0.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 ElowinyPanProject
{
	public static class PanRules
	{
		public const float VoidHeight = -65f;

		public const float MaxSunLux = 35f;

		public static bool ShouldKill(float height, bool indoors, bool inShip, bool alive, bool controlled)
		{
			return height < -65f && !indoors && !inShip && alive && controlled;
		}

		public static void ClampSun(Light sun)
		{
			HDAdditionalLightData component = ((Component)sun).GetComponent<HDAdditionalLightData>();
			if ((Object)(object)component != (Object)null && component.intensity > 35f)
			{
				component.SetIntensity(35f, (LightUnit)2);
			}
			if (sun.intensity > 35f)
			{
				sun.intensity = 35f;
			}
		}
	}
	[BepInPlugin("elowi.pan.runtime", "ElowinyPanProject Runtime", "0.3.0")]
	public sealed class PanPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static PanController Active;

		private static float nextSearch;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			harmony = new Harmony("elowi.pan.runtime");
			harmony.PatchAll(typeof(PanPlugin).Assembly);
			SceneManager.sceneLoaded += SceneLoaded;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Pan 0.3: scene callback and game-loop fallback ready.");
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= SceneLoaded;
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		private static void SceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			TryAttach(scene);
		}

		public static PanController TryAttach(Scene scene)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded || ((Scene)(ref scene)).name != "8Pan")
			{
				return null;
			}
			GameObject val = ((IEnumerable<GameObject>)((Scene)(ref scene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject g) => ((Object)g).name == "ElowinyPanProject_AsteroidCluster"));
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogWarning((object)"Pan scene found without authored exterior root.");
				}
				return null;
			}
			PanController panController = val.GetComponent<PanController>();
			if ((Object)(object)panController == (Object)null)
			{
				panController = val.AddComponent<PanController>();
				panController.Initialize(scene);
				ManualLogSource log2 = Log;
				if (log2 != null)
				{
					log2.LogInfo((object)("Pan scene attached: " + ((Scene)(ref scene)).name + " via authored root."));
				}
			}
			Active = panController;
			return panController;
		}

		internal static void Poll()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.unscaledTime < nextSearch))
			{
				nextSearch = Time.unscaledTime + 1f;
				TryAttach(SceneManager.GetSceneByName("8Pan"));
			}
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "Update")]
	internal static class PanSceneFallback
	{
		private static void Postfix()
		{
			PanPlugin.Poll();
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
	internal static class PanPlayerFallback
	{
		private static void Postfix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner)
			{
				PanPlugin.Poll();
				if ((Object)(object)PanPlugin.Active != (Object)null)
				{
					PanPlugin.Active.CheckPlayer(__instance);
				}
			}
		}
	}
	[DefaultExecutionOrder(20000)]
	public sealed class PanController : MonoBehaviour
	{
		private Scene scene;

		private Light[] suns;

		private bool ticking;

		private float nextAttempt;

		public void Initialize(Scene loaded)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			scene = loaded;
			suns = (from l in ((Scene)(ref loaded)).GetRootGameObjects().SelectMany((GameObject g) => g.GetComponentsInChildren<Light>(true))
				where (int)l.type == 1
				select l).ToArray();
		}

		private void LateUpdate()
		{
			if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded)
			{
				return;
			}
			if (!ticking)
			{
				ticking = true;
				ManualLogSource log = PanPlugin.Log;
				if (log != null)
				{
					log.LogInfo((object)("Pan controller ticking; void threshold=" + -65f));
				}
			}
			Light[] array = suns;
			foreach (Light val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					PanRules.ClampSun(val);
				}
			}
			CheckPlayer(GameNetworkManager.Instance?.localPlayerController);
		}

		public void CheckPlayer(PlayerControllerB player)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded || (Object)(object)player == (Object)null || !((NetworkBehaviour)player).IsOwner)
			{
				return;
			}
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || instance.inShipPhase || !PanRules.ShouldKill(((Component)player).transform.position.y, player.isInsideFactory, player.isInHangarShipRoom, !player.isPlayerDead, player.isPlayerControlled) || Time.unscaledTime < nextAttempt)
			{
				return;
			}
			nextAttempt = Time.unscaledTime + 1f;
			if (!player.AllowPlayerDeath())
			{
				ManualLogSource log = PanPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("Pan void reached but native death guard blocked it: allowLocalPlayerDeath=" + instance.allowLocalPlayerDeath + ", doors=" + instance.shipDoorsEnabled));
				}
				return;
			}
			ManualLogSource log2 = PanPlugin.Log;
			if (log2 != null)
			{
				log2.LogInfo((object)("Pan void fall: native gravity death at y=" + ((Component)player).transform.position.y));
			}
			player.KillPlayer(Vector3.zero, false, (CauseOfDeath)2, 0, default(Vector3), false);
		}

		private void OnDestroy()
		{
			if ((Object)(object)PanPlugin.Active == (Object)(object)this)
			{
				PanPlugin.Active = null;
			}
		}
	}
}

ElowinyPluto.Condensation.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ElowinyPluto.Condensation")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.8.2.0")]
[assembly: AssemblyInformationalVersion("0.8.2+15d6f9d5fbd32de9b1884f29ddec3be9133bd912")]
[assembly: AssemblyProduct("ElowinyPluto.Condensation")]
[assembly: AssemblyTitle("ElowinyPluto.Condensation")]
[assembly: AssemblyVersion("0.8.2.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 ElowinyMoonProject
{
	public static class CondensationMath
	{
		public const float Floor = -33.5f;

		public const float Rim = -4.5f;

		public const float StartHour = 12f;

		public const float EndHour = 22f;

		public const float PlatformFreeboard = 0.2f;

		public static float ClockHour(float normalizedTime, float numberOfHours)
		{
			return 6f + normalizedTime * numberOfHours;
		}

		public static float Progress(float clockHour)
		{
			return Math.Max(0f, Math.Min(1f, (clockHour - 12f) / 10f));
		}

		public static float Surface(float clockHour)
		{
			return -33.5f + 29f * Progress(clockHour);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("elowi.pluto.condensation", "ElowinyMoonProject Condensation", "0.8.2")]
	public sealed class PlutoCondensationPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log = Logger.CreateLogSource("PlutoCondensation");

		private static float nextSearch;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("elowi.pluto.condensation").PatchAll(typeof(PlutoCondensationPlugin).Assembly);
			SceneManager.sceneLoaded += SceneLoaded;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Pluto condensation ready: noon warning, rising ice until 10 PM, snowfall.");
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= SceneLoaded;
		}

		private static void SceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Scene)(ref scene)).name != "134340Pluto"))
			{
				Log.LogInfo((object)"Pluto scene loaded; locating condensation geometry.");
				TryAttach(scene);
			}
		}

		internal static void PollScene()
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.unscaledTime < nextSearch))
			{
				nextSearch = Time.unscaledTime + 1f;
				Scene sceneByName = SceneManager.GetSceneByName("134340Pluto");
				if (((Scene)(ref sceneByName)).IsValid() && ((Scene)(ref sceneByName)).isLoaded)
				{
					TryAttach(sceneByName);
				}
			}
		}

		internal static CondensationController TryAttach(Scene scene)
		{
			Transform val = ((Scene)(ref scene)).GetRootGameObjects().SelectMany((GameObject r) => r.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "Pluto condensation" && (Object)(object)t.Find("Floating ice chunks") != (Object)null));
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)("Pluto scene has no condensation geometry. Roots: " + string.Join(", ", from r in ((Scene)(ref scene)).GetRootGameObjects()
					select ((Object)r).name)));
				return null;
			}
			GameObject gameObject = ((Component)val.parent).gameObject;
			return gameObject.GetComponent<CondensationController>() ?? gameObject.AddComponent<CondensationController>();
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "Update")]
	internal static class CondensationSceneTick
	{
		private static void Postfix()
		{
			PlutoCondensationPlugin.PollScene();
		}
	}
	[DefaultExecutionOrder(10000)]
	public sealed class CondensationController : MonoBehaviour
	{
		internal static PlayerControllerB HazardPlayer;

		internal static bool HazardSupported;

		internal static CondensationController ActiveHazard;

		private float escapeUntil;

		private static readonly FieldRef<PlayerControllerB, bool> Jumping = AccessTools.FieldRefAccess<PlayerControllerB, bool>("isJumping");

		private Transform mechanic;

		private Transform surface;

		private Transform[] chunks;

		private Collider[] chunkColliders;

		private float[] restingHeights;

		private Rigidbody[] chunkBodies;

		private Vector3[] chunkAnchors;

		private Renderer surfaceRenderer;

		private Collider surfaceCollider;

		private Rigidbody surfaceBody;

		private PlayerControllerB affected;

		private bool warned;

		private bool alarmPlayed;

		private bool wasActive;

		private bool initialized;

		private bool completed;

		private float surfaceHeight = -33.5f;

		private float highestHour = 6f;

		private const float Hindrance = 2f;

		private float previousSinkingSpeed;

		private ParticleSystem snow;

		private bool surfaceVisible;

		private bool heightApplied;

		private Fog haze;

		private NavMeshObstacle snowNavigation;

		private Bounds exteriorBounds;

		private float navigationBottom;

		private float navigationHeight = float.NaN;

		private void Start()
		{
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Expected O, but got Unknown
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			mechanic = ((Component)this).transform.Find("Pluto condensation");
			surface = (((Object)(object)mechanic != (Object)null) ? mechanic.Find("Condensate surface") : null);
			Transform group = (((Object)(object)mechanic != (Object)null) ? mechanic.Find("Floating ice chunks") : null);
			if ((Object)(object)surface == (Object)null || (Object)(object)group == (Object)null || group.childCount < 7)
			{
				PlutoCondensationPlugin.Log.LogError((object)"Condensation geometry missing; install matching bundles and DLL.");
				((Behaviour)this).enabled = false;
				return;
			}
			chunks = (from i in Enumerable.Range(0, @group.childCount)
				select @group.GetChild(i)).ToArray();
			chunkColliders = chunks.Select((Transform c) => ((Component)c).GetComponent<Collider>()).ToArray();
			restingHeights = chunks.Select((Transform c) => c.localPosition.y).ToArray();
			chunkBodies = chunks.Select((Transform c) => ((Component)c).GetComponent<Rigidbody>()).ToArray();
			chunkAnchors = chunks.Select((Transform c) => c.position).ToArray();
			surfaceRenderer = ((Component)surface).GetComponent<Renderer>();
			surfaceCollider = ((Component)surface).GetComponent<Collider>();
			surfaceBody = ((Component)surface).GetComponent<Rigidbody>();
			Transform obj = ((Component)this).transform.Find("Pluto snowfall");
			snow = ((obj != null) ? ((Component)obj).GetComponent<ParticleSystem>() : null);
			Volume componentInChildren = ((Component)this).GetComponentInChildren<Volume>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.profile.TryGet<Fog>(ref haze);
			}
			Transform obj2 = ((Component)this).transform.Find("Hilly ice field and central chasm");
			Collider val = ((obj2 != null) ? ((Component)obj2).GetComponent<Collider>() : null);
			exteriorBounds = (Bounds)(((Object)(object)val != (Object)null) ? val.bounds : new Bounds(surface.position, new Vector3(1500f, 150f, 1500f)));
			navigationBottom = Mathf.Min(((Bounds)(ref exteriorBounds)).min.y - 3f, -36.5f);
			GameObject val2 = new GameObject("Rising snow navigation exclusion");
			val2.transform.SetParent(((Component)this).transform, false);
			val2.transform.rotation = Quaternion.identity;
			snowNavigation = val2.AddComponent<NavMeshObstacle>();
			((Behaviour)snowNavigation).enabled = false;
			snowNavigation.shape = (NavMeshObstacleShape)1;
			snowNavigation.carving = true;
			snowNavigation.carveOnlyStationary = false;
			snowNavigation.carvingMoveThreshold = 0.1f;
			PlutoSky.Initialize(((Component)this).gameObject);
			initialized = true;
			SetHeight(-33.5f, visible: false, null);
			PlutoCondensationPlugin.Log.LogInfo((object)("Attached condensation controller to 134340-Pluto; " + chunks.Length + " terrain-resting ice chunks found."));
		}

		private void LateUpdate()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Invalid comparison between Unknown and I4
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Invalid comparison between Unknown and I4
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				return;
			}
			StartOfRound instance = StartOfRound.Instance;
			TimeOfDay instance2 = TimeOfDay.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				Scene scene = ((Component)this).gameObject.scene;
				if (((Scene)(ref scene)).name == "134340Pluto" && !instance.inShipPhase && !instance.shipIsLeaving && (Object)(object)instance2 != (Object)null && instance2.totalTime > 0f)
				{
					wasActive = true;
					float num = CondensationMath.ClockHour(instance2.currentDayTime / instance2.totalTime, instance2.numberOfHours);
					highestHour = Mathf.Max(highestHour, num);
					num = highestHour;
					bool flag = num >= 12f;
					PlayerControllerB localPlayerController = instance.localPlayerController;
					if ((Object)(object)haze != (Object)null)
					{
						((VolumeParameter<float>)(object)haze.meanFreePath).value = (((int)instance.currentLevel.currentWeather == 3) ? 45 : 1050);
					}
					PlutoSky.SetState(num, (int)instance.currentLevel.currentWeather == 5);
					SetSnow(num, ((Object)(object)localPlayerController != (Object)null) ? ((Component)localPlayerController).transform.position : Vector3.zero, (Object)(object)localPlayerController != (Object)null && !localPlayerController.isInsideFactory && !localPlayerController.isInHangarShipRoom && !localPlayerController.isPlayerDead);
					if (flag && !warned && (Object)(object)HUDManager.Instance != (Object)null)
					{
						HUDManager instance3 = HUDManager.Instance;
						if (!alarmPlayed && (Object)(object)instance3.UIAudio != (Object)null && (Object)(object)instance3.shipAlarmHornSFX != (Object)null)
						{
							instance3.UIAudio.PlayOneShot(instance3.shipAlarmHornSFX, 0.8f);
							alarmPlayed = true;
						}
						if ((bool)AccessTools.Method(typeof(HUDManager), "CanTipDisplay", (Type[])null, (Type[])null).Invoke(instance3, new object[3] { true, false, "PlutoCondensation" }))
						{
							instance3.DisplayTip("ATMOSPHERE CONDENSATING", "Beware the chasm!", true, false, "LC_Tip1");
							warned = true;
							PlutoCondensationPlugin.Log.LogInfo((object)"Noon atmosphere warning delivered to this client.");
						}
					}
					if (!flag)
					{
						ClearHazard();
						warned = false;
						alarmPlayed = false;
						completed = false;
					}
					float height = CondensationMath.Surface(num);
					SetHeight(height, flag, localPlayerController);
					if (num >= 22f && !completed)
					{
						completed = true;
						PlutoCondensationPlugin.Log.LogInfo((object)"10 PM: condensate at rim height; ice field fully raised.");
					}
					UpdateHazard(localPlayerController, flag);
					return;
				}
			}
			ClearHazard();
			SetSnow(6f, Vector3.zero, outside: false);
			if (wasActive)
			{
				warned = false;
				alarmPlayed = false;
				completed = false;
				highestHour = 6f;
				SetHeight(-33.5f, visible: false, null);
			}
			wasActive = false;
		}

		private bool Eligible(PlayerControllerB player)
		{
			if ((Object)(object)player != (Object)null && ((NetworkBehaviour)player).IsOwner && player.isPlayerControlled && !player.isPlayerDead && !player.isInsideFactory && !player.isInElevator && !player.isInHangarShipRoom && !player.isClimbingLadder && !player.inSpecialInteractAnimation && (Object)(object)player.inAnimationWithEnemy == (Object)null && (Object)(object)player.thisController != (Object)null)
			{
				return ((Collider)player.thisController).enabled;
			}
			return false;
		}

		private bool OnChunk(PlayerControllerB player)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			if (!Eligible(player))
			{
				return false;
			}
			Bounds bounds = ((Collider)player.thisController).bounds;
			Vector3 min = ((Bounds)(ref bounds)).min;
			Vector3 position = ((Component)player).transform.position;
			RaycastHit val2 = default(RaycastHit);
			for (int i = 0; i < chunkColliders.Length; i++)
			{
				Collider val = chunkColliders[i];
				Bounds bounds2 = val.bounds;
				if (!(position.x < ((Bounds)(ref bounds2)).min.x) && !(position.x > ((Bounds)(ref bounds2)).max.x) && !(position.z < ((Bounds)(ref bounds2)).min.z) && !(position.z > ((Bounds)(ref bounds2)).max.z) && !(Mathf.Abs(min.y - ((Bounds)(ref bounds2)).max.y) > Mathf.Max(0.45f, player.thisController.skinWidth + 0.2f)) && val.Raycast(new Ray(new Vector3(position.x, min.y + 0.6f, position.z), Vector3.down), ref val2, 1.1f))
				{
					return true;
				}
			}
			return false;
		}

		private void SetHeight(float height, bool visible, PlayerControllerB player)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: 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_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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)
			float num = height - surfaceHeight;
			if (heightApplied && Mathf.Abs(num) < 1E-05f && surfaceVisible == visible && surfaceRenderer.enabled == visible)
			{
				return;
			}
			heightApplied = true;
			surfaceVisible = visible;
			bool flag = false;
			Bounds bounds;
			if (surfaceCollider.enabled && Eligible(player))
			{
				bounds = ((Collider)player.thisController).bounds;
				Vector3 min = ((Bounds)(ref bounds)).min;
				flag = TouchesSurface(min, player.thisController.skinWidth) && Mathf.Abs(min.y - surfaceHeight) < 0.6f;
			}
			float num2 = (flag ? num : 0f);
			if (OnChunk(player))
			{
				for (int i = 0; i < chunks.Length; i++)
				{
					Bounds bounds2 = chunkColliders[i].bounds;
					Vector3 position = ((Component)player).transform.position;
					if (position.x >= ((Bounds)(ref bounds2)).min.x && position.x <= ((Bounds)(ref bounds2)).max.x && position.z >= ((Bounds)(ref bounds2)).min.z && position.z <= ((Bounds)(ref bounds2)).max.z)
					{
						bounds = ((Collider)player.thisController).bounds;
						if (Mathf.Abs(((Bounds)(ref bounds)).min.y - ((Bounds)(ref bounds2)).max.y) < 0.45f)
						{
							num2 = Mathf.Max(num2, Mathf.Max(restingHeights[i], height + 0.2f - 0.6f) - chunks[i].localPosition.y);
						}
					}
				}
			}
			if (num2 > 1E-05f)
			{
				player.thisController.Move(Vector3.up * num2);
			}
			surfaceHeight = height;
			surface.localPosition = new Vector3(85f, height - 0.1f, 0f);
			surfaceRenderer.enabled = visible;
			surfaceCollider.enabled = visible;
			if ((Object)(object)surfaceBody != (Object)null)
			{
				surfaceBody.position = surface.position;
			}
			for (int j = 0; j < chunks.Length; j++)
			{
				Transform val = chunks[j];
				Vector3 localPosition = val.localPosition;
				localPosition.y = Mathf.Max(restingHeights[j], height + 0.2f - 0.6f);
				val.localPosition = localPosition;
				Rigidbody val2 = chunkBodies[j];
				if ((Object)(object)val2 != (Object)null)
				{
					val2.position = val.position;
				}
			}
			UpdateSnowNavigation(height, visible);
			Physics.SyncTransforms();
		}

		private void UpdateSnowNavigation(float height, bool visible)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)snowNavigation == (Object)null)
			{
				return;
			}
			if (!visible)
			{
				((Behaviour)snowNavigation).enabled = false;
				navigationHeight = float.NaN;
				return;
			}
			float num = Mathf.Ceil(height * 2f) * 0.5f + 0.35f;
			if (!((Behaviour)snowNavigation).enabled || !Mathf.Approximately(num, navigationHeight))
			{
				((Component)snowNavigation).transform.position = new Vector3(((Bounds)(ref exteriorBounds)).center.x, (num + navigationBottom) * 0.5f, ((Bounds)(ref exteriorBounds)).center.z);
				snowNavigation.size = new Vector3(((Bounds)(ref exteriorBounds)).size.x + 8f, num - navigationBottom, ((Bounds)(ref exteriorBounds)).size.z + 8f);
				navigationHeight = num;
				((Behaviour)snowNavigation).enabled = true;
			}
		}

		private void SetSnow(float hour, Vector3 position, bool outside)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_003a: 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_0073: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)snow == (Object)null)
			{
				return;
			}
			((Component)snow).transform.position = position + Vector3.up * 18f;
			EmissionModule emission = snow.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit((hour < 12f) ? 24f : (240f + 120f * CondensationMath.Progress(hour)));
			MainModule main = snow.main;
			((MainModule)(ref main)).startSize = new MinMaxCurve((hour < 12f) ? 0.035f : 0.08f, (hour < 12f) ? 0.09f : 0.2f);
			NoiseModule noise = snow.noise;
			((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit((hour < 12f) ? 0.3f : 0.85f);
			if (outside)
			{
				if (!snow.isPlaying)
				{
					snow.Play();
				}
			}
			else if (snow.isPlaying)
			{
				snow.Stop(true, (ParticleSystemStopBehavior)0);
			}
		}

		internal bool TouchesSurface(Vector3 feet, float skinWidth)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_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_007f: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00b8: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (!surfaceCollider.enabled)
			{
				return false;
			}
			Bounds bounds = surfaceCollider.bounds;
			if (feet.x < ((Bounds)(ref bounds)).min.x || feet.x > ((Bounds)(ref bounds)).max.x || feet.z < ((Bounds)(ref bounds)).min.z || feet.z > ((Bounds)(ref bounds)).max.z)
			{
				return false;
			}
			float num = Mathf.Max(0.45f, skinWidth + 0.2f);
			if (feet.y > ((Bounds)(ref bounds)).max.y + num)
			{
				return false;
			}
			if (feet.y < ((Bounds)(ref bounds)).max.y)
			{
				return true;
			}
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(new Ray(feet + Vector3.up * 0.6f, Vector3.down), ref val, 0.6f + num, -1, (QueryTriggerInteraction)1))
			{
				return (Object)(object)((RaycastHit)(ref val)).collider == (Object)(object)surfaceCollider;
			}
			return false;
		}

		private void UpdateHazard(PlayerControllerB player, bool active)
		{
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			if (active && Time.time >= escapeUntil && Eligible(player) && !Jumping.Invoke(player) && !player.isFallingFromJump && !OnChunk(player))
			{
				Bounds bounds = ((Collider)player.thisController).bounds;
				flag = TouchesSurface(((Bounds)(ref bounds)).min, player.thisController.skinWidth);
			}
			if (!flag)
			{
				ClearHazard();
				return;
			}
			if ((Object)(object)affected != (Object)(object)player)
			{
				ClearHazard();
				affected = player;
				HazardPlayer = player;
				ActiveHazard = this;
				previousSinkingSpeed = player.sinkingSpeedMultiplier;
				player.sourcesCausingSinking++;
				player.isMovementHindered++;
				player.hinderedMultiplier *= 2f;
			}
			HazardSupported = true;
			player.sinkingSpeedMultiplier = 0.12f;
			player.statusEffectAudioIndex = 0;
		}

		internal bool PrepareEscapeJump(PlayerControllerB player)
		{
			if ((Object)(object)affected != (Object)(object)player || !Eligible(player))
			{
				return false;
			}
			ClearHazard();
			return true;
		}

		internal void FinishEscapeJump(PlayerControllerB player, bool released)
		{
			if (released)
			{
				if (Jumping.Invoke(player))
				{
					escapeUntil = Time.time + 0.75f;
					player.sinkingValue = 0f;
				}
				else
				{
					UpdateHazard(player, active: true);
				}
			}
		}

		private void ClearHazard()
		{
			if ((Object)(object)affected != (Object)null)
			{
				affected.sourcesCausingSinking = Mathf.Max(0, affected.sourcesCausingSinking - 1);
				affected.isMovementHindered = Mathf.Max(0, affected.isMovementHindered - 1);
				affected.hinderedMultiplier = Mathf.Max(1f, affected.hinderedMultiplier / 2f);
				if (Mathf.Approximately(affected.sinkingSpeedMultiplier, 0.12f))
				{
					affected.sinkingSpeedMultiplier = previousSinkingSpeed;
				}
			}
			if ((Object)(object)HazardPlayer == (Object)(object)affected)
			{
				HazardPlayer = null;
				ActiveHazard = null;
			}
			HazardSupported = false;
			affected = null;
		}

		private void OnDisable()
		{
			ClearHazard();
			if ((Object)(object)snowNavigation != (Object)null)
			{
				((Behaviour)snowNavigation).enabled = false;
			}
		}

		private void OnDestroy()
		{
			PlutoSky.Clear(((Component)this).gameObject);
			ClearHazard();
		}
	}
	[HarmonyPatch(typeof(DungeonManager), "GetValidExtendedDungeonFlows")]
	internal static class PlutoInteriorPool
	{
		private static void Postfix(ExtendedLevel extendedLevel, List<ExtendedDungeonFlowWithRarity> __result)
		{
			if (!((Object)(object)((extendedLevel != null) ? extendedLevel.SelectableLevel : null) == (Object)null) && !(extendedLevel.SelectableLevel.sceneName != "134340Pluto"))
			{
				Replace(__result, PatchedContent.VanillaExtendedDungeonFlows);
			}
		}

		internal static void Replace(List<ExtendedDungeonFlowWithRarity> pool, IEnumerable<ExtendedDungeonFlow> vanilla)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			pool.Clear();
			foreach (ExtendedDungeonFlow item in vanilla)
			{
				if (!((Object)(object)item.DungeonFlow == (Object)null))
				{
					string name = ((Object)item.DungeonFlow).name;
					if (name == "Level3Flow")
					{
						pool.Add(new ExtendedDungeonFlowWithRarity(item, 70));
					}
					if (name == "Level1Flow")
					{
						pool.Add(new ExtendedDungeonFlowWithRarity(item, 30));
					}
				}
			}
			if (pool.Count != 2)
			{
				PlutoCondensationPlugin.Log.LogError((object)"Pluto interior whitelist could not find vanilla mine/facility flows.");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")]
	internal static class IceEscapeJump
	{
		private static void Prefix(PlayerControllerB __instance, out CondensationController __state)
		{
			__state = (((Object)(object)CondensationController.HazardPlayer == (Object)(object)__instance) ? CondensationController.ActiveHazard : null);
			if ((Object)(object)__state != (Object)null && !__state.PrepareEscapeJump(__instance))
			{
				__state = null;
			}
		}

		private static void Postfix(PlayerControllerB __instance, CondensationController __state)
		{
			if ((Object)(object)__state != (Object)null)
			{
				__state.FinishEscapeJump(__instance, released: true);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "CheckConditionsForSinkingInQuicksand")]
	internal static class IceSinkingConditions
	{
		private static void Postfix(PlayerControllerB __instance, ref bool __result)
		{
			if (!((Object)(object)CondensationController.HazardPlayer != (Object)(object)__instance))
			{
				__result = (Object)(object)__instance.thisController != (Object)null && (__instance.thisController.isGrounded || CondensationController.HazardSupported) && !__instance.isInsideFactory && !__instance.isClimbingLadder && !__instance.inSpecialInteractAnimation && (Object)(object)__instance.inAnimationWithEnemy == (Object)null && !__instance.isInElevator && !__instance.isInHangarShipRoom;
			}
		}
	}
	public static class PlutoSky
	{
		public static readonly Vector3 CharonDirection;

		public const float CharonRadius = 0.28f;

		public const float SunRadius = 0.004f;

		public static int RenderCount;

		private static Material material;

		private static Cubemap background;

		private static Light sourceLight;

		public const float MinimumSunSeparation = 0.33f;

		private static readonly MaterialPropertyBlock properties;

		public static Vector3 AvoidCharon(Vector3 direction)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			((Vector3)(ref direction)).Normalize();
			float num = Vector3.Dot(direction, CharonDirection);
			if (num <= Mathf.Cos(0.33f))
			{
				return direction;
			}
			Vector3 val = direction - CharonDirection * num;
			if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
			{
				val = Vector3.up - CharonDirection * CharonDirection.y;
			}
			Vector3 val2 = CharonDirection * Mathf.Cos(0.33f) + ((Vector3)(ref val)).normalized * Mathf.Sin(0.33f);
			return ((Vector3)(ref val2)).normalized;
		}

		public static Vector3 SunDirection(float hour)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Light val = (((Object)(object)TimeOfDay.Instance != (Object)null) ? TimeOfDay.Instance.sunDirect : null);
			if ((Object)(object)val == (Object)null)
			{
				val = sourceLight;
			}
			if ((Object)(object)val != (Object)null)
			{
				return AvoidCharon(-((Component)val).transform.forward);
			}
			float num = Mathf.Clamp01((hour - 6f) / 16f);
			float num2 = 6f + 44f * Mathf.Sin(num * MathF.PI) - Mathf.Max(0f, hour - 22f) * 8f;
			float num3 = Mathf.Lerp(335f, 240f, num) * (MathF.PI / 180f);
			float num4 = num2 * (MathF.PI / 180f);
			return AvoidCharon(new Vector3(Mathf.Cos(num3) * Mathf.Cos(num4), Mathf.Sin(num4), Mathf.Sin(num3) * Mathf.Cos(num4)));
		}

		public static void Initialize(GameObject root)
		{
			//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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			Transform val = root.transform.Find("Pluto dynamic sky references");
			if (!((Object)(object)val == (Object)null))
			{
				Scene scene = root.scene;
				sourceLight = ((Scene)(ref scene)).GetRootGameObjects().SelectMany((GameObject r) => r.GetComponentsInChildren<Light>(true)).FirstOrDefault((Func<Light, bool>)((Light l) => (int)l.type == 1 && ((Object)l).name == "SunWithShadows"));
				material = ((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterial;
				background = (Cubemap)material.GetTexture("_Cubemap");
				SetState(6f, eclipsed: false);
			}
		}

		public static void SetState(float hour, bool eclipsed)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)material == (Object)null))
			{
				material.SetVector("_SunDirection", Vector4.op_Implicit(SunDirection(hour)));
				material.SetVector("_CharonDirection", Vector4.op_Implicit(CharonDirection));
				material.SetFloat("_SunRadius", 0.004f);
				material.SetFloat("_CharonRadius", 0.28f);
				material.SetFloat("_Eclipsed", (float)(eclipsed ? 1 : 0));
			}
		}

		public static void Clear(GameObject root)
		{
			Transform val = root.transform.Find("Pluto dynamic sky references");
			if ((Object)(object)val != (Object)null && (Object)(object)((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterial == (Object)(object)material)
			{
				material = null;
				background = null;
				sourceLight = null;
			}
		}

		public static bool Render(BuiltinSkyParameters p, bool cubemap)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			SkySettings skySettings = p.skySettings;
			HDRISky val = (HDRISky)(object)((skySettings is HDRISky) ? skySettings : null);
			if ((Object)(object)material == (Object)null || (Object)(object)val == (Object)null || (Object)(object)((VolumeParameter<Texture>)(object)val.hdriSky).value != (Object)(object)background)
			{
				return false;
			}
			properties.SetMatrix("_PixelCoordToViewDirWS", p.pixelCoordToViewDirMatrix);
			properties.SetFloat("_SkyIntensity", Mathf.Pow(2f, ((VolumeParameter<float>)(object)((SkySettings)val).exposure).value) * ((VolumeParameter<float>)(object)((SkySettings)val).multiplier).value);
			RenderCount++;
			CoreUtils.DrawFullScreen(p.commandBuffer, material, properties, (!cubemap) ? 1 : 0);
			return true;
		}

		public static void InstallPreview(GameObject root)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Initialize(root);
			new Harmony("elowi.pluto.sky.preview").PatchAll(typeof(PlutoSkyRenderHook));
		}

		public static void RemovePreview(GameObject root)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("elowi.pluto.sky.preview").UnpatchSelf();
			Clear(root);
		}

		static PlutoSky()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			Vector3 val = Quaternion.Euler(0f, -25f, 0f) * new Vector3(-1f, 0.59f, -0.18f);
			CharonDirection = ((Vector3)(ref val)).normalized;
			properties = new MaterialPropertyBlock();
		}
	}
	[HarmonyPatch]
	internal static class PlutoSkyRenderHook
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(AccessTools.TypeByName("UnityEngine.Rendering.HighDefinition.HDRISkyRenderer"), "RenderSky", (Type[])null, (Type[])null);
		}

		private static bool Prefix(BuiltinSkyParameters builtinParams, bool renderForCubemap)
		{
			return !PlutoSky.Render(builtinParams, renderForCubemap);
		}
	}
}

ElowinyPuck.Runtime.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ElowinyPuck.Runtime")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.5.4.0")]
[assembly: AssemblyInformationalVersion("0.5.4+15d6f9d5fbd32de9b1884f29ddec3be9133bd912")]
[assembly: AssemblyProduct("ElowinyPuck.Runtime")]
[assembly: AssemblyTitle("ElowinyPuck.Runtime")]
[assembly: AssemblyVersion("0.5.4.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 ElowinyPuck
{
	public static class GravityActorVerification
	{
		private static void Check(bool ok, string why)
		{
			if (!ok)
			{
				throw new InvalidOperationException("GRAVITY_ACTOR_FIXTURE_FAILED " + why);
			}
		}

		public unsafe static void Run()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_002a: 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_0043: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Expected O, but got Unknown
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_0133: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: 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_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			PuckWorld.Discover(force: true);
			Check(PuckWorld.RingMode, "ring not active");
			Physics.SyncTransforms();
			PuckSurface.Clear();
			GameObject val = new GameObject("Ring actor collision fixture");
			try
			{
				Vector3 val2 = PuckSurface.Sample(PuckWorld.Centre + new Vector3(8f, -75f, 0f));
				float[] array = new float[3]
				{
					MathF.PI / 2f,
					MathF.PI,
					4.712389f
				};
				for (int i = 0; i < array.Length; i++)
				{
					float num = array[i];
					Vector3 val3 = PuckWorld.Centre + new Vector3(8f, (0f - Mathf.Cos(num)) * 75f, Mathf.Sin(num) * 75f);
					Vector3[] array2 = PuckSurface.Route(val2, val3);
					Check(array2.Length > 5, "no route to quarter " + num);
					val.transform.position = val2;
					int num2 = 0;
					int num3 = 0;
					Vector3 val5;
					while (num2 < array2.Length && num3++ < 7000)
					{
						if (Vector3.Distance(val.transform.position, array2[num2]) < 0.7f)
						{
							num2++;
							continue;
						}
						Vector3 val4 = PuckWorld.UpAt(val.transform.position);
						Transform transform = val.transform;
						val5 = Vector3.ProjectOnPlane(array2[num2] - val.transform.position, val4);
						PuckEnemyMotor.MoveSurface(transform, ((Vector3)(ref val5)).normalized, 0.15f);
					}
					bool ok = num2 == array2.Length;
					string[] obj = new string[6]
					{
						"ring follower blocked quarter=",
						num.ToString(),
						" waypoint=",
						num2.ToString(),
						" pos=",
						null
					};
					val5 = val.transform.position;
					obj[5] = ((object)(*(Vector3*)(&val5))/*cast due to .constrained prefix*/).ToString();
					Check(ok, string.Concat(obj));
					val5 = PuckCruiserGravity.Acceleration(val3);
					Check(Vector3.Dot(((Vector3)(ref val5)).normalized, -PuckWorld.UpAt(val3)) > 0.999f, "cruiser force");
					Debug.Log((object)("TYAUR_ACTOR_ROUTE_OK quarter=" + num + " nodes=" + array2.Length + " steps=" + num3));
				}
				Type[] array3 = new Type[10]
				{
					typeof(MaskedPlayerEnemy),
					typeof(MouthDogAI),
					typeof(BaboonBirdAI),
					typeof(ForestGiantAI),
					typeof(FlowerSnakeEnemy),
					typeof(RadMechAI),
					typeof(GiantKiwiAI),
					typeof(DoublewingAI),
					typeof(DocileLocustBeesAI),
					typeof(RedLocustBees)
				};
				foreach (Type type in array3)
				{
					GameObject val6 = new GameObject("Gravity species fixture " + type.Name);
					val6.SetActive(false);
					try
					{
						val6.transform.position = val2;
						EnemyAI val7 = (EnemyAI)val6.AddComponent(type);
						((Behaviour)val7).enabled = false;
						val7.isOutside = true;
						Check(PuckActors.Outside(val7), "species not enabled " + type.Name);
						Vector3 val8 = PuckWorld.UpAt(val2);
						PuckActorHooks.Rotation(val6.transform, Quaternion.identity);
						Check(Vector3.Dot(val6.transform.up, val8) > 0.999f, "root rotation adapter " + type.Name);
						Check((from m in type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
							where m.GetMethodBody() != null && !m.ContainsGenericParameters
							select m).Any((MethodInfo m) => PuckActorHooks.Rewrite(PuckVerification.ReadInstructions(m), m).Any((CodeInstruction val12) => val12.operand is MethodInfo methodInfo && (methodInfo.DeclaringType == typeof(PuckActorHooks) || methodInfo.DeclaringType == typeof(GravitySpecies)))), "no rewritten calls " + type.Name);
						if (val7 is GiantKiwiAI)
						{
							Vector3 v = PuckWorld.Centre + Vector3.up * 75f;
							GravitySpecies.KeepHeight(ref v, -2f, val7);
							Check(v.y > PuckWorld.Centre.y + 70f, "kiwi ship-Y flattening");
						}
						RadMechAI val9 = (RadMechAI)(object)((val7 is RadMechAI) ? val7 : null);
						if (val9 != null)
						{
							AccessTools.Field(type, "inFlyingMode").SetValue(val9, true);
							Vector3 val10 = PuckWorld.Centre + new Vector3(8f, 0f, 75f);
							AccessTools.Field(type, "landingPosition").SetValue(val9, val10);
							Vector3 val11 = GravitySpecies.FlightStep(val2, val10, 0.2f, val9);
							Check(PuckSurface.Ground(val11, out var ground) && Mathf.Abs(Vector3.Dot(val11 - ground, PuckWorld.UpAt(val11)) - 2f) < 0.1f, "Old Bird flight follows curved surface");
						}
						Debug.Log((object)("GRAVITY_SPECIES_ADAPTER_OK " + type.Name));
					}
					finally
					{
						Object.DestroyImmediate((Object)(object)val6);
					}
				}
				Debug.Log((object)"TYAUR_ACTOR_FIXTURE_OK graph/follower/ten species adapters/radial cruiser; live AI and network behaviour still require playtesting");
			}
			finally
			{
				Object.DestroyImmediate((Object)(object)val);
				PuckWorld.Clear();
			}
		}
	}
	public static class GravitySpecies
	{
		private sealed class FlightRoute
		{
			public Vector3 Goal;

			public Vector3[] Points;

			public int Index;

			public float Expires;
		}

		private static readonly Dictionary<int, FlightRoute> flights = new Dictionary<int, FlightRoute>();

		public static void Clear()
		{
			flights.Clear();
		}

		private static FieldInfo Field(Type t, string n)
		{
			return AccessTools.Field(t, n) ?? throw new MissingFieldException(t.Name, n);
		}

		private static T Get<T>(object obj, string name)
		{
			return (T)Field(obj.GetType(), name).GetValue(obj);
		}

		private static void Set(object obj, string name, object value)
		{
			Field(obj.GetType(), name).SetValue(obj, value);
		}

		public static void Install(Harmony h)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			string[] array = new string[6] { "leaping", "leapDirection", "leapTime", "hitWallInLeap", "fallFromLeapTimer", "fallingFromLeap" };
			foreach (string n in array)
			{
				Field(typeof(FlowerSnakeEnemy), n);
			}
			array = new string[3] { "inFlyingMode", "landingPosition", "finishingFlight" };
			foreach (string n2 in array)
			{
				Field(typeof(RadMechAI), n2);
			}
			Field(typeof(GiantKiwiAI), "birdNest");
			h.Patch((MethodBase)AccessTools.Method(typeof(FlowerSnakeEnemy), "DoLeapAndDropPhysics", (Type[])null, (Type[])null), new HarmonyMethod(typeof(GravitySpecies), "Leap", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			h.Patch((MethodBase)AccessTools.Method(typeof(GiantKiwiAI), "SpawnNestEggs", (Type[])null, (Type[])null), new HarmonyMethod(typeof(GravitySpecies), "KiwiNest", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			h.Patch((MethodBase)AccessTools.Method(typeof(DoublewingAI), "TryLanding", (Type[])null, (Type[])null), new HarmonyMethod(typeof(GravitySpecies), "BirdLanding", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			h.Patch((MethodBase)AccessTools.Method(typeof(NetworkObject), "Spawn", new Type[1] { typeof(bool) }, (Type[])null), new HarmonyMethod(typeof(GravitySpecies), "NestSpawn", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static void KeepHeight(ref Vector3 v, float y, object owner)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			EnemyAI val = (EnemyAI)((owner is EnemyAI) ? owner : null);
			if (val == null || !PuckActors.Outside(val) || !PuckWorld.Near(v))
			{
				v.y = y;
			}
		}

		private static void AlignNest(GameObject g)
		{
			//IL_000f: 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_003a: 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)
			if ((Object)(object)g != (Object)null && PuckWorld.Near(g.transform.position) && (Object)(object)g.GetComponent<EnemyAINestSpawnObject>() != (Object)null)
			{
				g.transform.rotation = PuckWorld.SurfaceFrame(PuckWorld.UpAt(g.transform.position), g.transform.forward);
			}
		}

		private static void NestSpawn(NetworkObject __instance)
		{
			AlignNest(((Component)__instance).gameObject);
		}

		private static void KiwiNest(GiantKiwiAI __instance)
		{
			//IL_0025: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (PuckActors.Outside((EnemyAI)(object)__instance))
			{
				AlignNest(Get<GameObject>(__instance, "birdNest"));
				((Component)__instance).transform.rotation = PuckWorld.SurfaceFrame(PuckWorld.UpAt(((Component)__instance).transform.position), ((Component)__instance).transform.forward);
			}
		}

		private static bool BirdLanding(DoublewingAI __instance, ref bool __result)
		{
			//IL_0013: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (!PuckActors.Outside((EnemyAI)(object)__instance))
			{
				return true;
			}
			__result = false;
			if (!PuckSurface.Ground(((Component)__instance).transform.position, out var ground))
			{
				return false;
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null && Physics.CheckSphere(ground, 16f, StartOfRound.Instance.playersMask, (QueryTriggerInteraction)1))
			{
				return false;
			}
			if (Vector3.Distance(ground, ((Component)__instance).transform.position) > 1f)
			{
				if (!((EnemyAI)__instance).SetDestinationToPosition(ground, true))
				{
					return false;
				}
				PuckActorHooks.Warp(((EnemyAI)__instance).agent, ((EnemyAI)__instance).destination);
			}
			__result = true;
			return false;
		}

		public static Vector3 FlightStep(Vector3 from, Vector3 to, float distance, RadMechAI owner)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009d: 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)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			if (!PuckActors.Outside((EnemyAI)(object)owner) || !Get<bool>(owner, "inFlyingMode") || Vector3.Distance(from, ((Component)owner).transform.position) > 0.01f)
			{
				return Vector3.MoveTowards(from, to, distance);
			}
			if (!PuckSurface.Ground(from, out var ground))
			{
				return from;
			}
			Vector3 val = PuckWorld.UpAt(from);
			Vector3 val2 = Vector3.ProjectOnPlane(to - from, val);
			int instanceID = ((Object)owner).GetInstanceID();
			if (!flights.TryGetValue(instanceID, out var value) || Time.time > value.Expires || Vector3.Distance(value.Goal, to) > 3f)
			{
				value = new FlightRoute
				{
					Goal = to,
					Points = PuckSurface.Route(ground, to),
					Expires = Time.time + 2f
				};
				flights[instanceID] = value;
			}
			while (value.Index < value.Points.Length && Vector3.Distance(value.Points[value.Index], ground) < 1f)
			{
				value.Index++;
			}
			Vector3 val3 = ((value.Index < value.Points.Length) ? value.Points[value.Index] : to);
			if (val3 != Vector3.zero)
			{
				val2 = Vector3.ProjectOnPlane(val3 - ground, val);
			}
			if (!PuckSurface.Ground(ground + ((Vector3)(ref val2)).normalized * Mathf.Min(distance, ((Vector3)(ref val2)).magnitude), out var ground2))
			{
				return from;
			}
			return ground2 + PuckWorld.UpAt(ground2) * 2f;
		}

		public static Vector3 FlightVector(float x, float y, float z, RadMechAI owner)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 result = default(Vector3);
			((Vector3)(ref result))..ctor(x, y, z);
			if (!PuckActors.Outside((EnemyAI)(object)owner) || !Get<bool>(owner, "inFlyingMode"))
			{
				return result;
			}
			Vector3 val = Get<Vector3>(owner, "landingPosition");
			if (Mathf.Abs(x - val.x) < 0.001f && Mathf.Abs(z - val.z) < 0.001f && Mathf.Abs(y - ((Component)owner).transform.position.y) < 0.001f && PuckSurface.Ground(val, out var ground))
			{
				return ground + PuckWorld.UpAt(ground) * 2f;
			}
			return result;
		}

		private static bool Leap(FlowerSnakeEnemy __instance)
		{
			//IL_0059: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			if (!PuckActors.Outside((EnemyAI)(object)__instance))
			{
				return true;
			}
			float num = Mathf.Min(Time.deltaTime, 0.05f);
			if (Get<bool>(__instance, "fallingFromLeap"))
			{
				float num2 = Get<float>(__instance, "fallFromLeapTimer") - num;
				Set(__instance, "fallFromLeapTimer", num2);
				((Component)__instance).transform.position = Vector3.MoveTowards(((Component)__instance).transform.position, __instance.landingPoint, 5f * num);
				if (num2 <= 0f || Vector3.Distance(((Component)__instance).transform.position, __instance.landingPoint) < 0.02f)
				{
					if (((NetworkBehaviour)__instance).IsOwner)
					{
						PuckActorHooks.SetEnabled((Behaviour)(object)((EnemyAI)__instance).agent, value: true);
					}
					((EnemyAI)__instance).inSpecialAnimation = false;
					Set(__instance, "fallingFromLeap", false);
				}
			}
			if (!Get<bool>(__instance, "leaping") || (Object)(object)__instance.clingingToPlayer != (Object)null)
			{
				return false;
			}
			bool flag = Get<bool>(__instance, "hitWallInLeap");
			float num3 = Get<float>(__instance, "leapTime") + num * (float)((!flag) ? 1 : 2) / Mathf.Max(0.1f, __instance.leapTimeMultiplier);
			Set(__instance, "leapTime", num3);
			if (!PuckSurface.Ground(((Component)__instance).transform.position, out var ground) || num3 > 1f)
			{
				__instance.StopLeapOnLocalClient(true, ground);
				return false;
			}
			Vector3 val = PuckWorld.UpAt(ground);
			Vector3 val2 = Vector3.ProjectOnPlane(Get<Vector3>(__instance, "leapDirection"), val);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			if (!PuckSurface.Ground(ground + normalized * (flag ? 0f : (__instance.leapSpeedMultiplier * num)), out var ground2))
			{
				Set(__instance, "hitWallInLeap", true);
				return false;
			}
			float num4 = Mathf.Max(0.1f, __instance.leapVerticalCurve.Evaluate(num3) * __instance.leapVerticalMultiplier);
			Vector3 val3 = ground2 + PuckWorld.UpAt(ground2) * num4;
			if (Physics.Linecast(((Component)__instance).transform.position, val3, 301992193, (QueryTriggerInteraction)1))
			{
				if (num3 > 0.45f)
				{
					Set(__instance, "hitWallInLeap", true);
				}
				return false;
			}
			((Component)__instance).transform.position = val3;
			((Component)__instance).transform.rotation = PuckWorld.SurfaceFrame(PuckWorld.UpAt(val3), normalized);
			return false;
		}
	}
	[HarmonyPatch(typeof(RoundManager), "PositionEdgeCheck")]
	internal static class GravityNestEdge
	{
		private static bool Prefix(Vector3 position, float width, ref Vector3 __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (!PuckWorld.Near(position))
			{
				return true;
			}
			__result = PuckSurface.Sample(position);
			return false;
		}
	}
	[HarmonyPatch(typeof(EnemyAI), "Update")]
	internal static class GravityEnemyGround
	{
		private static void Postfix(EnemyAI __instance)
		{
			//IL_0027: 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_003c: 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 (PuckActors.Outside(__instance) && !__instance.inSpecialAnimation && ((NetworkBehaviour)__instance).IsOwner && __instance is RadMechAI && PuckSurface.Ground(((Component)__instance).transform.position, out var ground) && Vector3.Distance(ground, ((Component)__instance).transform.position) > 1f)
			{
				((Component)__instance).transform.position = ground;
			}
		}
	}
	[HarmonyPatch(typeof(DoublewingAI), "Update")]
	internal static class GravityBirdFrame
	{
		private static void Postfix(DoublewingAI __instance)
		{
			//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_0037: Unknown result type (might be due to invalid IL or missing references)
			if (PuckActors.Outside((EnemyAI)(object)__instance) && (Object)(object)__instance.Body != (Object)null)
			{
				__instance.Body.rotation = PuckWorld.SurfaceFrame(PuckWorld.UpAt(__instance.Body.position), __instance.Body.forward);
			}
		}
	}
	public interface IGravitySurface
	{
		float ProbeDistance { get; }

		Vector3 Up(Vector3 position);

		bool Contains(Vector3 position);

		Ray GroundRay(Vector3 position);

		Vector3 Interpolate(Vector3 a, Vector3 b, float fraction);

		IEnumerable<Vector3> NavigationSeeds();

		Vector3 FallbackFloor(Vector3 position, float offset);
	}
	public sealed class SphereGravitySurface : IGravitySurface
	{
		private readonly Func<Vector3> centre;

		private readonly float radius;

		private readonly float range;

		public float ProbeDistance => radius + 30f;

		public SphereGravitySurface(Func<Vector3> centre, float radius, float range)
		{
			this.centre = centre;
			this.radius = radius;
			this.range = range;
		}

		public Vector3 Up(Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			Vector3 val = p - centre();
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
			{
				return ((Vector3)(ref val)).normalized;
			}
			return Vector3.up;
		}

		public bool Contains(Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = p - centre();
			return ((Vector3)(ref val)).sqrMagnitude < range * range;
		}

		public Ray GroundRay(Vector3 p)
		{
			//IL_0006: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//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)
			return new Ray(centre() + Up(p) * (radius + 27.5f), -Up(p));
		}

		public Vector3 Interpolate(Vector3 a, Vector3 b, float t)
		{
			//IL_0006: 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_0013: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return centre() + Vector3.Slerp(Up(a), Up(b), t) * (radius + 2.5f);
		}

		public IEnumerable<Vector3> NavigationSeeds()
		{
			for (int row = 1; row < 32; row++)
			{
				for (int col = 0; col < 64; col++)
				{
					float num = (float)row * MathF.PI / 32f;
					float num2 = (float)col * MathF.PI * 2f / 64f;
					yield return centre() + new Vector3(Mathf.Sin(num) * Mathf.Cos(num2), Mathf.Cos(num), Mathf.Sin(num) * Mathf.Sin(num2)) * (radius + 2.5f);
				}
			}
			yield return centre() + Vector3.up * (radius + 2.5f);
			yield return centre() + Vector3.down * (radius + 2.5f);
		}

		public Vector3 FallbackFloor(Vector3 p, float offset)
		{
			//IL_0006: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			return centre() + Up(p) * (radius + offset);
		}
	}
	public sealed class InnerCylinderGravitySurface : IGravitySurface
	{
		private readonly Func<Vector3> centre;

		private readonly Vector3 axis;

		private readonly float radius;

		private readonly float halfWidth;

		public float ProbeDistance => radius + 25f;

		public InnerCylinderGravitySurface(Func<Vector3> centre, Vector3 axis, float radius, float halfWidth)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			this.centre = centre;
			this.axis = ((Vector3)(ref axis)).normalized;
			this.radius = radius;
			this.halfWidth = halfWidth;
		}

		private Vector3 AxisPoint(Vector3 p)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			return centre() + axis * Vector3.Dot(p - centre(), axis);
		}

		public Vector3 Up(Vector3 p)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = AxisPoint(p) - p;
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
			{
				return ((Vector3)(ref val)).normalized;
			}
			Vector3 val2 = Vector3.ProjectOnPlane(Vector3.up, axis);
			return ((Vector3)(ref val2)).normalized;
		}

		public bool Contains(Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (Mathf.Abs(Vector3.Dot(p - centre(), axis)) < halfWidth + 48f)
			{
				Vector3 val = p - AxisPoint(p);
				return ((Vector3)(ref val)).sqrMagnitude < (radius + 45f) * (radius + 45f);
			}
			return false;
		}

		public Ray GroundRay(Vector3 p)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Ray(AxisPoint(p), -Up(p));
		}

		public Vector3 Interpolate(Vector3 a, Vector3 b, float t)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			return Vector3.Lerp(AxisPoint(a), AxisPoint(b), t) - Vector3.Slerp(Up(a), Up(b), t) * (radius - 2f);
		}

		public IEnumerable<Vector3> NavigationSeeds()
		{
			Vector3 val = Vector3.ProjectOnPlane(Vector3.up, axis);
			Vector3 u = ((Vector3)(ref val)).normalized;
			Vector3 v = Vector3.Cross(axis, u);
			for (int row = 0; row < 160; row++)
			{
				for (int col = 0; col <= 14; col++)
				{
					float num = (float)row * MathF.PI * 2f / 160f;
					float num2 = Mathf.Lerp(0f - halfWidth + 1f, halfWidth - 1f, (float)col / 14f);
					yield return centre() + axis * num2 + (u * Mathf.Cos(num) + v * Mathf.Sin(num)) * (radius - 2f);
				}
			}
		}

		public Vector3 FallbackFloor(Vector3 p, float offset)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return AxisPoint(p) - Up(p) * (radius - offset);
		}
	}
	public static class GravitySurfaces
	{
		private static readonly Dictionary<string, IGravitySurface> providers = new Dictionary<string, IGravitySurface>
		{
			{
				"ElowinyPuckProject_RadialSphere",
				new SphereGravitySurface(() => PuckWorld.Centre, 37.5f, 90f)
			},
			{
				"ElowinyTyaurProject_InnerRing",
				new InnerCylinderGravitySurface(() => PuckWorld.Centre, Vector3.right, 75f, 21f)
			}
		};

		public static string Marker = "ElowinyPuckProject_RadialSphere";

		public static IGravitySurface Current
		{
			get
			{
				if (!providers.TryGetValue(Marker, out var value))
				{
					return providers["ElowinyPuckProject_RadialSphere"];
				}
				return value;
			}
		}

		public static void Register(string rootMarker, IGravitySurface surface)
		{
			if (string.IsNullOrEmpty(rootMarker) || surface == null)
			{
				throw new ArgumentException("Marker and gravity surface required");
			}
			providers[rootMarker] = surface;
			PuckSurface.Clear();
		}

		public static bool Knows(string rootMarker)
		{
			return providers.ContainsKey(rootMarker);
		}
	}
	public static class MoonPresentation
	{
		private static bool installed;

		private static Volume sky;

		private static Transform dungeon;

		private static Renderer[] rooms;

		private static float next;

		private static readonly Dictionary<Renderer, bool> hidden = new Dictionary<Renderer, bool>();

		public static void Install()
		{
			if (!installed)
			{
				installed = true;
				RenderPipelineManager.beginCameraRendering += Begin;
				RenderPipelineManager.endCameraRendering += End;
			}
		}

		public static bool HideInterior(bool active, bool inside)
		{
			if (active)
			{
				return !inside;
			}
			return false;
		}

		public static void Tick()
		{
			if (!PuckWorld.Active)
			{
				return;
			}
			if ((Object)(object)sky == (Object)null && !PuckWorld.RingMode)
			{
				GameObject obj = GameObject.Find("ElowinyPuckProject_RadialSphere");
				sky = ((obj != null) ? ((IEnumerable<Volume>)obj.GetComponentsInChildren<Volume>(true)).FirstOrDefault((Func<Volume, bool>)((Volume v) => ((Object)v).name == "Puck Uranus sky")) : null);
				if ((Object)(object)sky != (Object)null)
				{
					sky.isGlobal = true;
					sky.priority = 100000f;
				}
			}
			if ((Object)(object)sky != (Object)null)
			{
				Volume obj2 = sky;
				GameNetworkManager instance = GameNetworkManager.Instance;
				((Behaviour)obj2).enabled = instance == null || instance.localPlayerController?.isInsideFactory != true;
			}
			MoonShipPlacement.Tick();
		}

		private static void Begin(ScriptableRenderContext context, Camera camera)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			Restore();
			if (!PuckWorld.Active || (int)camera.cameraType != 1)
			{
				return;
			}
			Tick();
			PlayerControllerB val = ((Component)camera).GetComponentInParent<PlayerControllerB>() ?? GameNetworkManager.Instance?.localPlayerController;
			bool inside = val?.isInsideFactory ?? false;
			if ((Object)(object)val != (Object)null && val.isPlayerDead && (Object)(object)val.spectatedPlayerScript != (Object)null)
			{
				inside = val.spectatedPlayerScript.isInsideFactory;
			}
			ManualCameraRenderer val2 = StartOfRound.Instance?.mapScreen;
			if ((Object)(object)val2 != (Object)null && ((Object)(object)camera == (Object)(object)val2.mapCamera || (Object)(object)camera == (Object)(object)val2.headMountedCam))
			{
				if ((Object)(object)val2.targetedPlayer != (Object)null)
				{
					inside = val2.targetedPlayer.isInsideFactory;
				}
				else if (val2.targetTransformIndex >= 0 && val2.targetTransformIndex < val2.radarTargets.Count)
				{
					Transform transform = val2.radarTargets[val2.targetTransformIndex].transform;
					inside = transform != null && ((Component)transform).GetComponentInParent<GrabbableObject>()?.isInFactory == true;
				}
			}
			if (!HideInterior(PuckWorld.Active, inside))
			{
				return;
			}
			RoundManager instance = RoundManager.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				RuntimeDungeon dungeonGenerator = instance.dungeonGenerator;
				if (dungeonGenerator == null)
				{
					obj = null;
				}
				else
				{
					DungeonGenerator generator = dungeonGenerator.Generator;
					obj = ((generator != null) ? generator.CurrentDungeon : null);
				}
			}
			Dungeon val3 = (Dungeon)obj;
			Transform val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).transform : null);
			if ((Object)(object)val4 == (Object)null)
			{
				return;
			}
			if ((Object)(object)dungeon != (Object)(object)val4 || Time.unscaledTime >= next)
			{
				dungeon = val4;
				rooms = ((Component)val4).GetComponentsInChildren<Renderer>(true).Concat((from e in Object.FindObjectsOfType<EnemyAI>()
					where !e.isOutside
					select e).SelectMany((EnemyAI e) => ((Component)e).GetComponentsInChildren<Renderer>(true))).Concat((from g in Object.FindObjectsOfType<GrabbableObject>()
					where g.isInFactory
					select g).SelectMany((GrabbableObject g) => ((Component)g).GetComponentsInChildren<Renderer>(true)))
					.Distinct()
					.ToArray();
				next = Time.unscaledTime + 1f;
			}
			HideRenderers(rooms);
		}

		private static void End(ScriptableRenderContext context, Camera camera)
		{
			Restore();
		}

		public static void HideRenderers(Renderer[] renderers)
		{
			foreach (Renderer val in renderers)
			{
				if ((Object)(object)val != (Object)null && !hidden.ContainsKey(val))
				{
					hidden[val] = val.forceRenderingOff;
					val.forceRenderingOff = true;
				}
			}
		}

		public static void Restore()
		{
			foreach (KeyValuePair<Renderer, bool> item in hidden)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					item.Key.forceRenderingOff = item.Value;
				}
			}
			hidden.Clear();
		}

		public static void Clear()
		{
			Restore();
			sky = null;
			dungeon = null;
			rooms = null;
			next = 0f;
			MoonShipPlacement.Clear();
		}
	}
	public static class MoonShipPlacement
	{
		private static Transform parent;

		private static Transform anchor;

		private static Vector3 offset;

		private static bool applied;

		public static void Tick()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if (applied || !PuckWorld.Active)
			{
				return;
			}
			GameObject val = GameObject.Find("Elowiny ship placement offset");
			if (!((Object)(object)val == (Object)null))
			{
				StartOfRound instance = StartOfRound.Instance;
				if (!((Object)(object)instance?.shipAnimator == (Object)null) && !((Object)(object)((Component)instance.shipAnimator).transform.parent == (Object)null))
				{
					offset = val.transform.localPosition;
					parent = ((Component)instance.shipAnimator).transform.parent;
					anchor = instance.shipLandingPosition;
					TranslateShipAssembly(instance, offset);
					applied = true;
				}
			}
		}

		public static void TranslateShipAssembly(StartOfRound r, Vector3 delta)
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)r.shipAnimator).transform.parent;
			Transform shipLandingPosition = r.shipLandingPosition;
			if ((Object)(object)r.shipInnerRoomBounds != (Object)null && r.allPlayerScripts != null)
			{
				PlayerControllerB[] allPlayerScripts = r.allPlayerScripts;
				foreach (PlayerControllerB val2 in allPlayerScripts)
				{
					if ((Object)(object)val2 != (Object)null && !((Component)val2).transform.IsChildOf(val))
					{
						Bounds bounds = r.shipInnerRoomBounds.bounds;
						if (((Bounds)(ref bounds)).Contains(((Component)val2).transform.position + Vector3.up * 0.25f))
						{
							Transform transform = ((Component)val2).transform;
							transform.position += delta;
						}
					}
				}
			}
			val.position += delta;
			if ((Object)(object)shipLandingPosition != (Object)null && !shipLandingPosition.IsChildOf(val))
			{
				shipLandingPosition.position += delta;
			}
			Physics.SyncTransforms();
		}

		public static void Clear()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (applied && (Object)(object)parent != (Object)null)
			{
				StartOfRound instance = StartOfRound.Instance;
				if ((Object)(object)instance != (Object)null)
				{
					TranslateShipAssembly(instance, -offset);
				}
				else
				{
					Transform obj = parent;
					obj.position -= offset;
				}
			}
			applied = false;
			parent = (anchor = null);
			offset = Vector3.zero;
		}
	}
	public static class PuckSurface
	{
		private const int Rows = 32;

		private const int Columns = 64;

		public const int Mask = 301992193;

		private static Vector3[] points;

		private static List<int>[] edges;

		private static bool[] valid;

		public static int Count
		{
			get
			{
				Vector3[] array = points;
				if (array == null)
				{
					return 0;
				}
				return array.Length;
			}
		}

		public static Mesh BakeNavigation()
		{
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			Clear();
			BuildRing();
			int[] array = (from i in Enumerable.Range(0, points.Length)
				where valid[i]
				select i).ToArray();
			Dictionary<int, int> dictionary = array.Select((int id, int n) => new { id, n }).ToDictionary(p => p.id, p => p.n);
			List<int> list = new List<int>();
			int[] array2 = array;
			foreach (int num2 in array2)
			{
				foreach (int item in edges[num2])
				{
					if (item > num2 && valid[item])
					{
						list.Add(dictionary[num2]);
						list.Add(dictionary[item]);
					}
				}
			}
			Mesh val = new Mesh
			{
				name = "Tyaur baked navigation",
				indexFormat = (IndexFormat)1,
				vertices = array.Select((int i) => points[i] - PuckWorld.Centre).ToArray()
			};
			val.SetIndices(list.ToArray(), (MeshTopology)3, 0);
			val.RecalculateBounds();
			return val;
		}

		private static bool LoadNavigation()
		{
			GameObject val = GameObject.Find("ElowinyTyaurProject_InnerRing");
			object obj;
			if (val == null)
			{
				obj = null;
			}
			else
			{
				Transform obj2 = val.transform.Find("Baked radial navigation");
				obj = ((obj2 != null) ? ((Component)obj2).GetComponent<MeshFilter>() : null);
			}
			MeshFilter f = (MeshFilter)obj;
			if ((Object)(object)f == (Object)null || (Object)(object)f.sharedMesh == (Object)null)
			{
				return false;
			}
			Stopwatch stopwatch = Stopwatch.StartNew();
			Mesh sharedMesh = f.sharedMesh;
			points = sharedMesh.vertices.Select((Vector3 p) => ((Component)f).transform.TransformPoint(p)).ToArray();
			edges = points.Select((Vector3 p) => new List<int>()).ToArray();
			valid = Enumerable.Repeat(element: true, points.Length).ToArray();
			int[] indices = sharedMesh.GetIndices(0);
			for (int num = 0; num < indices.Length; num += 2)
			{
				edges[indices[num]].Add(indices[num + 1]);
				edges[indices[num + 1]].Add(indices[num]);
			}
			Debug.Log((object)("TYAUR_NAV_LOADED nodes=" + points.Length + " milliseconds=" + stopwatch.ElapsedMilliseconds));
			return points.Length != 0;
		}

		public static void Clear()
		{
			points = null;
			edges = null;
			valid = null;
			PuckActorHooks.Paths.Clear();
		}

		public static bool Ground(Vector3 position, out Vector3 ground)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = PuckWorld.UpAt(position);
			ground = position;
			foreach (RaycastHit item in from h in Physics.RaycastAll(GravitySurfaces.Current.GroundRay(position), GravitySurfaces.Current.ProbeDistance, 301992193, (QueryTriggerInteraction)1)
				orderby ((RaycastHit)(ref h)).distance
				select h)
			{
				RaycastHit current = item;
				if (!((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<EnemyAI>() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<VehicleController>() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<PlayerControllerB>() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent<GrabbableObject>() != (Object)null) && ((Component)((RaycastHit)(ref current)).collider).GetComponentsInParent<Transform>().Any((Transform t) => ((Object)t).name == GravitySurfaces.Marker))
				{
					if (Vector3.Dot(((RaycastHit)(ref current)).normal, val) < 0.55f)
					{
						return false;
					}
					ground = ((RaycastHit)(ref current)).point + val * 0.04f;
					return true;
				}
			}
			return false;
		}

		public static bool Edge(Vector3 a, Vector3 b, float radius = 0.55f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0083: 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_0085: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Max(1, Mathf.CeilToInt(Vector3.Distance(a, b) / 0.7f));
			Vector3 val = a;
			RaycastHit val7 = default(RaycastHit);
			for (int i = 1; i <= num; i++)
			{
				if (!Ground(GravitySurfaces.Current.Interpolate(a, b, (float)i / (float)num), out var ground))
				{
					return false;
				}
				Vector3 val2 = PuckWorld.UpAt(ground);
				Vector3 val3 = ground - val;
				float num2 = Mathf.Abs(Vector3.Dot(val3, val2));
				Vector3 val4 = Vector3.ProjectOnPlane(val3, val2);
				if (num2 > Mathf.Max(0.4f, ((Vector3)(ref val4)).magnitude * 0.9f))
				{
					return false;
				}
				Vector3 val5 = val + PuckWorld.UpAt(val) * 1.05f;
				Vector3 val6 = ground + val2 * 1.05f;
				val4 = val6 - val5;
				if (Physics.SphereCast(val5, radius, ((Vector3)(ref val4)).normalized, ref val7, Vector3.Distance(val5, val6), 301992193, (QueryTriggerInteraction)1))
				{
					return false;
				}
				val = ground;
			}
			return true;
		}

		public static void Build()
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if (points != null)
			{
				return;
			}
			if (GravitySurfaces.Current is InnerCylinderGravitySurface)
			{
				if (!LoadNavigation())
				{
					BuildRing();
				}
				return;
			}
			if (!(GravitySurfaces.Current is SphereGravitySurface))
			{
				BuildCustom();
				return;
			}
			int num = 1986;
			points = (Vector3[])(object)new Vector3[num];
			edges = new List<int>[num];
			valid = new bool[num];
			for (int i = 1; i < 32; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num2 = (float)i * MathF.PI / 32f;
					float num3 = (float)j * MathF.PI * 2f / 64f;
					int num4 = (i - 1) * 64 + j;
					valid[num4] = Ground(PuckWorld.Centre + new Vector3(Mathf.Sin(num2) * Mathf.Cos(num3), Mathf.Cos(num2), Mathf.Sin(num2) * Mathf.Sin(num3)) * 40f, out points[num4]);
				}
			}
			valid[num - 2] = Ground(PuckWorld.Centre + Vector3.up * 40f, out points[num - 2]);
			valid[num - 1] = Ground(PuckWorld.Centre + Vector3.down * 40f, out points[num - 1]);
			for (int k = 0; k < num; k++)
			{
				edges[k] = new List<int>();
			}
			Action<int, int> action = delegate(int a, int b)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (a < b && valid[a] && valid[b] && Edge(points[a], points[b]))
				{
					edges[a].Add(b);
					edges[b].Add(a);
				}
			};
			for (int num5 = 1; num5 < 32; num5++)
			{
				for (int num6 = 0; num6 < 64; num6++)
				{
					int arg = (num5 - 1) * 64 + num6;
					for (int num7 = -1; num7 <= 1; num7++)
					{
						for (int num8 = -1; num8 <= 1; num8++)
						{
							int num9 = num5 + num7;
							if (num9 > 0 && num9 < 32)
							{
								action(arg, (num9 - 1) * 64 + (num6 + num8 + 64) % 64);
							}
						}
					}
					if (num5 == 1)
					{
						action(arg, num - 2);
					}
					if (num5 == 31)
					{
						action(arg, num - 1);
					}
				}
			}
			bool[] array = new bool[num];
			List<int> list = new List<int>();
			for (int num10 = 0; num10 < num; num10++)
			{
				if (!valid[num10] || array[num10])
				{
					continue;
				}
				List<int> list2 = new List<int>();
				Queue<int> queue = new Queue<int>();
				queue.Enqueue(num10);
				array[num10] = true;
				while (queue.Count > 0)
				{
					int num11 = queue.Dequeue();
					list2.Add(num11);
					foreach (int item in edges[num11])
					{
						if (!array[item])
						{
							array[item] = true;
							queue.Enqueue(item);
						}
					}
				}
				if (list2.Count > list.Count)
				{
					list = list2;
				}
			}
			HashSet<int> hashSet = new HashSet<int>(list);
			for (int num12 = 0; num12 < num; num12++)
			{
				valid[num12] &= hashSet.Contains(num12);
			}
			Debug.Log((object)("PUCK_NAV_GRAPH connected nodes=" + valid.Count((bool v) => v) + " edges=" + edges.Where((List<int> e, int num13) => valid[num13]).Sum((List<int> e) => e.Count) / 2));
		}

		private static void BuildCustom()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = GravitySurfaces.Current.NavigationSeeds().ToArray();
			int num = array.Length;
			points = (Vector3[])(object)new Vector3[num];
			edges = new List<int>[num];
			valid = new bool[num];
			for (int i = 0; i < num; i++)
			{
				valid[i] = Ground(array[i], out points[i]);
				edges[i] = new List<int>();
			}
			int a;
			for (a = 0; a < num; a++)
			{
				if (!valid[a])
				{
					continue;
				}
				foreach (int item in Enumerable.Range(0, num).Where(delegate(int b)
				{
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					//IL_002d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0032: Unknown result type (might be due to invalid IL or missing references)
					if (b > a && valid[b])
					{
						Vector3 val = points[a] - points[b];
						return ((Vector3)(ref val)).sqrMagnitude < 49f;
					}
					return false;
				}).OrderBy(delegate(int b)
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val = points[a] - points[b];
					return ((Vector3)(ref val)).sqrMagnitude;
				})
					.Take(12))
				{
					if (Edge(points[a], points[item]))
					{
						edges[a].Add(item);
						edges[item].Add(a);
					}
				}
			}
			bool[] array2 = new bool[num];
			List<int> list = new List<int>();
			for (int num2 = 0; num2 < num; num2++)
			{
				if (!valid[num2] || array2[num2])
				{
					continue;
				}
				List<int> list2 = new List<int>();
				Queue<int> queue = new Queue<int>();
				queue.Enqueue(num2);
				array2[num2] = true;
				while (queue.Count > 0)
				{
					int num3 = queue.Dequeue();
					list2.Add(num3);
					foreach (int item2 in edges[num3])
					{
						if (!array2[item2])
						{
							array2[item2] = true;
							queue.Enqueue(item2);
						}
					}
				}
				if (list2.Count > list.Count)
				{
					list = list2;
				}
			}
			HashSet<int> hashSet = new HashSet<int>(list);
			for (int num4 = 0; num4 < num; num4++)
			{
				valid[num4] &= hashSet.Contains(num4);
			}
			Debug.Log((object)("GRAVITY_CUSTOM_NAV_GRAPH connected=" + list.Count));
		}

		private static void BuildRing()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = GravitySurfaces.Current.NavigationSeeds().ToArray();
			int num = array.Length;
			points = (Vector3[])(object)new Vector3[num];
			valid = new bool[num];
			edges = new List<int>[num];
			for (int i = 0; i < num; i++)
			{
				valid[i] = Ground(array[i], out points[i]);
				edges[i] = new List<int>();
			}
			int num2 = num / 15;
			for (int j = 0; j < num2; j++)
			{
				for (int k = 0; k < 15; k++)
				{
					int num3 = j * 15 + k;
					if (!valid[num3])
					{
						continue;
					}
					for (int l = -1; l <= 1; l++)
					{
						for (int m = -1; m <= 1; m++)
						{
							int num4 = k + m;
							if (num4 >= 0 && num4 < 15)
							{
								int num5 = (j + l + num2) % num2 * 15 + num4;
								if (num5 > num3 && valid[num5] && Edge(points[num3], points[num5]))
								{
									edges[num3].Add(num5);
									edges[num5].Add(num3);
								}
							}
						}
					}
				}
			}
			bool[] array2 = new bool[num];
			List<int> list = new List<int>();
			for (int n = 0; n < num; n++)
			{
				if (!valid[n] || array2[n])
				{
					continue;
				}
				List<int> list2 = new List<int>();
				Queue<int> queue = new Queue<int>();
				queue.Enqueue(n);
				array2[n] = true;
				while (queue.Count > 0)
				{
					int num6 = queue.Dequeue();
					list2.Add(num6);
					foreach (int item in edges[num6])
					{
						if (!array2[item])
						{
							array2[item] = true;
							queue.Enqueue(item);
						}
					}
				}
				if (list2.Count > list.Count)
				{
					list = list2;
				}
			}
			HashSet<int> hashSet = new HashSet<int>(list);
			for (int num7 = 0; num7 < num; num7++)
			{
				valid[num7] &= hashSet.Contains(num7);
			}
			Debug.Log((object)("TYAUR_NAV_GRAPH connected=" + list.Count + " / " + num));
		}

		private static int Nearest(Vector3 p)
		{
			//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_0030: 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)
			int result = -1;
			float num = float.MaxValue;
			for (int i = 0; i < points.Length; i++)
			{
				if (valid[i] && edges[i].Count > 0)
				{
					Vector3 val = points[i] - p;
					float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						result = i;
					}
				}
			}
			return result;
		}

		public static Vector3 Sample(Vector3 p)
		{
			//IL_0005: 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_0010: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			Build();
			int num = Nearest(p);
			if (num < 0)
			{
				return p;
			}
			if (Ground(p, out var ground) && Vector3.Distance(ground, points[num]) < 3f && Edge(points[num], ground))
			{
				return ground;
			}
			return points[num];
		}

		public static Vector3[] Route(Vector3 start, Vector3 destination)
		{
			//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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: 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_0108: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			Build();
			int num = Nearest(start);
			int num2 = Nearest(destination);
			if (num < 0 || num2 < 0)
			{
				return Array.Empty<Vector3>();
			}
			float[] array = Enumerable.Repeat(float.PositiveInfinity, points.Length).ToArray();
			int[] array2 = Enumerable.Repeat(-1, points.Length).ToArray();
			bool[] array3 = new bool[points.Length];
			array[num] = 0f;
			SortedSet<(float, int)> sortedSet = new SortedSet<(float, int)>();
			sortedSet.Add((Vector3.Distance(points[num], points[num2]), num));
			while (sortedSet.Count > 0)
			{
				(float, int) min = sortedSet.Min;
				sortedSet.Remove(min);
				int item = min.Item2;
				if (array3[item])
				{
					continue;
				}
				if (item == num2)
				{
					break;
				}
				array3[item] = true;
				foreach (int item2 in edges[item])
				{
					if (!array3[item2])
					{
						float num3 = array[item] + Vector3.Distance(points[item], points[item2]);
						if (num3 < array[item2])
						{
							float num4 = Vector3.Distance(points[item2], points[num2]);
							sortedSet.Remove((array[item2] + num4, item2));
							array[item2] = num3;
							array2[item2] = item;
							sortedSet.Add((num3 + num4, item2));
						}
					}
				}
			}
			if (float.IsPositiveInfinity(array[num2]))
			{
				return Array.Empty<Vector3>();
			}
			List<Vector3> list = new List<Vector3>();
			for (int num5 = num2; num5 >= 0; num5 = array2[num5])
			{
				list.Add(points[num5]);
			}
			list.Reverse();
			Vector3 val = Sample(destination);
			if (Edge(list.Last(), val))
			{
				list.Add(val);
			}
			return list.ToArray();
		}
	}
	public sealed class PuckEnemyMotor : MonoBehaviour
	{
		public EnemyAI Enemy;

		public Vector3 Velocity;

		public Vector3 Destination;

		public bool Enabled = true;

		private Vector3[] route = Array.Empty<Vector3>();

		private int waypoint;

		private float repathAt;

		private float blockedFor;

		private Vector3 requested;

		public static void MoveSurface(Transform actor, Vector3 tangent, float travel)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0045: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			int num = Mathf.Max(1, Mathf.CeilToInt(travel / 0.2f));
			RaycastHit val4 = default(RaycastHit);
			for (int i = 0; i < num; i++)
			{
				Vector3 position = actor.position;
				if (PuckSurface.Ground(position + tangent * (travel / (float)num), out var ground) && !(Mathf.Abs(Vector3.Dot(ground - position, PuckWorld.UpAt(position))) > 0.5f))
				{
					Vector3 val = position + PuckWorld.UpAt(position) * 1.05f;
					Vector3 val2 = ground + PuckWorld.UpAt(ground) * 1.05f;
					Vector3 val3 = val2 - val;
					if (!Physics.SphereCast(val, 0.5f, ((Vector3)(ref val3)).normalized, ref val4, Vector3.Distance(val, val2), 301992193, (QueryTriggerInteraction)1))
					{
						actor.position = ground;
						continue;
					}
					break;
				}
				break;
			}
		}

		public void SetGoal(Vector3 goal)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Destination = goal;
			Vector3 val = requested - goal;
			if (!(((Vector3)(ref val)).sqrMagnitude < 4f) || !(Time.time < repathAt))
			{
				requested = goal;
				repathAt = Time.time + 1f;
				route = PuckSurface.Route(((Component)this).transform.position, goal);
				waypoint = 0;
			}
		}

		public void Step(float dt)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: 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_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: 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_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: 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_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			if (!PuckActors.Outside(Enemy))
			{
				return;
			}
			Vector3 val = PuckWorld.UpAt(((Component)this).transform.position);
			if (!((NetworkBehaviour)Enemy).IsOwner)
			{
				if (PuckActors.Frames.TryGetValue(((NetworkBehaviour)Enemy).NetworkObjectId, out var value))
				{
					((Component)this).transform.rotation = value;
				}
				else
				{
					((Component)this).transform.rotation = PuckWorld.SurfaceFrame(val, ((Component)this).transform.forward);
				}
				return;
			}
			if ((Object)(object)Enemy.agent != (Object)null)
			{
				Enemy.agent.updatePosition = false;
				Enemy.agent.updateRotation = false;
				((Behaviour)Enemy.agent).enabled = false;
			}
			if (Enemy.isEnemyDead || Enemy.inSpecialAnimation || !Enabled || Enemy.stunNormalizedTimer > 0f)
			{
				Velocity = Vector3.zero;
				return;
			}
			if (Enemy.movingTowardsTargetPlayer && (Object)(object)Enemy.targetPlayer != (Object)null && !Enemy.targetPlayer.isInsideFactory)
			{
				SetGoal(((Component)Enemy.targetPlayer).transform.position);
			}
			else if (Enemy.moveTowardsDestination)
			{
				SetGoal(Enemy.destination);
			}
			float num = (((Object)(object)Enemy.agent != (Object)null) ? Mathf.Max(0f, Enemy.agent.speed) : 0f);
			Vector3 position = ((Component)this).transform.position;
			while (waypoint < route.Length && Vector3.Distance(((Component)this).transform.position, route[waypoint]) < 0.7f)
			{
				waypoint++;
			}
			if (waypoint < route.Length && num > 0f)
			{
				Vector3 val2 = Vector3.ProjectOnPlane(route[waypoint] - ((Component)this).transform.position, val);
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				float travel = Mathf.Min(num * dt, Vector3.Distance(((Component)this).transform.position, route[waypoint]));
				MoveSurface(((Component)this).transform, normalized, travel);
				val = PuckWorld.UpAt(((Component)this).transform.position);
				if (Enemy.agent.angularSpeed > 0f)
				{
					((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, PuckWorld.SurfaceFrame(val, normalized), Enemy.agent.angularSpeed * dt);
				}
			}
			((Component)this).transform.rotation = PuckWorld.SurfaceFrame(val, ((Component)this).transform.forward);
			Velocity = (((Component)this).transform.position - position) / Mathf.Max(0.001f, dt);
			if (num > 1f && ((Vector3)(ref Velocity)).magnitude < 0.1f)
			{
				blockedFor += dt;
				if (blockedFor > 1f)
				{
					repathAt = 0f;
					requested = Vector3.zero;
					blockedFor = 0f;
				}
			}
			else
			{
				blockedFor = 0f;
			}
		}

		private void LateUpdate()
		{
			if (PuckActors.Outside(Enemy))
			{
				Step(Mathf.Min(Time.deltaTime, 0.05f));
			}
			else if ((Object)(object)Enemy != (Object)null && (Object)(object)Enemy.agent != (Object)null && !Enemy.isEnemyDead)
			{
				Enemy.agent.updatePosition = true;
				Enemy.agent.updateRotation = true;
				((Behaviour)Enemy.agent).enabled = Enabled;
				Object.Destroy((Object)(object)this);
			}
		}
	}
	public static class PuckActors
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__Receive;
		}

		private const string Message = "elowiny.puck.enemies.v1";

		private static NetworkManager messaging;

		private static float sendAt;

		public static readonly Dictionary<ulong, Quaternion> Frames = new Dictionary<ulong, Quaternion>();

		private static readonly Dictionary<NavMeshAgent, PuckEnemyMotor> motors = new Dictionary<NavMeshAgent, PuckEnemyMotor>();

		public static bool Supported(EnemyAI e)
		{
			if (!(e is MaskedPlayerEnemy) && !(e is MouthDogAI) && !(e is BaboonBirdAI) && !(e is ForestGiantAI) && !(e is FlowerSnakeEnemy) && !(e is DoublewingAI) && !(e is DocileLocustBeesAI) && !(e is RedLocustBees) && !(e is GiantKiwiAI))
			{
				return e is RadMechAI;
			}
			return true;
		}

		public static bool Outside(EnemyAI e)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)e != (Object)null && Supported(e) && PuckWorld.Near(((Component)e).transform.position))
			{
				return e.isOutside;
			}
			return false;
		}

		public static PuckEnemyMotor Motor(NavMeshAgent a)
		{
			//IL_006d: 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)
			if ((Object)(object)a == (Object)null)
			{
				return null;
			}
			if (motors.TryGetValue(a, out var value) && (Object)(object)value != (Object)null && Outside(value.Enemy))
			{
				return value;
			}
			EnemyAI componentInParent = ((Component)a).GetComponentInParent<EnemyAI>();
			if (!Outside(componentInParent))
			{
				return null;
			}
			value = ((Component)componentInParent).GetComponent<PuckEnemyMotor>();
			if ((Object)(object)value == (Object)null)
			{
				value = ((Component)componentInParent).gameObject.AddComponent<PuckEnemyMotor>();
				value.Enemy = componentInParent;
				value.Destination = ((Component)componentInParent).transform.position;
				motors[a] = value;
				a.updatePosition = false;
				a.updateRotation = false;
				((Behaviour)a).enabled = false;
				ManualLogSource log = PuckPlugin.Log;
				if (log != null)
				{
					log.LogInfo((object)("PUCK_ENEMY_ATTACHED " + ((object)componentInParent).GetType().Name));
				}
			}
			return value;
		}

		public static void Clear()
		{
			PuckSurface.Clear();
			GravitySpecies.Clear();
			Frames.Clear();
			PuckCruiserGravity[] array = Object.FindObjectsOfType<PuckCruiserGravity>();
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Restore();
			}
			foreach (PuckEnemyMotor value in motors.Values)
			{
				if ((Object)(object)value != (Object)null)
				{
					if ((Object)(object)value.Enemy.agent != (Object)null)
					{
						value.Enemy.agent.updatePosition = true;
						value.Enemy.agent.updateRotation = true;
						((Behaviour)value.Enemy.agent).enabled = value.Enabled && !value.Enemy.isEnemyDead;
					}
					Object.Destroy((Object)(object)value);
				}
			}
			motors.Clear();
		}

		public static void Tick()
		{
			//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_0051: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null)
			{
				return;
			}
			if ((Object)(object)singleton != (Object)(object)messaging)
			{
				messaging = singleton;
				CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager;
				object obj = <>O.<0>__Receive;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = Receive;
					<>O.<0>__Receive = val;
					obj = (object)val;
				}
				customMessagingManager.RegisterNamedMessageHandler("elowiny.puck.enemies.v1", (HandleNamedMessageDelegate)obj);
			}
			if (!PuckWorld.Active || !singleton.IsListening || Time.unscaledTime < sendAt)
			{
				return;
			}
			sendAt = Time.unscaledTime + 0.1f;
			PuckEnemyMotor[] array = motors.Values.ToArray();
			foreach (PuckEnemyMotor puckEnemyMotor in array)
			{
				if ((Object)(object)puckEnemyMotor != (Object)null && Outside(puckEnemyMotor.Enemy) && ((NetworkBehaviour)puckEnemyMotor.Enemy).IsOwner && ((NetworkBehaviour)puckEnemyMotor.Enemy).IsSpawned)
				{
					Send(singleton, ((NetworkBehaviour)puckEnemyMotor.Enemy).NetworkObjectId, ((Component)puckEnemyMotor).transform.rotation, singleton.IsServer);
				}
			}
		}

		private unsafe static void Send(NetworkManager nm, ulong id, Quaternion q, bool relay)
		{
			//IL_0011: 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_0075: 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)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref id, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe(ref q);
				if (relay)
				{
					foreach (ulong connectedClientsId in nm.ConnectedClientsIds)
					{
						if (connectedClientsId != 0L)
						{
							nm.CustomMessagingManager.SendNamedMessage("elowiny.puck.enemies.v1", connectedClientsId, val, (NetworkDelivery)1);
						}
					}
					return;
				}
				nm.CustomMessagingManager.SendNamedMessage("elowiny.puck.enemies.v1", 0uL, val, (NetworkDelivery)1);
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private static void Receive(ulong sender, FastBufferReader reader)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			if (!PuckWorld.Active || ((FastBufferReader)(ref reader)).Length < 24)
			{
				return;
			}
			ulong num = default(ulong);
			((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives));
			Quaternion val = default(Quaternion);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref val);
			float num2 = val.x * val.x + val.y * val.y + val.z * val.z + val.w * val.w;
			if (!float.IsNaN(num2) && !(num2 < 0.5f) && !(num2 > 1.5f) && messaging.SpawnManager.SpawnedObjects.TryGetValue(num, out var value) && Outside(((Component)value).GetComponent<EnemyAI>()) && (!messaging.IsServer || value.OwnerClientId == sender))
			{
				Frames[num] = ((Quaternion)(ref val)).normalized;
				if (messaging.IsServer)
				{
					Send(messaging, num, ((Quaternion)(ref val)).normalized, relay: true);
				}
			}
		}
	}
	public static class PuckActorHooks
	{
		public static readonly Dictionary<NavMeshPath, Vector3[]> Paths = new Dictionary<NavMeshPath, Vector3[]>();

		private static readonly Dictionary<MethodInfo, MethodInfo> replacements = new Dictionary<MethodInfo, MethodInfo>();

		private static void Map(Type type, string method, string replacement)
		{
			replacements[AccessTools.Method(type, method, (Type[])null, (Type[])null)] = AccessTools.Method(typeof(PuckActorHooks), replacement, (Type[])null, (Type[])null);
		}

		public static void Install(Harmony harmony)
		{
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Expected O, but got Unknown
			Map(typeof(NavMeshAgent), "get_velocity", "Velocity");
			Map(typeof(NavMeshAgent), "get_destination", "Destination");
			Map(typeof(NavMeshAgent), "get_isOnNavMesh", "OnMesh");
			Map(typeof(Behaviour), "get_enabled", "Enabled");
			Map(typeof(Behaviour), "set_enabled", "SetEnabled");
			Map(typeof(NavMeshAgent), "SetDestination", "SetDestination");
			Map(typeof(NavMeshAgent), "CalculatePath", "CalculatePath");
			Map(typeof(NavMeshPath), "GetCornersNonAlloc", "Corners");
			Map(typeof(NavMeshPath), "get_corners", "AllCorners");
			Map(typeof(NavMeshPath), "get_status", "PathStatus");
			Map(typeof(NavMeshAgent), "Warp", "Warp");
			replacements[AccessTools.Method(typeof(NavMesh), "CalculatePath", new Type[4]
			{
				typeof(Vector3),
				typeof(Vector3),
				typeof(int),
				typeof(NavMeshPath)
			}, (Type[])null)] = AccessTools.Method(typeof(PuckActorHooks), "StaticPath", (Type[])null, (Type[])null);
			Map(typeof(Transform), "set_rotation", "Rotation");
			Map(typeof(Transform), "set_localEulerAngles", "LocalEuler");
			GravitySpecies.Install(harmony);
			Type[] array = new Type[12]
			{
				typeof(EnemyAI),
				typeof(MaskedPlayerEnemy),
				typeof(MouthDogAI),
				typeof(BaboonBirdAI),
				typeof(ForestGiantAI),
				typeof(FlowerSnakeEnemy),
				typeof(DoublewingAI),
				typeof(DocileLocustBeesAI),
				typeof(RedLocustBees),
				typeof(GiantKiwiAI),
				typeof(RadMechAI),
				typeof(VehicleController)
			};
			foreach (Type type in array)
			{
				foreach (Type item in new Type[1] { type }.Concat(type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic)))
				{
					MethodInfo[] methods = item.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (MethodInfo methodInfo in methods)
					{
						if (methodInfo.GetMethodBody() != null && !methodInfo.ContainsGenericParameters && PuckVerification.ReadInstructions(methodInfo).Any((CodeInstruction val) => val.operand is MethodInfo methodInfo2 && (replacements.ContainsKey(methodInfo2) || methodInfo2 == AccessTools.PropertyGetter(typeof(Vector3), "up") || methodInfo2 == AccessTools.PropertyGetter(typeof(Vector3), "down") || methodInfo2 == AccessTools.PropertySetter(typeof(Transform), "eulerAngles"))))
						{
							harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PuckActorHooks), "Rewrite", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
						}
					}
				}
			}
		}

		public static Vector3 Up(object instance)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			EnemyAI val = (EnemyAI)((instance is EnemyAI) ? instance : null);
			VehicleController val2 = (VehicleController)((instance is VehicleController) ? instance : null);
			if ((Object)(object)val == (Object)null && (Object)(object)val2 == (Object)null && instance != null)
			{
				object? obj = instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((FieldInfo f) => typeof(EnemyAI).IsAssignableFrom(f.FieldType) || typeof(VehicleController).IsAssignableFrom(f.FieldType))?.GetValue(instance);
				val = (EnemyAI)((obj is EnemyAI) ? obj : null);
				val2 = (VehicleController)((obj is VehicleController) ? obj : null);
			}
			if (!PuckActors.Outside(val))
			{
				if (!((Object)(object)val2 != (Object)null) || !PuckWorld.Near(((Component)val2).transform.position) || val2.magnetedToShip)
				{
					return Vector3.up;
				}
				return

ElowinyScrap.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Dawn;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ElowinyScrap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+82cd04292d2afc9ff3eab37ff684c9b3945adb54")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("ElowinyScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 ElowinyScrap
{
	[BepInPlugin("com.elowiny.elowinyscrap", "ElowinyScrap", "1.0.0")]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public static readonly NamespacedKey<DawnItemInfo> MyScrapKey = NamespacedKey<DawnItemInfo>.From("elowiny", "custom_scrap");

		private readonly Harmony harmony = new Harmony("com.elowiny.elowinyscrap");

		private const int BaseWeaponSpawnWeight = 50;

		private int ReadWeaponSpawnWeight()
		{
			float num = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "WeaponSpawnMultiplier", 1f, "Scales natural scrap spawn weights for ElowinyScrap's ranged weapons. 1 = default (50 per weapon); 0 = disabled; 0.5 = half weight; 2 = double weight. Positive weights are rounded to whole numbers (minimum 1). Restart the game to apply.").Value;
			if (float.IsNaN(num) || float.IsInfinity(num))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"WeaponSpawnMultiplier must be finite; using 1.");
				num = 1f;
			}
			if (num <= 0f)
			{
				return 0;
			}
			double val = Math.Round(50.0 * (double)num, MidpointRounding.AwayFromZero);
			return (int)Math.Min(134217727.0, Math.Max(1.0, val));
		}

		private static void RegisterWeapon(string key, Item item, int weight)
		{
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", key), item, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				if (weight > 0)
				{
					builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrap)
					{
						scrap.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weights)
						{
							weights.SetGlobalWeight(weight);
						});
					});
				}
			});
		}

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ElowinyScrap has started loading!");
			int num = ReadWeaponSpawnWeight();
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Ranged weapon scrap spawn weight: {num} per item.");
			harmony.PatchAll();
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "elowinyscrap_bundle"));
			Item val2 = val.LoadAsset<Item>("Assets/LaurentScrap/LaurentScrap.asset");
			Item val3 = val.LoadAsset<Item>("Assets/GoldMacronScrap/GoldMacronScrap.asset");
			Item val4 = val.LoadAsset<Item>("Assets/LorisFigurineScrap/LorisFigurineScrap.asset");
			Item val5 = val.LoadAsset<Item>("Assets/MeopaSkullScrap/MeopaSkullScrap.asset");
			Item val6 = val.LoadAsset<Item>("Assets/KatzenHelmetScrap/KatzenHelmetScrap.asset");
			Item val7 = val.LoadAsset<Item>("Assets/MedievalShieldScrap/MedievalShieldScrap.asset");
			Item val8 = val.LoadAsset<Item>("Assets/LorisKatanaScrap/LorisKatanaScrap.asset");
			Item val9 = val.LoadAsset<Item>("Assets/GoldenLugerScrap/GoldenLugerScrap.asset");
			Item val10 = val.LoadAsset<Item>("Assets/CromwellHeadScrap/CromwellHeadScrap.asset");
			Item val11 = val.LoadAsset<Item>("Assets/KatzenRailgunScrap/KatzenRailgunScrap.asset");
			Item val12 = val.LoadAsset<Item>("Assets/KatzenFlamethrowerScrap/KatzenFlamethrowerScrap.asset");
			Item val13 = val.LoadAsset<Item>("Assets/KatzenLaserScrap/KatzenLaserScrap.asset");
			Item val14 = val.LoadAsset<Item>("Assets/KatzenBolterScrap/KatzenBolterScrap.asset");
			Item val15 = val.LoadAsset<Item>("Assets/KatzenHeavyFlamethrowerScrap/KatzenHeavyFlamethrowerScrap.asset");
			Item val16 = val.LoadAsset<Item>("Assets/PimousseBustScrap/PimousseBustScrap.asset");
			Item val17 = val.LoadAsset<Item>("Assets/BlueChickenScrap/BlueChickenScrap.asset");
			Item val18 = val.LoadAsset<Item>("Assets/LostGourdScrap/LostGourdScrap.asset");
			Item val19 = val.LoadAsset<Item>("Assets/ForestPlushieScrap/ForestPlushieScrap.asset");
			Item val20 = val.LoadAsset<Item>("Assets/SonicPlushieScrap/SonicPlushieScrap.asset");
			Item val21 = val.LoadAsset<Item>("Assets/PetainPlateScrap/PetainPlateScrap.asset");
			Item val22 = val.LoadAsset<Item>("Assets/BlahajPlushieScrap/BlahajPlushieScrap.asset");
			Item val23 = val.LoadAsset<Item>("Assets/KatzenAMRScrap/KatzenAMRScrap.asset");
			Item val24 = val.LoadAsset<Item>("Assets/KatzenRecoillessScrap/KatzenRecoillessScrap.asset");
			Item val25 = val.LoadAsset<Item>("Assets/KatzenSpearScrap/KatzenSpearScrap.asset");
			val9.saveItemVariable = true;
			val11.saveItemVariable = true;
			val12.saveItemVariable = true;
			val13.saveItemVariable = true;
			val14.saveItemVariable = true;
			val15.saveItemVariable = true;
			val23.saveItemVariable = true;
			val24.saveItemVariable = true;
			val25.saveItemVariable = true;
			val6.spawnPrefab.AddComponent<DamageModifierComponent>().damageReductionMultiplier = 0.3f;
			val7.spawnPrefab.AddComponent<FlatDamageModifierComponent>().flatDamageReduction = 15;
			SimpleWeaponComponent simpleWeaponComponent = val9.spawnPrefab.AddComponent<SimpleWeaponComponent>();
			simpleWeaponComponent.ammo = 6;
			simpleWeaponComponent.playerDamage = 30;
			simpleWeaponComponent.entityDamage = 2;
			AudioClip shootSound = val.LoadAsset<AudioClip>("Assets/GoldenLugerScrap/GoldenLugerShot.mp3");
			GameObject val26 = val.LoadAsset<GameObject>("Assets/GoldenLugerScrap/GoldenLugerParticle.prefab");
			simpleWeaponComponent.shootSound = shootSound;
			simpleWeaponComponent.shootParticlePrefab = val26;
			Transform val27 = val9.spawnPrefab.transform.Find("BarrelTip");
			simpleWeaponComponent.barrelLocation = (((Object)(object)val27 != (Object)null) ? val27 : val9.spawnPrefab.transform);
			SimpleWeaponComponent simpleWeaponComponent2 = val11.spawnPrefab.AddComponent<SimpleWeaponComponent>();
			simpleWeaponComponent2.ammo = 2;
			simpleWeaponComponent2.playerDamage = 150;
			simpleWeaponComponent2.entityDamage = 20;
			AudioClip shootSound2 = val.LoadAsset<AudioClip>("Assets/KatzenRailgunScrap/KatzenRailgunShot.mp3");
			GameObject shootParticlePrefab = val.LoadAsset<GameObject>("Assets/KatzenRailgunScrap/KatzenRailgunParticle.prefab");
			simpleWeaponComponent2.shootSound = shootSound2;
			simpleWeaponComponent2.shootParticlePrefab = shootParticlePrefab;
			Transform val28 = val11.spawnPrefab.transform.Find("BarrelTip");
			simpleWeaponComponent2.barrelLocation = (((Object)(object)val28 != (Object)null) ? val28 : val11.spawnPrefab.transform);
			SimpleWeaponComponent simpleWeaponComponent3 = val14.spawnPrefab.AddComponent<SimpleWeaponComponent>();
			simpleWeaponComponent3.ammo = 8;
			simpleWeaponComponent3.playerDamage = 50;
			simpleWeaponComponent3.entityDamage = 3;
			AudioClip shootSound3 = val.LoadAsset<AudioClip>("Assets/KatzenBolterScrap/KatzenBolterShot.mp3");
			GameObject shootParticlePrefab2 = val.LoadAsset<GameObject>("Assets/KatzenBolterScrap/KatzenBolterParticle.prefab");
			simpleWeaponComponent3.shootSound = shootSound3;
			simpleWeaponComponent3.shootParticlePrefab = shootParticlePrefab2;
			Transform val29 = val14.spawnPrefab.transform.Find("BarrelTip");
			simpleWeaponComponent3.barrelLocation = (((Object)(object)val29 != (Object)null) ? val29 : val14.spawnPrefab.transform);
			ContinuousWeaponComponent continuousWeaponComponent = val12.spawnPrefab.AddComponent<ContinuousWeaponComponent>();
			continuousWeaponComponent.maxAmmoSeconds = 15f;
			continuousWeaponComponent.currentAmmo = 15f;
			continuousWeaponComponent.hitboxWidth = 0.5f;
			continuousWeaponComponent.hitboxLength = 5f;
			continuousWeaponComponent.playerDamage = 5;
			continuousWeaponComponent.entityDamage = 1;
			continuousWeaponComponent.damageInterval = 0.5f;
			AudioClip firingSound = val.LoadAsset<AudioClip>("Assets/KatzenFlamethrowerScrap/KatzenFlamethrowerSound.mp3");
			GameObject shootParticlePrefab3 = val.LoadAsset<GameObject>("Assets/KatzenFlamethrowerScrap/KatzenFlamethrowerParticle.prefab");
			continuousWeaponComponent.firingSound = firingSound;
			continuousWeaponComponent.shootParticlePrefab = shootParticlePrefab3;
			Transform val30 = val12.spawnPrefab.transform.Find("BarrelTip");
			continuousWeaponComponent.barrelLocation = (((Object)(object)val30 != (Object)null) ? val30 : val12.spawnPrefab.transform);
			ContinuousWeaponComponent continuousWeaponComponent2 = val13.spawnPrefab.AddComponent<ContinuousWeaponComponent>();
			continuousWeaponComponent2.maxAmmoSeconds = 6f;
			continuousWeaponComponent2.currentAmmo = 6f;
			continuousWeaponComponent2.hitboxWidth = 0.2f;
			continuousWeaponComponent2.hitboxLength = 50f;
			continuousWeaponComponent2.playerDamage = 5;
			continuousWeaponComponent2.entityDamage = 1;
			continuousWeaponComponent2.damageInterval = 0.33f;
			AudioClip firingSound2 = val.LoadAsset<AudioClip>("Assets/KatzenLaserScrap/KatzenLaserSound.mp3");
			GameObject shootParticlePrefab4 = val.LoadAsset<GameObject>("Assets/KatzenLaserScrap/KatzenLaserParticle.prefab");
			continuousWeaponComponent2.firingSound = firingSound2;
			continuousWeaponComponent2.shootParticlePrefab = shootParticlePrefab4;
			Transform val31 = val13.spawnPrefab.transform.Find("BarrelTip");
			continuousWeaponComponent2.barrelLocation = (((Object)(object)val31 != (Object)null) ? val31 : val13.spawnPrefab.transform);
			ContinuousWeaponComponent continuousWeaponComponent3 = val15.spawnPrefab.AddComponent<ContinuousWeaponComponent>();
			continuousWeaponComponent3.maxAmmoSeconds = 12f;
			continuousWeaponComponent3.currentAmmo = 12f;
			continuousWeaponComponent3.hitboxWidth = 1f;
			continuousWeaponComponent3.hitboxLength = 15f;
			continuousWeaponComponent3.playerDamage = 5;
			continuousWeaponComponent3.entityDamage = 1;
			continuousWeaponComponent3.damageInterval = 0.5f;
			AudioClip firingSound3 = val.LoadAsset<AudioClip>("Assets/KatzenHeavyFlamethrowerScrap/KatzenHeavyFlamethrowerSound.mp3");
			GameObject shootParticlePrefab5 = val.LoadAsset<GameObject>("Assets/KatzenHeavyFlamethrowerScrap/KatzenHeavyFlamethrowerParticle.prefab");
			continuousWeaponComponent3.firingSound = firingSound3;
			continuousWeaponComponent3.shootParticlePrefab = shootParticlePrefab5;
			Transform val32 = val15.spawnPrefab.transform.Find("BarrelTip");
			continuousWeaponComponent3.barrelLocation = (((Object)(object)val32 != (Object)null) ? val32 : val15.spawnPrefab.transform);
			ProjectileWeaponComponent projectileWeaponComponent = val23.spawnPrefab.AddComponent<ProjectileWeaponComponent>();
			AudioClip impactSound = val.LoadAsset<AudioClip>("Assets/KatzenAMRScrap/KatzenAMRImpactExplosion.mp3");
			GameObject impactParticlePrefab = val.LoadAsset<GameObject>("Assets/KatzenAMRScrap/KatzenAMRImpactParticle.prefab");
			GameObject projectileModelPrefab = val.LoadAsset<GameObject>("Assets/KatzenAMRScrap/KatzenAMRBullet.prefab");
			projectileWeaponComponent.ammo = 2;
			projectileWeaponComponent.fireCooldown = 1.5f;
			projectileWeaponComponent.projectileSpeed = 20f;
			projectileWeaponComponent.projectileGravity = 0f;
			projectileWeaponComponent.shootSound = shootSound;
			projectileWeaponComponent.shootParticlePrefab = shootParticlePrefab2;
			projectileWeaponComponent.projectileModelPrefab = projectileModelPrefab;
			projectileWeaponComponent.projectileParticlePrefab = val26;
			projectileWeaponComponent.projectileLoopSound = null;
			projectileWeaponComponent.impactParticlePrefab = impactParticlePrefab;
			projectileWeaponComponent.impactSound = impactSound;
			projectileWeaponComponent.impactDamagePlayer = 500;
			projectileWeaponComponent.impactDamageEntity = 50;
			projectileWeaponComponent.explosionRadius = 5f;
			projectileWeaponComponent.explosionDamagePlayer = 90;
			projectileWeaponComponent.explosionDamageEntity = 20;
			projectileWeaponComponent.trackingRange = 15f;
			projectileWeaponComponent.trackingStrength = 5f;
			Transform val33 = val23.spawnPrefab.transform.Find("BarrelTip");
			projectileWeaponComponent.barrelLocation = (((Object)(object)val33 != (Object)null) ? val33 : val23.spawnPrefab.transform);
			ProjectileWeaponComponent projectileWeaponComponent2 = val24.spawnPrefab.AddComponent<ProjectileWeaponComponent>();
			AudioClip impactSound2 = val.LoadAsset<AudioClip>("Assets/KatzenAMRScrap/KatzenAMRImpactExplosion.mp3");
			AudioClip shootSound4 = val.LoadAsset<AudioClip>("Assets/KatzenRecoillessScrap/KatzenRecoillessLaunchSound.mp3");
			GameObject impactParticlePrefab2 = val.LoadAsset<GameObject>("Assets/KatzenAMRScrap/KatzenAMRImpactParticle.prefab");
			GameObject projectileModelPrefab2 = val.LoadAsset<GameObject>("Assets/KatzenRecoillessScrap/KatzenRecoillessBullet_Model.prefab");
			projectileWeaponComponent2.ammo = 2;
			projectileWeaponComponent2.fireCooldown = 1.5f;
			projectileWeaponComponent2.projectileSpeed = 200f;
			projectileWeaponComponent2.projectileGravity = 0.5f;
			projectileWeaponComponent2.shootSound = shootSound4;
			projectileWeaponComponent2.shootParticlePrefab = shootParticlePrefab2;
			projectileWeaponComponent2.projectileModelPrefab = projectileModelPrefab2;
			projectileWeaponComponent2.projectileParticlePrefab = val26;
			projectileWeaponComponent2.projectileLoopSound = null;
			projectileWeaponComponent2.impactParticlePrefab = impactParticlePrefab2;
			projectileWeaponComponent2.impactSound = impactSound2;
			projectileWeaponComponent2.impactDamagePlayer = 500;
			projectileWeaponComponent2.impactDamageEntity = 50;
			projectileWeaponComponent2.explosionRadius = 5f;
			projectileWeaponComponent2.explosionDamagePlayer = 90;
			projectileWeaponComponent2.explosionDamageEntity = 20;
			projectileWeaponComponent2.trackingRange = 0f;
			projectileWeaponComponent2.trackingStrength = 0f;
			Transform val34 = val24.spawnPrefab.transform.Find("BarrelTip");
			projectileWeaponComponent2.barrelLocation = (((Object)(object)val34 != (Object)null) ? val34 : val24.spawnPrefab.transform);
			ProjectileWeaponComponent projectileWeaponComponent3 = val25.spawnPrefab.AddComponent<ProjectileWeaponComponent>();
			AudioClip impactSound3 = val.LoadAsset<AudioClip>("Assets/KatzenAMRScrap/KatzenAMRImpactExplosion.mp3");
			AudioClip shootSound5 = val.LoadAsset<AudioClip>("Assets/KatzenSpearScrap/KatzenSpearMissileLaunchSound.mp3");
			GameObject impactParticlePrefab3 = val.LoadAsset<GameObject>("Assets/KatzenAMRScrap/KatzenAMRImpactParticle.prefab");
			GameObject projectileModelPrefab3 = val.LoadAsset<GameObject>("Assets/KatzenSpearScrap/KatzenSpearMissile_Model.prefab");
			projectileWeaponComponent3.ammo = 2;
			projectileWeaponComponent3.fireCooldown = 1.5f;
			projectileWeaponComponent3.projectileSpeed = 100f;
			projectileWeaponComponent3.projectileGravity = 0f;
			projectileWeaponComponent3.shootSound = shootSound5;
			projectileWeaponComponent3.shootParticlePrefab = shootParticlePrefab2;
			projectileWeaponComponent3.projectileModelPrefab = projectileModelPrefab3;
			projectileWeaponComponent3.projectileParticlePrefab = val26;
			projectileWeaponComponent3.projectileLoopSound = null;
			projectileWeaponComponent3.impactParticlePrefab = impactParticlePrefab3;
			projectileWeaponComponent3.impactSound = impactSound3;
			projectileWeaponComponent3.impactDamagePlayer = 500;
			projectileWeaponComponent3.impactDamageEntity = 50;
			projectileWeaponComponent3.explosionRadius = 5f;
			projectileWeaponComponent3.explosionDamagePlayer = 90;
			projectileWeaponComponent3.explosionDamageEntity = 20;
			projectileWeaponComponent3.trackingRange = 20f;
			projectileWeaponComponent3.trackingStrength = 20f;
			Transform val35 = val25.spawnPrefab.transform.Find("BarrelTip");
			projectileWeaponComponent3.barrelLocation = (((Object)(object)val35 != (Object)null) ? val35 : val25.spawnPrefab.transform);
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val5.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val6.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val7.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val8.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val9.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val10.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val11.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val12.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val13.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val14.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val15.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val16.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val17.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val18.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val19.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val20.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val21.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val22.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val24.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val23.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val25.spawnPrefab);
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "laurentscrap"), val2, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "goldmacronscrap"), val3, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "lorisfigurinescrap"), val4, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "meopaskullscrap"), val5, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "katzenhelmetscrap"), val6, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "medievalshieldscrap"), val7, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "loriskatanascrap"), val8, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			RegisterWeapon("goldenlugerscrap", val9, num);
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "cromwellheadscrap"), val10, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			RegisterWeapon("katzenrailgunscrap", val11, num);
			RegisterWeapon("katzenflamethrowerscrap", val12, num);
			RegisterWeapon("katzenlaserscrap", val13, num);
			RegisterWeapon("katzenbolterscrap", val14, num);
			RegisterWeapon("katzenheavyflamethrower", val15, num);
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "pimoussebustscrap"), val16, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "bluechickenscrap"), val17, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "lostgourdscrap"), val18, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "forestplushiescrap"), val19, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "sonicplushiescrap"), val20, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "petainplatescrap"), val21, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			DawnLib.DefineItem(NamespacedKey<DawnItemInfo>.From("elowiny", "blahajplushiescrap"), val22, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder)
					{
						weightBuilder.SetGlobalWeight(100);
					});
				});
			});
			RegisterWeapon("katzenamrscrap", val23, num);
			RegisterWeapon("katzenrecoillessscrap", val24, num);
			RegisterWeapon("katzenspearscrap", val25, num);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ElowinyScrap finished loading!");
		}
	}
	public class DamageModifierComponent : MonoBehaviour
	{
		public float damageReductionMultiplier;
	}
	public class FlatDamageModifierComponent : MonoBehaviour
	{
		public int flatDamageReduction;
	}
	public class ProjectileWeaponComponent : MonoBehaviour
	{
		public int ammo = 5;

		public float fireCooldown = 1f;

		[NonSerialized]
		public float cooldownTimer;

		public AudioClip shootSound;

		public GameObject shootParticlePrefab;

		public Transform barrelLocation;

		public GameObject projectileModelPrefab;

		public float projectileSpeed = 30f;

		public float projectileGravity;

		public GameObject projectileParticlePrefab;

		public AudioClip projectileLoopSound;

		public GameObject impactParticlePrefab;

		public AudioClip impactSound;

		public int impactDamagePlayer = 40;

		public int impactDamageEntity = 2;

		public float explosionRadius = 5f;

		public int explosionDamagePlayer = 100;

		public int explosionDamageEntity = 5;

		public float trackingRange;

		public float trackingStrength;

		private void Update()
		{
			if (cooldownTimer > 0f)
			{
				cooldownTimer -= Time.deltaTime;
			}
		}
	}
	public class ProjectileBehavior : MonoBehaviour
	{
		private float speed;

		private float gravityMultiplier;

		private Vector3 velocity;

		private bool isLocalOwner;

		private PlayerControllerB ownerPlayer;

		private GrabbableObject weaponItem;

		private int impactDamagePlayer;

		private int impactDamageEntity;

		private float explosionRadius;

		private int explosionDamagePlayer;

		private int explosionDamageEntity;

		private GameObject impactParticlePrefab;

		private AudioClip impactSound;

		private Vector3 lastPosition;

		private float age;

		private const float maxLifetime = 15f;

		private float trackingRange;

		private float trackingStrength;

		public void Initialize(Vector3 direction, ProjectileWeaponComponent config, bool isLocalOwner, PlayerControllerB ownerPlayer, GrabbableObject weaponItem)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			speed = config.projectileSpeed;
			gravityMultiplier = config.projectileGravity;
			velocity = direction * speed;
			this.isLocalOwner = isLocalOwner;
			this.ownerPlayer = ownerPlayer;
			this.weaponItem = weaponItem;
			impactDamagePlayer = config.impactDamagePlayer;
			impactDamageEntity = config.impactDamageEntity;
			explosionRadius = config.explosionRadius;
			explosionDamagePlayer = config.explosionDamagePlayer;
			explosionDamageEntity = config.explosionDamageEntity;
			impactParticlePrefab = config.impactParticlePrefab;
			impactSound = config.impactSound;
			trackingRange = config.trackingRange;
			trackingStrength = config.trackingStrength;
			lastPosition = ((Component)this).transform.position;
		}

		private void Update()
		{
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: 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)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: 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_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_0147: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			age += Time.deltaTime;
			if (age >= 15f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			if (trackingRange > 0f)
			{
				int num = 2621440;
				Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, trackingRange, num, (QueryTriggerInteraction)2);
				Transform val = null;
				float num2 = trackingRange * trackingRange;
				Collider[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					EnemyAICollisionDetect component = ((Component)array2[i]).GetComponent<EnemyAICollisionDetect>();
					if ((Object)(object)component != (Object)null && (Object)(object)component.mainScript != (Object)null && !component.mainScript.isEnemyDead)
					{
						Vector3 val2 = component.mainScript.serverPosition - ((Component)this).transform.position;
						float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
						if (sqrMagnitude < num2)
						{
							num2 = sqrMagnitude;
							val = ((Component)component.mainScript).transform;
						}
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					Vector3 val3 = val.position + Vector3.up * 1f - ((Component)this).transform.position;
					Vector3 normalized = ((Vector3)(ref val3)).normalized;
					val3 = Vector3.Slerp(((Vector3)(ref velocity)).normalized, normalized, trackingStrength * Time.deltaTime);
					Vector3 normalized2 = ((Vector3)(ref val3)).normalized;
					velocity = normalized2 * ((Vector3)(ref velocity)).magnitude;
				}
			}
			velocity += Physics.gravity * gravityMultiplier * Time.deltaTime;
			if (((Vector3)(ref velocity)).sqrMagnitude > 0.001f)
			{
				((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref velocity)).normalized);
			}
			Vector3 val4 = velocity * Time.deltaTime;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			if (magnitude > 0f)
			{
				Vector3 normalized3 = ((Vector3)(ref val4)).normalized;
				int num3 = 2623753;
				RaycastHit[] array3 = Physics.RaycastAll(lastPosition, normalized3, magnitude, num3, (QueryTriggerInteraction)2);
				if (array3.Length != 0)
				{
					Array.Sort(array3, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
					RaycastHit[] array4 = array3;
					for (int i = 0; i < array4.Length; i++)
					{
						RaycastHit hit = array4[i];
						if ((!((Object)(object)ownerPlayer != (Object)null) || !((RaycastHit)(ref hit)).transform.IsChildOf(((Component)ownerPlayer).transform)) && (!((Object)(object)weaponItem != (Object)null) || !((RaycastHit)(ref hit)).transform.IsChildOf(((Component)weaponItem).transform)))
						{
							((Component)this).transform.position = ((RaycastHit)(ref hit)).point;
							OnImpact(hit);
							return;
						}
					}
				}
			}
			Transform transform = ((Component)this).transform;
			transform.position += val4;
			lastPosition = ((Component)this).transform.position;
		}

		private void OnImpact(RaycastHit hit)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)impactParticlePrefab != (Object)null)
			{
				Object.Destroy((Object)(object)Object.Instantiate<GameObject>(impactParticlePrefab, ((RaycastHit)(ref hit)).point, Quaternion.LookRotation(((RaycastHit)(ref hit)).normal)), 3f);
			}
			if ((Object)(object)impactSound != (Object)null)
			{
				AudioSource.PlayClipAtPoint(impactSound, ((RaycastHit)(ref hit)).point, 1f);
			}
			if (isLocalOwner && (Object)(object)ownerPlayer != (Object)null)
			{
				GameObject gameObject = ((Component)((RaycastHit)(ref hit)).collider).gameObject;
				PlayerControllerB val = gameObject.GetComponentInParent<PlayerControllerB>();
				if ((Object)(object)val == (Object)null)
				{
					val = gameObject.GetComponent<PlayerControllerB>();
				}
				if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)ownerPlayer)
				{
					val.DamagePlayerFromOtherClientServerRpc(impactDamagePlayer, ((Vector3)(ref velocity)).normalized, (int)ownerPlayer.playerClientId);
				}
				else
				{
					EnemyAICollisionDetect component = gameObject.GetComponent<EnemyAICollisionDetect>();
					if ((Object)(object)component != (Object)null && (Object)(object)component.mainScript != (Object)null)
					{
						component.mainScript.HitEnemyOnLocalClient(impactDamageEntity, ((Vector3)(ref velocity)).normalized, ownerPlayer, true, -1);
					}
				}
				if (explosionRadius > 0f)
				{
					Explode(((RaycastHit)(ref hit)).point);
				}
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void Explode(Vector3 center)
		{
			//IL_0006: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			int num = 2621448;
			Collider[] array = Physics.OverlapSphere(center, explosionRadius, num, (QueryTriggerInteraction)2);
			HashSet<object> hashSet = new HashSet<object>();
			Collider[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				GameObject gameObject = ((Component)array2[i]).gameObject;
				PlayerControllerB val = gameObject.GetComponentInParent<PlayerControllerB>();
				if ((Object)(object)val == (Object)null)
				{
					val = gameObject.GetComponent<PlayerControllerB>();
				}
				Vector3 val2;
				if ((Object)(object)val != (Object)null)
				{
					if (!hashSet.Contains(val))
					{
						val2 = ((Component)val).transform.position - center;
						Vector3 normalized = ((Vector3)(ref val2)).normalized;
						if ((Object)(object)val == (Object)(object)ownerPlayer)
						{
							val.DamagePlayer(explosionDamagePlayer, true, true, (CauseOfDeath)3, 0, false, normalized);
						}
						else
						{
							val.DamagePlayerFromOtherClientServerRpc(explosionDamagePlayer, normalized, (int)ownerPlayer.playerClientId);
						}
						hashSet.Add(val);
					}
				}
				else
				{
					EnemyAICollisionDetect component = gameObject.GetComponent<EnemyAICollisionDetect>();
					if ((Object)(object)component != (Object)null && (Object)(object)component.mainScript != (Object)null && !hashSet.Contains(component.mainScript))
					{
						val2 = ((Component)component).transform.position - center;
						Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
						component.mainScript.HitEnemyOnLocalClient(explosionDamageEntity, normalized2, ownerPlayer, true, -1);
						hashSet.Add(component.mainScript);
					}
				}
			}
		}
	}
	public class SimpleWeaponComponent : MonoBehaviour
	{
		public int ammo = 6;

		public int playerDamage = 30;

		public int entityDamage = 2;

		public AudioClip shootSound;

		public GameObject shootParticlePrefab;

		public Transform barrelLocation;
	}
	public class ContinuousWeaponComponent : MonoBehaviour
	{
		public float maxAmmoSeconds = 10f;

		public float currentAmmo = 10f;

		public int playerDamage = 2;

		public int entityDamage = 1;

		public float hitboxWidth = 4f;

		public float hitboxLength = 8f;

		public float damageInterval = 0.25f;

		public GameObject shootParticlePrefab;

		public AudioClip firingSound;

		public Transform barrelLocation;

		private bool isFiring;

		private float damageTickTimer;

		private ParticleSystem spawnedParticles;

		private AudioSource audioSource;

		private GrabbableObject itemScript;

		private void Start()
		{
			itemScript = ((Component)this).GetComponent<GrabbableObject>();
			audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			audioSource.playOnAwake = false;
			audioSource.spatialBlend = 1f;
			audioSource.rolloffMode = (AudioRolloffMode)1;
			audioSource.maxDistance = 30f;
			if ((Object)(object)itemScript != (Object)null && (Object)(object)itemScript.itemProperties != (Object)null)
			{
				itemScript.itemProperties.holdButtonUse = true;
			}
		}

		private void Update()
		{
			if ((Object)(object)itemScript != (Object)null && (!itemScript.isHeld || itemScript.isPocketed))
			{
				if (isFiring)
				{
					SetFiringState(state: false);
					itemScript.isBeingUsed = false;
				}
			}
			else
			{
				if (!isFiring)
				{
					return;
				}
				if (currentAmmo <= 0f)
				{
					currentAmmo = 0f;
					SetFiringState(state: false);
					if ((Object)(object)itemScript != (Object)null)
					{
						itemScript.isBeingUsed = false;
					}
					return;
				}
				currentAmmo -= Time.deltaTime;
				if ((Object)(object)itemScript.playerHeldBy != (Object)null && (Object)(object)itemScript.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					damageTickTimer += Time.deltaTime;
					if (damageTickTimer >= damageInterval)
					{
						damageTickTimer = 0f;
						FireSphereCast(itemScript.playerHeldBy);
					}
				}
			}
		}

		private void FireSphereCast(PlayerControllerB player)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)player.gameplayCamera).transform.position, ((Component)player.gameplayCamera).transform.forward);
			float num = hitboxWidth / 2f;
			int num2 = 2621448;
			RaycastHit[] array = Physics.SphereCastAll(((Ray)(ref val)).origin, num, ((Ray)(ref val)).direction, hitboxLength, num2, (QueryTriggerInteraction)2);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val2 = array[i];
				GameObject gameObject = ((Component)((RaycastHit)(ref val2)).collider).gameObject;
				PlayerControllerB val3 = gameObject.GetComponentInParent<PlayerControllerB>();
				if ((Object)(object)val3 == (Object)null)
				{
					val3 = gameObject.GetComponent<PlayerControllerB>();
				}
				if ((Object)(object)val3 != (Object)null)
				{
					if ((Object)(object)val3 != (Object)(object)player)
					{
						val3.DamagePlayerFromOtherClientServerRpc(playerDamage, ((Ray)(ref val)).direction, (int)player.playerClientId);
					}
					continue;
				}
				EnemyAICollisionDetect component = gameObject.GetComponent<EnemyAICollisionDetect>();
				if ((Object)(object)component != (Object)null && (Object)(object)component.mainScript != (Object)null)
				{
					component.mainScript.HitEnemyOnLocalClient(entityDamage, ((Ray)(ref val)).direction, player, true, -1);
				}
			}
		}

		public void SetFiringState(bool state)
		{
			//IL_0047: 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)
			isFiring = state;
			if ((Object)(object)spawnedParticles == (Object)null && (Object)(object)shootParticlePrefab != (Object)null)
			{
				Transform val = (((Object)(object)barrelLocation != (Object)null) ? barrelLocation : ((Component)this).transform);
				GameObject val2 = Object.Instantiate<GameObject>(shootParticlePrefab, val.position, val.rotation, val);
				spawnedParticles = val2.GetComponent<ParticleSystem>();
			}
			if (isFiring)
			{
				if ((Object)(object)spawnedParticles != (Object)null)
				{
					spawnedParticles.Play();
				}
				if ((Object)(object)audioSource != (Object)null && (Object)(object)firingSound != (Object)null)
				{
					audioSource.clip = firingSound;
					audioSource.loop = true;
					if (!audioSource.isPlaying)
					{
						audioSource.Play();
					}
				}
			}
			else
			{
				if ((Object)(object)spawnedParticles != (Object)null)
				{
					spawnedParticles.Stop();
				}
				if ((Object)(object)audioSource != (Object)null)
				{
					audioSource.Stop();
				}
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	public class ContinuousWeaponPatch
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPrefix]
		public static bool ItemActivatePrefix(GrabbableObject __instance, bool used, bool buttonDown)
		{
			ContinuousWeaponComponent component = ((Component)__instance).GetComponent<ContinuousWeaponComponent>();
			if ((Object)(object)component != (Object)null)
			{
				if (buttonDown && component.currentAmmo > 0f)
				{
					__instance.isBeingUsed = true;
					component.SetFiringState(state: true);
				}
				else if (!buttonDown)
				{
					__instance.isBeingUsed = false;
					component.SetFiringState(state: false);
				}
				return true;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerDamagePatch
	{
		[HarmonyPatch("DamagePlayer")]
		[HarmonyPrefix]
		public static void Prefix(PlayerControllerB __instance, ref int damageNumber)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.currentlyHeldObjectServer == (Object)null))
			{
				DamageModifierComponent component = ((Component)__instance.currentlyHeldObjectServer).GetComponent<DamageModifierComponent>();
				FlatDamageModifierComponent component2 = ((Component)__instance.currentlyHeldObjectServer).GetComponent<FlatDamageModifierComponent>();
				float num = damageNumber;
				if ((Object)(object)component != (Object)null && component.damageReductionMultiplier > 0f)
				{
					num *= 1f - component.damageReductionMultiplier;
				}
				if ((Object)(object)component2 != (Object)null && component2.flatDamageReduction > 0)
				{
					num -= (float)component2.flatDamageReduction;
				}
				damageNumber = Mathf.Max(0, Mathf.RoundToInt(num));
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	[HarmonyPatch(typeof(GrabbableObject))]
	[HarmonyPatch(typeof(GrabbableObject))]
	public class WeaponUsePatch
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPrefix]
		public static void Prefix(GrabbableObject __instance, bool used, bool buttonDown)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Expected O, but got Unknown
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: 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_0435: Unknown result type (might be due to invalid IL or missing references)
			if (!buttonDown)
			{
				return;
			}
			SimpleWeaponComponent component = ((Component)__instance).GetComponent<SimpleWeaponComponent>();
			if ((Object)(object)component != (Object)null && component.ammo > 0)
			{
				component.ammo--;
				if ((Object)(object)component.shootSound != (Object)null)
				{
					AudioSource component2 = ((Component)__instance).GetComponent<AudioSource>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.PlayOneShot(component.shootSound, 1f);
					}
					else
					{
						AudioSource.PlayClipAtPoint(component.shootSound, ((Component)__instance).transform.position, 1f);
					}
				}
				if ((Object)(object)component.shootParticlePrefab != (Object)null)
				{
					Transform val = (((Object)(object)component.barrelLocation != (Object)null) ? component.barrelLocation : ((Component)__instance).transform);
					Object.Destroy((Object)(object)Object.Instantiate<GameObject>(component.shootParticlePrefab, val.position, val.rotation), 2f);
				}
				if ((Object)(object)__instance.playerHeldBy != (Object)null && (Object)(object)__instance.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					PlayerControllerB playerHeldBy = __instance.playerHeldBy;
					Ray val2 = default(Ray);
					((Ray)(ref val2))..ctor(((Component)playerHeldBy.gameplayCamera).transform.position, ((Component)playerHeldBy.gameplayCamera).transform.forward);
					int num = 2623753;
					RaycastHit[] array = Physics.RaycastAll(val2, 50f, num, (QueryTriggerInteraction)2);
					Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
					RaycastHit[] array2 = array;
					for (int num2 = 0; num2 < array2.Length; num2++)
					{
						RaycastHit val3 = array2[num2];
						GameObject gameObject = ((Component)((RaycastHit)(ref val3)).collider).gameObject;
						PlayerControllerB val4 = gameObject.GetComponentInParent<PlayerControllerB>();
						if ((Object)(object)val4 == (Object)null)
						{
							val4 = gameObject.GetComponent<PlayerControllerB>();
						}
						if ((Object)(object)val4 != (Object)null)
						{
							if ((Object)(object)val4 != (Object)(object)playerHeldBy)
							{
								val4.DamagePlayerFromOtherClientServerRpc(component.playerDamage, ((Ray)(ref val2)).direction, (int)playerHeldBy.playerClientId);
								break;
							}
							continue;
						}
						EnemyAICollisionDetect component3 = gameObject.GetComponent<EnemyAICollisionDetect>();
						if ((Object)(object)component3 != (Object)null && (Object)(object)component3.mainScript != (Object)null)
						{
							component3.mainScript.HitEnemyOnLocalClient(component.entityDamage, ((Ray)(ref val2)).direction, playerHeldBy, true, -1);
							break;
						}
						if (gameObject.layer == 8 || gameObject.layer == 11 || gameObject.layer == 0)
						{
							break;
						}
					}
				}
			}
			ProjectileWeaponComponent component4 = ((Component)__instance).GetComponent<ProjectileWeaponComponent>();
			if (!((Object)(object)component4 != (Object)null))
			{
				return;
			}
			PlayerControllerB playerHeldBy2 = __instance.playerHeldBy;
			bool flag = (Object)(object)playerHeldBy2 != (Object)null && (Object)(object)playerHeldBy2 == (Object)(object)GameNetworkManager.Instance.localPlayerController;
			if ((flag && component4.cooldownTimer > 0f) || component4.ammo <= 0)
			{
				return;
			}
			component4.ammo--;
			component4.cooldownTimer = component4.fireCooldown;
			if ((Object)(object)component4.shootSound != (Object)null)
			{
				AudioSource component5 = ((Component)__instance).GetComponent<AudioSource>();
				if ((Object)(object)component5 != (Object)null)
				{
					component5.PlayOneShot(component4.shootSound, 1f);
				}
				else
				{
					AudioSource.PlayClipAtPoint(component4.shootSound, ((Component)__instance).transform.position, 1f);
				}
			}
			Transform val5 = (((Object)(object)component4.barrelLocation != (Object)null) ? component4.barrelLocation : ((Component)__instance).transform);
			if ((Object)(object)component4.shootParticlePrefab != (Object)null)
			{
				Object.Destroy((Object)(object)Object.Instantiate<GameObject>(component4.shootParticlePrefab, val5.position, val5.rotation), 2f);
			}
			Vector3 val9;
			if ((Object)(object)playerHeldBy2 != (Object)null && (Object)(object)playerHeldBy2.gameplayCamera != (Object)null)
			{
				if (flag)
				{
					Ray val6 = default(Ray);
					((Ray)(ref val6))..ctor(((Component)playerHeldBy2.gameplayCamera).transform.position, ((Component)playerHeldBy2.gameplayCamera).transform.forward);
					Vector3 point = ((Ray)(ref val6)).GetPoint(100f);
					int num3 = 2623745;
					RaycastHit[] array3 = Physics.RaycastAll(val6, 100f, num3, (QueryTriggerInteraction)2);
					if (array3.Length != 0)
					{
						Array.Sort(array3, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
						RaycastHit[] array2 = array3;
						for (int num2 = 0; num2 < array2.Length; num2++)
						{
							RaycastHit val7 = array2[num2];
							if (!((RaycastHit)(ref val7)).transform.IsChildOf(((Component)__instance).transform) && !((RaycastHit)(ref val7)).transform.IsChildOf(((Component)playerHeldBy2).transform))
							{
								point = ((RaycastHit)(ref val7)).point;
								break;
							}
						}
					}
					Vector3 val8 = point - val5.position;
					val9 = ((!(((Vector3)(ref val8)).sqrMagnitude > 0.001f)) ? ((Component)playerHeldBy2.gameplayCamera).transform.forward : ((Vector3)(ref val8)).normalized);
				}
				else
				{
					val9 = ((Component)playerHeldBy2.gameplayCamera).transform.forward;
				}
			}
			else
			{
				val9 = val5.forward;
			}
			GameObject val10 = new GameObject("ProjectileContainer");
			val10.transform.position = val5.position;
			val10.transform.rotation = Quaternion.LookRotation(val9);
			if ((Object)(object)component4.projectileModelPrefab != (Object)null)
			{
				GameObject val11 = Object.Instantiate<GameObject>(component4.projectileModelPrefab);
				NetworkObject component6 = val11.GetComponent<NetworkObject>();
				if ((Object)(object)component6 != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)component6);
				}
				GrabbableObject component7 = val11.GetComponent<GrabbableObject>();
				if ((Object)(object)component7 != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)component7);
				}
				SimpleWeaponComponent component8 = val11.GetComponent<SimpleWeaponComponent>();
				if ((Object)(object)component8 != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)component8);
				}
				ContinuousWeaponComponent component9 = val11.GetComponent<ContinuousWeaponComponent>();
				if ((Object)(object)component9 != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)component9);
				}
				ProjectileWeaponComponent component10 = val11.GetComponent<ProjectileWeaponComponent>();
				if ((Object)(object)component10 != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)component10);
				}
				val11.transform.SetParent(val10.transform, false);
				val11.transform.localPosition = Vector3.zero;
				val11.transform.localRotation = Quaternion.identity;
				Collider[] componentsInChildren = val11.GetComponentsInChildren<Collider>();
				for (int num2 = 0; num2 < componentsInChildren.Length; num2++)
				{
					componentsInChildren[num2].enabled = false;
				}
				if ((Object)(object)val11.GetComponent<Rigidbody>() != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)val11.GetComponent<Rigidbody>());
				}
			}
			if ((Object)(object)component4.projectileParticlePrefab != (Object)null)
			{
				GameObject obj = Object.Instantiate<GameObject>(component4.projectileParticlePrefab, val10.transform);
				obj.transform.localPosition = Vector3.zero;
				obj.transform.localRotation = Quaternion.identity;
			}
			if ((Object)(object)component4.projectileLoopSound != (Object)null)
			{
				AudioSource obj2 = val10.AddComponent<AudioSource>();
				obj2.clip = component4.projectileLoopSound;
				obj2.loop = true;
				obj2.spatialBlend = 1f;
				obj2.minDistance = 2f;
				obj2.maxDistance = 20f;
				obj2.Play();
			}
			val10.AddComponent<ProjectileBehavior>().Initialize(val9, component4, flag, playerHeldBy2, __instance);
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class HUDManagerPatch
	{
		public static TextMeshProUGUI armorText;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPostfix(HUDManager __instance)
		{
			//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_0059: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ElowinyArmorText");
			val.transform.SetParent(((Component)((Graphic)__instance.weightCounter).canvas).transform, false);
			armorText = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)armorText).font = ((TMP_Text)__instance.weightCounter).font;
			((TMP_Text)armorText).fontSize = 16f;
			((Graphic)armorText).color = Color.green;
			((TMP_Text)armorText).alignment = (TextAlignmentOptions)514;
			RectTransform component = ((Component)armorText).GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(300f, 50f);
			component.anchorMin = new Vector2(0.5f, 0f);
			component.anchorMax = new Vector2(0.5f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.anchoredPosition = new Vector2(0f, 100f);
			((TMP_Text)armorText).text = "";
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void UpdatePostfix(HUDManager __instance)
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (Object)(object)armorText == (Object)null)
			{
				return;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController.currentlyHeldObjectServer != (Object)null)
			{
				DamageModifierComponent component = ((Component)localPlayerController.currentlyHeldObjectServer).GetComponent<DamageModifierComponent>();
				FlatDamageModifierComponent component2 = ((Component)localPlayerController.currentlyHeldObjectServer).GetComponent<FlatDamageModifierComponent>();
				SimpleWeaponComponent component3 = ((Component)localPlayerController.currentlyHeldObjectServer).GetComponent<SimpleWeaponComponent>();
				ContinuousWeaponComponent component4 = ((Component)localPlayerController.currentlyHeldObjectServer).GetComponent<ContinuousWeaponComponent>();
				ProjectileWeaponComponent component5 = ((Component)localPlayerController.currentlyHeldObjectServer).GetComponent<ProjectileWeaponComponent>();
				string text = "";
				if ((Object)(object)component3 != (Object)null)
				{
					text += $"Ammo Remaining: {component3.ammo}\n";
				}
				if ((Object)(object)component5 != (Object)null)
				{
					text += $"Ammo Remaining: {component5.ammo}\n";
				}
				((TMP_Text)armorText).text = text.Trim();
				if ((Object)(object)component != (Object)null && component.damageReductionMultiplier > 0f)
				{
					int num = Mathf.RoundToInt(component.damageReductionMultiplier * 100f);
					text += $"Percentage Damage Reduction: {num}%\n";
				}
				if ((Object)(object)component2 != (Object)null && component2.flatDamageReduction > 0)
				{
					text += $"Flat DMG Reduction: {component2.flatDamageReduction} DMG";
				}
				if ((Object)(object)component4 != (Object)null)
				{
					int num2 = Mathf.CeilToInt(component4.currentAmmo);
					text += $"Fuel: {num2}s\n";
				}
				((TMP_Text)armorText).text = text.Trim();
			}
			else
			{
				((TMP_Text)armorText).text = "";
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	public class WeaponSavePatch
	{
		[HarmonyPatch("GetItemDataToSave")]
		[HarmonyPostfix]
		public static void SaveAmmo(GrabbableObject __instance, ref int __result)
		{
			SimpleWeaponComponent component = ((Component)__instance).GetComponent<SimpleWeaponComponent>();
			if ((Object)(object)component != (Object)null)
			{
				__result = component.ammo + 1000;
				return;
			}
			ContinuousWeaponComponent component2 = ((Component)__instance).GetComponent<ContinuousWeaponComponent>();
			if ((Object)(object)component2 != (Object)null)
			{
				__result = Mathf.RoundToInt(component2.currentAmmo * 100f) + 10000;
				return;
			}
			ProjectileWeaponComponent component3 = ((Component)__instance).GetComponent<ProjectileWeaponComponent>();
			if ((Object)(object)component3 != (Object)null)
			{
				__result = component3.ammo + 1000;
			}
		}

		[HarmonyPatch("LoadItemSaveData")]
		[HarmonyPostfix]
		public static void LoadAmmo(GrabbableObject __instance, int saveData)
		{
			SimpleWeaponComponent component = ((Component)__instance).GetComponent<SimpleWeaponComponent>();
			if ((Object)(object)component != (Object)null)
			{
				if (saveData >= 1000)
				{
					component.ammo = saveData - 1000;
				}
				return;
			}
			ContinuousWeaponComponent component2 = ((Component)__instance).GetComponent<ContinuousWeaponComponent>();
			if ((Object)(object)component2 != (Object)null)
			{
				if (saveData >= 10000)
				{
					component2.currentAmmo = (float)(saveData - 10000) / 100f;
				}
				return;
			}
			ProjectileWeaponComponent component3 = ((Component)__instance).GetComponent<ProjectileWeaponComponent>();
			if ((Object)(object)component3 != (Object)null && saveData >= 1000)
			{
				component3.ammo = saveData - 1000;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ElowinyScrap";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

ElowinyVenus.AcidRain.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ElowinyVenus.AcidRain")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.3.1.0")]
[assembly: AssemblyInformationalVersion("0.3.1+15d6f9d5fbd32de9b1884f29ddec3be9133bd912")]
[assembly: AssemblyProduct("ElowinyVenus.AcidRain")]
[assembly: AssemblyTitle("ElowinyVenus.AcidRain")]
[assembly: AssemblyVersion("0.3.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 ElowinyVenus
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("elowi.venus.acidrain", "Elowiny Venus Acid Rain", "0.3.1")]
	public class VenusPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private static float nextPoll;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("elowi.venus.acidrain").PatchAll(typeof(VenusPlugin).Assembly);
			SceneManager.sceneLoaded += SceneLoaded;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Venus acid rain ready; scene-load and game-clock attachment enabled.");
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= SceneLoaded;
		}

		private static void SceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (((Scene)(ref scene)).name == "2Venus")
			{
				Attach(scene);
			}
		}

		internal static void PollScene()
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.unscaledTime < nextPoll))
			{
				nextPoll = Time.unscaledTime + 1f;
				Scene sceneByName = SceneManager.GetSceneByName("2Venus");
				if (((Scene)(ref sceneByName)).IsValid() && ((Scene)(ref sceneByName)).isLoaded)
				{
					Attach(sceneByName);
				}
			}
		}

		internal static void Attach(Scene scene)
		{
			Transform? obj = ((Scene)(ref scene)).GetRootGameObjects().SelectMany((GameObject g) => g.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "ElowinyVenus_Exterior" && (Object)(object)t.Find("Venus acid droplets") != (Object)null));
			GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<VenusRainController>() == (Object)null)
			{
				val.AddComponent<VenusRainController>();
				if (Log != null)
				{
					Log.LogInfo((object)"Venus acid rain attached; host-scheduled showers with five-second warnings, roof-aware damage.");
				}
				else
				{
					Debug.Log((object)"Venus acid rain attached; host-scheduled showers with five-second warnings, roof-aware damage.");
				}
			}
			if ((Object)(object)val != (Object)null && (Object)(object)val.transform.Find("Venus revision v3") != (Object)null && (Object)(object)val.GetComponent<VenusDetailController>() == (Object)null)
			{
				val.AddComponent<VenusDetailController>();
			}
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "Update")]
	internal static class VenusSceneTick
	{
		private static void Postfix()
		{
			VenusPlugin.PollScene();
		}
	}
	public static class AcidRules
	{
		public const double MinDuration = 5.0;

		public const double MaxDuration = 15.0;

		public const double WarningLead = 5.0;

		public const double Tick = 0.5;

		public static int SolidMask
		{
			get
			{
				int num = LayerMask.NameToLayer("ScanNode");
				if (num >= 0)
				{
					return ~(1 << num);
				}
				return -1;
			}
		}

		public static double Interval(Random rng)
		{
			return 30.0 + rng.NextDouble() * 30.0;
		}

		public static double Duration(Random rng)
		{
			return 5.0 + rng.NextDouble() * 10.0;
		}

		public static bool ValidDuration(double start, double end)
		{
			if (!(start < 0.0) || !(end < 0.0))
			{
				if (end - start >= 5.0)
				{
					return end - start <= 15.0;
				}
				return false;
			}
			return true;
		}

		public static bool Active(double now, double start, double end)
		{
			if (start >= 0.0 && now >= start)
			{
				return now < end;
			}
			return false;
		}

		public static bool RoofAbove(Vector3 head, Transform ignoredPlayer = null)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.RaycastAll(head, Vector3.up, 300f, SolidMask, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if ((!((Object)(object)ignoredPlayer != (Object)null) || !((RaycastHit)(ref val)).transform.IsChildOf(ignoredPlayer)) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PlayerControllerB>() != (Object)null) && (((RaycastHit)(ref val)).normal.y < -0.15f || ((RaycastHit)(ref val)).point.y > head.y + 0.25f))
				{
					return true;
				}
			}
			return false;
		}
	}
	public class VenusRainController : MonoBehaviour
	{
		private const string Message = "ElowinyVenus.AcidRain.v2";

		private NetworkManager network;

		private Random rng;

		private double start = -1.0;

		private double end = -1.0;

		private double nextEvent;

		private double nextBroadcast;

		private int eventId;

		private int warnedId = -1;

		private bool dayActive;

		private bool raining;

		private double nextDamage;

		private float nextSteam;

		private ParticleSystem rain;

		private ParticleSystem steam;

		private Fog fog;

		private Volume exteriorHaze;

		private bool pendingWarning;

		private AudioSource sizzle;

		private AudioClip sizzleClip;

		private void Start()
		{
			rain = ((Component)((Component)this).transform.Find("Venus acid droplets")).GetComponent<ParticleSystem>();
			steam = ((Component)((Component)this).transform.Find("Venus ground sizzling")).GetComponent<ParticleSystem>();
			exteriorHaze = ((Component)((Component)this).transform.Find("Venus exterior haze")).GetComponent<Volume>();
			exteriorHaze.sharedProfile.TryGet<Fog>(ref fog);
			sizzle = ((Component)this).gameObject.AddComponent<AudioSource>();
			sizzle.loop = true;
			sizzle.playOnAwake = false;
			sizzle.volume = 0.1f;
			sizzle.spatialBlend = 0f;
			float[] array = new float[44100];
			Random random = new Random(202602);
			float num = 0f;
			for (int i = 0; i < array.Length; i++)
			{
				num = (array[i] = 0.82f * num + 0.18f * ((float)random.NextDouble() * 2f - 1f));
			}
			sizzleClip = AudioClip.Create("Venus acid sizzling", array.Length, 1, 22050, false);
			sizzleClip.SetData(array, 0);
			sizzle.clip = sizzleClip;
		}

		private void BindNetwork()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			NetworkManager singleton = NetworkManager.Singleton;
			if (!((Object)(object)network == (Object)(object)singleton) && !((Object)(object)singleton == (Object)null) && singleton.CustomMessagingManager != null)
			{
				if ((Object)(object)network != (Object)null && network.CustomMessagingManager != null)
				{
					network.CustomMessagingManager.UnregisterNamedMessageHandler("ElowinyVenus.AcidRain.v2");
				}
				network = singleton;
				network.CustomMessagingManager.RegisterNamedMessageHandler("ElowinyVenus.AcidRain.v2", new HandleNamedMessageDelegate(Receive));
			}
		}

		private void Receive(ulong sender, FastBufferReader reader)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)network == (Object)null) && !network.IsServer && sender == 0L)
			{
				int num = default(int);
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
				double num2 = default(double);
				((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref num2, default(ForPrimitives));
				double num3 = default(double);
				((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref num3, default(ForPrimitives));
				if (AcidRules.ValidDuration(num2, num3))
				{
					eventId = num;
					start = num2;
					end = num3;
				}
			}
		}

		private unsafe void Broadcast()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(20, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref eventId, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref start, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref end, default(ForPrimitives));
				foreach (ulong connectedClientsId in network.ConnectedClientsIds)
				{
					if (connectedClientsId != 0L)
					{
						network.CustomMessagingManager.SendNamedMessage("ElowinyVenus.AcidRain.v2", connectedClientsId, val, (NetworkDelivery)3);
					}
				}
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void Update()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Invalid comparison between Unknown and I4
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			BindNetwork();
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)network == (Object)null || !network.IsListening || (Object)(object)instance == (Object)null)
			{
				return;
			}
			PlayerControllerB localPlayerController = instance.localPlayerController;
			exteriorHaze.weight = (((Object)(object)localPlayerController != (Object)null && !localPlayerController.isInsideFactory) ? 1 : 0);
			NetworkTime serverTime = network.ServerTime;
			double time = ((NetworkTime)(ref serverTime)).Time;
			if (instance.shipHasLanded && !instance.inShipPhase && !instance.shipIsLeaving)
			{
				Scene scene = ((Component)this).gameObject.scene;
				if (((Scene)(ref scene)).isLoaded)
				{
					if (!dayActive)
					{
						dayActive = true;
						if (network.IsServer)
						{
							rng = new Random(instance.randomMapSeed ^ 0x35B7A);
							nextEvent = time + AcidRules.Interval(rng) - 5.0;
							VenusPlugin.Log.LogInfo((object)("Venus landed: first acid shower in " + (nextEvent + 5.0 - time).ToString("F1") + " seconds."));
						}
					}
					if (network.IsServer)
					{
						if (time >= nextEvent)
						{
							start = time + 5.0;
							end = start + AcidRules.Duration(rng);
							eventId++;
							nextEvent = start + AcidRules.Interval(rng) - 5.0;
							nextBroadcast = 0.0;
							VenusPlugin.Log.LogInfo((object)("ACID RAIN event " + eventId + ": warning now; rain in five seconds for " + (end - start).ToString("F1") + " seconds."));
						}
						if (time >= nextBroadcast)
						{
							Broadcast();
							nextBroadcast = time + 0.5;
						}
					}
					bool flag = (Object)(object)localPlayerController != (Object)null && !localPlayerController.isInsideFactory && !localPlayerController.isPlayerDead;
					if (start >= 0.0 && time >= start - 5.0 && time < start && warnedId != eventId && flag)
					{
						warnedId = eventId;
						pendingWarning = true;
						HUDManager instance2 = HUDManager.Instance;
						if ((Object)(object)instance2 != (Object)null && (Object)(object)instance2.UIAudio != (Object)null && (Object)(object)instance2.shipAlarmHornSFX != (Object)null)
						{
							instance2.UIAudio.PlayOneShot(instance2.shipAlarmHornSFX, 0.65f);
						}
					}
					if (pendingWarning && (Object)(object)HUDManager.Instance != (Object)null)
					{
						if (time >= start || !flag)
						{
							pendingWarning = false;
						}
						else if ((bool)AccessTools.Method(typeof(HUDManager), "CanTipDisplay", (Type[])null, (Type[])null).Invoke(HUDManager.Instance, new object[3] { true, false, "VenusAcidRain" }))
						{
							HUDManager.Instance.DisplayTip("ACID RAIN", "Seek cover!", true, false, "LC_Tip1");
							pendingWarning = false;
						}
					}
					bool flag2 = AcidRules.Active(time, start, end);
					PlayerControllerB localPlayerController2 = instance.localPlayerController;
					bool flag3 = (Object)(object)localPlayerController2 != (Object)null && !localPlayerController2.isPlayerDead && !localPlayerController2.isInsideFactory && !localPlayerController2.isInHangarShipRoom;
					if (flag3)
					{
						((Component)rain).transform.position = ((Component)localPlayerController2).transform.position + Vector3.up * 16f;
						if (flag2 && Time.unscaledTime >= nextSteam)
						{
							EmitSteam(((Component)localPlayerController2).transform.position);
							nextSteam = Time.unscaledTime + 0.1f;
						}
					}
					SetRain(flag2 && flag3);
					if ((Object)(object)fog != (Object)null)
					{
						((VolumeParameter<float>)(object)fog.meanFreePath).value = (((int)instance.currentLevel.currentWeather == 3) ? 65 : 230);
					}
					if (!flag2)
					{
						nextDamage = start;
						return;
					}
					if (nextDamage < start || nextDamage > end)
					{
						nextDamage = start;
					}
					if (time >= nextDamage)
					{
						nextDamage = ((time - nextDamage > 0.5) ? (time + 0.5) : (nextDamage + 0.5));
						if (flag3 && ((NetworkBehaviour)localPlayerController2).IsOwner && !AcidRules.RoofAbove(((Component)localPlayerController2.gameplayCamera).transform.position, ((Component)localPlayerController2).transform))
						{
							localPlayerController2.DamagePlayer(1, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
						}
					}
					return;
				}
			}
			if (dayActive)
			{
				start = (end = -1.0);
				eventId = 0;
				warnedId = -1;
				pendingWarning = false;
			}
			dayActive = false;
			SetRain(enabled: false);
		}

		private void EmitSteam(Vector3 center)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			for (int i = 0; i < 5; i++)
			{
				if (Physics.Raycast(center + new Vector3(Random.Range(-15f, 15f), 60f, Random.Range(-15f, 15f)), Vector3.down, ref val, 180f, AcidRules.SolidMask, (QueryTriggerInteraction)1) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PlayerControllerB>() != (Object)null) && !AcidRules.RoofAbove(((RaycastHit)(ref val)).point + Vector3.up * 0.15f))
				{
					EmitParams val2 = default(EmitParams);
					((EmitParams)(ref val2)).position = ((RaycastHit)(ref val)).point + Vector3.up * 0.12f;
					((EmitParams)(ref val2)).velocity = Vector3.up * Random.Range(0.8f, 1.8f);
					((EmitParams)(ref val2)).startSize = Random.Range(0.3f, 0.8f);
					EmitParams val3 = val2;
					steam.Emit(val3, 1);
				}
			}
		}

		private void SetRain(bool enabled)
		{
			if ((Object)(object)rain == (Object)null || raining == enabled)
			{
				return;
			}
			raining = enabled;
			if (enabled)
			{
				rain.Play();
				if ((Object)(object)sizzle != (Object)null)
				{
					sizzle.Play();
				}
				return;
			}
			rain.Stop(true, (ParticleSystemStopBehavior)0);
			steam.Stop(true, (ParticleSystemStopBehavior)0);
			if ((Object)(object)sizzle != (Object)null)
			{
				sizzle.Stop();
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)network != (Object)null && network.CustomMessagingManager != null)
			{
				network.CustomMessagingManager.UnregisterNamedMessageHandler("ElowinyVenus.AcidRain.v2");
			}
			if ((Object)(object)sizzleClip != (Object)null)
			{
				Object.Destroy((Object)(object)sizzleClip);
			}
		}
	}
	public static class VenusBalance
	{
		public static readonly string[] Fields = new string[20]
		{
			"spawnableScrap", "minScrap", "maxScrap", "minTotalScrapValue", "maxTotalScrapValue", "riskLevel", "maxEnemyPowerCount", "maxOutsideEnemyPowerCount", "maxDaytimeEnemyPowerCount", "maxInsideDiversityPowerCount",
			"maxOutsideDiversityPowerCount", "Enemies", "OutsideEnemies", "DaytimeEnemies", "specialEnemyRarity", "enemySpawnChanceThroughoutDay", "outsideEnemySpawnChanceThroughDay", "daytimeEnemySpawnChanceThroughDay", "spawnProbabilityRange", "daytimeEnemiesProbabilityRange"
		};

		public static void Copy(SelectableLevel source, SelectableLevel target)
		{
			string[] fields = Fields;
			foreach (string text in fields)
			{
				FieldInfo field = typeof(SelectableLevel).GetField(text);
				if (field == null)
				{
					throw new MissingFieldException(text);
				}
				field.SetValue(target, field.GetValue(source));
			}
		}
	}
	public class VenusDetailController : MonoBehaviour
	{
		private AudioSource wind;

		private Volume indoor;

		private Collider[] heat;

		private double nextHeat;

		private bool populated;

		private SelectableLevel balanced;

		private NetworkManager bound;

		private const string ScrapMessage = "ElowinyVenus.TunnelScrap.v1";

		private void Start()
		{
			wind = ((Component)((Component)this).transform.Find("Venus revision v3/Venus wind ambience")).GetComponent<AudioSource>();
			indoor = ((Component)((Component)this).transform.Find("Venus revision v3/Venus ship glare reduction")).GetComponent<Volume>();
			heat = (from c in ((Component)this).GetComponentsInChildren<Collider>()
				where ((Object)c).name.StartsWith("Venus lethal vent core")
				select c).ToArray();
		}

		private void Update()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.localPlayerController == (Object)null)
			{
				return;
			}
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)bound == (Object)null && (Object)(object)singleton != (Object)null && singleton.CustomMessagingManager != null)
			{
				bound = singleton;
				bound.CustomMessagingManager.RegisterNamedMessageHandler("ElowinyVenus.TunnelScrap.v1", new HandleNamedMessageDelegate(ReceiveScrap));
			}
			PlayerControllerB localPlayerController = instance.localPlayerController;
			indoor.weight = 0f;
			if ((Object)(object)wind != (Object)null)
			{
				float num = (localPlayerController.isInsideFactory ? 0f : (localPlayerController.isInHangarShipRoom ? 0.16f : (AcidRules.RoofAbove(((Component)localPlayerController.gameplayCamera).transform.position, ((Component)localPlayerController).transform) ? 0.36f : 0.66f)));
				wind.volume = Mathf.MoveTowards(wind.volume, num, Time.unscaledDeltaTime * 1.5f);
				if (!wind.isPlaying && (Object)(object)wind.clip != (Object)null)
				{
					wind.Play();
				}
			}
			if ((Object)(object)balanced != (Object)(object)instance.currentLevel && (Object)(object)instance.currentLevel != (Object)null && instance.currentLevel.PlanetName.Contains("Venus"))
			{
				SelectableLevel val = ((IEnumerable<SelectableLevel>)instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel l) => (Object)(object)l != (Object)null && l.PlanetName.Contains("Offense")));
				if ((Object)(object)val != (Object)null)
				{
					VenusBalance.Copy(val, instance.currentLevel);
					balanced = instance.currentLevel;
				}
			}
			if (!instance.shipHasLanded || instance.inShipPhase || instance.shipIsLeaving)
			{
				populated = false;
				return;
			}
			NetworkManager singleton2 = NetworkManager.Singleton;
			if (!populated && (Object)(object)singleton2 != (Object)null && singleton2.IsServer)
			{
				populated = true;
				((MonoBehaviour)this).StartCoroutine(SpawnTunnelScrap(instance.randomMapSeed));
			}
			if (!((NetworkBehaviour)localPlayerController).IsOwner || localPlayerController.isPlayerDead || localPlayerController.isInsideFactory || localPlayerController.isInHangarShipRoom)
			{
				return;
			}
			double unscaledTimeAsDouble = Time.unscaledTimeAsDouble;
			if (!(unscaledTimeAsDouble < nextHeat))
			{
				nextHeat = unscaledTimeAsDouble + 0.25;
				Vector3 p = ((Component)localPlayerController).transform.position + Vector3.up * 0.8f;
				if (heat.Any(delegate(Collider c)
				{
					//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_0015: Unknown result type (might be due to invalid IL or missing references)
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					if (c.enabled)
					{
						Vector3 val2 = c.ClosestPoint(p) - p;
						return ((Vector3)(ref val2)).sqrMagnitude < 0.001f;
					}
					return false;
				}))
				{
					localPlayerController.DamagePlayer(10, false, true, (CauseOfDeath)13, 0, false, default(Vector3));
				}
			}
		}

		private unsafe IEnumerator SpawnTunnelScrap(int seed)
		{
			yield return (object)new WaitForSeconds(15f);
			StartOfRound instance = StartOfRound.Instance;
			RoundManager manager = RoundManager.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)manager == (Object)null || !instance.shipHasLanded || instance.shipIsLeaving)
			{
				yield break;
			}
			Random rng = new Random(seed ^ 0x318FB);
			if (rng.NextDouble() > 0.55)
			{
				yield break;
			}
			SpawnableItemWithRarity[] array = instance.currentLevel.spawnableScrap.Where((SpawnableItemWithRarity e) => e.rarity > 0 && (Object)(object)e.spawnableItem != (Object)null && e.spawnableItem.isScrap && !e.spawnableItem.twoHanded && e.spawnableItem.weight <= 1.1f && (Object)(object)e.spawnableItem.spawnPrefab != (Object)null).ToArray();
			Transform[] array2 = (from Transform t in (IEnumerable)((Component)this).transform.Find("Venus revision v3/Venus tunnel scrap points")
				orderby rng.Next()
				select t).ToArray();
			if (array.Length == 0 || array2.Length == 0)
			{
				yield break;
			}
			int num = Math.Min(array2.Length, rng.Next(1, 4));
			List<NetworkObjectReference> references = new List<NetworkObjectReference>();
			List<int> values = new List<int>();
			for (int num2 = 0; num2 < num; num2++)
			{
				int num3 = rng.Next(array.Sum((SpawnableItemWithRarity e) => e.rarity));
				SpawnableItemWithRarity val = array[0];
				SpawnableItemWithRarity[] array3 = array;
				foreach (SpawnableItemWithRarity val2 in array3)
				{
					num3 -= val2.rarity;
					if (num3 < 0)
					{
						val = val2;
						break;
					}
				}
				Item spawnableItem = val.spawnableItem;
				GameObject val3 = Object.Instantiate<GameObject>(spawnableItem.spawnPrefab, array2[num2].position + Vector3.up * 0.15f, Quaternion.Euler(spawnableItem.restingRotation));
				SceneManager.MoveGameObjectToScene(val3, ((Component)this).gameObject.scene);
				GrabbableObject component = val3.GetComponent<GrabbableObject>();
				NetworkObject component2 = val3.GetComponent<NetworkObject>();
				if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
				{
					Object.Destroy((Object)(object)val3);
					continue;
				}
				component.fallTime = 0f;
				int num5 = (int)((float)rng.Next(spawnableItem.minValue, Math.Max(spawnableItem.minValue + 1, spawnableItem.maxValue)) * manager.scrapValueMultiplier);
				component.SetScrapValue(num5);
				component2.Spawn(false);
				references.Add(NetworkObjectReference.op_Implicit(component2));
				values.Add(num5);
			}
			yield return (object)new WaitForSeconds(0.5f);
			if (references.Count <= 0)
			{
				yield break;
			}
			manager.totalScrapValueInLevel += (float)values.Sum();
			FastBufferWriter val4 = default(FastBufferWriter);
			((FastBufferWriter)(ref val4))..ctor(1024, (Allocator)2, -1);
			try
			{
				int num4 = references.Count;
				((FastBufferWriter)(ref val4)).WriteValueSafe<int>(ref num4, default(ForPrimitives));
				for (int num6 = 0; num6 < references.Count; num6++)
				{
					NetworkObjectReference val5 = references[num6];
					((FastBufferWriter)(ref val4)).WriteValueSafe<NetworkObjectReference>(ref val5, default(ForNetworkSerializable));
					num4 = values[num6];
					((FastBufferWriter)(ref val4)).WriteValueSafe<int>(ref num4, default(ForPrimitives));
				}
				foreach (ulong connectedClientsId in bound.ConnectedClientsIds)
				{
					if (connectedClientsId != 0L)
					{
						bound.CustomMessagingManager.SendNamedMessage("ElowinyVenus.TunnelScrap.v1", connectedClientsId, val4, (NetworkDelivery)3);
					}
				}
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val4))/*cast due to .constrained prefix*/).Dispose();
			}
			VenusPlugin.Log.LogInfo((object)("Venus tunnel scrap: " + references.Count));
		}

		private void ReceiveScrap(ulong sender, FastBufferReader reader)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_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)
			if ((Object)(object)bound == (Object)null || bound.IsServer || sender != 0L)
			{
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (num >= 1 && num <= 3)
			{
				NetworkObjectReference[] array = (NetworkObjectReference[])(object)new NetworkObjectReference[num];
				int[] array2 = new int[num];
				for (int i = 0; i < num; i++)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref array[i], default(ForNetworkSerializable));
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref array2[i], default(ForPrimitives));
				}
				((MonoBehaviour)this).StartCoroutine(ApplyScrap(array, array2));
			}
		}

		private IEnumerator ApplyScrap(NetworkObjectReference[] refs, int[] values)
		{
			yield return (object)new WaitForSeconds(0.5f);
			NetworkObject val = default(NetworkObject);
			for (int i = 0; i < refs.Length; i++)
			{
				if (((NetworkObjectReference)(ref refs[i])).TryGet(ref val, (NetworkManager)null))
				{
					GrabbableObject component = ((Component)val).GetComponent<GrabbableObject>();
					if ((Object)(object)component != (Object)null)
					{
						component.SetScrapValue(values[i]);
					}
				}
			}
			if ((Object)(object)RoundManager.Instance != (Object)null)
			{
				RoundManager instance = RoundManager.Instance;
				instance.totalScrapValueInLevel += (float)values.Sum();
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)wind != (Object)null)
			{
				wind.Stop();
			}
			if ((Object)(object)bound != (Object)null && bound.CustomMessagingManager != null)
			{
				bound.CustomMessagingManager.UnregisterNamedMessageHandler("ElowinyVenus.TunnelScrap.v1");
			}
		}
	}
}

JetpackSafetyProtocol.dll

Decompiled an hour ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("JetpackSafetyProtocol")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JetpackSafetyProtocol")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e54827aa-9989-41ab-95e5-52e1eec3d12c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace JetpackSafetyProtocol;

[BepInPlugin("com.yourname.jetpacksafety", "Jetpack Safety Protocol", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static ConfigEntry<string> BannedUsersConfig;

	private void Awake()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		BannedUsersConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Targeting", "BannedUsernames", "Elowiny,Jimmy,Coco", "A comma-separated list of usernames.");
		Harmony val = new Harmony("com.yourname.jetpacksafety");
		val.PatchAll(typeof(JetpackPatch));
	}
}
[HarmonyPatch(typeof(PlayerControllerB))]
public class JetpackPatch
{
	[HarmonyPatch("BeginGrabObject")]
	[HarmonyPostfix]
	public static void BeginGrabObjectPostfix(PlayerControllerB __instance, ref GrabbableObject ___currentlyGrabbingObject)
	{
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)___currentlyGrabbingObject == (Object)null || !(___currentlyGrabbingObject is JetpackItem) || StartOfRound.Instance.inShipPhase)
		{
			return;
		}
		string value = Plugin.BannedUsersConfig.Value;
		string[] array = value.Split(new char[1] { ',' });
		bool flag = false;
		string[] array2 = array;
		foreach (string text in array2)
		{
			if (__instance.playerUsername == text.Trim())
			{
				flag = true;
				break;
			}
		}
		if (flag)
		{
			Landmine.SpawnExplosion(((Component)__instance).transform.position, true, 0f, 0f, 0, 0f, (GameObject)null, false);
			__instance.DamagePlayer(1000, true, true, (CauseOfDeath)3, 0, false, default(Vector3));
			___currentlyGrabbingObject = null;
			__instance.isGrabbingObjectAnimation = false;
		}
	}
}