Decompiled source of CreativePlus v1.0.1

CreativeMode.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("CreativeMode")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("CreativeMode")]
[assembly: AssemblyTitle("CreativeMode")]
[assembly: AssemblyVersion("1.0.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 CreativeMode
{
	internal static class Targeting
	{
		public static Vector3 LookPoint(Player player, float maxDistance)
		{
			//IL_003b: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//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_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_00c0: 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_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_00aa: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return ((Component)player).transform.position + ((Component)player).transform.forward * 6f;
			}
			RaycastHit[] array = Physics.RaycastAll(((Component)main).transform.position, ((Component)main).transform.forward, maxDistance, -1, (QueryTriggerInteraction)1);
			Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
			RaycastHit[] array2 = array;
			for (int num = 0; num < array2.Length; num++)
			{
				RaycastHit val = array2[num];
				if (!((Object)(object)((Component)((RaycastHit)(ref val)).collider).transform.root == (Object)(object)((Component)player).transform.root))
				{
					return ((RaycastHit)(ref val)).point;
				}
			}
			return ((Component)main).transform.position + ((Component)main).transform.forward * Mathf.Min(maxDistance, 40f);
		}
	}
	[HarmonyPatch(typeof(Humanoid), "UseItem")]
	internal static class Humanoid_UseItem
	{
		private static float lastUse;

		private static bool Prefix(Humanoid __instance, ItemData item)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)__instance != (Object)(object)localPlayer || item == null || (Object)(object)item.m_dropPrefab == (Object)null)
			{
				return true;
			}
			string name = ((Object)item.m_dropPrefab).name;
			bool flag = name.StartsWith("CM_Egg_");
			bool flag2 = name == "CM_Nuke";
			bool flag3 = name == "CM_JukeboxItem";
			if (!flag && !flag2 && !flag3)
			{
				return true;
			}
			if (Time.time - lastUse < 0.4f)
			{
				return false;
			}
			lastUse = Time.time;
			if (flag)
			{
				SpawnEgg(localPlayer, name.Substring("CM_Egg_".Length));
			}
			else if (flag3)
			{
				if (PlaceJukebox(localPlayer))
				{
					((Humanoid)localPlayer).GetInventory().RemoveOneItem(item);
				}
			}
			else if (Nuke.Launch(localPlayer))
			{
				((Humanoid)localPlayer).GetInventory().RemoveOneItem(item);
			}
			return false;
		}

		private static bool PlaceJukebox(Player player)
		{
			//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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0062: 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_0077: 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)
			GameObject prefab = ZNetScene.instance.GetPrefab("CM_Jukebox");
			if ((Object)(object)prefab == (Object)null)
			{
				((Character)player).Message((MessageType)2, "Jukebox prefab missing", 0, (Sprite)null, false);
				return false;
			}
			Vector3 val = Targeting.LookPoint(player, 12f);
			Vector3 val2 = ((Component)player).transform.position - val;
			val2.y = 0f;
			Quaternion val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? Quaternion.LookRotation(((Vector3)(ref val2)).normalized) : Quaternion.identity);
			Object.Instantiate<GameObject>(prefab, val, val3);
			((Character)player).Message((MessageType)1, "Jukebox placed", 0, (Sprite)null, false);
			return true;
		}

		private static void SpawnEgg(Player player, string creature)
		{
			//IL_0031: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ZNetScene.instance.GetPrefab(creature);
			if ((Object)(object)prefab == (Object)null)
			{
				((Character)player).Message((MessageType)2, "Unknown creature " + creature, 0, (Sprite)null, false);
				return;
			}
			Vector3 val = Targeting.LookPoint(player, 100f) + Vector3.up * 0.3f;
			Object.Instantiate<GameObject>(prefab, val, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f));
			((Character)player).Message((MessageType)1, "Spawned " + creature, 0, (Sprite)null, false);
		}
	}
	public class CreativeMenu : MonoBehaviour
	{
		private class Entry
		{
			public GameObject Button;

			public string PrefabName;

			public string DisplayName;

			public string Category;
		}

		private static readonly string[] Categories = new string[13]
		{
			"All", "Weapons", "Armor", "Tools", "Food", "Materials", "Trophies", "Misc", "Eggs", "Discs",
			"Special", "Weather", "Fun Stuff"
		};

		private readonly List<Entry> entries = new List<Entry>();

		private GameObject root;

		private InputField search;

		private GameObject scrollGo;

		private GameObject weatherPanel;

		private GameObject funPanel;

		private Text musicLabel;

		private bool weatherBuilt;

		private Text hoverLabel;

		private string category = "All";

		private Font font;

		public static bool Open { get; private set; }

		public static void Toggle()
		{
			CreativeMenu creativeMenu = ((Component)Plugin.Instance).GetComponent<CreativeMenu>();
			if ((Object)(object)creativeMenu == (Object)null)
			{
				creativeMenu = ((Component)Plugin.Instance).gameObject.AddComponent<CreativeMenu>();
			}
			creativeMenu.SetOpen(!Open);
		}

		public static void Close()
		{
			if (Open)
			{
				CreativeMenu component = ((Component)Plugin.Instance).GetComponent<CreativeMenu>();
				if ((Object)(object)component != (Object)null)
				{
					component.SetOpen(open: false);
				}
			}
		}

		private void SetOpen(bool open)
		{
			if (open && (Object)(object)root == (Object)null)
			{
				Build();
			}
			if ((Object)(object)root != (Object)null)
			{
				root.SetActive(open);
			}
			Open = open;
			if (open)
			{
				Refilter();
				search.ActivateInputField();
			}
		}

		private void Update()
		{
			if (Open)
			{
				if (Input.GetKeyDown((KeyCode)27))
				{
					SetOpen(open: false);
					return;
				}
				RefreshFun();
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}

		private static string CategoryOf(SharedData s)
		{
			switch (((object)Unsafe.As<ItemType, ItemType>(ref s.m_itemType)/*cast due to .constrained prefix*/).ToString())
			{
			case "OneHandedWeapon":
			case "TwoHandedWeapon":
			case "Shield":
			case "Ammo":
			case "Attach_Atgeir":
			case "Torch":
			case "TwoHandedWeaponLeft":
			case "Bow":
			case "AmmoNonEquipable":
				return "Weapons";
			case "Helmet":
			case "Legs":
			case "Customization":
			case "Chest":
			case "Hands":
			case "Shoulder":
			case "Trinket":
			case "Utility":
				return "Armor";
			case "Tool":
			case "Fish":
				return "Tools";
			case "Consumable":
				return "Food";
			case "Material":
				return "Materials";
			case "Trophy":
				return "Trophies";
			default:
				return "Misc";
			}
		}

		private void Build()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00e4: 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_0120: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: 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_0440: 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_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Expected O, but got Unknown
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: 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_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Expected O, but got Unknown
			//IL_0583: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: 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_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Expected O, but got Unknown
			//IL_065a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_0692: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Expected O, but got Unknown
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_0750: Unknown result type (might be due to invalid IL or missing references)
			//IL_075f: Unknown result type (might be due to invalid IL or missing references)
			//IL_076e: Unknown result type (might be due to invalid IL or missing references)
			font = FindFont();
			root = new GameObject("CreativeMenuCanvas", new Type[3]
			{
				typeof(Canvas),
				typeof(CanvasScaler),
				typeof(GraphicRaycaster)
			});
			Object.DontDestroyOnLoad((Object)(object)root);
			Canvas component = root.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.sortingOrder = 500;
			CanvasScaler component2 = root.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			GameObject val = MakeImage("Panel", root.transform, new Color(0.08f, 0.07f, 0.06f, 0.96f));
			Rect(val, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(1400f, 760f));
			Rect(MakeText("Title", val.transform, "Creative Items", 30, (TextAnchor)3), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, -30f), new Vector2(-40f, 50f));
			GameObject val2 = MakeImage("Search", val.transform, new Color(0.18f, 0.16f, 0.14f, 1f));
			Rect(val2, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-190f, -30f), new Vector2(340f, 40f));
			GameObject val3 = MakeText("Text", val2.transform, "", 22, (TextAnchor)3);
			Stretch(val3, 10f, 4f);
			GameObject val4 = MakeText("Placeholder", val2.transform, "Search...", 22, (TextAnchor)3);
			((Graphic)val4.GetComponent<Text>()).color = new Color(1f, 1f, 1f, 0.4f);
			Stretch(val4, 10f, 4f);
			search = val2.AddComponent<InputField>();
			search.textComponent = val3.GetComponent<Text>();
			search.placeholder = (Graphic)(object)val4.GetComponent<Text>();
			((UnityEvent<string>)(object)search.onValueChanged).AddListener((UnityAction<string>)delegate
			{
				Refilter();
			});
			float num = 20f;
			string[] categories = Categories;
			foreach (string text in categories)
			{
				string c = text;
				Rect(MakeButton(val.transform, c, 20, new Color(0.25f, 0.2f, 0.15f, 1f), (UnityAction)delegate
				{
					category = c;
					Refilter();
				}), new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(num + 49f, -85f), new Vector2(98f, 36f));
				num += 104f;
			}
			GameObject val5 = (scrollGo = MakeImage("Scroll", val.transform, new Color(0f, 0f, 0f, 0.25f)));
			weatherPanel = MakeImage("WeatherPanel", val.transform, new Color(0f, 0f, 0f, 0.25f));
			Rect(weatherPanel, new Vector2(0f, 0f), new Vector2(1f, 1f), Vector2.zero, Vector2.zero);
			weatherPanel.GetComponent<RectTransform>().offsetMin = new Vector2(20f, 60f);
			weatherPanel.GetComponent<RectTransform>().offsetMax = new Vector2(-20f, -120f);
			GridLayoutGroup obj = weatherPanel.AddComponent<GridLayoutGroup>();
			obj.cellSize = new Vector2(250f, 48f);
			obj.spacing = new Vector2(10f, 10f);
			((LayoutGroup)obj).padding = new RectOffset(14, 14, 14, 14);
			weatherPanel.SetActive(false);
			funPanel = MakeImage("FunPanel", val.transform, new Color(0f, 0f, 0f, 0.25f));
			Rect(funPanel, new Vector2(0f, 0f), new Vector2(1f, 1f), Vector2.zero, Vector2.zero);
			funPanel.GetComponent<RectTransform>().offsetMin = new Vector2(20f, 60f);
			funPanel.GetComponent<RectTransform>().offsetMax = new Vector2(-20f, -120f);
			GridLayoutGroup obj2 = funPanel.AddComponent<GridLayoutGroup>();
			obj2.cellSize = new Vector2(420f, 60f);
			obj2.spacing = new Vector2(10f, 10f);
			((LayoutGroup)obj2).padding = new RectOffset(14, 14, 14, 14);
			funPanel.SetActive(false);
			BuildFun();
			Rect(val5, new Vector2(0f, 0f), new Vector2(1f, 1f), new Vector2(0f, -20f), new Vector2(-40f, -230f));
			val5.GetComponent<RectTransform>().offsetMin = new Vector2(20f, 60f);
			val5.GetComponent<RectTransform>().offsetMax = new Vector2(-20f, -120f);
			val5.AddComponent<RectMask2D>();
			GameObject val6 = new GameObject("Content", new Type[3]
			{
				typeof(RectTransform),
				typeof(GridLayoutGroup),
				typeof(ContentSizeFitter)
			});
			val6.transform.SetParent(val5.transform, false);
			RectTransform component3 = val6.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 1f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.pivot = new Vector2(0.5f, 1f);
			component3.sizeDelta = Vector2.zero;
			GridLayoutGroup component4 = val6.GetComponent<GridLayoutGroup>();
			component4.cellSize = new Vector2(64f, 64f);
			component4.spacing = new Vector2(6f, 6f);
			((LayoutGroup)component4).padding = new RectOffset(8, 8, 8, 8);
			val6.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			ScrollRect obj3 = val5.AddComponent<ScrollRect>();
			obj3.content = component3;
			obj3.horizontal = false;
			obj3.scrollSensitivity = 40f;
			hoverLabel = MakeText("Hover", val.transform, "Click: full stack   Shift/Right-click: 1", 22, (TextAnchor)3).GetComponent<Text>();
			Rect(((Component)hoverLabel).gameObject, new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 30f), new Vector2(-40f, 40f));
			BuildItemButtons(val6.transform);
		}

		private void BuildItemButtons(Transform parent)
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				return;
			}
			foreach (GameObject item in ObjectDB.instance.m_items)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				ItemDrop component = item.GetComponent<ItemDrop>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				SharedData shared = component.m_itemData.m_shared;
				if (shared.m_icons != null && shared.m_icons.Length != 0 && !((Object)(object)shared.m_icons[0] == (Object)null))
				{
					Entry entry = new Entry
					{
						PrefabName = ((Object)item).name,
						DisplayName = Localization.instance.Localize(shared.m_name),
						Category = (((Object)item).name.StartsWith("CM_Egg_") ? "Eggs" : (((Object)item).name.StartsWith("CM_Disc_") ? "Discs" : (((Object)item).name.StartsWith("CM_") ? "Special" : CategoryOf(shared))))
					};
					GameObject val = MakeImage(((Object)item).name, parent, new Color(0.22f, 0.19f, 0.16f, 1f));
					GameObject obj = MakeImage("Icon", val.transform, Color.white);
					obj.GetComponent<Image>().sprite = shared.m_icons[0];
					((Graphic)obj.GetComponent<Image>()).raycastTarget = false;
					Stretch(obj, 4f, 4f);
					string captured = ((Object)item).name;
					ItemSlotHandler itemSlotHandler = val.AddComponent<ItemSlotHandler>();
					itemSlotHandler.OnClick = delegate(PointerEventData ev)
					{
						Give(captured, ev);
					};
					itemSlotHandler.OnHover = delegate
					{
						hoverLabel.text = entry.DisplayName + "  (" + captured + ")";
					};
					entry.Button = val;
					entries.Add(entry);
				}
			}
		}

		private void BuildWeather()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_008e: 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_00a0: Expected O, but got Unknown
			//IL_00a6: 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: Expected O, but got Unknown
			//IL_00be: 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_00d0: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//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_016f: Expected O, but got Unknown
			weatherBuilt = true;
			Transform parent = weatherPanel.transform;
			Color color = default(Color);
			((Color)(ref color))..ctor(0.2f, 0.3f, 0.45f, 1f);
			Add("Auto weather", new Color(0.3f, 0.45f, 0.2f, 1f), (UnityAction)delegate
			{
				SetWeather("");
			});
			Add("Time: Dawn", color, (UnityAction)delegate
			{
				SetTime(0.25f);
			});
			Add("Time: Noon", color, (UnityAction)delegate
			{
				SetTime(0.5f);
			});
			Add("Time: Dusk", color, (UnityAction)delegate
			{
				SetTime(0.75f);
			});
			Add("Time: Midnight", color, (UnityAction)delegate
			{
				SetTime(0f);
			});
			Add("Resume time", new Color(0.3f, 0.45f, 0.2f, 1f), (UnityAction)delegate
			{
				SetTime(-1f);
			});
			foreach (EnvSetup environment in EnvMan.instance.m_environments)
			{
				string name = environment.m_name;
				Add(name, new Color(0.25f, 0.2f, 0.15f, 1f), (UnityAction)delegate
				{
					SetWeather(name);
				});
			}
			void Add(string label, Color color2, UnityAction act)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				((Object)MakeButton(parent, label, 22, color2, act)).name = label;
			}
		}

		private void BuildFun()
		{
			//IL_0027: 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_003d: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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)
			GameObject val = MakeButton(funPanel.transform, "", 22, new Color(0.25f, 0.2f, 0.15f, 1f), (UnityAction)delegate
			{
				CreativeMusic.Toggle();
				RefreshFun();
			});
			musicLabel = val.GetComponentInChildren<Text>();
			RefreshFun();
			GameObject obj = MakeText("Tip", funPanel.transform, "", 18, (TextAnchor)0);
			obj.GetComponent<Text>().text = "Creative music replaces the world music with your own tracks (shuffled). Put .ogg / .wav / .mp3 files in:\n" + SafeMusicFolder() + "\nTurn it off to bring the normal music back.";
			obj.AddComponent<LayoutElement>().ignoreLayout = true;
			RectTransform component = obj.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.anchoredPosition = new Vector2(0f, 14f);
			component.sizeDelta = new Vector2(-40f, 70f);
		}

		private static string SafeMusicFolder()
		{
			try
			{
				return CreativeMusic.MusicFolder;
			}
			catch
			{
				return "BepInEx/plugins/CreativeMode/music";
			}
		}

		private void RefreshFun()
		{
			if ((Object)(object)musicLabel != (Object)null)
			{
				musicLabel.text = "Creative Music: " + (CreativeMusic.On ? "ON" : "OFF");
			}
		}

		private void SetWeather(string env)
		{
			if (!((Object)(object)EnvMan.instance == (Object)null))
			{
				EnvMan.instance.SetForceEnvironment(env);
				if (env.Length > 0)
				{
					EnvMan.instance.ForceInstantEnvironmentSwitch();
				}
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null)
				{
					((Character)localPlayer).Message((MessageType)1, (env.Length > 0) ? ("Weather: " + env) : "Weather: automatic", 0, (Sprite)null, false);
				}
			}
		}

		private void SetTime(float fraction)
		{
			if (!((Object)(object)EnvMan.instance == (Object)null))
			{
				EnvMan.instance.m_debugTimeOfDay = fraction >= 0f;
				if (fraction >= 0f)
				{
					EnvMan.instance.m_debugTime = fraction;
				}
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null)
				{
					((Character)localPlayer).Message((MessageType)1, (fraction >= 0f) ? "Time locked" : "Time resumed", 0, (Sprite)null, false);
				}
			}
		}

		private void Refilter()
		{
			bool flag = category == "Weather";
			bool flag2 = category == "Fun Stuff";
			if ((Object)(object)scrollGo != (Object)null)
			{
				scrollGo.SetActive(!flag && !flag2);
			}
			if ((Object)(object)funPanel != (Object)null)
			{
				funPanel.SetActive(flag2);
			}
			if ((Object)(object)weatherPanel != (Object)null)
			{
				weatherPanel.SetActive(flag);
				if (flag && !weatherBuilt && (Object)(object)EnvMan.instance != (Object)null)
				{
					BuildWeather();
				}
			}
			string text = (((Object)(object)search != (Object)null) ? search.text.Trim().ToLowerInvariant() : "");
			foreach (Entry entry in entries)
			{
				bool flag3 = category == "All" || entry.Category == category;
				bool flag4 = text.Length == 0 || entry.DisplayName.ToLowerInvariant().Contains(text) || entry.PrefabName.ToLowerInvariant().Contains(text);
				entry.Button.SetActive(flag3 && flag4);
			}
		}

		private void Give(string prefabName, PointerEventData ev)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName);
			if (!((Object)(object)itemPrefab == (Object)null))
			{
				SharedData shared = itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared;
				int num = (((int)ev.button == 1 || Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) ? 1 : Mathf.Max(1, shared.m_maxStackSize));
				int num2 = Mathf.Max(1, shared.m_maxQuality);
				if (((Humanoid)localPlayer).GetInventory().AddItem(prefabName, num, num2, 0, 0L, "", false, false) == null)
				{
					((Character)localPlayer).Message((MessageType)2, "Inventory full", 0, (Sprite)null, false);
				}
			}
		}

		public static Font FindFont()
		{
			Font val = null;
			Font[] array = Resources.FindObjectsOfTypeAll<Font>();
			foreach (Font val2 in array)
			{
				if (((Object)val2).name.Contains("Averia"))
				{
					return val2;
				}
				if ((Object)(object)val == (Object)null)
				{
					val = val2;
				}
			}
			if (!((Object)(object)val != (Object)null))
			{
				return Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
			}
			return val;
		}

		private GameObject MakeImage(string name, Transform parent, Color color)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(parent, false);
			((Graphic)val.GetComponent<Image>()).color = color;
			return val;
		}

		private GameObject MakeText(string name, Transform parent, string text, int size, TextAnchor anchor)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(Text)
			});
			val.transform.SetParent(parent, false);
			Text component = val.GetComponent<Text>();
			component.font = font;
			component.text = text;
			component.fontSize = size;
			component.alignment = anchor;
			((Graphic)component).color = new Color(0.95f, 0.9f, 0.8f, 1f);
			((Graphic)component).raycastTarget = false;
			return val;
		}

		private GameObject MakeButton(Transform parent, string label, int size, Color color, UnityAction onClick)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MakeImage("Tab_" + label, parent, color);
			((UnityEvent)val.AddComponent<Button>().onClick).AddListener(onClick);
			Stretch(MakeText("Label", val.transform, label, size, (TextAnchor)4), 0f, 0f);
			return val;
		}

		private static void Rect(GameObject go, Vector2 anchorMin, Vector2 anchorMax, Vector2 pos, Vector2 size)
		{
			//IL_0007: 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_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)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMin = anchorMin;
			component.anchorMax = anchorMax;
			component.anchoredPosition = pos;
			component.sizeDelta = size;
		}

		private static void Stretch(GameObject go, float padX, float padY)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(padX, padY);
			component.offsetMax = new Vector2(0f - padX, 0f - padY);
		}
	}
	internal class ItemSlotHandler : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler
	{
		public Action<PointerEventData> OnClick;

		public Action OnHover;

		public void OnPointerClick(PointerEventData e)
		{
			OnClick?.Invoke(e);
		}

		public void OnPointerEnter(PointerEventData e)
		{
			OnHover?.Invoke();
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
	internal static class GameCamera_UpdateMouseCapture
	{
		private static bool Prefix()
		{
			return !CreativeMenu.Open;
		}
	}
	[HarmonyPatch(typeof(PlayerController), "TakeInput")]
	internal static class PlayerController_TakeInput
	{
		private static void Postfix(ref bool __result)
		{
			if (CreativeMenu.Open)
			{
				__result = false;
			}
		}
	}
	internal class CreativeMusic : MonoBehaviour
	{
		private static CreativeMusic instance;

		private AudioSource source;

		private readonly List<AudioClip> tracks = new List<AudioClip>();

		private readonly List<int> order = new List<int>();

		private bool loading;

		public static bool On { get; private set; }

		public static string MusicFolder => Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location), "music");

		public static void Toggle()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = ((Component)Plugin.Instance).gameObject.AddComponent<CreativeMusic>();
			}
			if (On)
			{
				instance.Stop();
			}
			else
			{
				instance.StartLoading();
			}
		}

		private void Awake()
		{
			source = ((Component)this).gameObject.AddComponent<AudioSource>();
			source.spatialBlend = 0f;
			source.playOnAwake = false;
		}

		private static void Tell(string message)
		{
			Plugin.Log.LogInfo((object)message);
			Player localPlayer = Player.m_localPlayer;
			if (localPlayer != null)
			{
				((Character)localPlayer).Message((MessageType)1, message, 0, (Sprite)null, false);
			}
		}

		private void Stop()
		{
			On = false;
			source.Stop();
		}

		private void StartLoading()
		{
			if (!loading)
			{
				Directory.CreateDirectory(MusicFolder);
				((MonoBehaviour)this).StartCoroutine(LoadAndPlay());
			}
		}

		private IEnumerator LoadAndPlay()
		{
			loading = true;
			tracks.Clear();
			order.Clear();
			string[] files = Directory.GetFiles(MusicFolder);
			int failed = 0;
			string[] array = files;
			foreach (string file in array)
			{
				AudioType val;
				switch (Path.GetExtension(file).ToLowerInvariant())
				{
				case ".ogg":
					val = (AudioType)14;
					break;
				case ".wav":
					val = (AudioType)20;
					break;
				case ".mp3":
					val = (AudioType)13;
					break;
				default:
					continue;
				}
				UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(new Uri(file).AbsoluteUri, val);
				try
				{
					yield return req.SendWebRequest();
					if ((int)req.result != 1)
					{
						failed++;
						Plugin.Log.LogWarning((object)("Could not load " + file + ": " + req.error));
						continue;
					}
					AudioClip content = DownloadHandlerAudioClip.GetContent(req);
					if ((Object)(object)content == (Object)null || content.length <= 0f)
					{
						failed++;
						continue;
					}
					((Object)content).name = Path.GetFileNameWithoutExtension(file);
					tracks.Add(content);
				}
				finally
				{
					((IDisposable)req)?.Dispose();
				}
			}
			loading = false;
			if (tracks.Count == 0)
			{
				Tell((failed > 0) ? "Creative music: none of your files could be loaded (see the BepInEx log)" : "Creative music: no tracks found. Add .ogg/.wav/.mp3 files to the music folder.");
				yield break;
			}
			On = true;
			Tell(string.Format("Creative music ON ({0} track{1})", tracks.Count, (tracks.Count == 1) ? "" : "s"));
			PlayNext();
		}

		private void PlayNext()
		{
			if (order.Count == 0)
			{
				for (int i = 0; i < tracks.Count; i++)
				{
					order.Add(i);
				}
				for (int num = order.Count - 1; num > 0; num--)
				{
					int index = Random.Range(0, num + 1);
					int value = order[num];
					order[num] = order[index];
					order[index] = value;
				}
			}
			int index2 = order[order.Count - 1];
			order.RemoveAt(order.Count - 1);
			source.clip = tracks[index2];
			source.loop = tracks.Count == 1;
			source.volume = Mathf.Clamp01((MusicMan.m_masterMusicVolume > 0f) ? MusicMan.m_masterMusicVolume : 0.6f);
			source.Play();
			Tell("Now playing: " + ((Object)tracks[index2]).name);
		}

		private void Update()
		{
			if (On)
			{
				source.volume = Mathf.Clamp01((MusicMan.m_masterMusicVolume > 0f) ? MusicMan.m_masterMusicVolume : 0.6f);
				if (!source.isPlaying && tracks.Count > 0)
				{
					PlayNext();
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character), "CustomFixedUpdate")]
	internal static class Flight
	{
		private static readonly FieldInfo Body = AccessTools.Field(typeof(Character), "m_body");

		private static readonly FieldInfo MaxAir = AccessTools.Field(typeof(Character), "m_maxAirAltitude");

		private static void Postfix(Character __instance)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00b2: 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_00c2: 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_00c5: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.Flying || !Plugin.Creative || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || CreativeMenu.Open)
			{
				return;
			}
			object? value = Body.GetValue(__instance);
			Rigidbody val = (Rigidbody)((value is Rigidbody) ? value : null);
			Camera main = Camera.main;
			if (!((Object)(object)val == (Object)null) && !((Object)(object)main == (Object)null))
			{
				Vector3 forward = ((Component)main).transform.forward;
				forward.y = 0f;
				((Vector3)(ref forward)).Normalize();
				Vector3 right = ((Component)main).transform.right;
				right.y = 0f;
				((Vector3)(ref right)).Normalize();
				Vector3 val2 = Vector3.zero;
				if (Input.GetKey((KeyCode)119))
				{
					val2 += forward;
				}
				if (Input.GetKey((KeyCode)115))
				{
					val2 -= forward;
				}
				if (Input.GetKey((KeyCode)100))
				{
					val2 += right;
				}
				if (Input.GetKey((KeyCode)97))
				{
					val2 -= right;
				}
				if (((Vector3)(ref val2)).sqrMagnitude > 1f)
				{
					((Vector3)(ref val2)).Normalize();
				}
				float num = 0f;
				if (Input.GetKey((KeyCode)32))
				{
					num += 1f;
				}
				if (Input.GetKey((KeyCode)306))
				{
					num -= 1f;
				}
				float num2 = Plugin.FlySpeed.Value * (Input.GetKey((KeyCode)304) ? 3f : 1f);
				Vector3 linearVelocity = val.linearVelocity;
				Vector3 val3 = Vector3.Lerp(new Vector3(linearVelocity.x, 0f, linearVelocity.z), val2 * num2, 0.35f);
				val.useGravity = false;
				val.linearVelocity = new Vector3(val3.x, num * num2, val3.z);
				MaxAir?.SetValue(__instance, val.position.y);
			}
		}
	}
	internal class FlingTracker : MonoBehaviour
	{
		private class Entry
		{
			public Rigidbody rb;

			public ZDO zdo;

			public Vector3 pos;

			public Vector3 vel;

			public float age;
		}

		private static FlingTracker instance;

		private readonly List<Entry> entries = new List<Entry>();

		public static void Track(Rigidbody rb, Vector3 velocity)
		{
			//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_0069: 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)
			ZNetView componentInParent = ((Component)rb).GetComponentInParent<ZNetView>();
			if (!((Object)(object)componentInParent == (Object)null) && componentInParent.IsValid())
			{
				if ((Object)(object)instance == (Object)null)
				{
					instance = ((Component)Plugin.Instance).gameObject.AddComponent<FlingTracker>();
				}
				instance.entries.Add(new Entry
				{
					rb = rb,
					zdo = componentInParent.GetZDO(),
					pos = rb.position,
					vel = velocity
				});
			}
		}

		private void FixedUpdate()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_0092: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: 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_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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			float fixedDeltaTime = Time.fixedDeltaTime;
			for (int num = entries.Count - 1; num >= 0; num--)
			{
				Entry entry = entries[num];
				entry.age += fixedDeltaTime;
				if (entry.age > 40f || entry.zdo == null || !entry.zdo.IsValid())
				{
					entries.RemoveAt(num);
					continue;
				}
				if ((Object)(object)entry.rb != (Object)null)
				{
					entry.pos = entry.rb.position;
					entry.vel = entry.rb.linearVelocity;
					if (entry.age > 2f && ((Vector3)(ref entry.vel)).sqrMagnitude < 0.5f)
					{
						entries.RemoveAt(num);
					}
					continue;
				}
				ZNetView val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.FindInstance(entry.zdo) : null);
				if ((Object)(object)val != (Object)null)
				{
					Rigidbody componentInChildren = ((Component)val).GetComponentInChildren<Rigidbody>();
					if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.isKinematic)
					{
						componentInChildren.linearVelocity = entry.vel;
						entry.rb = componentInChildren;
						continue;
					}
				}
				entry.vel += Physics.gravity * fixedDeltaTime;
				entry.vel *= 0.995f;
				entry.pos += entry.vel * fixedDeltaTime;
				float num2 = (((Object)(object)ZoneSystem.instance != (Object)null) ? ZoneSystem.instance.m_waterLevel : 30f);
				float num3 = Mathf.Max(WorldGenerator.instance.GetHeight(entry.pos.x, entry.pos.z), num2);
				bool num4 = entry.pos.y <= num3 + 0.3f;
				if (num4)
				{
					entry.pos.y = num3 + 0.3f;
				}
				if (!entry.zdo.IsOwner())
				{
					entry.zdo.SetOwner(ZDOMan.GetSessionID());
				}
				entry.zdo.SetPosition(entry.pos);
				if (num4)
				{
					entries.RemoveAt(num);
				}
			}
		}
	}
	internal static class Icons
	{
		private const int Size = 64;

		private static Sprite Draw(Func<float, float, Color> shader)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_00a5: 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_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_006c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1
			};
			Color32[] array = (Color32[])(object)new Color32[4096];
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					array[i * 64 + j] = Color32.op_Implicit(shader(((float)j + 0.5f) / 64f * 2f - 1f, ((float)i + 0.5f) / 64f * 2f - 1f));
				}
			}
			val.SetPixels32(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f);
		}

		public static Color ColorFor(string key, float sat = 0.55f, float val = 0.9f)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			uint num = 2166136261u;
			foreach (char c in key)
			{
				num = (num ^ c) * 16777619;
			}
			return Color.HSVToRGB((float)(num & 0xFFFF) / 65535f, sat, val);
		}

		public static Sprite Egg(string key, bool boss)
		{
			//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_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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			Color body = ColorFor(key);
			Color spot = Color.Lerp(body, Color.black, 0.35f);
			return Draw(delegate(float u, float v)
			{
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: 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_0095: 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_0039: 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_0116: 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)
				float num = Mathf.Sqrt(u * u + v * v);
				if (boss && num > 0.86f && num < 0.97f)
				{
					return new Color(1f, 0.82f, 0.2f, 1f);
				}
				float num2 = 0.62f * (1f - 0.22f * v);
				float num3 = u * u / (num2 * num2) + v * v / 0.6724f;
				if (num3 > 1f)
				{
					return new Color(0f, 0f, 0f, 0f);
				}
				if (num3 > 0.88f)
				{
					return Color.Lerp(body, Color.black, 0.6f);
				}
				float num4 = Mathf.Clamp01(0.75f + 0.35f * ((0f - u) * 0.6f + v * 0.5f));
				Color result = Color.Lerp(Color.black, body, num4);
				if (Mathf.Sin(u * 17f + 3f) * Mathf.Cos(v * 13f - 1f) + Mathf.Sin((u + v) * 9f) > 1.15f)
				{
					result = spot;
				}
				return result;
			});
		}

		public static Sprite Disc(string key)
		{
			//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)
			Color label = ColorFor(key, 0.7f, 0.95f);
			return Draw(delegate(float u, float v)
			{
				//IL_0029: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				float num = Mathf.Sqrt(u * u + v * v);
				if (num > 0.92f)
				{
					return new Color(0f, 0f, 0f, 0f);
				}
				if (num < 0.07f)
				{
					return new Color(0f, 0f, 0f, 0f);
				}
				if (num < 0.36f)
				{
					return label;
				}
				float num2 = 0.5f + 0.5f * Mathf.Sin(num * 90f);
				float num3 = Mathf.Clamp01(Mathf.Cos(Mathf.Atan2(v, u) * 2f - 0.8f)) * 0.25f;
				float num4 = 0.06f + 0.06f * num2 + num3 * 0.5f;
				return new Color(num4, num4, num4 * 1.1f, 1f);
			});
		}

		public static Sprite Nuke()
		{
			return Draw(delegate(float u, float v)
			{
				//IL_0029: 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_0045: 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_0085: Unknown result type (might be due to invalid IL or missing references)
				float num = Mathf.Sqrt(u * u + v * v);
				if (num > 0.92f)
				{
					return new Color(0f, 0f, 0f, 0f);
				}
				if (num > 0.86f)
				{
					return Color.black;
				}
				if (num < 0.16f)
				{
					return Color.black;
				}
				return (Color)((num > 0.26f && num < 0.78f && Mathf.Repeat(Mathf.Atan2(v, u) * 57.29578f + 360f - 30f, 120f) < 60f) ? Color.black : new Color(1f, 0.85f, 0.1f, 1f));
			});
		}

		public static Sprite Wand()
		{
			return Draw(delegate(float u, float v)
			{
				//IL_003c: 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_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
				float num = Mathf.Sqrt((u - 0.5f) * (u - 0.5f) + (v - 0.5f) * (v - 0.5f));
				if (num < 0.2f)
				{
					return Color.Lerp(new Color(1f, 1f, 1f), new Color(1f, 0.15f, 0.1f), num / 0.2f);
				}
				if (num < 0.34f)
				{
					float num2 = 1f - (num - 0.2f) / 0.14f;
					return new Color(1f, 0.2f, 0.1f, num2 * 0.7f);
				}
				float num3 = Mathf.Abs(u - v) / 1.4142f;
				float num4 = (u + v) / 1.4142f;
				return (num3 < 0.07f && num4 > -1f && num4 < 0.65f) ? ((!(num3 < 0.03f)) ? new Color(0.38f, 0.22f, 0.1f) : new Color(0.62f, 0.4f, 0.2f)) : new Color(0f, 0f, 0f, 0f);
			});
		}

		private static float Hash(int x, int y, int seed)
		{
			int num = (x * 73856093) ^ (y * 19349663) ^ (seed * 83492791);
			int num2 = (num ^ (num >>> 13)) * 1274126177;
			return (float)(uint)((num2 ^ (num2 >>> 16)) & 0xFFFF) / 65535f;
		}

		private static Color Plank(int x, int y)
		{
			//IL_0044: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_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)
			Color val = default(Color);
			((Color)(ref val))..ctor(0.62f, 0.46f, 0.26f);
			float num = (Hash(x, y, 1) - 0.5f) * 0.14f + (Hash(x / 4, y, 2) - 0.5f) * 0.1f;
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(val.r + num, val.g + num, val.b + num * 0.7f);
			if (y % 4 == 3)
			{
				val2 = Color.Lerp(val2, new Color(0.3f, 0.2f, 0.1f), 0.55f);
			}
			if ((x + y / 4 * 7) % 16 == 0)
			{
				val2 = Color.Lerp(val2, new Color(0.3f, 0.2f, 0.1f), 0.4f);
			}
			val2.a = 1f;
			return val2;
		}

		private static Texture2D PixelTexture(Func<int, int, Color> pixel)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 16; i++)
			{
				for (int j = 0; j < 16; j++)
				{
					val.SetPixel(j, i, pixel(j, i));
				}
			}
			val.Apply();
			return val;
		}

		public static Texture2D JukeboxSideTexture()
		{
			return PixelTexture(delegate(int x, int y)
			{
				//IL_0024: 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_008d: 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)
				if (x == 0 || y == 0 || x == 15 || y == 15)
				{
					return new Color(0.28f, 0.18f, 0.09f, 1f);
				}
				float num = (float)x - 7.5f;
				float num2 = (float)y - 7.5f;
				float num3 = Mathf.Sqrt(num * num + num2 * num2);
				if (num3 < 2.6f)
				{
					return new Color(0.06f, 0.04f, 0.03f, 1f);
				}
				return (Color)((num3 < 3.6f) ? new Color(0.2f, 0.12f, 0.06f, 1f) : Plank(x, y));
			});
		}

		public static Texture2D JukeboxTopTexture()
		{
			return PixelTexture(delegate(int x, int y)
			{
				//IL_0024: 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_0085: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
				if (x == 0 || y == 0 || x == 15 || y == 15)
				{
					return new Color(0.28f, 0.18f, 0.09f, 1f);
				}
				float num = (float)x - 7.5f;
				float num2 = (float)y - 7.5f;
				float num3 = Mathf.Sqrt(num * num + num2 * num2);
				if (num3 < 1.2f)
				{
					return new Color(0.7f, 0.2f, 0.2f, 1f);
				}
				if (num3 < 4.2f)
				{
					return new Color(0.08f, 0.07f, 0.07f, 1f);
				}
				return (Color)((num3 < 5.2f) ? new Color(0.22f, 0.14f, 0.07f, 1f) : Plank(x, y));
			});
		}

		public static Sprite Jukebox()
		{
			//IL_0019: 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)
			return Sprite.Create(JukeboxSideTexture(), new Rect(0f, 0f, 16f, 16f), new Vector2(0.5f, 0.5f), 16f);
		}

		private static Sprite JukeboxOld()
		{
			return Draw(delegate(float u, float v)
			{
				//IL_002e: 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_0101: 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_00a0: 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)
				if (Mathf.Abs(u) > 0.78f || Mathf.Abs(v) > 0.88f)
				{
					return new Color(0f, 0f, 0f, 0f);
				}
				if (Mathf.Abs(u) > 0.7f || Mathf.Abs(v) > 0.8f)
				{
					return new Color(0.25f, 0.14f, 0.06f, 1f);
				}
				float num = Mathf.Sqrt(u * u + (v - 0.3f) * (v - 0.3f));
				if (num < 0.38f)
				{
					if (!(num < 0.1f))
					{
						return new Color(0.08f, 0.08f, 0.1f);
					}
					return new Color(0.9f, 0.3f, 0.3f);
				}
				return (v < -0.35f && v > -0.6f && Mathf.Abs(u) < 0.5f) ? new Color(1f, 0.8f, 0.2f) : new Color(0.5f, 0.3f, 0.14f, 1f);
			});
		}
	}
	[HarmonyPatch]
	internal static class InstantBreak
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(WearNTear), "RPC_Damage", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(Destructible), "RPC_Damage", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(TreeBase), "RPC_Damage", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(TreeLog), "RPC_Damage", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(MineRock5), "RPC_Damage", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(MineRock), "RPC_Hit", (Type[])null, (Type[])null);
		}

		private static void Prefix(HitData hit)
		{
			//IL_001b: 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)
			Player localPlayer = Player.m_localPlayer;
			if (Plugin.Creative && !((Object)(object)localPlayer == (Object)null) && hit != null && !(hit.m_attacker != ((Character)localPlayer).GetZDOID()))
			{
				hit.m_damage.m_damage = 100000f;
				hit.m_damage.m_chop = 100000f;
				hit.m_damage.m_pickaxe = 100000f;
				hit.m_toolTier = 100;
			}
		}
	}
	public class Jukebox : MonoBehaviour, Hoverable, Interactable
	{
		private const string TrackKey = "cm_track";

		public const float Range = 40f;

		private static readonly List<Jukebox> All = new List<Jukebox>();

		private ZNetView nview;

		private AudioSource source;

		private string playing = "";

		private bool IsRealAndPlaying
		{
			get
			{
				if ((Object)(object)nview != (Object)null && nview.IsValid() && (Object)(object)source != (Object)null)
				{
					return source.isPlaying;
				}
				return false;
			}
		}

		private string Track
		{
			get
			{
				if (!((Object)(object)nview != (Object)null) || !nview.IsValid())
				{
					return "";
				}
				return nview.GetZDO().GetString("cm_track", "");
			}
		}

		private void Awake()
		{
			nview = ((Component)this).GetComponent<ZNetView>();
			source = ((Component)this).gameObject.AddComponent<AudioSource>();
			source.spatialBlend = 1f;
			source.rolloffMode = (AudioRolloffMode)1;
			source.minDistance = 4f;
			source.maxDistance = 40f;
			source.playOnAwake = false;
			if ((Object)(object)MusicMan.instance != (Object)null)
			{
				source.outputAudioMixerGroup = MusicMan.instance.m_musicMixer;
			}
		}

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

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

		public static bool AnyPlayingNear(Vector3 point)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//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)
			foreach (Jukebox item in All)
			{
				if ((Object)(object)item != (Object)null && item.IsRealAndPlaying)
				{
					Vector3 val = ((Component)item).transform.position - point;
					if (((Vector3)(ref val)).sqrMagnitude <= 1600f)
					{
						return true;
					}
				}
			}
			return false;
		}

		private void Update()
		{
			if (!((Object)(object)nview == (Object)null) && nview.IsValid())
			{
				string track = Track;
				if (track != playing)
				{
					playing = track;
					source.Stop();
				}
				if (playing.Length > 0 && !source.isPlaying)
				{
					StartClip(playing);
				}
			}
		}

		private void StartClip(string trackName)
		{
			if ((Object)(object)MusicMan.instance == (Object)null)
			{
				return;
			}
			foreach (NamedMusic item in MusicMan.instance.m_music)
			{
				if (item != null && !(item.m_name != trackName) && item.m_clips != null && item.m_clips.Length != 0)
				{
					source.clip = item.m_clips[Random.Range(0, item.m_clips.Length)];
					source.volume = Mathf.Clamp(item.m_volume, 0.3f, 1f);
					source.Play();
					break;
				}
			}
		}

		private void SetTrack(string trackName)
		{
			if (!((Object)(object)nview == (Object)null) && nview.IsValid())
			{
				nview.ClaimOwnership();
				nview.GetZDO().Set("cm_track", trackName);
			}
		}

		public string GetHoverName()
		{
			return "Jukebox";
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public string GetHoverText()
		{
			string track = Track;
			string text = ((track.Length > 0) ? ("Playing: " + Registry.Pretty(track) + "\n[<color=yellow><b>E</b></color>] Stop") : "Use a Music Disc on it to play");
			return "Jukebox\n" + text;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold)
			{
				return false;
			}
			if (Track.Length == 0)
			{
				return false;
			}
			SetTrack("");
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			if (item == null || (Object)(object)item.m_dropPrefab == (Object)null)
			{
				return false;
			}
			string name = ((Object)item.m_dropPrefab).name;
			if (!name.StartsWith("CM_Disc_"))
			{
				return false;
			}
			SetTrack(name.Substring("CM_Disc_".Length));
			((Character)user).Message((MessageType)2, "Now playing: " + Registry.Pretty(name.Substring("CM_Disc_".Length)), 0, (Sprite)null, false);
			return true;
		}
	}
	internal static class WorldMusicMute
	{
		private static readonly FieldInfo VanillaSource = AccessTools.Field(typeof(MusicMan), "m_musicSource");

		private static bool wasMuted;

		public static void Tick()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			AudioSource val = (AudioSource)(((Object)(object)MusicMan.instance != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
			if (!((Object)(object)val == (Object)null))
			{
				Player localPlayer = Player.m_localPlayer;
				if (CreativeMusic.On || ((Object)(object)localPlayer != (Object)null && Jukebox.AnyPlayingNear(((Component)localPlayer).transform.position)))
				{
					val.mute = true;
					wasMuted = true;
				}
				else if (wasMuted)
				{
					val.mute = false;
					wasMuted = false;
				}
			}
		}
	}
	internal class LaserWand : MonoBehaviour
	{
		private const float Range = 220f;

		private const float TickInterval = 0.05f;

		private static LaserWand instance;

		private LineRenderer outer;

		private LineRenderer core;

		private Transform glow;

		private Material glowMat;

		private Light impactLight;

		private AudioSource hum;

		private float nextTick;

		private float nextDig;

		private bool firing;

		public static bool IsEquipped(Humanoid h)
		{
			ItemData val = (((Object)(object)h != (Object)null) ? h.GetCurrentWeapon() : null);
			if (val != null && (Object)(object)val.m_dropPrefab != (Object)null)
			{
				return ((Object)val.m_dropPrefab).name == "CM_LaserWand";
			}
			return false;
		}

		public static void Tick(Player player, bool inputFree)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			bool flag = inputFree && IsEquipped((Humanoid)(object)player) && Input.GetMouseButton(0);
			if (flag || !((Object)(object)instance == (Object)null))
			{
				if ((Object)(object)instance == (Object)null)
				{
					instance = new GameObject("CM_LaserBeam").AddComponent<LaserWand>();
					instance.Build();
				}
				instance.Fire(player, flag);
			}
		}

		private void Build()
		{
			//IL_0020: 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_00b2: 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)
			outer = MakeLine("Outer", 0.55f, new Color(1f, 0.12f, 0.08f, 0.55f));
			core = MakeLine("Core", 0.16f, new Color(1f, 0.95f, 0.85f, 1f));
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			val.transform.SetParent(((Component)this).transform, false);
			glowMat = Visuals.Particle(additiveBlend: true, lumpy: false);
			val.GetComponent<Renderer>().sharedMaterial = glowMat;
			glow = val.transform;
			impactLight = new GameObject("Light").AddComponent<Light>();
			((Component)impactLight).transform.SetParent(((Component)this).transform, false);
			impactLight.color = new Color(1f, 0.25f, 0.15f);
			impactLight.range = 30f;
			impactLight.intensity = 6f;
			hum = ((Component)this).gameObject.AddComponent<AudioSource>();
			hum.clip = HumClip();
			hum.loop = true;
			hum.spatialBlend = 0f;
			hum.volume = 0.35f;
		}

		private LineRenderer MakeLine(string name, float width, Color color)
		{
			//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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(((Component)this).transform, false);
			LineRenderer obj = val.AddComponent<LineRenderer>();
			obj.positionCount = 2;
			obj.useWorldSpace = true;
			float startWidth = (obj.endWidth = width);
			obj.startWidth = startWidth;
			obj.numCapVertices = 6;
			Material val2 = new Material(Shader.Find("Legacy Shaders/Particles/Additive") ?? Shader.Find("Mobile/Particles/Additive") ?? Visuals.Unlit());
			val2.mainTexture = (Texture)(object)Visuals.SoftTexture(lumpy: false);
			Visuals.SetTint(val2, color, additiveBlend: true);
			((Renderer)obj).sharedMaterial = val2;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			return obj;
		}

		private void Fire(Player player, bool on)
		{
			//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_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)
			//IL_00a8: 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_00b7: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//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_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: 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_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: 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_02fa: 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_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			if (on != firing)
			{
				firing = on;
				if (on)
				{
					hum.Play();
				}
				else
				{
					hum.Stop();
				}
			}
			LineRenderer obj = outer;
			bool enabled = (((Renderer)core).enabled = on);
			((Renderer)obj).enabled = enabled;
			((Component)glow).gameObject.SetActive(on);
			((Behaviour)impactLight).enabled = on;
			if (!on)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				instance = null;
				return;
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)main).transform.position;
			Vector3 forward = ((Component)main).transform.forward;
			Vector3 val = position + ((Component)main).transform.right * 0.35f - ((Component)main).transform.up * 0.3f + forward * 0.9f;
			float num = 220f;
			RaycastHit[] array = Physics.SphereCastAll(position, 0.6f, forward, 220f, -1, (QueryTriggerInteraction)1);
			Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
			HashSet<Component> done = new HashSet<Component>();
			bool flag2 = Time.time >= nextTick;
			if (flag2)
			{
				nextTick = Time.time + 0.05f;
			}
			Vector3? val2 = null;
			RaycastHit[] array2 = array;
			for (int num2 = 0; num2 < array2.Length; num2++)
			{
				RaycastHit val3 = array2[num2];
				if (!((Object)(object)((Component)((RaycastHit)(ref val3)).collider).transform.root == (Object)(object)((Component)player).transform.root))
				{
					if (Destroyer.IsTerrain(((RaycastHit)(ref val3)).collider))
					{
						num = ((RaycastHit)(ref val3)).distance;
						val2 = ((RaycastHit)(ref val3)).point;
						break;
					}
					if (flag2)
					{
						Destroyer.Hit(((RaycastHit)(ref val3)).collider, position, done);
					}
				}
			}
			if (val2.HasValue && Input.GetMouseButton(1) && Time.time >= nextDig)
			{
				nextDig = Time.time + 0.12f;
				Dig(val2.Value);
			}
			Vector3 val4 = position + forward * num;
			float num3 = 1f + 0.18f * Mathf.Sin(Time.time * 60f);
			outer.SetPosition(0, val);
			outer.SetPosition(1, val4);
			core.SetPosition(0, val);
			core.SetPosition(1, val4);
			LineRenderer obj2 = outer;
			float startWidth = (outer.endWidth = 0.55f * num3);
			obj2.startWidth = startWidth;
			glow.position = val4;
			glow.rotation = ((Component)main).transform.rotation;
			glow.localScale = Vector3.one * 7f * num3;
			Visuals.SetTint(glowMat, new Color(1f, 0.35f, 0.15f, 0.9f), additiveBlend: true);
			((Component)impactLight).transform.position = val4 - forward * 1.5f;
		}

		private static void Dig(Vector3 point)
		{
			//IL_0021: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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)
			TerrainOp digOp = Registry.DigOp;
			if (!((Object)(object)digOp == (Object)null) && !((Object)(object)ZoneSystem.instance == (Object)null) && ZoneSystem.instance.IsZoneLoaded(point) && TerrainSafe.ReadyFor(point, 5f, create: true))
			{
				float groundHeight = ZoneSystem.instance.GetGroundHeight(point);
				Object.Instantiate<TerrainOp>(digOp, new Vector3(point.x, groundHeight - 1.2f, point.z), Quaternion.identity);
			}
		}

		private static AudioClip HumClip()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			float phase1 = 0f;
			float phase2 = 0f;
			return AudioClip.Create("CM_LaserHum", 22050, 1, 22050, true, (PCMReaderCallback)delegate(float[] buffer)
			{
				for (int i = 0; i < buffer.Length; i++)
				{
					phase1 += 0.039893243f;
					phase2 += 0.08064134f;
					buffer[i] = 0.35f * Mathf.Sin(phase1) + 0.2f * Mathf.Sin(phase2 + Mathf.Sin(phase1 * 0.5f));
				}
			}, (PCMSetPositionCallback)null);
		}
	}
	[HarmonyPatch(typeof(Humanoid), "StartAttack")]
	internal static class Humanoid_StartAttack
	{
		private static bool Prefix(Humanoid __instance, ref bool __result)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !LaserWand.IsEquipped(__instance))
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateAvailablePiecesList")]
	internal static class Player_UpdateAvailablePiecesList
	{
		private static readonly FieldInfo Known = AccessTools.Field(typeof(Player), "m_knownRecipes");

		private static void Prefix(Player __instance)
		{
			(Known?.GetValue(__instance) as HashSet<string>)?.Add("Jukebox");
		}
	}
	internal class MenuOptions : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__13_0;

			public static UnityAction <>9__13_1;

			internal void <Build>b__13_0()
			{
				NewCreative = !NewCreative;
			}

			internal void <Build>b__13_1()
			{
				NewFlat = !NewFlat;
			}
		}

		public static bool NewCreative;

		public static bool NewFlat;

		private static readonly FieldInfo SelectedWorld = AccessTools.Field(typeof(FejdStartup), "m_world");

		private GameObject root;

		private GameObject newPanel;

		private GameObject listPanel;

		private Text creativeLabel;

		private Text flatLabel;

		private Text listLabel;

		private string listWorld;

		public static void ResetNew()
		{
			NewCreative = (NewFlat = false);
		}

		public static void Ensure()
		{
			if ((Object)(object)((Component)Plugin.Instance).GetComponent<MenuOptions>() == (Object)null)
			{
				((Component)Plugin.Instance).gameObject.AddComponent<MenuOptions>();
			}
		}

		private void Update()
		{
			FejdStartup instance = FejdStartup.instance;
			if ((Object)(object)instance == (Object)null)
			{
				if ((Object)(object)root != (Object)null)
				{
					root.SetActive(false);
				}
				return;
			}
			if ((Object)(object)root == (Object)null)
			{
				Build();
			}
			bool flag = (Object)(object)instance.m_newWorldName != (Object)null && ((Component)instance.m_newWorldName).gameObject.activeInHierarchy;
			bool flag2 = !flag && (Object)(object)instance.m_worldListPanel != (Object)null && instance.m_worldListPanel.activeInHierarchy;
			root.SetActive(flag || flag2);
			newPanel.SetActive(flag);
			listPanel.SetActive(flag2);
			if (flag)
			{
				creativeLabel.text = (NewCreative ? "[X]" : "[  ]") + "  Creative Mode";
				flatLabel.text = (NewFlat ? "[X]" : "[  ]") + "  Super Flat world";
			}
			else if (flag2)
			{
				ref string reference = ref listWorld;
				object? obj = SelectedWorld?.GetValue(instance);
				reference = ((World)(((obj is World) ? obj : null)?)).m_name;
				listLabel.text = ((listWorld == null) ? "Select a world to change its Creative Mode" : ("Creative Mode: " + (WorldFlags.CreativeAllowed(listWorld) ? "ENABLED" : "OFF") + "  (" + listWorld + ")"));
			}
		}

		private void Build()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00eb: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			root = new GameObject("CreativeMenuOptions", new Type[3]
			{
				typeof(Canvas),
				typeof(CanvasScaler),
				typeof(GraphicRaycaster)
			});
			Object.DontDestroyOnLoad((Object)(object)root);
			Canvas component = root.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.sortingOrder = 600;
			CanvasScaler component2 = root.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			Font font = CreativeMenu.FindFont();
			newPanel = Panel("NewWorldOptions", new Vector2(1f, 0.5f), new Vector2(-20f, 0f), new Vector2(380f, 170f));
			Label(newPanel.transform, font, "CREATIVE MOD OPTIONS", 20, new Vector2(0f, 55f), new Vector2(360f, 30f), (TextAnchor)4);
			Transform transform = newPanel.transform;
			Vector2 pos = new Vector2(0f, 12f);
			object obj = <>c.<>9__13_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					NewCreative = !NewCreative;
				};
				<>c.<>9__13_0 = val;
				obj = (object)val;
			}
			creativeLabel = Button(transform, font, pos, (UnityAction)obj);
			Transform transform2 = newPanel.transform;
			Vector2 pos2 = new Vector2(0f, -42f);
			object obj2 = <>c.<>9__13_1;
			if (obj2 == null)
			{
				UnityAction val2 = delegate
				{
					NewFlat = !NewFlat;
				};
				<>c.<>9__13_1 = val2;
				obj2 = (object)val2;
			}
			flatLabel = Button(transform2, font, pos2, (UnityAction)obj2);
			listPanel = Panel("WorldListOptions", new Vector2(1f, 0f), new Vector2(-20f, 150f), new Vector2(520f, 70f));
			listLabel = Button(listPanel.transform, font, Vector2.zero, (UnityAction)delegate
			{
				if (listWorld != null)
				{
					WorldFlags.SetCreativeAllowed(listWorld, !WorldFlags.CreativeAllowed(listWorld));
				}
			});
			listLabel.fontSize = 20;
		}

		private GameObject Panel(string name, Vector2 anchor, Vector2 pos, Vector2 size)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0071: 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_007f: 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_008d: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(root.transform, false);
			((Graphic)val.GetComponent<Image>()).color = new Color(0.05f, 0.04f, 0.03f, 0.85f);
			RectTransform component = val.GetComponent<RectTransform>();
			Vector2 anchorMin = (component.anchorMax = anchor);
			component.anchorMin = anchorMin;
			component.pivot = anchor;
			component.anchoredPosition = pos;
			component.sizeDelta = size;
			return val;
		}

		private static Text Label(Transform parent, Font font, string text, int size, Vector2 pos, Vector2 dim, TextAnchor anchor)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0054: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Label", new Type[2]
			{
				typeof(RectTransform),
				typeof(Text)
			});
			val.transform.SetParent(parent, false);
			Text component = val.GetComponent<Text>();
			component.font = font;
			component.text = text;
			component.fontSize = size;
			component.alignment = anchor;
			((Graphic)component).color = new Color(0.95f, 0.9f, 0.8f);
			((Graphic)component).raycastTarget = false;
			RectTransform component2 = val.GetComponent<RectTransform>();
			component2.anchoredPosition = pos;
			component2.sizeDelta = dim;
			return component;
		}

		private static Text Button(Transform parent, Font font, Vector2 pos, UnityAction click)
		{
			//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_0044: 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_0068: 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_0081: 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_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_00a0: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Button", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Button)
			});
			val.transform.SetParent(parent, false);
			((Graphic)val.GetComponent<Image>()).color = new Color(0.25f, 0.2f, 0.15f, 1f);
			((UnityEvent)val.GetComponent<Button>().onClick).AddListener(click);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchoredPosition = pos;
			Vector2 sizeDelta = ((Component)parent).GetComponent<RectTransform>().sizeDelta;
			component.sizeDelta = new Vector2(sizeDelta.x - 20f, (sizeDelta.y > 100f) ? 48f : (sizeDelta.y - 20f));
			return Label(val.transform, font, "", 22, Vector2.zero, component.sizeDelta, (TextAnchor)4);
		}
	}
	internal static class Destroyer
	{
		public static HitData MakeHit(Vector3 point, Vector3 dir)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0035: 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_0055: 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_005e: 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_0065: 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_0076: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			return new HitData
			{
				m_damage = 
				{
					m_damage = 1000000f
				},
				m_damage = 
				{
					m_blunt = 1000000f
				},
				m_damage = 
				{
					m_fire = 1000000f
				},
				m_damage = 
				{
					m_chop = 1000000f
				},
				m_damage = 
				{
					m_pickaxe = 1000000f
				},
				m_toolTier = 100,
				m_point = point,
				m_dir = dir,
				m_pushForce = 200f,
				m_ignorePVP = true,
				m_dodgeable = false,
				m_blockable = false
			};
		}

		public static bool Hit(Collider col, Vector3 origin, HashSet<Component> done)
		{
			//IL_0036: 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)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0053: Unknown result type (might be due to invalid IL or missing references)
			IDestructible componentInParent = ((Component)col).GetComponentInParent<IDestructible>();
			Component val = (Component)(object)((componentInParent is Component) ? componentInParent : null);
			if ((Object)(object)val == (Object)null || (done != null && !done.Add(val)))
			{
				return false;
			}
			if ((Object)(object)val.GetComponentInParent<Player>() != (Object)null)
			{
				return false;
			}
			Vector3 point = col.ClosestPoint(origin);
			Vector3 val2 = val.transform.position - origin;
			componentInParent.Damage(MakeHit(point, ((Vector3)(ref val2)).normalized));
			return true;
		}

		public static bool IsTerrain(Collider col)
		{
			return (Object)(object)((Component)col).GetComponentInParent<Heightmap>() != (Object)null;
		}
	}
	internal static class Nuke
	{
		private class CraterJob
		{
			public readonly Queue<Vector3> Queue = new Queue<Vector3>();

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

			private readonly Vector3 center;

			private readonly float radius;

			private float nextRetry;

			private float deadline;

			private bool smoothing;

			private bool smoothQueued;

			public bool Done
			{
				get
				{
					if (Queue.Count != 0 || retry.Count != 0 || !smoothQueued)
					{
						return Time.time > deadline;
					}
					return true;
				}
			}

			public CraterJob(Vector3 center, float radius)
			{
				//IL_001d: 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_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_008f: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: 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)
				this.center = center;
				this.radius = radius;
				deadline = Time.time + 60f;
				List<Vector3> list = new List<Vector3>();
				for (float num = 0f - radius; num <= radius; num += 6f)
				{
					for (float num2 = 0f - radius; num2 <= radius; num2 += 6f)
					{
						if (num * num + num2 * num2 <= radius * radius)
						{
							list.Add(new Vector3(center.x + num, center.y, center.z + num2));
						}
					}
				}
				list.Sort(delegate(Vector3 a, Vector3 b)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//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_0017: Unknown result type (might be due to invalid IL or missing references)
					//IL_0019: Unknown result type (might be due to invalid IL or missing references)
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0023: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val = a - center;
					float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
					val = b - center;
					return sqrMagnitude.CompareTo(((Vector3)(ref val)).sqrMagnitude);
				});
				foreach (Vector3 item in list)
				{
					Queue.Enqueue(item);
				}
				foreach (Vector3 item2 in list)
				{
					TerrainSafe.ReadyFor(item2, 9f, create: true);
				}
			}

			private static bool FullyLoaded(Vector3 p, float r)
			{
				//IL_000f: 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_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_003c: 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_004e: 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_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_007f: 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_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_00ab: 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_00c1: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				ZoneSystem instance = ZoneSystem.instance;
				float num = r * 0.7f;
				if (instance.IsZoneLoaded(p) && instance.IsZoneLoaded(p + new Vector3(r, 0f, 0f)) && instance.IsZoneLoaded(p + new Vector3(0f - r, 0f, 0f)) && instance.IsZoneLoaded(p + new Vector3(0f, 0f, r)) && instance.IsZoneLoaded(p + new Vector3(0f, 0f, 0f - r)) && instance.IsZoneLoaded(p + new Vector3(num, 0f, num)) && instance.IsZoneLoaded(p + new Vector3(0f - num, 0f, num)) && instance.IsZoneLoaded(p + new Vector3(num, 0f, 0f - num)))
				{
					return instance.IsZoneLoaded(p + new Vector3(0f - num, 0f, 0f - num));
				}
				return false;
			}

			public void Step_(int perFrame)
			{
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_019a: Unknown result type (might be due to invalid IL or missing references)
				//IL_019c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: 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_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0209: Unknown result type (might be due to invalid IL or missing references)
				//IL_021c: 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_0234: Unknown result type (might be due to invalid IL or missing references)
				//IL_0268: Unknown result type (might be due to invalid IL or missing references)
				//IL_027d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0284: Unknown result type (might be due to invalid IL or missing references)
				//IL_0289: 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_01ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0158: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)Registry.CraterOp == (Object)null || (Object)(object)Registry.SmoothOp == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null)
				{
					Queue.Clear();
					retry.Clear();
					smoothQueued = true;
					return;
				}
				if (Queue.Count == 0 && retry.Count > 0 && Time.time >= nextRetry)
				{
					foreach (Vector3 item in retry)
					{
						Queue.Enqueue(item);
					}
					retry.Clear();
					nextRetry = Time.time + 0.4f;
				}
				if (Queue.Count == 0 && retry.Count == 0 && !smoothQueued)
				{
					smoothQueued = (smoothing = true);