Decompiled source of CraftKill v0.1.1

CraftKill.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using CraftKill.Classes;
using CraftKill.Helpers;
using GameConsole;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using ULTRAKILL.Portal;
using Unity.AI.Navigation;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using plog;
using plog.Models;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class ExtensionMarkerAttribute : Attribute
	{
		private readonly string <Name>k__BackingField;

		public string Name => <Name>k__BackingField;

		public ExtensionMarkerAttribute(string name)
		{
			<Name>k__BackingField = name;
		}
	}
}
namespace UltrakillStupid.Patches
{
	[HarmonyPatch(typeof(LeaderboardController))]
	[HarmonyPatch("SubmitLevelScore")]
	internal class LeaderboardControllerPatch
	{
		public static bool Prefix(string levelName, int difficulty, float seconds, int kills, int style, int restartCount, bool pRank = false)
		{
			return (Object)(object)CubePlacer.instance == (Object)null;
		}
	}
}
namespace CraftKill
{
	public static class Minefart
	{
		[CompilerGenerated]
		private sealed class <LoadLevelAsync>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private AsyncOperation <sceneload>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LoadLevelAsync>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<sceneload>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					SceneHelper.PendingScene = "Minefart";
					MonoSingleton<SceneHelper>.Instance.loadingBlocker.SetActive(true);
					SceneHelper.SetLoadingSubtext("Loading world...");
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!_loaded)
					{
						Plugin.LogInfo("Empty Scene Bundle wasn't loaded before trying to enter the scene.");
						Load();
						goto IL_00a9;
					}
					goto IL_00b6;
				case 2:
					<>1__state = -1;
					goto IL_00a9;
				case 3:
					{
						<>1__state = -1;
						break;
					}
					IL_00a9:
					if (!_loaded)
					{
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					goto IL_00b6;
					IL_00b6:
					if (SceneHelper.CurrentScene != "Minefart")
					{
						SceneHelper.LastScene = SceneHelper.CurrentScene;
					}
					SceneHelper.CurrentScene = "Minefart";
					<sceneload>5__1 = SceneManager.LoadSceneAsync("Assets/Scenes/PeterGriffin.unity");
					break;
				}
				if (!<sceneload>5__1.isDone)
				{
					<>2__current = null;
					<>1__state = 3;
					return true;
				}
				SceneHelper.PendingScene = null;
				Plugin.LogInfo("Scene loaded!");
				SceneHelper.SetLoadingSubtext("");
				MonoSingleton<SceneHelper>.Instance.loadingBlocker.SetActive(false);
				MonoSingleton<MusicManager>.Instance.battleTheme.outputAudioMixerGroup = MonoSingleton<AudioMixerController>.Instance.musicGroup;
				MonoSingleton<MusicManager>.Instance.cleanTheme.outputAudioMixerGroup = MonoSingleton<AudioMixerController>.Instance.musicGroup;
				MonoSingleton<MusicManager>.Instance.bossTheme.outputAudioMixerGroup = MonoSingleton<AudioMixerController>.Instance.musicGroup;
				((Component)MonoSingleton<MusicManager>.Instance).GetComponent<AudioSource>().outputAudioMixerGroup = MonoSingleton<AudioMixerController>.Instance.musicGroup;
				((Component)MonoSingleton<ChallengeManager>.Instance.challengePanel.transform.parent.Find("ChallengeText")).GetComponent<TMP_Text>().text = "(NO CHALLENGE)";
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static bool _loaded;

		public const string MinefartSceneName = "Minefart";

		public static void Load()
		{
			Plugin.Ass<GameObject>("FirstRoom");
			Plugin.Ass<GameObject>("FirstRoom Pit");
			Plugin.Ass<GameObject>("Wrapped Shop");
			Plugin.Ass<GameObject>("Assets/Prefabs/Levels/Hakita.prefab");
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("scene.bundle");
			AssetBundleCreateRequest val = AssetBundle.LoadFromStreamAsync(manifestResourceStream);
			((AsyncOperation)val).completed += delegate
			{
				Plugin.LogInfo("Loaded Empty Scene bundle.");
				_loaded = true;
			};
		}

		public static void LoadLevel()
		{
			((MonoBehaviour)Plugin.instance).StartCoroutine(LoadLevelAsync());
		}

		[IteratorStateMachine(typeof(<LoadLevelAsync>d__4))]
		public static IEnumerator LoadLevelAsync()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadLevelAsync>d__4(0);
		}
	}
	[HarmonyPatch]
	public static class SceneHelperPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(SceneHelper), "LoadSceneAsync")]
		public static bool LoadSceneAsyncPatch(ref Coroutine __result, string sceneName)
		{
			if (sceneName == "Minefart")
			{
				__result = ((MonoBehaviour)Plugin.instance).StartCoroutine(Minefart.LoadLevelAsync());
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	public static class GetMissionNamePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GetMissionName), "GetMission")]
		public static bool Patch1(ref string __result, int missionNum)
		{
			if (missionNum == -6767)
			{
				__result = "WORLD";
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GetMissionName), "GetSceneName")]
		public static bool Patch3(ref string __result, int missionNum)
		{
			if (missionNum == -6767)
			{
				__result = "Minefart";
				return false;
			}
			return true;
		}
	}
	[BepInPlugin("duviz.craftkill", "CraftKill", "0.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__3_0;

			internal void <OnSceneLoad>b__3_0()
			{
				Minefart.LoadLevel();
			}
		}

		public static Plugin instance;

		public static ConfigFile config;

		public void Awake()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			config = ((BaseUnityPlugin)this).Config;
			new Harmony("duviz.craftkill").PatchAll();
			SceneManager.sceneLoaded += delegate
			{
				OnSceneLoad();
			};
		}

		public void OnSceneLoad()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//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_00aa: Expected O, but got Unknown
			if (!(SceneHelper.CurrentScene == "Main Menu"))
			{
				return;
			}
			Button[] array = Object.FindObjectsOfType<Button>(true);
			foreach (Button val in array)
			{
				if (!(((Object)val).name == "Sandbox"))
				{
					continue;
				}
				GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent);
				val2.GetComponentInChildren<TMP_Text>(true).text = "WORLD";
				Button component = val2.GetComponent<Button>();
				component.onClick = new ButtonClickedEvent();
				ButtonClickedEvent onClick = component.onClick;
				object obj = <>c.<>9__3_0;
				if (obj == null)
				{
					UnityAction val3 = delegate
					{
						Minefart.LoadLevel();
					};
					<>c.<>9__3_0 = val3;
					obj = (object)val3;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
				break;
			}
		}

		public void Start()
		{
			BundleLoader.LoadBundle("assets.bundle");
			MonoSingleton<Console>.Instance.RegisterCommand((ICommand)(object)new BlockCommand());
			MonoSingleton<Console>.Instance.RegisterCommand((ICommand)(object)new FillCommand());
			MonoSingleton<Console>.Instance.RegisterCommand((ICommand)(object)new SoftBlocks());
			MonoSingleton<Console>.Instance.RegisterCommand((ICommand)(object)new ChangeDimension());
		}

		public static T Ass<T>(string path)
		{
			return AssHelper.Ass<T>(path);
		}

		public static void LogInfo(object msg)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo(msg);
		}

		public static void LogWarning(object msg)
		{
			((BaseUnityPlugin)instance).Logger.LogWarning(msg);
		}

		public static void LogError(object msg)
		{
			((BaseUnityPlugin)instance).Logger.LogError(msg);
		}
	}
	public class PluginInfo
	{
		public const string GUID = "duviz.craftkill";

		public const string Name = "CraftKill";

		public const string Version = "0.1.1";
	}
}
namespace CraftKill.Helpers
{
	public static class AssHelper
	{
		[SpecialName]
		public sealed class <G>$34505F560D9EACF86A87F3ED1F85E448
		{
			[SpecialName]
			public static class <M>$69FE22D2D9367C6033D7C9FA04F1ABE9
			{
			}

			[ExtensionMarker("<M>$69FE22D2D9367C6033D7C9FA04F1ABE9")]
			public int Occurrences(char lookUp)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$69FE22D2D9367C6033D7C9FA04F1ABE9")]
			public IEnumerable<int> Occurences(char lookUp)
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <Occurences>d__9 : IEnumerable<int>, IEnumerable, IEnumerator<int>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private int <>2__current;

			private int <>l__initialThreadId;

			private string str;

			public string <>3__str;

			private char lookUp;

			public char <>3__lookUp;

			private int <i>5__1;

			int IEnumerator<int>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Occurences>d__9(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					goto IL_0062;
				}
				<>1__state = -1;
				<i>5__1 = 0;
				goto IL_0072;
				IL_0062:
				<i>5__1++;
				goto IL_0072;
				IL_0072:
				if (<i>5__1 < str.Length)
				{
					if (str[<i>5__1] == lookUp)
					{
						<>2__current = <i>5__1;
						<>1__state = 1;
						return true;
					}
					goto IL_0062;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<int> IEnumerable<int>.GetEnumerator()
			{
				<Occurences>d__9 <Occurences>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<Occurences>d__ = this;
				}
				else
				{
					<Occurences>d__ = new <Occurences>d__9(0);
				}
				<Occurences>d__.str = <>3__str;
				<Occurences>d__.lookUp = <>3__lookUp;
				return <Occurences>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<int>)this).GetEnumerator();
			}
		}

		private static List<string> cache_PrefabKeys = null;

		public static Dictionary<string, object> CachedAddressableAssets = new Dictionary<string, object>();

		public static IResourceLocator MainAddressablesLocator => Addressables.ResourceLocators.FirstOrDefault((Func<IResourceLocator, bool>)((IResourceLocator loc) => loc.LocatorId == "AddressablesMainContentCatalog"));

		public static IEnumerable<object> GetAddressableKeys()
		{
			IResourceLocator mainAddressablesLocator = MainAddressablesLocator;
			return ((mainAddressablesLocator != null) ? mainAddressablesLocator.Keys : null) ?? Array.Empty<object>();
		}

		public static List<string> GetPrefabAddressableKeys(Func<string, bool> Search = null)
		{
			if (cache_PrefabKeys != null)
			{
				return cache_PrefabKeys.Where(Search).ToList();
			}
			List<string> list = new List<string>();
			IList<IResourceLocation> list2 = default(IList<IResourceLocation>);
			foreach (object addressableKey in GetAddressableKeys())
			{
				if (MainAddressablesLocator.Locate(addressableKey, typeof(GameObject), ref list2) && !list.Contains(list2[0].PrimaryKey))
				{
					list.Add(list2[0].PrimaryKey);
				}
			}
			list.Sort();
			cache_PrefabKeys = list;
			return list.Where(Search).ToList();
		}

		public static T Ass<T>(string key)
		{
			//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)
			if (CachedAddressableAssets.TryGetValue(key + typeof(T).Name, out var value))
			{
				return (T)value;
			}
			T val = Addressables.LoadAssetAsync<T>((object)key).WaitForCompletion();
			if (val != null)
			{
				CachedAddressableAssets.Add(key + typeof(T).Name, val);
			}
			else
			{
				Plugin.LogError("Failed to load asset: " + key);
			}
			return val;
		}

		public static int Occurrences(this string str, char lookUp)
		{
			int num = 0;
			foreach (char c in str)
			{
				if (c == lookUp)
				{
					num++;
				}
			}
			return num;
		}

		[IteratorStateMachine(typeof(<Occurences>d__9))]
		public static IEnumerable<int> Occurences(this string str, char lookUp)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Occurences>d__9(-2)
			{
				<>3__str = str,
				<>3__lookUp = lookUp
			};
		}
	}
	public static class BundleLoader
	{
		public static AssetBundle bundle { get; private set; }

		public static void LoadBundle(string path)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text = path ?? "";
			using Stream stream = executingAssembly.GetManifestResourceStream(text);
			if (stream == null)
			{
				Plugin.LogError("Bundle not found: " + text);
				return;
			}
			UnloadBundle();
			bundle = AssetBundle.LoadFromStream(stream);
		}

		public static void UnloadBundle()
		{
			AssetBundle obj = bundle;
			if (obj != null)
			{
				obj.Unload(false);
			}
		}
	}
	public static class EnemiesHelper
	{
		public enum Spawnable
		{
			Filth,
			Stalker,
			Stray,
			Schism,
			Soldier,
			Insurrectionist,
			MirrorReaper,
			SwordsMachine,
			Drone,
			Mindflayer,
			StreetCleaner,
			GutterMan,
			GutterTank,
			Maurice,
			Cerberi,
			Mass,
			Idol,
			Mannequin,
			Providence,
			Virtue,
			Power,
			MinosPrime,
			SisyphusPrime
		}

		public static Dictionary<Spawnable, string> EnemyToAddressableKey = new Dictionary<Spawnable, string>
		{
			[Spawnable.Filth] = "Assets/Prefabs/Enemies/Rewrite/Zombie/Filth.prefab",
			[Spawnable.Stalker] = "Assets/Prefabs/Enemies/Stalker.prefab",
			[Spawnable.Stray] = "Assets/Prefabs/Enemies/Rewrite/Zombie/Stray.prefab",
			[Spawnable.Schism] = "Assets/Prefabs/Enemies/Schism.prefab",
			[Spawnable.Soldier] = "Assets/Prefabs/Enemies/Rewrite/Zombie/Soldier.prefab",
			[Spawnable.Insurrectionist] = "Assets/Prefabs/Enemies/Sisyphus.prefab",
			[Spawnable.MirrorReaper] = "Assets/Prefabs/Enemies/MirrorReaperCyberGrind.prefab",
			[Spawnable.SwordsMachine] = "Assets/Prefabs/Enemies/Rewrite/Machine/Swordsmachine.prefab",
			[Spawnable.Drone] = "Assets/Prefabs/Enemies/Drone.prefab",
			[Spawnable.Mindflayer] = "Assets/Particles/Enemies/MindflayerCharge.prefab",
			[Spawnable.StreetCleaner] = "Assets/Prefabs/Enemies/Streetcleaner.prefab",
			[Spawnable.GutterMan] = "Assets/Prefabs/Enemies/Gutterman.prefab",
			[Spawnable.GutterTank] = "Assets/Prefabs/Enemies/Guttertank.prefab",
			[Spawnable.Maurice] = "Assets/Prefabs/Enemies/Malicious Face.prefab",
			[Spawnable.Cerberi] = "Assets/Prefabs/Enemies/Rewrite/Statue/Cerberus.prefab",
			[Spawnable.Mass] = "Assets/Prefabs/Enemies/Mass.prefab",
			[Spawnable.Idol] = "Assets/Prefabs/Enemies/Idol.prefab",
			[Spawnable.Mannequin] = "Assets/Prefabs/Enemies/Mannequin.prefab",
			[Spawnable.Providence] = "Assets/Prefabs/Enemies/Providence.prefab",
			[Spawnable.Virtue] = "Assets/Prefabs/Enemies/Virtue.prefab",
			[Spawnable.Power] = "Assets/Prefabs/Enemies/Power.prefab",
			[Spawnable.MinosPrime] = "Assets/Prefabs/Enemies/MinosPrime.prefab",
			[Spawnable.SisyphusPrime] = "Assets/Prefabs/Enemies/SisyphusPrime.prefab"
		};
	}
	public static class UniversalFloatParse
	{
		public static void Fix()
		{
			Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
		}
	}
}
namespace CraftKill.Classes
{
	public enum BlockType
	{
		block,
		tnt,
		bedrock,
		lava,
		healthBonus
	}
	public class Block : ScriptableObject
	{
		public string ID = "";

		public int chance = 0;

		[Space]
		public Texture texture;

		public Material mat;

		public BlockType type = BlockType.block;

		public Block(string iD, Texture texture, BlockType type, int chance, Material mat = null)
		{
			ID = iD;
			this.texture = texture;
			this.type = type;
			this.chance = chance;
			if (Object.op_Implicit((Object)(object)mat))
			{
				this.mat = mat;
			}
		}
	}
	public class BlockCommand : ICommand, IConsoleLogger
	{
		public Logger Log { get; } = new Logger("Minefart");


		public string Name => "Minefart";

		public string Description => "Lets you place blocks on whichever level you are";

		public string Command => "minefart";

		public void Execute(Console con, string[] args)
		{
			GameObjectExtensions.GetOrAddComponent<CubePlacer>(((Component)MonoSingleton<CameraController>.Instance).gameObject);
			foreach (Block block2 in CubePlacer.instance.blocks)
			{
				Block block = Object.Instantiate<Block>(block2);
				block.type = ((block.type != BlockType.bedrock) ? block.type : BlockType.block);
				CubePlacer.instance.ClearBlock(block2, 1000000);
				if (block.type != BlockType.lava)
				{
					CubePlacer.instance.ClearBlock(block, 1000000);
					CubePlacer.instance.GiveBlock(block, 10000);
				}
			}
		}
	}
	public class SoftBlocks : ICommand, IConsoleLogger
	{
		public Logger Log { get; } = new Logger("SoftBlocks");


		public string Name => "SoftBlocks";

		public string Description => "Makes every block breakable";

		public string Command => "softblocks";

		public void Execute(Console con, string[] args)
		{
			GameObjectExtensions.GetOrAddComponent<CubePlacer>(((Component)MonoSingleton<CameraController>.Instance).gameObject);
			foreach (Block block in CubePlacer.instance.blocks)
			{
				block.type = BlockType.block;
			}
		}
	}
	public class ChangeDimension : ICommand, IConsoleLogger
	{
		public Logger Log { get; } = new Logger("ChangeDimension");


		public string Name => "ChangeDimension";

		public string Description => "Changes your current dimension (usage: changedimension <DIMENSION>)";

		public string Command => "changedimension";

		public void Execute(Console con, string[] args)
		{
			if (Object.op_Implicit((Object)(object)Generation.instance))
			{
				if (args.Length != 1)
				{
					Log.Error("You need to specify a dimension", (IEnumerable<Tag>)null, (string)null, (object)null);
					return;
				}
				int dimension = int.Parse(args[0]);
				Generation.instance.ChangeDimension(dimension);
			}
		}
	}
	public class FillCommand : ICommand, IConsoleLogger
	{
		public Logger Log { get; } = new Logger("Fill");


		public string Name => "Fill";

		public string Description => "Fills a gap with blocks";

		public string Command => "fill";

		public void Execute(Console con, string[] args)
		{
			//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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			GameObjectExtensions.GetOrAddComponent<CubePlacer>(((Component)MonoSingleton<CameraController>.Instance).gameObject);
			int num = 10;
			int num2 = 10;
			int num3 = 10;
			int index = 0;
			if (args.Length == 2)
			{
				index = int.Parse(args[0]);
				num = (num2 = (num3 = int.Parse(args[1])));
			}
			else if (args.Length == 3)
			{
				index = int.Parse(args[0]);
				num = (num3 = int.Parse(args[1]));
				num2 = int.Parse(args[2]);
			}
			else if (args.Length == 4)
			{
				index = int.Parse(args[0]);
				num = int.Parse(args[1]);
				num2 = int.Parse(args[2]);
				num3 = int.Parse(args[3]);
			}
			Vector3 position = MonoSingleton<NewMovement>.Instance.Position;
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num2; j++)
				{
					for (int k = 0; k < num3; k++)
					{
						CubePlacer.instance.PlaceCube(CubePlacer.V3ToGrid(position + new Vector3((float)i, (float)j, (float)k) * CubePlacer.blockSize), CubePlacer.instance.blocks[index], null, optimized: true);
					}
				}
			}
		}
	}
	public class BlockInfo : MonoBehaviour
	{
		public Block block;
	}
	public class BlockInfoPickup : MonoBehaviour
	{
		public Block block;

		public Rigidbody rb;

		private float livingTime = 0f;

		public void Start()
		{
			//IL_0021: 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_003d: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			rb = ((Component)this).GetComponent<Rigidbody>();
			rb.constraints = (RigidbodyConstraints)112;
			rb.velocity = Vector3.up * 8f;
			Rigidbody obj = rb;
			obj.velocity += Vector3.right * Random.Range(-5f, 5f);
			Rigidbody obj2 = rb;
			obj2.velocity += Vector3.forward * Random.Range(-5f, 5f);
		}

		public void Update()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			livingTime += Time.deltaTime;
			((Component)this).transform.Rotate(0f, 360f * Time.deltaTime, 0f);
			if (livingTime > 120f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else if (((Component)this).transform.position.y < -100f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void OnTriggerEnter(Collider other)
		{
			if (((Component)other).tag == "Player")
			{
				CubePlacer.instance.GiveBlock(block, 1);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void FixedUpdate()
		{
			//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_0014: 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_002c: 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)
			Vector3 velocity = rb.velocity;
			rb.velocity = new Vector3(clamp(velocity.x), clamp(velocity.y), clamp(velocity.z));
		}

		public float clamp(float v)
		{
			return Mathf.Clamp(v, -20f, 20f);
		}
	}
	public class CubeParticle : MonoBehaviour
	{
		public float time = 2f;

		public void Update()
		{
			time -= Time.deltaTime;
			if (time <= 0f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public class CubePlacer : MonoBehaviour
	{
		public static CubePlacer instance;

		public Camera cam;

		public List<Block> blocks = new List<Block>();

		public List<(Block, int)> inventory = new List<(Block, int)>();

		public int selectedBlock = 0;

		public GameObject ghostCube;

		public GameObject placedCube;

		public GameObject ItemsCanvas;

		public Transform ItemsContainer;

		public Material defaultMaterial;

		public Mesh defaultMesh;

		public AudioSource source;

		public Dictionary<string, GameObject> assets = new Dictionary<string, GameObject>();

		public Dictionary<Block, Material> materials = new Dictionary<Block, Material>();

		private LayerMask layerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[4] { "Outdoors", "OutdoorsBaked", "Environment", "EnvironmentBaked" }));

		public static float blockSize = 5f;

		public float reach = 25f;

		public bool inventoryDirty = true;

		public float timeWithoutNavmeshUpdate = 100f;

		public float navmeshSyncRate = 2.5f;

		public KeyCode toggleKeycode = (KeyCode)120;

		public KeyCode changeBlockKeycode = (KeyCode)308;

		public NavMeshSurface surface;

		public void Awake()
		{
			//IL_003d: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			cam = ((Component)this).GetComponent<CameraController>().cam;
			ghostCube = Object.Instantiate<GameObject>(BundleLoader.bundle.LoadAsset<GameObject>("Ghost"));
			ghostCube.transform.localScale = Vector3.one * blockSize;
			ghostCube.SetActive(false);
			placedCube = BundleLoader.bundle.LoadAsset<GameObject>("Block");
			source = ((Component)this).gameObject.AddComponent<AudioSource>();
			defaultMaterial = Plugin.Ass<Material>("Assets/Materials/uk_construct/ConstructWallRed.mat");
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			defaultMesh = val.GetComponent<MeshFilter>().sharedMesh;
			Object.Destroy((Object)(object)val);
			SetupAssets();
			SetupItemsCanvas();
			SetupDefaultBlocks();
			if (SceneHelper.CurrentScene == "Minefart")
			{
				((Component)this).gameObject.AddComponent<Generation>();
				surface = Object.FindObjectOfType<NavMeshSurface>();
				surface.layerMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "Outdoors" }));
				surface.size = new Vector3(1f, 0.75f, 1f) * (float)Generation.chunkSize * blockSize * 2f;
				surface.voxelSize = 0.5f;
			}
		}

		private void SetupAssets()
		{
			assets["explosion"] = Plugin.Ass<GameObject>("Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion.prefab");
			assets["pickup"] = BundleLoader.bundle.LoadAsset<GameObject>("Pickup");
			assets["breakParticle"] = BundleLoader.bundle.LoadAsset<GameObject>("BreakParticle");
		}

		private void SetupItemsCanvas()
		{
			ItemsCanvas = Object.Instantiate<GameObject>(BundleLoader.bundle.LoadAsset<GameObject>("ItemCanvas"));
			ItemsContainer = ItemsCanvas.transform.Find("Items");
		}

		private void SetupDefaultBlocks()
		{
			NewBlock("Default", GetSandboxMaterial("Procedural Cube").mainTexture, BlockType.block, 3);
			NewBlock("BlowMe", BundleLoader.bundle.LoadAsset<Texture>("blowme"), BlockType.tnt, 1);
			NewBlock("cat", BundleLoader.bundle.LoadAsset<Texture>("cat"), BlockType.block, 0);
			NewBlock("cat2", BundleLoader.bundle.LoadAsset<Texture>("cat2"), BlockType.block, 0);
			NewBlock("Mrbones", BundleLoader.bundle.LoadAsset<Texture>("Mrbones"), BlockType.block, 0);
			NewBlock("StrongRock", BundleLoader.bundle.LoadAsset<Texture>("BackgroundTile"), BlockType.bedrock, 0);
			NewBlock("Lava", Plugin.Ass<Material>("Assets/Materials/Liquids/Lava.mat").mainTexture, BlockType.lava, 0);
			NewBlock("Grass", Plugin.Ass<Material>("Assets/Materials/Environment/Layer 1/Grass.mat").mainTexture, BlockType.bedrock, 0);
			NewBlock("CaveRock", Plugin.Ass<Material>("Assets/Materials/Environment/Layer 5/CaveRock1.mat").mainTexture, BlockType.block, 20);
			NewBlock("BoneWall", Plugin.Ass<Material>("Assets/Materials/Environment/Layer 6/BoneWall.mat").mainTexture, BlockType.block, 4);
			NewBlock("FleshStrong", Plugin.Ass<Material>("Assets/Materials/Environment/Layer 3/Flesh1.mat").mainTexture, BlockType.bedrock, 0, Plugin.Ass<Material>("Assets/Materials/Environment/Layer 3/Flesh1.mat"));
			NewBlock("MincedStrong", Plugin.Ass<Material>("Assets/Materials/Environment/Layer 3/Minced 1.mat").mainTexture, BlockType.bedrock, 0, Plugin.Ass<Material>("Assets/Materials/Environment/Layer 3/Minced 1.mat"));
			NewBlock("Glass", GetSandboxMaterial("Procedural Glass Variant").mainTexture, BlockType.block, 5, GetSandboxMaterial("Procedural Glass Variant"));
			NewBlock("SandStrong", Plugin.Ass<Material>("Assets/Materials/Environment/Layer 4/SandLarge.mat").mainTexture, BlockType.bedrock, 0, Plugin.Ass<Material>("Assets/Materials/Environment/Layer 4/SandLarge.mat"));
			NewBlock("Acid", BundleLoader.bundle.LoadAsset<Texture>("acid"), BlockType.lava, 0);
			NewBlock("LustStrong", Plugin.Ass<Material>("Assets/Materials/Environment/Layer 2/Standalone4.mat").mainTexture, BlockType.bedrock, 0);
			NewBlock("Wood", Plugin.Ass<Material>("Assets/Materials/Environment/Layer 1/Barrel Wood.mat").mainTexture, BlockType.block, 10);
		}

		private void ReloadInventory()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			Transform child = ItemsContainer.GetChild(0);
			foreach (Transform item in ItemsContainer)
			{
				Transform val = item;
				if ((Object)(object)val != (Object)(object)child)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
			((Component)child).gameObject.SetActive(false);
			int num = 0;
			foreach (var item2 in inventory)
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)child).gameObject, ItemsContainer);
				val2.SetActive(true);
				((Component)val2.transform.Find("Icon")).GetComponent<RawImage>().texture = item2.Item1.texture;
				((Component)val2.transform.Find("Highlight")).gameObject.SetActive(selectedBlock == num);
				string text = ((item2.Item2 == 1) ? "" : item2.Item2.ToString());
				((Component)val2.transform.Find("Amount")).GetComponent<TMP_Text>().text = text;
				num++;
			}
		}

		private void NewBlock(string blockID, Texture texture, BlockType type, int chance, Material mat = null)
		{
			Block item = new Block(blockID, texture, type, chance, Object.op_Implicit((Object)(object)mat) ? mat : null);
			blocks.Add(item);
		}

		public void ClearBlock(Block block, int amount)
		{
			int num = inventory.FindIndex(((Block, int) x) => (Object)(object)x.Item1 == (Object)(object)block);
			inventoryDirty = true;
			if (num != -1)
			{
				(Block, int) value = inventory[num];
				value.Item2 -= amount;
				if (value.Item2 <= 0)
				{
					inventory.RemoveAt(num);
				}
				else
				{
					inventory[num] = value;
				}
			}
		}

		public void GiveBlock(Block block, int amount)
		{
			int num = inventory.FindIndex(((Block, int) x) => (Object)(object)x.Item1 == (Object)(object)block);
			inventoryDirty = true;
			if (num != -1)
			{
				(Block, int) value = inventory[num];
				value.Item2 += amount;
				inventory[num] = value;
			}
			else
			{
				inventory.Add((block, amount));
			}
			PlayPickupSFX();
		}

		public void Update()
		{
			//IL_0048: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)MonoSingleton<GunControl>.Instance.currentWeapon) && !MonoSingleton<GunControl>.Instance.currentWeapon.activeSelf && MonoSingleton<NewMovement>.Instance.activated && !MonoSingleton<OptionsManager>.Instance.paused)
			{
				if (Input.GetKey(changeBlockKeycode))
				{
					MonoSingleton<GunControl>.Instance.scrollCooldown = 5f;
					selectedBlock += (int)Input.mouseScrollDelta.y;
					inventoryDirty = true;
				}
				if (selectedBlock >= inventory.Count)
				{
					selectedBlock = 0;
				}
				if (selectedBlock < 0)
				{
					selectedBlock = inventory.Count - 1;
				}
				if (TryRaycastPos(out var pos, out var hitTransform))
				{
					if (inventory.Count > 0)
					{
						ghostCube.transform.position = pos;
						ghostCube.SetActive(true);
						if (MonoSingleton<InputManager>.Instance.InputSource.Fire2.WasPerformedThisFrame && !CheckCollision(((Component)MonoSingleton<NewMovement>.Instance).transform, ghostCube.transform))
						{
							PlaceCubeByPlayer(pos);
						}
					}
					else
					{
						ghostCube.SetActive(false);
					}
					if (MonoSingleton<InputManager>.Instance.InputSource.Fire1.WasPerformedThisFrame && ((Object)hitTransform).name == "CraftKill_Breakable" && ((Component)hitTransform).GetComponent<BlockInfo>().block.type != BlockType.bedrock)
					{
						CreateParticle(hitTransform.position, ((Component)hitTransform).GetComponent<BlockInfo>().block);
						CreatePickup(hitTransform.position, ((Component)hitTransform).GetComponent<BlockInfo>().block);
						Object.Destroy((Object)(object)((Component)hitTransform).gameObject);
					}
				}
				else
				{
					ghostCube.SetActive(false);
				}
			}
			else
			{
				ghostCube.SetActive(false);
			}
			if (Input.GetKeyDown(toggleKeycode) && Object.op_Implicit((Object)(object)MonoSingleton<GunControl>.Instance.currentWeapon))
			{
				MonoSingleton<GunControl>.Instance.currentWeapon.SetActive(!MonoSingleton<GunControl>.Instance.currentWeapon.activeSelf);
			}
			if (inventoryDirty)
			{
				inventoryDirty = false;
				ReloadInventory();
			}
			timeWithoutNavmeshUpdate += Time.deltaTime;
			if (timeWithoutNavmeshUpdate >= navmeshSyncRate && Object.op_Implicit((Object)(object)surface))
			{
				timeWithoutNavmeshUpdate = 0f;
				((Component)surface).transform.position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
				surface.BuildNavMesh();
			}
		}

		public void PlaceCubeByPlayer(Vector3 pos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PlaceCube(pos, inventory[selectedBlock].Item1);
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.pitch = Random.Range(0.9f, 1.1f);
			val2.spatialize = true;
			val2.maxDistance = 50f;
			val2.minDistance = 5f;
			val2.playOnAwake = false;
			val2.spatialBlend = 1f;
			val2.rolloffMode = (AudioRolloffMode)1;
			val2.clip = Plugin.Ass<AudioClip>("Assets/Sounds/Gore/GORE - WEAP - Disembowel_Gore_5 Short.wav");
			val2.Play();
			ClearBlock(inventory[selectedBlock].Item1, 1);
		}

		public GameObject PlaceCube(Vector3 pos, Block block, Transform forceParent = null, bool optimized = false)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Expected O, but got Unknown
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			GameObject cube = Object.Instantiate<GameObject>(placedCube, pos, Quaternion.identity);
			if (Object.op_Implicit((Object)(object)forceParent))
			{
				cube.transform.SetParent(forceParent);
			}
			((Object)cube).name = "CraftKill_Breakable";
			cube.transform.localScale = Vector3.one * blockSize;
			cube.layer = LayerMask.NameToLayer("Outdoors");
			cube.tag = "Floor";
			cube.GetComponent<BoxCollider>().size = Vector3.one * 1.05f;
			if (!optimized)
			{
				cube.AddComponent<PortalAwareRenderer>();
			}
			cube.GetComponent<Renderer>().material = GetMaterial(block);
			cube.AddComponent<BlockInfo>().block = block;
			if (!optimized)
			{
				NavMeshObstacle val = cube.AddComponent<NavMeshObstacle>();
				val.carving = true;
			}
			Breakable val2 = cube.AddComponent<Breakable>();
			val2.destroyEvent = new UltrakillEvent
			{
				onActivate = new UnityEvent(),
				onDisActivate = new UnityEvent(),
				toActivateObjects = Array.Empty<GameObject>(),
				toDisActivateObjects = Array.Empty<GameObject>()
			};
			val2.destroyOnBreak = Array.Empty<GameObject>();
			val2.activateOnBreak = Array.Empty<GameObject>();
			if (block.type == BlockType.tnt)
			{
				val2.destroyEvent.onActivate.AddListener((UnityAction)delegate
				{
					//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)
					Explosion componentInChildren = Object.Instantiate<GameObject>(assets["explosion"], cube.transform.position, Quaternion.identity).GetComponentInChildren<Explosion>();
					componentInChildren.damage = 100;
					componentInChildren.enemyDamageMultiplier = 2f;
					componentInChildren.maxSize = 25f;
					componentInChildren.speed = 3f;
				});
			}
			else if (block.type == BlockType.bedrock)
			{
				Object.Destroy((Object)(object)val2);
			}
			else if (block.type == BlockType.lava)
			{
				Object.Destroy((Object)(object)val2);
				Object.Destroy((Object)(object)cube.GetComponent<BoxCollider>());
				GameObject val3 = new GameObject("Water");
				val3.transform.SetParent(cube.transform, false);
				val3.transform.localScale = Vector3.one;
				((Collider)val3.AddComponent<BoxCollider>()).isTrigger = true;
				val3.AddComponent<Water>().clr = new Color(1f, 0.3387192f, 0f);
				HurtZone val4 = val3.AddComponent<HurtZone>();
				val4.damageType = (EnviroDamageType)1;
				val4.trigger = true;
				val4.affected = (AffectedSubjects)0;
				val4.ignoreDashingPlayer = false;
				val4.ignoreInvincibility = false;
				val4.bounceForce = 500f;
				val4.hurtCooldown = 1f;
				val4.setDamage = 50f;
				val4.hardDamagePercentage = 0.35f;
				val3.layer = LayerMask.NameToLayer("Water");
				ScrollMe scrollMe = cube.AddComponent<ScrollMe>();
			}
			else
			{
				val2.destroyEvent.onActivate.AddListener((UnityAction)delegate
				{
					//IL_0008: 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)
					CreateParticle(pos, block);
					CreatePickup(pos, block);
				});
			}
			return cube;
		}

		public void CreatePickup(Vector3 pos, Block block)
		{
			//IL_0011: 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)
			GameObject val = Object.Instantiate<GameObject>(assets["pickup"], pos, Quaternion.identity);
			val.layer = LayerMask.NameToLayer("Outdoors");
			val.tag = "Floor";
			val.GetComponent<Renderer>().material = GetMaterial(block);
			val.AddComponent<BlockInfoPickup>().block = block;
		}

		public void PlayPickupSFX()
		{
			source.pitch = Random.Range(0.7f, 0.9f);
			source.spatialize = true;
			source.maxDistance = 50f;
			source.minDistance = 5f;
			source.playOnAwake = false;
			source.spatialBlend = 1f;
			source.rolloffMode = (AudioRolloffMode)1;
			source.clip = Plugin.Ass<AudioClip>("Assets/Sounds/UI/Click1b.wav");
			source.Play();
		}

		public void CreateParticle(Vector3 pos, Block block)
		{
			//IL_0011: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(assets["breakParticle"], pos, Quaternion.identity);
			val.layer = LayerMask.NameToLayer("Outdoors");
			MainModule main = val.GetComponent<ParticleSystem>().main;
			((MainModule)(ref main)).startSizeMultiplier = 1f;
			ShapeModule shape = val.GetComponent<ParticleSystem>().shape;
			((ShapeModule)(ref shape)).radius = blockSize / 2f;
			((Renderer)val.GetComponent<ParticleSystemRenderer>()).material = GetMaterial(block);
			val.AddComponent<CubeParticle>();
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.pitch = Random.Range(0.9f, 1.1f);
			val2.spatialize = true;
			val2.maxDistance = 50f;
			val2.minDistance = 5f;
			val2.playOnAwake = false;
			val2.spatialBlend = 1f;
			val2.rolloffMode = (AudioRolloffMode)1;
			val2.clip = Plugin.Ass<AudioClip>("Assets/Sounds/Environment/boulder_impact_on_stones_14 fast.wav");
			val2.Play();
		}

		public bool TryRaycastPos(out Vector3 pos, out Transform hitTransform)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			PhysicsCastResult val = default(PhysicsCastResult);
			PortalTraversalV2[] array = default(PortalTraversalV2[]);
			Vector3 val2 = default(Vector3);
			bool result = PortalPhysicsV2.Raycast(((Component)cam).transform.position, ((Component)cam).transform.forward, reach, LayerMask.op_Implicit(layerMask), ref val, ref array, ref val2, (QueryTriggerInteraction)0);
			pos = V3ToGrid(val.point - ((Component)cam).transform.forward * 0.1f);
			hitTransform = val.transform;
			return result;
		}

		public Material GetMaterial(Block block)
		{
			if (materials.ContainsKey(block))
			{
				return materials[block];
			}
			if (Object.op_Implicit((Object)(object)block.mat))
			{
				return block.mat;
			}
			Material val = Object.Instantiate<Material>(defaultMaterial);
			val.mainTexture = block.texture;
			materials[block] = val;
			return val;
		}

		public static Vector3 V3ToGrid(Vector3 grid)
		{
			//IL_0001: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(GridPos(grid.x), GridPos(grid.y), GridPos(grid.z));
		}

		public static float GridPos(float num)
		{
			return Mathf.Round((num - blockSize / 2f) / blockSize) * blockSize + blockSize / 2f;
		}

		public bool CheckCollision(Transform t1, Transform t2)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_005d: 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_006f: 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_0083: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = t1.position;
			Vector3 val = t1.localScale * 0.5f;
			Vector3 position2 = t2.position;
			Vector3 val2 = t2.localScale * 0.5f;
			bool flag = Mathf.Abs(position.x - position2.x) <= val.x + val2.x;
			bool flag2 = Mathf.Abs(position.y - position2.y) <= val.y + val2.y;
			bool flag3 = Mathf.Abs(position.z - position2.z) <= val.z + val2.z;
			return flag && flag2 && flag3;
		}

		private Material GetSandboxMaterial(string path)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(Plugin.Ass<GameObject>("Assets/Prefabs/Sandbox/" + path + ".prefab"));
			Material result = new Material(val.GetComponent<Renderer>().material);
			Object.Destroy((Object)(object)val);
			return result;
		}

		private Material GetPathMaterial(string path)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			return new Material(Plugin.Ass<Material>("Assets/Materials/" + path + ".mat"));
		}
	}
	[HarmonyPatch]
	public class CameraPatch
	{
		[HarmonyPatch(typeof(CameraController), "Start")]
		public static void Prefix(CameraController __instance)
		{
			if (SceneHelper.CurrentScene == "Minefart")
			{
				((Component)__instance).gameObject.AddComponent<CubePlacer>();
			}
		}
	}
	public class Generation : MonoBehaviour
	{
		public class Biome
		{
			public string name;

			public List<string> enemies;

			public int block;

			public int height;

			public int minItems;

			public int liquidBlock;

			public Biome(string name, int block, int height, int minItems, int liquidBlock, List<EnemiesHelper.Spawnable> enemies)
			{
				this.name = name;
				this.enemies = enemies.Select((EnemiesHelper.Spawnable e) => EnemiesHelper.EnemyToAddressableKey[e]).ToList();
				this.block = block;
				this.height = height;
				this.minItems = minItems;
				this.liquidBlock = liquidBlock;
				base..ctor();
			}
		}

		public class Dimension
		{
			public string name;

			public List<Biome> biomes;

			public int maxHeight;

			public string skybox;

			public float perlinScale;

			public Dimension(string name, List<Biome> biomes, int maxHeight, string skybox, float perlinScale = 0.04f)
			{
				this.name = name;
				this.biomes = biomes;
				this.maxHeight = maxHeight;
				this.skybox = skybox;
				this.perlinScale = perlinScale;
				base..ctor();
			}
		}

		[CompilerGenerated]
		private sealed class <GenerateChunkIE>d__15 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int chunkX;

			public int chunkZ;

			public int seed;

			public Generation <>4__this;

			private GameObject <c>5__1;

			private float <blockSize>5__2;

			private int <x>5__3;

			private int <z>5__4;

			private int <worldX>5__5;

			private int <worldZ>5__6;

			private int <value>5__7;

			private Biome <biome>5__8;

			private Vector3 <cubePos>5__9;

			private int <cube>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GenerateChunkIE>d__15(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<c>5__1 = null;
				<biome>5__8 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_0056: 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_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_0203: Unknown result type (might be due to invalid IL or missing references)
				//IL_020e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0213: Unknown result type (might be due to invalid IL or missing references)
				//IL_0219: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					goto IL_028a;
				}
				<>1__state = -1;
				<c>5__1 = new GameObject("Chunk");
				<c>5__1.AddComponent<GoreZone>();
				<>4__this.chunks[new Vector2Int(chunkX, chunkZ)] = <c>5__1;
				<blockSize>5__2 = CubePlacer.blockSize;
				<x>5__3 = 0;
				goto IL_029b;
				IL_028a:
				<x>5__3++;
				goto IL_029b;
				IL_029b:
				if (<x>5__3 < chunkSize)
				{
					<z>5__4 = 0;
					while (<z>5__4 < chunkSize)
					{
						<worldX>5__5 = chunkX * chunkSize + <x>5__3;
						<worldZ>5__6 = chunkZ * chunkSize + <z>5__4;
						<value>5__7 = GetValue(<worldX>5__5, <worldZ>5__6, seed, dimensions[currentDimension].maxHeight, dimensions[currentDimension].perlinScale);
						<biome>5__8 = GetBiome(<worldX>5__5, <worldZ>5__6, seed);
						<cubePos>5__9 = GetPos(new Vector3((float)<worldX>5__5, (float)<value>5__7, (float)<worldZ>5__6), <blockSize>5__2);
						<cube>5__10 = <>4__this.GetFloorCube(<biome>5__8);
						NewCube(<cubePos>5__9, <cube>5__10, <c>5__1);
						CheckForNewMob(<worldX>5__5, <value>5__7, <worldZ>5__6, <c>5__1.transform, <biome>5__8);
						CheckForNewCrate(<worldX>5__5, <value>5__7, <worldZ>5__6, <c>5__1.transform, <biome>5__8);
						if (<value>5__7 == 1 && <biome>5__8.liquidBlock > -1)
						{
							<cubePos>5__9 = GetPos(new Vector3((float)<worldX>5__5, (float)(<value>5__7 + 1), (float)<worldZ>5__6), <blockSize>5__2);
							NewCube(<cubePos>5__9, <biome>5__8.liquidBlock, <c>5__1);
						}
						<biome>5__8 = null;
						<z>5__4++;
					}
					if (<x>5__3 % 2 == 0)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_028a;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static Generation instance;

		public static int maxHeight = 10;

		public static int chunkSize = 16;

		public static int loadDistance = 4;

		public static int minMobHeight = 3;

		public static float mobChance;

		public static float crateChance = 0.0001953125f;

		public Dictionary<Vector2Int, GameObject> chunks = new Dictionary<Vector2Int, GameObject>();

		public static List<Dimension> dimensions = new List<Dimension>(2)
		{
			new Dimension("Overworld", new List<Biome>(4)
			{
				new Biome("Desert", 13, 100, 10, -1, new List<EnemiesHelper.Spawnable>(6)
				{
					EnemiesHelper.Spawnable.Stalker,
					EnemiesHelper.Spawnable.Insurrectionist,
					EnemiesHelper.Spawnable.Virtue,
					EnemiesHelper.Spawnable.Schism,
					EnemiesHelper.Spawnable.Cerberi,
					EnemiesHelper.Spawnable.Maurice
				}),
				new Biome("Plains", 7, 70, 5, 6, new List<EnemiesHelper.Spawnable>(9)
				{
					EnemiesHelper.Spawnable.Filth,
					EnemiesHelper.Spawnable.Soldier,
					EnemiesHelper.Spawnable.Stray,
					EnemiesHelper.Spawnable.Schism,
					EnemiesHelper.Spawnable.Cerberi,
					EnemiesHelper.Spawnable.SwordsMachine,
					EnemiesHelper.Spawnable.Maurice,
					EnemiesHelper.Spawnable.Mass,
					EnemiesHelper.Spawnable.Drone
				}),
				new Biome("Hell", 10, 50, 20, 6, new List<EnemiesHelper.Spawnable>(8)
				{
					EnemiesHelper.Spawnable.Cerberi,
					EnemiesHelper.Spawnable.SwordsMachine,
					EnemiesHelper.Spawnable.Mannequin,
					EnemiesHelper.Spawnable.GutterTank,
					EnemiesHelper.Spawnable.GutterMan,
					EnemiesHelper.Spawnable.Providence,
					EnemiesHelper.Spawnable.StreetCleaner,
					EnemiesHelper.Spawnable.Mindflayer
				}),
				new Biome("Deep Hell", 11, 25, 50, 6, new List<EnemiesHelper.Spawnable>(5)
				{
					EnemiesHelper.Spawnable.MirrorReaper,
					EnemiesHelper.Spawnable.Idol,
					EnemiesHelper.Spawnable.Providence,
					EnemiesHelper.Spawnable.Power,
					EnemiesHelper.Spawnable.Insurrectionist
				})
			}, 10, "Sky_Overworld"),
			new Dimension("Lust", new List<Biome>(1)
			{
				new Biome("Plains", 15, 100, 5, -1, new List<EnemiesHelper.Spawnable>(1) { EnemiesHelper.Spawnable.Drone })
			}, 3, "LustSkybox1", 0.2f)
		};

		public static int currentDimension = 0;

		public int seed = 0;

		public static int GetValue(int x, int z, int seed, int maxH, float scale = 0.04f)
		{
			float num = (float)(x + seed) * scale;
			float num2 = (float)(z + seed) * scale;
			float num3 = Mathf.PerlinNoise(num, num2);
			int num4 = Mathf.FloorToInt(num3 * (float)maxH) + 1;
			return Mathf.Clamp(num4, 1, maxH);
		}

		public void GenerateChunk(int chunkX, int chunkZ, int seed)
		{
			((MonoBehaviour)this).StartCoroutine(GenerateChunkIE(chunkX, chunkZ, seed));
		}

		[IteratorStateMachine(typeof(<GenerateChunkIE>d__15))]
		public IEnumerator GenerateChunkIE(int chunkX, int chunkZ, int seed)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateChunkIE>d__15(0)
			{
				<>4__this = this,
				chunkX = chunkX,
				chunkZ = chunkZ,
				seed = seed
			};
		}

		public int GetFloorCube(Biome biome)
		{
			return biome.block;
		}

		public static Biome GetBiome(int x, int z, int seed)
		{
			int value = GetValue(x, z, seed + 1, 100, 0.005f);
			Biome result = null;
			int num = 1000;
			foreach (Biome biome in dimensions[currentDimension].biomes)
			{
				if (value <= biome.height && num > biome.height)
				{
					result = biome;
					num = biome.height;
				}
			}
			return result;
		}

		public static void CheckForNewMob(int worldX, int value, int worldZ, Transform c, Biome biome)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (Random.value <= mobChance)
			{
				NewMob(GetPos(new Vector3((float)worldX, (float)(value + 1), (float)worldZ), CubePlacer.blockSize), c, GetEnemy(biome));
			}
		}

		public static string GetEnemy(Biome biome)
		{
			List<string> enemies = biome.enemies;
			return enemies[Random.Range(0, enemies.Count)];
		}

		public static void CheckForNewCrate(int worldX, int value, int worldZ, Transform c, Biome biome)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (Random.value <= crateChance && biome.minItems > 0)
			{
				NewCrate(GetPos(new Vector3((float)worldX, (float)(value + 1), (float)worldZ), CubePlacer.blockSize), c, biome.minItems, (int)((float)biome.minItems * 1.2f));
			}
		}

		public static void NewMob(Vector3 pos, Transform c, string enemy)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (MonoSingleton<NewMovement>.Instance.activated)
			{
				GameObject val = Object.Instantiate<GameObject>(Plugin.Ass<GameObject>(enemy), pos - Vector3.up * (CubePlacer.blockSize / 2f), Quaternion.identity);
				if (((Object)val).name.StartsWith("Providence"))
				{
					val.transform.Translate(0f, 5f, 0f);
				}
				val.transform.SetParent(c);
			}
		}

		public static void NewCube(Vector3 cubePos, int block, GameObject c)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			CubePlacer.instance.PlaceCube(cubePos, CubePlacer.instance.blocks[block], c.transform, optimized: true);
		}

		public static void NewCrate(Vector3 pos, Transform c, int min = 30, int max = 50)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(Plugin.Ass<GameObject>("Assets/Prefabs/Levels/Interactive/Crate.prefab"), pos, Quaternion.identity);
			val.transform.localScale = Vector3.one * (CubePlacer.blockSize / 2f);
			Transform transform = val.transform;
			transform.position -= Vector3.right * (CubePlacer.blockSize / 2f);
			Transform transform2 = val.transform;
			transform2.position += Vector3.forward * (CubePlacer.blockSize / 2f);
			Transform transform3 = val.transform;
			transform3.position += Vector3.down * (CubePlacer.blockSize / 2f);
			val.GetComponent<Breakable>().destroyEvent.onActivate.AddListener((UnityAction)delegate
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				SpawnThingies(pos, min, max);
			});
			val.GetComponent<Breakable>().crate = false;
			if (Object.op_Implicit((Object)(object)c))
			{
				val.transform.SetParent(c);
			}
		}

		public static void SpawnThingies(Vector3 pos, int min, int max)
		{
			//IL_008c: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			List<Block> list = new List<Block>();
			foreach (Block block in CubePlacer.instance.blocks)
			{
				if (block.chance != 0)
				{
					for (int i = 0; i < block.chance; i++)
					{
						list.Add(block);
					}
				}
			}
			for (int j = 0; j < Random.Range(min, max); j++)
			{
				if (list.Count == 0)
				{
					break;
				}
				CubePlacer.instance.CreatePickup(pos + new Vector3(Random.value - 0.5f, Random.value - 0.5f, Random.value - 0.5f) * (CubePlacer.blockSize / 2f), list[Random.Range(0, list.Count)]);
			}
		}

		public static Vector3 GetPos(Vector3 pos, float blockSize)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			return new Vector3(pos.x * blockSize, pos.y * blockSize - 100f, pos.z * blockSize) + Vector3.one * blockSize / 2f;
		}

		public void Awake()
		{
			instance = this;
		}

		public void Start()
		{
			Generate(Random.Range(0, 100000));
		}

		public void Update()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: 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_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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)chunkSize * CubePlacer.blockSize;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(((Component)MonoSingleton<NewMovement>.Instance).transform.position.x, ((Component)MonoSingleton<NewMovement>.Instance).transform.position.z);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(Mathf.Round(val.x / num), Mathf.Round(val.y / num));
			Vector2Int key = default(Vector2Int);
			for (int i = -loadDistance / 2; i <= loadDistance / 2; i++)
			{
				for (int j = -loadDistance / 2; j <= loadDistance / 2; j++)
				{
					Vector2 val3 = val2 + Vector2Int.op_Implicit(new Vector2Int(i, j));
					((Vector2Int)(ref key))..ctor((int)val3.x, (int)val3.y);
					if (!chunks.ContainsKey(key))
					{
						GenerateChunk(((Vector2Int)(ref key)).x, ((Vector2Int)(ref key)).y, seed);
					}
				}
			}
			Vector2Int val5 = default(Vector2Int);
			foreach (KeyValuePair<Vector2Int, GameObject> item in chunks.ToList())
			{
				Vector2 val4 = val2;
				((Vector2Int)(ref val5))..ctor((int)val4.x, (int)val4.y);
				Vector2Int key2 = item.Key;
				float num2 = ((Vector2Int)(ref key2)).x;
				key2 = item.Key;
				if (Vector2.Distance(new Vector2(num2, (float)((Vector2Int)(ref key2)).y), Vector2Int.op_Implicit(val5)) > (float)loadDistance)
				{
					Object.Destroy((Object)(object)item.Value);
					chunks.Remove(item.Key);
				}
			}
		}

		public void Generate(int seed)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Plugin.LogInfo("Generating...");
			this.seed = seed;
			SetDefaultChances();
			GenerateChunk(0, 0, seed);
			NewCrate(new Vector3(-5f, 3f, 5f), null, 8, 9);
		}

		public static void SetDefaultChances()
		{
			mobChance = 0.0003125f;
			mobChance *= MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", 0);
			currentDimension = 0;
			UpdateSkybox();
		}

		public void ClearChunks()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<Vector2Int, GameObject> item in chunks.ToList())
			{
				Object.Destroy((Object)(object)item.Value);
				chunks.Remove(item.Key);
			}
		}

		public void ChangeDimension(int dimension)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (MonoSingleton<NewMovement>.Instance.activated)
			{
				((Component)MonoSingleton<NewMovement>.Instance).transform.position = Vector3.zero;
			}
			MonoSingleton<LevelNamePopup>.Instance.CustomNameAppear("CRAFTKILL", dimensions[dimension].name.ToUpper());
			ClearChunks();
			currentDimension = dimension;
			UpdateSkybox();
		}

		public static void UpdateSkybox()
		{
			RenderSettings.skybox = BundleLoader.bundle.LoadAsset<Material>(dimensions[currentDimension].skybox);
		}
	}
	[HarmonyPatch]
	public class EnemyDeathRewardPatch
	{
		[HarmonyPatch(typeof(EnemyIdentifier), "ProcessDeath")]
		public static void Prefix(EnemyIdentifier __instance)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!(SceneHelper.CurrentScene != "Minefart"))
			{
				int enemyRank = MonoSingleton<EnemyTracker>.Instance.GetEnemyRank(__instance);
				if (enemyRank > 0)
				{
					enemyRank++;
					Generation.SpawnThingies(((Component)__instance).transform.position + Vector3.up * 5f, enemyRank * 2, enemyRank * 3);
				}
			}
		}
	}
	public class ScrollMe : MonoBehaviour
	{
		public MeshRenderer mr;

		public void Start()
		{
			mr = ((Component)this).GetComponent<MeshRenderer>();
		}

		public void Update()
		{
			//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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			((Renderer)mr).material.SetTextureOffset("_MainTex", ((Renderer)mr).material.GetTextureOffset("_MainTex") + Vector2.right * 0.2f * Time.deltaTime);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}