Decompiled source of LethalMayhem v0.1.2

LethalMayhem.dll

Decompiled 5 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.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using LethalMayhem.Casino;
using LethalMayhem.Items;
using LethalMayhem.Monsters;
using LethalMayhem.Moons;
using LethalMayhem.Moons.HoarfrostParts;
using LethalMayhem.Moons.LumenParts;
using LethalMayhem.Moons.RevelryParts;
using LethalMayhem.Net;
using LethalMayhem.Util;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.AI.Navigation;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalMayhem")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("LethalMayhem")]
[assembly: AssemblyTitle("LethalMayhem")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalMayhem
{
	[BepInPlugin("com.brandon.lethalmayhem", "Lethal Mayhem", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "com.brandon.lethalmayhem";

		public const string Name = "Lethal Mayhem";

		public const string Version = "0.1.0";

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		internal static ConfigEntry<bool> CasinoEnabled;

		internal static ConfigEntry<bool> EvacuateOnTakeoff;

		internal static ConfigEntry<string> PortalPositionOverride;

		internal static ConfigEntry<string> PortalAnchorObject;

		internal static ConfigEntry<bool> QuotaGambleEnabled;

		internal static ConfigEntry<int> QuotaGamblePercent;

		internal static ConfigEntry<float> BlackMarketDiscount;

		internal static ConfigEntry<int> MysteryCratePrice;

		internal static ConfigEntry<float> NeonIntensity;

		internal static ConfigEntry<float> LightIntensity;

		internal static ConfigEntry<float> CasinoExposure;

		internal static ConfigEntry<float> CasinoMusicVolume;

		internal static ConfigEntry<bool> SortMoonCatalogue;

		internal static ConfigEntry<bool> ShowMoonRiskLevel;

		internal static ConfigEntry<bool> ShowMoonPrice;

		internal static ConfigEntry<bool> DevMode;

		private void Awake()
		{
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Expected O, but got Unknown
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			CasinoEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Casino", "Enabled", true, "Build the casino at the Company building (Gordion).");
			EvacuateOnTakeoff = ((BaseUnityPlugin)this).Config.Bind<bool>("Casino", "EvacuateOnTakeoff", true, "Teleport players who are still inside the casino back onto the ship when it takes off. Turn off for maximum cruelty.");
			PortalPositionOverride = ((BaseUnityPlugin)this).Config.Bind<string>("Casino", "PortalPositionOverride", "", "Optional world position for the casino portal at the Company, as \"x,y,z\". Leave empty for automatic placement.");
			PortalAnchorObject = ((BaseUnityPlugin)this).Config.Bind<string>("Casino", "PortalAnchorObject", "Environment/Map/ShippingContainers/ShippingContainer (8)", "Scene path of an object to mount the casino portal against (centred on its most reachable side). Default is the big shipping container beside the Company landing platform. Empty or missing = find a spot automatically.");
			QuotaGambleEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Casino", "QuotaGambleEnabled", true, "Enable the Double-or-Nothing quota button.");
			QuotaGamblePercent = ((BaseUnityPlugin)this).Config.Bind<int>("Casino", "QuotaGamblePercent", 25, new ConfigDescription("How much the quota moves (percent) when someone presses the Double-or-Nothing button.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 100), Array.Empty<object>()));
			BlackMarketDiscount = ((BaseUnityPlugin)this).Config.Bind<float>("Casino", "BlackMarketDiscount", 0.2f, new ConfigDescription("Discount (0-0.9) the black market kiosk gives compared to the ship terminal price.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.9f), Array.Empty<object>()));
			MysteryCratePrice = ((BaseUnityPlugin)this).Config.Bind<int>("Casino", "MysteryCratePrice", 120, "Chip cost of one mystery crate.");
			NeonIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "NeonIntensity", 6f, "Brightness multiplier for neon signs and strips.");
			LightIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "LightIntensity", 1f, "Brightness multiplier for the casino's lights.");
			CasinoExposure = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "CasinoExposure", 3f, "Fixed camera exposure (EV100) inside the casino. Lower = brighter.");
			CasinoMusicVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "CasinoMusicVolume", 0.35f, new ConfigDescription("Volume of the casino lounge music.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			SortMoonCatalogue = ((BaseUnityPlugin)this).Config.Bind<bool>("Terminal", "SortMoonCatalogue", true, "Group the terminal's MOONS list by the mod that adds each moon (vanilla first, then Lethal Mayhem, then other mods A-Z) and sort each group from easiest to hardest. Picks up moons from other mods automatically, including LethalLevelLoader moon packs.");
			ShowMoonRiskLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("Terminal", "ShowMoonRiskLevel", true, "Show each moon's risk level next to its name in the sorted MOONS list.");
			ShowMoonPrice = ((BaseUnityPlugin)this).Config.Bind<bool>("Terminal", "ShowMoonPrice", true, "Show each moon's route cost next to its name in the sorted MOONS list.");
			DevMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DevMode", false, "Enables chat commands for testing: /casino, /chips <n>, /credits <n>, /company, /lever, /tp <spot>, /portalhere, /where, /give <item>, /items.");
			ItemRegistry.RegisterAll();
			MonsterRegistry.RegisterAll();
			Harmony val = new Harmony("com.brandon.lethalmayhem");
			val.PatchAll(typeof(Plugin).Assembly);
			MoonCatalogue.Init(val);
			Log.LogInfo((object)"Lethal Mayhem 0.1.0 loaded.");
		}
	}
	internal class Runner : MonoBehaviour
	{
		private static Runner _instance;

		public static Runner Instance
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_instance == (Object)null)
				{
					GameObject val = new GameObject("LethalMayhem.Runner");
					Object.DontDestroyOnLoad((Object)val);
					((Object)val).hideFlags = (HideFlags)61;
					_instance = val.AddComponent<Runner>();
				}
				return _instance;
			}
		}
	}
}
namespace LethalMayhem.Util
{
	internal static class Build
	{
		public const int RoomLayer = 8;

		public const int InteractableLayer = 9;

		private static Shader _lit;

		private static readonly Dictionary<string, Material> MatCache = new Dictionary<string, Material>();

		private static Shader _unlit;

		private static TMP_FontAsset _font;

		private static AudioMixerGroup _mixer;

		private static Sprite _handIcon;

		private static Shader Lit
		{
			get
			{
				if ((Object)(object)_lit == (Object)null)
				{
					_lit = Shader.Find("HDRP/Lit");
				}
				if ((Object)(object)_lit == (Object)null)
				{
					Plugin.Log.LogError((object)"HDRP/Lit shader not found!");
				}
				return _lit;
			}
		}

		public static TMP_FontAsset Font
		{
			get
			{
				if ((Object)(object)_font == (Object)null && (Object)(object)HUDManager.Instance != (Object)null && (Object)(object)HUDManager.Instance.chatText != (Object)null)
				{
					_font = ((TMP_Text)HUDManager.Instance.chatText).font;
				}
				return _font;
			}
		}

		private static Sprite HandIcon
		{
			get
			{
				if ((Object)(object)_handIcon == (Object)null)
				{
					StartMatchLever val = Object.FindObjectOfType<StartMatchLever>();
					if ((Object)(object)val != (Object)null && (Object)(object)val.triggerScript != (Object)null)
					{
						_handIcon = val.triggerScript.hoverIcon;
					}
				}
				return _handIcon;
			}
		}

		public static void ClearCache()
		{
			foreach (Material value in MatCache.Values)
			{
				if ((Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
			}
			MatCache.Clear();
		}

		public static Material Solid(Color color, float smoothness = 0.35f, float metallic = 0f)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			string key = $"s{color}{smoothness}{metallic}";
			if (MatCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = new Material(Lit);
			val.SetColor("_BaseColor", color);
			val.SetFloat("_Smoothness", smoothness);
			val.SetFloat("_Metallic", metallic);
			Validate(val);
			MatCache[key] = val;
			return val;
		}

		public static Material Textured(Texture2D tex, Vector2 tiling, float smoothness = 0.3f, float metallic = 0f, Color? tint = null)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			string key = $"t{((Object)tex).name}{tiling}{smoothness}{metallic}{tint}";
			if (MatCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = new Material(Lit);
			val.SetTexture("_BaseColorMap", (Texture)(object)tex);
			val.SetTextureScale("_BaseColorMap", tiling);
			val.SetColor("_BaseColor", (Color)(((??)tint) ?? Color.white));
			val.SetFloat("_Smoothness", smoothness);
			val.SetFloat("_Metallic", metallic);
			Validate(val);
			MatCache[key] = val;
			return val;
		}

		public static Material Neon(Color color, float intensity = 1f)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			string key = $"n{color}{intensity}";
			if (MatCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = new Material(Lit);
			val.SetColor("_BaseColor", color * 0.2f);
			val.SetFloat("_Smoothness", 0.6f);
			Color val2 = color * (Plugin.NeonIntensity.Value * intensity);
			val.SetColor("_EmissiveColor", val2);
			val.SetFloat("_EmissiveExposureWeight", 0f);
			val.SetFloat("_UseEmissiveIntensity", 0f);
			Validate(val);
			MatCache[key] = val;
			return val;
		}

		public static Material NeonTextured(Texture2D tex, Color color, float intensity, Vector2 tiling, Color? baseColor = null)
		{
			//IL_0016: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0085: 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_007c: 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_00b9: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			string key = $"nt{((Object)tex).name}{color}{intensity}{tiling}{baseColor}";
			if (MatCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = new Material(Lit);
			val.SetColor("_BaseColor", (Color)(((??)baseColor) ?? (color * 0.15f)));
			val.SetTexture("_BaseColorMap", (Texture)(object)tex);
			val.SetTextureScale("_BaseColorMap", tiling);
			val.SetTexture("_EmissiveColorMap", (Texture)(object)tex);
			val.SetTextureScale("_EmissiveColorMap", tiling);
			val.SetColor("_EmissiveColor", color * (Plugin.NeonIntensity.Value * intensity));
			val.SetFloat("_EmissiveExposureWeight", 0f);
			val.SetFloat("_UseEmissiveIntensity", 0f);
			val.SetFloat("_Smoothness", 0.4f);
			Validate(val);
			MatCache[key] = val;
			return val;
		}

		public static Material NeonInstance(Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//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_0042: Expected O, but got Unknown
			//IL_0043: Expected O, but got Unknown
			Material val = new Material(Lit);
			val.SetColor("_BaseColor", color * 0.2f);
			SetNeonColor(val, color);
			val.SetFloat("_EmissiveExposureWeight", 0f);
			Validate(val);
			return val;
		}

		public static void SetNeonColor(Material m, Color color, float intensity = 1f)
		{
			//IL_0006: 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)
			m.SetColor("_EmissiveColor", color * (Plugin.NeonIntensity.Value * intensity));
		}

		public static Material DoubleSided(Material src)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			string key = "ds" + ((Object)src).GetInstanceID();
			if (MatCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = new Material(src);
			val.SetFloat("_DoubleSidedEnable", 1f);
			val.SetFloat("_DoubleSidedNormalMode", 1f);
			val.SetFloat("_CullMode", 0f);
			val.SetFloat("_CullModeForward", 0f);
			Validate(val);
			MatCache[key] = val;
			return val;
		}

		public static Material Glass(Color color, float alpha, float smoothness = 0.92f, Texture2D tex = null, Vector2? tiling = null)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00c7: 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)
			string key = string.Format("g{0}{1}{2}{3}{4}", color, alpha, smoothness, ((Object)(object)tex != (Object)null) ? ((Object)tex).name : "", tiling);
			if (MatCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = new Material(Lit);
			val.SetColor("_BaseColor", new Color(color.r, color.g, color.b, alpha));
			if ((Object)(object)tex != (Object)null)
			{
				val.SetTexture("_BaseColorMap", (Texture)(object)tex);
				val.SetTextureScale("_BaseColorMap", (Vector2)(((??)tiling) ?? Vector2.one));
			}
			val.SetFloat("_Smoothness", smoothness);
			val.SetFloat("_SurfaceType", 1f);
			val.SetFloat("_BlendMode", 0f);
			val.SetFloat("_EnableBlendModePreserveSpecularLighting", 1f);
			val.SetFloat("_ZWrite", 0f);
			val.SetFloat("_TransparentZWrite", 0f);
			val.SetFloat("_DoubleSidedEnable", 1f);
			val.SetFloat("_CullMode", 0f);
			val.SetFloat("_CullModeForward", 0f);
			val.renderQueue = 3000;
			Validate(val);
			MatCache[key] = val;
			return val;
		}

		public static Material Particle(Texture2D tex, Color tint, bool additive)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			string key = $"p{((Object)tex).name}{tint}{additive}";
			if (MatCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			if ((Object)(object)_unlit == (Object)null)
			{
				_unlit = Shader.Find("HDRP/Unlit");
			}
			Material val = new Material(_unlit);
			val.SetTexture("_UnlitColorMap", (Texture)(object)tex);
			val.SetColor("_UnlitColor", tint);
			val.SetFloat("_SurfaceType", 1f);
			val.SetFloat("_BlendMode", additive ? 1f : 0f);
			val.SetFloat("_ZWrite", 0f);
			val.SetFloat("_CullMode", 0f);
			val.SetFloat("_DoubleSidedEnable", 1f);
			val.renderQueue = 3000;
			Validate(val);
			MatCache[key] = val;
			return val;
		}

		public static Material Cutout(Texture2D tex, Vector2 tiling, float cutoff = 0.5f, float smoothness = 0.3f, float metallic = 0f)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0076: 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)
			string key = $"c{((Object)tex).name}{tiling}{cutoff}{smoothness}{metallic}";
			if (MatCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = new Material(Lit);
			val.SetTexture("_BaseColorMap", (Texture)(object)tex);
			val.SetTextureScale("_BaseColorMap", tiling);
			val.SetColor("_BaseColor", Color.white);
			val.SetFloat("_Smoothness", smoothness);
			val.SetFloat("_Metallic", metallic);
			val.SetFloat("_AlphaCutoffEnable", 1f);
			val.SetFloat("_AlphaCutoff", cutoff);
			val.SetFloat("_DoubleSidedEnable", 1f);
			val.SetFloat("_CullMode", 0f);
			val.SetFloat("_CullModeForward", 0f);
			Validate(val);
			MatCache[key] = val;
			return val;
		}

		private static void Validate(Material m)
		{
			try
			{
				HDMaterial.ValidateMaterial(m);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("ValidateMaterial skipped: " + ex.Message));
			}
		}

		public static GameObject Box(Transform parent, string name, Vector3 localPos, Vector3 size, Material mat, bool collider = true, Quaternion? rot = null)
		{
			//IL_0028: 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_0040: 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)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = name;
			val.layer = 8;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localRotation = (Quaternion)(((??)rot) ?? Quaternion.identity);
			val.transform.localScale = size;
			((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = mat;
			if (!collider)
			{
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
			}
			return val;
		}

		public static GameObject Cylinder(Transform parent, string name, Vector3 localPos, float radius, float height, Material mat, bool collider = true, Quaternion? rot = null)
		{
			//IL_0027: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj).name = name;
			obj.layer = 8;
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = localPos;
			obj.transform.localRotation = (Quaternion)(((??)rot) ?? Quaternion.identity);
			obj.transform.localScale = new Vector3(radius * 2f, height / 2f, radius * 2f);
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = mat;
			Collider component = obj.GetComponent<Collider>();
			if (!collider)
			{
				Object.Destroy((Object)(object)component);
			}
			return obj;
		}

		public static GameObject Sphere(Transform parent, string name, Vector3 localPos, float radius, Material mat, bool collider = false)
		{
			//IL_0028: 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_003a: 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)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val).name = name;
			val.layer = 8;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localScale = Vector3.one * radius * 2f;
			((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = mat;
			if (!collider)
			{
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
			}
			return val;
		}

		public static TextMeshPro Text(Transform parent, string name, Vector3 localPos, string text, float size, Color color, float width = 4f, float height = 1f, Quaternion? rot = null, TextAlignmentOptions align = (TextAlignmentOptions)514)
		{
			//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_0013: 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_001f: 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_0031: 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_0053: 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_00b0: 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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localRotation = (Quaternion)(((??)rot) ?? Quaternion.identity) * Quaternion.Euler(0f, 180f, 0f);
			TextMeshPro val2 = val.AddComponent<TextMeshPro>();
			if ((Object)(object)Font != (Object)null)
			{
				((TMP_Text)val2).font = Font;
			}
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = size;
			((TMP_Text)val2).enableAutoSizing = true;
			((TMP_Text)val2).fontSizeMax = size;
			((TMP_Text)val2).fontSizeMin = size * 0.2f;
			((Graphic)val2).color = color;
			((TMP_Text)val2).alignment = align;
			((TMP_Text)val2).enableWordWrapping = false;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
			((TMP_Text)val2).rectTransform.sizeDelta = new Vector2(width, height);
			return val2;
		}

		public static void PointLight(Transform parent, Vector3 localPos, Color color, float lumens, float range)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_001e: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Light");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			try
			{
				HDAdditionalLightData obj = GameObjectExtension.AddHDLight(val, (HDLightTypeAndShape)0);
				obj.SetColor(color, -1f);
				obj.SetIntensity(lumens * Plugin.LightIntensity.Value, (LightUnit)0);
				obj.SetRange(range);
				obj.EnableShadows(false);
				obj.volumetricDimmer = 0f;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("HD light setup failed, using plain light: " + ex.Message));
				Light obj2 = val.GetComponent<Light>() ?? val.AddComponent<Light>();
				obj2.type = (LightType)2;
				obj2.color = color;
				obj2.range = range;
				obj2.intensity = lumens * Plugin.LightIntensity.Value;
			}
		}

		public static AudioSource Audio(Transform parent, Vector3 localPos, float maxDistance = 20f, float spatial = 1f)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			GameObject val = new GameObject("Audio");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.playOnAwake = false;
			val2.spatialBlend = spatial;
			val2.rolloffMode = (AudioRolloffMode)1;
			val2.minDistance = 2f;
			val2.maxDistance = maxDistance;
			val2.dopplerLevel = 0f;
			if ((Object)(object)_mixer == (Object)null && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.shipDoorAudioSource != (Object)null)
			{
				_mixer = StartOfRound.Instance.shipDoorAudioSource.outputAudioMixerGroup;
			}
			if ((Object)(object)_mixer != (Object)null)
			{
				val2.outputAudioMixerGroup = _mixer;
			}
			return val2;
		}

		public static void OneShotAt(Vector3 position, AudioClip clip, float volume = 1f, float maxDistance = 30f)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			if (!((Object)(object)clip == (Object)null))
			{
				GameObject val = new GameObject("OneShot");
				val.transform.position = position;
				AudioSource val2 = val.AddComponent<AudioSource>();
				val2.spatialBlend = 1f;
				val2.rolloffMode = (AudioRolloffMode)1;
				val2.minDistance = 2f;
				val2.maxDistance = maxDistance;
				val2.dopplerLevel = 0f;
				if ((Object)(object)_mixer == (Object)null && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.shipDoorAudioSource != (Object)null)
				{
					_mixer = StartOfRound.Instance.shipDoorAudioSource.outputAudioMixerGroup;
				}
				if ((Object)(object)_mixer != (Object)null)
				{
					val2.outputAudioMixerGroup = _mixer;
				}
				val2.PlayOneShot(clip, volume);
				Object.Destroy((Object)val, clip.length + 0.2f);
			}
		}

		public static GrabbableObject SpawnItem(Item item, Vector3 position, int scrapValue)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Transform propsContainer = StartOfRound.Instance.propsContainer;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(Random.Range(-0.2f, 0.2f), 0f, Random.Range(-0.2f, 0.2f));
			GameObject obj = Object.Instantiate<GameObject>(item.spawnPrefab, position + val + Vector3.up * 0.3f, Quaternion.identity, propsContainer);
			GrabbableObject component = obj.GetComponent<GrabbableObject>();
			if ((Object)(object)component != (Object)null)
			{
				component.fallTime = 0f;
				if (scrapValue > 0)
				{
					component.SetScrapValue(scrapValue);
				}
			}
			NetworkObject component2 = obj.GetComponent<NetworkObject>();
			component2.Spawn(false);
			if (scrapValue > 0 && (Object)(object)RoundManager.Instance != (Object)null)
			{
				RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(component2) }, new int[1] { scrapValue });
			}
			return component;
		}

		public static InteractTrigger Button(Transform parent, string name, Vector3 localPos, Vector3 size, string tip, Action<PlayerControllerB> onUse, float holdSeconds = 0f, string holdTip = null)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0040: 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_004c: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			GameObject val = new GameObject(name)
			{
				layer = 9,
				tag = "InteractTrigger"
			};
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			BoxCollider obj = val.AddComponent<BoxCollider>();
			obj.size = size;
			((Collider)obj).isTrigger = true;
			InteractTrigger obj2 = val.AddComponent<InteractTrigger>();
			obj2.hoverIcon = HandIcon;
			obj2.disabledHoverIcon = HandIcon;
			obj2.hoverTip = tip;
			obj2.disabledHoverTip = tip;
			obj2.interactable = true;
			obj2.oneHandedItemAllowed = true;
			obj2.twoHandedItemAllowed = true;
			obj2.holdInteraction = holdSeconds > 0f;
			obj2.timeToHold = Mathf.Max(holdSeconds, 0.01f);
			obj2.timeToHoldSpeedMultiplier = 1f;
			obj2.holdTip = holdTip ?? tip;
			obj2.interactCooldown = true;
			obj2.cooldownTime = 0.35f;
			obj2.disableTriggerMesh = false;
			obj2.holdingInteractEvent = new InteractEventFloat();
			obj2.onInteract = new InteractEvent();
			obj2.onInteractEarly = new InteractEvent();
			obj2.onInteractEarlyOtherClients = new InteractEvent();
			obj2.onStopInteract = new InteractEvent();
			obj2.onCancelAnimation = new InteractEvent();
			((UnityEvent<PlayerControllerB>)(object)obj2.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate(PlayerControllerB p)
			{
				if ((Object)(object)p == (Object)null || (Object)(object)p != (Object)(object)StartOfRound.Instance.localPlayerController)
				{
					return;
				}
				try
				{
					onUse(p);
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)$"Button '{name}' failed: {arg}");
				}
			});
			return obj2;
		}

		public static Color Hex(string hex)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			if (!ColorUtility.TryParseHtmlString(hex, ref result))
			{
				return Color.magenta;
			}
			return result;
		}
	}
	internal class IconPainter
	{
		private const int Size = 128;

		private readonly Color32[] _px = (Color32[])(object)new Color32[16384];

		public IconPainter Circle(float cx, float cy, float r, Color c)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return Fill((float x, float y) => Sq(x - cx) + Sq(y - cy) <= r * r, c);
		}

		public IconPainter Ring(float cx, float cy, float r, float width, Color c)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return Fill(delegate(float x, float y)
			{
				float num = Mathf.Sqrt(Sq(x - cx) + Sq(y - cy));
				return num <= r && num >= r - width;
			}, c);
		}

		public IconPainter Rect(float x0, float y0, float x1, float y1, Color c)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return Fill((float num, float num2) => num >= x0 && num <= x1 && num2 >= y0 && num2 <= y1, c);
		}

		public IconPainter Ellipse(float cx, float cy, float rx, float ry, Color c)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return Fill((float x, float y) => Sq((x - cx) / rx) + Sq((y - cy) / ry) <= 1f, c);
		}

		public IconPainter Tri(Vector2 a, Vector2 b, Vector2 c, Color col)
		{
			//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_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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			return Fill(delegate(float x, float y)
			{
				//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_000f: 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_001c: 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_002e: 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)
				Vector2 p = new Vector2(x, y);
				float num = Side(p, a, b);
				float num2 = Side(p, b, c);
				float num3 = Side(p, c, a);
				bool flag = num < 0f || num2 < 0f || num3 < 0f;
				bool flag2 = num > 0f || num2 > 0f || num3 > 0f;
				return !(flag && flag2);
			}, col);
		}

		public IconPainter Line(float x0, float y0, float x1, float y1, float width, Color c)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			return Fill(delegate(float num, float num2)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: 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_0063: 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_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: 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_007c: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(x0, y0);
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(x1, y1);
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor(num, num2);
				float num3 = Vector2.Dot(val3 - val, val2 - val);
				Vector2 val4 = val2 - val;
				float num4 = Mathf.Clamp01(num3 / Mathf.Max(((Vector2)(ref val4)).sqrMagnitude, 1E-06f));
				val4 = val + (val2 - val) * num4 - val3;
				return ((Vector2)(ref val4)).magnitude <= width / 2f;
			}, c);
		}

		public Sprite ToSprite(string name)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				name = name,
				filterMode = (FilterMode)1
			};
			val.SetPixels32(_px);
			val.Apply(false, true);
			return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f);
		}

		private IconPainter Fill(Func<float, float, bool> inside, Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Color32 val = Color32.op_Implicit(c);
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					if (inside(((float)j + 0.5f) / 128f, ((float)i + 0.5f) / 128f))
					{
						_px[i * 128 + j] = val;
					}
				}
			}
			return this;
		}

		private static float Sq(float v)
		{
			return v * v;
		}

		private static float Side(Vector2 p, Vector2 a, Vector2 b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			return (p.x - b.x) * (a.y - b.y) - (a.x - b.x) * (p.y - b.y);
		}
	}
	internal static class Noise
	{
		private static int Hash(int x, int y, int seed)
		{
			uint num = (uint)(seed * -1640531535);
			num ^= (uint)(x * -2048144777);
			num = ((num << 13) | (num >> 19)) * 3266489917u;
			num ^= (uint)(y * 668265263);
			num = ((num << 13) | (num >> 19)) * 374761393;
			num ^= num >> 15;
			num *= 2246822519u;
			num ^= num >> 13;
			num *= 3266489917u;
			return (int)(num ^ (num >> 16));
		}

		private static float Grad(int hash, float x, float y)
		{
			return (hash & 7) switch
			{
				0 => x + y, 
				1 => 0f - x + y, 
				2 => x - y, 
				3 => 0f - x - y, 
				4 => x, 
				5 => 0f - x, 
				6 => y, 
				_ => 0f - y, 
			};
		}

		private static float Fade(float t)
		{
			return t * t * t * (t * (t * 6f - 15f) + 10f);
		}

		private static int Wrap(int i, int period)
		{
			if (period > 0)
			{
				return (i % period + period) % period;
			}
			return i;
		}

		public static float Perlin(float x, float y, int seed, int period = 0)
		{
			int num = Mathf.FloorToInt(x);
			int num2 = Mathf.FloorToInt(y);
			float num3 = x - (float)num;
			float num4 = y - (float)num2;
			int x2 = Wrap(num, period);
			int x3 = Wrap(num + 1, period);
			int y2 = Wrap(num2, period);
			int y3 = Wrap(num2 + 1, period);
			float num5 = Grad(Hash(x2, y2, seed), num3, num4);
			float num6 = Grad(Hash(x3, y2, seed), num3 - 1f, num4);
			float num7 = Grad(Hash(x2, y3, seed), num3, num4 - 1f);
			float num8 = Grad(Hash(x3, y3, seed), num3 - 1f, num4 - 1f);
			float num9 = Fade(num3);
			float num10 = Fade(num4);
			return Mathf.Lerp(Mathf.Lerp(num5, num6, num9), Mathf.Lerp(num7, num8, num9), num10) * 0.9f;
		}

		public static float TileFbm(float u, float v, int freq, int octaves, int seed, float gain = 0.5f)
		{
			float num = 0f;
			float num2 = 1f;
			float num3 = 0f;
			for (int i = 0; i < octaves; i++)
			{
				int num4 = freq << i;
				num += Perlin(u * (float)num4, v * (float)num4, seed + i * 101, num4) * num2;
				num3 += num2;
				num2 *= gain;
			}
			return Mathf.Clamp01(num / num3 * 0.5f + 0.5f);
		}

		public static float Fbm(float x, float y, int octaves, int seed, float gain = 0.5f, float lacunarity = 2f)
		{
			float num = 0f;
			float num2 = 1f;
			float num3 = 0f;
			float num4 = 1f;
			for (int i = 0; i < octaves; i++)
			{
				num += Perlin(x * num4, y * num4, seed + i * 101) * num2;
				num3 += num2;
				num2 *= gain;
				num4 *= lacunarity;
			}
			return Mathf.Clamp01(num / num3 * 0.5f + 0.5f);
		}

		public static float Ridged(float x, float y, int octaves, int seed)
		{
			float num = 0f;
			float num2 = 0.5f;
			float num3 = 1f;
			float num4 = 1f;
			for (int i = 0; i < octaves; i++)
			{
				float num5 = 1f - Mathf.Abs(Perlin(x * num3, y * num3, seed + i * 131));
				num5 *= num5;
				num += num5 * num2 * num4;
				num4 = num5;
				num2 *= 0.5f;
				num3 *= 2f;
			}
			return Mathf.Clamp01(num);
		}

		public static void TileWorley(float u, float v, int cells, int seed, out float f1, out float f2, out int cellId)
		{
			float num = u * (float)cells;
			float num2 = v * (float)cells;
			int num3 = Mathf.FloorToInt(num);
			int num4 = Mathf.FloorToInt(num2);
			f1 = (f2 = 9f);
			cellId = 0;
			for (int i = -1; i <= 1; i++)
			{
				for (int j = -1; j <= 1; j++)
				{
					int num5 = num3 + j;
					int num6 = num4 + i;
					int num7 = Hash(Wrap(num5, cells), Wrap(num6, cells), seed);
					float num8 = (float)num5 + (float)(num7 & 0x3FF) / 1023f;
					float num9 = (float)num6 + (float)((num7 >> 10) & 0x3FF) / 1023f;
					float num10 = Mathf.Sqrt((num8 - num) * (num8 - num) + (num9 - num2) * (num9 - num2));
					if (num10 < f1)
					{
						f2 = f1;
						f1 = num10;
						cellId = num7;
					}
					else if (num10 < f2)
					{
						f2 = num10;
					}
				}
			}
		}

		public static float Smooth(float edge0, float edge1, float x)
		{
			float num = Mathf.Clamp01((x - edge0) / (edge1 - edge0));
			return num * num * (3f - 2f * num);
		}

		public static float Value(int x, int y, int seed)
		{
			return (float)(Hash(x, y, seed) & 0xFFFFFF) / 16777215f;
		}
	}
	internal static class ProcTex
	{
		private const int Size = 256;

		private static readonly Dictionary<string, Texture2D> Cache = new Dictionary<string, Texture2D>();

		public static Texture2D Carpet => Get("carpet", CarpetPixel);

		public static Texture2D Damask => Get("damask", DamaskPixel);

		public static Texture2D Marble => Get("marble", MarblePixel);

		public static Texture2D Wood => Get("wood", WoodPixel);

		public static Texture2D Felt => Get("felt", FeltPixel);

		public static Texture2D Velvet => Get("velvet", VelvetPixel);

		private static Texture2D Get(string name, Func<float, float, Color> pixel)
		{
			return Paint(name, pixel);
		}

		public static Texture2D Paint(string name, Func<float, float, Color> pixel, int size = 256)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (Cache.TryGetValue(name, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = new Texture2D(size, size, (TextureFormat)4, true)
			{
				name = "mayhem_" + name,
				wrapMode = (TextureWrapMode)0,
				filterMode = (FilterMode)2,
				anisoLevel = 4
			};
			Color[] array = (Color[])(object)new Color[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					array[i * size + j] = pixel((float)j / (float)size, (float)i / (float)size);
				}
			}
			value.SetPixels(array);
			value.Apply(true, true);
			Cache[name] = value;
			return value;
		}

		private static float TileNoise(float u, float v, float scale, float seed)
		{
			float num = u * MathF.PI * 2f;
			float num2 = v * MathF.PI * 2f;
			return Mathf.PerlinNoise(seed + Mathf.Cos(num) * scale, seed + Mathf.Sin(num) * scale + Mathf.Cos(num2) * scale * 0.7f) * 0.5f + Mathf.PerlinNoise(seed * 2f + Mathf.Cos(num2) * scale, seed + Mathf.Sin(num2) * scale) * 0.5f;
		}

		private static Color C(string hex)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			if (!ColorUtility.TryParseHtmlString(hex, ref result))
			{
				return Color.magenta;
			}
			return result;
		}

		private static Color CarpetPixel(float u, float v)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			//IL_008e: 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_010d: 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_00cd: 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_00b4: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			Color val = C("#4A0A16");
			Color val2 = C("#C7963A");
			Color val3 = C("#1E6A70");
			Color val4 = C("#2A0A2E");
			Color val5 = C("#E8C98A");
			float num = u * 2f % 1f;
			float num2 = v * 2f % 1f;
			float num3 = Mathf.Abs(num - 0.5f);
			float num4 = Mathf.Abs(num2 - 0.5f);
			float num5 = num3 + num4;
			Color val6 = val;
			if (Mathf.Abs(num5 - 0.5f) < 0.025f)
			{
				val6 = val2;
			}
			else if (num5 < 0.18f)
			{
				val6 = ((((int)(u * 2f) + (int)(v * 2f)) % 2 == 0) ? val3 : val4);
			}
			else if (Mathf.Abs(num5 - 0.24f) < 0.02f)
			{
				val6 = val5;
			}
			else if (num5 > 0.5f && Mathf.Min(num3, num4) < 0.03f)
			{
				val6 = Color.Lerp(val, val2, 0.5f);
			}
			float num6 = TileNoise(u, v, 8f, 3.1f);
			return val6 * (0.85f + 0.3f * num6);
		}

		private static Color DamaskPixel(float u, float v)
		{
			//IL_0005: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_00ac: 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_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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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)
			Color val = C("#2B0F30");
			Color val2 = C("#3F1A45");
			Color val3 = C("#7A5E28");
			float num = u * 2f % 1f;
			float num2 = v * 2f % 1f;
			float num3 = (num - 0.5f) * 2f;
			float num4 = (num2 - 0.5f) * 2f;
			float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4);
			float num6 = Mathf.Atan2(num4, num3);
			float num7 = 0.55f + 0.25f * Mathf.Cos(num6 * 6f);
			Color val4 = val;
			if (num5 < num7 && num5 > num7 - 0.12f)
			{
				val4 = val2;
			}
			if (num5 < 0.18f)
			{
				val4 = val2;
			}
			if (Mathf.Abs(Mathf.Abs(num3) + Mathf.Abs(num4) - 1.6f) < 0.04f)
			{
				val4 = val3;
			}
			return val4 * (0.9f + 0.2f * TileNoise(u, v, 12f, 7.7f));
		}

		private static Color MarblePixel(float u, float v)
		{
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00cb: 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)
			float num = TileNoise(u, v, 3f, 1.3f) * 6f + TileNoise(u, v, 9f, 4.2f) * 1.5f;
			float x = Mathf.Abs(Mathf.Sin((u + v) * MathF.PI * 4f + num));
			Color val = Color.Lerp(C("#EDE7DA"), C("#D8CFBF"), TileNoise(u, v, 5f, 9.9f));
			Color val2 = Color.Lerp(C("#6E6A66"), val, Noise.Smooth(0f, 0.12f, x));
			if (u * 2f % 1f < 0.008f || v * 2f % 1f < 0.008f)
			{
				val2 *= 0.75f;
			}
			return val2;
		}

		private static Color WoodPixel(float u, float v)
		{
			//IL_0032: 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_0050: 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)
			float num = TileNoise(u, v, 4f, 2.2f);
			float num2 = Mathf.Sin((v * 40f + num * 8f) * MathF.PI);
			Color val = C("#2E120A");
			Color val2 = C("#5A2A14");
			return Color.Lerp(val, val2, 0.5f + 0.35f * num2) * (0.9f + 0.2f * TileNoise(u, v, 20f, 5.5f));
		}

		private static Color FeltPixel(float u, float v)
		{
			//IL_0005: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			return Color.Lerp(C("#0B4A24"), C("#136B34"), TileNoise(u, v, 30f, 8.8f));
		}

		private static Color VelvetPixel(float u, float v)
		{
			//IL_0005: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			return Color.Lerp(C("#3A0716"), C("#6A0F28"), Mathf.Pow(TileNoise(u, v, 14f, 6.6f), 1.5f));
		}
	}
	internal static class Shapes
	{
		internal sealed class Batch
		{
			private readonly Dictionary<Material, List<CombineInstance>> _parts = new Dictionary<Material, List<CombineInstance>>();

			public void Add(Mesh mesh, Material mat, Vector3 pos, Quaternion rot, Vector3 scale)
			{
				//IL_0026: 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_0037: 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_003b: 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)
				if (!_parts.TryGetValue(mat, out var value))
				{
					value = (_parts[mat] = new List<CombineInstance>());
				}
				List<CombineInstance> list2 = value;
				CombineInstance item = default(CombineInstance);
				((CombineInstance)(ref item)).mesh = mesh;
				((CombineInstance)(ref item)).transform = Matrix4x4.TRS(pos, rot, scale);
				list2.Add(item);
			}

			public void Beam(Material mat, Vector3 a, Vector3 b, float thickness, bool round = false)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_002b: 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_002d: 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_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: 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_006e: 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)
				Vector3 val = b - a;
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (!(magnitude < 0.0001f))
				{
					Add(round ? Cylinder : Cube, mat, (a + b) * 0.5f, round ? Quaternion.FromToRotation(Vector3.up, val) : Quaternion.LookRotation(val), round ? new Vector3(thickness, magnitude * 0.5f, thickness) : new Vector3(thickness, thickness, magnitude));
				}
			}

			public void Flush(Transform parent, string name)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				//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_005b: 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)
				foreach (KeyValuePair<Material, List<CombineInstance>> part in _parts)
				{
					Mesh val = new Mesh
					{
						name = name,
						indexFormat = (IndexFormat)1
					};
					val.CombineMeshes(part.Value.ToArray(), true, true);
					val.RecalculateBounds();
					GameObject val2 = new GameObject(name)
					{
						layer = ((Component)parent).gameObject.layer
					};
					val2.transform.SetParent(parent, false);
					val2.AddComponent<MeshFilter>().sharedMesh = val;
					((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = part.Key;
				}
				_parts.Clear();
			}
		}

		private static readonly Dictionary<PrimitiveType, Mesh> Primitives = new Dictionary<PrimitiveType, Mesh>();

		private static readonly Dictionary<string, Mesh> Cache = new Dictionary<string, Mesh>();

		public static Mesh Cube => Primitive((PrimitiveType)3);

		public static Mesh Sphere => Primitive((PrimitiveType)0);

		public static Mesh Cylinder => Primitive((PrimitiveType)2);

		public static Mesh Capsule => Primitive((PrimitiveType)1);

		public static Mesh Quad => Primitive((PrimitiveType)5);

		public static Mesh Cone => Lathe("cone", (Vector2[])(object)new Vector2[2]
		{
			new Vector2(0.5f, -0.5f),
			new Vector2(0f, 0.5f)
		});

		public static Mesh Primitive(PrimitiveType type)
		{
			//IL_0005: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			if (Primitives.TryGetValue(type, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			GameObject obj = GameObject.CreatePrimitive(type);
			value = obj.GetComponent<MeshFilter>().sharedMesh;
			Object.Destroy((Object)(object)obj);
			Primitives[type] = value;
			return value;
		}

		public static Transform Part(Transform parent, Mesh mesh, Material mat, Vector3 pos, Vector3 scale, Vector3 euler = default(Vector3), string name = "Part")
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003e: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = ((Component)parent).gameObject.layer
			};
			val.transform.SetParent(parent, false);
			val.transform.localPosition = pos;
			val.transform.localEulerAngles = euler;
			val.transform.localScale = scale;
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat;
			return val.transform;
		}

		public static Mesh Lathe(string key, Vector2[] profile, int segments = 20, bool capBottom = true, bool capTop = true, float arcStartDeg = 0f, float arcEndDeg = 360f)
		{
			//IL_0061: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			float num = arcStartDeg * (MathF.PI / 180f);
			float num2 = arcEndDeg * (MathF.PI / 180f);
			List<Vector3> list = new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			List<int> list3 = new List<int>();
			int num3 = profile.Length;
			float[] array = new float[num3];
			for (int i = 1; i < num3; i++)
			{
				array[i] = array[i - 1] + Vector2.Distance(profile[i], profile[i - 1]);
			}
			float num4 = Mathf.Max(array[num3 - 1], 0.0001f);
			for (int j = 0; j < num3; j++)
			{
				for (int k = 0; k <= segments; k++)
				{
					float num5 = Mathf.Lerp(num, num2, (float)k / (float)segments);
					list.Add(new Vector3(Mathf.Cos(num5) * profile[j].x, profile[j].y, Mathf.Sin(num5) * profile[j].x));
					list2.Add(new Vector2((float)k / (float)segments, array[j] / num4));
				}
			}
			int num6 = segments + 1;
			for (int l = 0; l < num3 - 1; l++)
			{
				for (int m = 0; m < segments; m++)
				{
					int num7 = l * num6 + m;
					int num8 = num7 + 1;
					int num9 = num7 + num6;
					int num10 = num9 + 1;
					list3.AddRange(new int[6] { num7, num9, num8, num8, num9, num10 });
				}
			}
			if (capBottom)
			{
				Cap(list, list3, profile[0], segments, top: false);
			}
			if (capTop)
			{
				Cap(list, list3, profile[num3 - 1], segments, top: true);
			}
			while (list2.Count < list.Count)
			{
				list2.Add(new Vector2(0.5f, 0.5f));
			}
			Mesh val = new Mesh
			{
				name = key
			};
			val.SetVertices(list);
			val.SetUVs(0, list2);
			val.SetTriangles(list3, 0);
			val.RecalculateNormals();
			val.RecalculateBounds();
			Cache[key] = val;
			return val;
		}

		private static void Cap(List<Vector3> verts, List<int> tris, Vector2 ring, int segments, bool top)
		{
			//IL_0000: 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_0026: 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_005b: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			if (ring.x <= 0.0001f)
			{
				return;
			}
			int count = verts.Count;
			verts.Add(new Vector3(0f, ring.y, 0f));
			int count2 = verts.Count;
			for (int i = 0; i <= segments; i++)
			{
				float num = (float)i / (float)segments * MathF.PI * 2f;
				verts.Add(new Vector3(Mathf.Cos(num) * ring.x, ring.y, Mathf.Sin(num) * ring.x));
			}
			for (int j = 0; j < segments; j++)
			{
				if (top)
				{
					tris.AddRange(new int[3]
					{
						count,
						count2 + j + 1,
						count2 + j
					});
				}
				else
				{
					tris.AddRange(new int[3]
					{
						count,
						count2 + j,
						count2 + j + 1
					});
				}
			}
		}

		public static Mesh Torus(float thickness = 0.12f)
		{
			//IL_00b3: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			string text = $"torus{thickness}";
			if (Cache.TryGetValue(text, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i <= 24; i++)
			{
				float num = (float)i / 24f * MathF.PI * 2f;
				((Vector3)(ref val))..ctor(Mathf.Cos(num) * 0.5f, 0f, Mathf.Sin(num) * 0.5f);
				for (int j = 0; j <= 10; j++)
				{
					float num2 = (float)j / 10f * MathF.PI * 2f;
					((Vector3)(ref val2))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num));
					list.Add(val + val2 * (Mathf.Cos(num2) * thickness) + Vector3.up * (Mathf.Sin(num2) * thickness));
				}
			}
			int num3 = 11;
			for (int k = 0; k < 24; k++)
			{
				for (int l = 0; l < 10; l++)
				{
					int num4 = k * num3 + l;
					int num5 = num4 + num3;
					list2.AddRange(new int[6]
					{
						num4,
						num4 + 1,
						num5,
						num4 + 1,
						num5 + 1,
						num5
					});
				}
			}
			Mesh val3 = new Mesh
			{
				name = text
			};
			val3.SetVertices(list);
			val3.SetTriangles(list2, 0);
			val3.RecalculateNormals();
			val3.RecalculateBounds();
			Cache[text] = val3;
			return val3;
		}

		public static Transform Beam(Transform parent, Material mat, Vector3 a, Vector3 b, float thickness, bool round = false)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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_0032: 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_005c: 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_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_0081: 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_0087: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = b - a;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude < 0.0001f)
			{
				val = Vector3.up;
			}
			Transform obj = Part(parent, round ? Cylinder : Cube, mat, (a + b) * 0.5f, round ? new Vector3(thickness, magnitude * 0.5f, thickness) : new Vector3(thickness, thickness, magnitude), default(Vector3), "Beam");
			obj.localRotation = (round ? Quaternion.FromToRotation(Vector3.up, val) : Quaternion.LookRotation(val));
			return obj;
		}

		public static Mesh Tube(IList<Vector3> points, float radius, int sides = 6)
		{
			//IL_004a: 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)
			//IL_0057: 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_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_005c: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			//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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_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_00ca: 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)
			//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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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)
			List<Vector3> list = new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			List<int> list3 = new List<int>();
			float num = 0f;
			for (int i = 0; i < points.Count; i++)
			{
				Vector3 val = ((i < points.Count - 1) ? (points[i + 1] - points[i]) : (points[i] - points[i - 1]));
				if (i > 0 && i < points.Count - 1)
				{
					val = points[i + 1] - points[i - 1];
				}
				if (((Vector3)(ref val)).sqrMagnitude < 1E-08f)
				{
					val = Vector3.forward;
				}
				Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, (Mathf.Abs(Vector3.Dot(((Vector3)(ref val)).normalized, Vector3.up)) > 0.99f) ? Vector3.right : Vector3.up);
				if (i > 0)
				{
					num += Vector3.Distance(points[i], points[i - 1]);
				}
				for (int j = 0; j <= sides; j++)
				{
					float num2 = (float)j / (float)sides * MathF.PI * 2f;
					list.Add(points[i] + val2 * new Vector3(Mathf.Cos(num2) * radius, Mathf.Sin(num2) * radius, 0f));
					list2.Add(new Vector2((float)j / (float)sides, num));
				}
			}
			int num3 = sides + 1;
			for (int k = 0; k < points.Count - 1; k++)
			{
				for (int l = 0; l < sides; l++)
				{
					int num4 = k * num3 + l;
					int num5 = num4 + 1;
					int num6 = num4 + num3;
					int num7 = num6 + 1;
					list3.AddRange(new int[6] { num4, num5, num6, num5, num7, num6 });
				}
			}
			Mesh val3 = new Mesh
			{
				name = "tube"
			};
			if (list.Count > 65000)
			{
				val3.indexFormat = (IndexFormat)1;
			}
			val3.SetVertices(list);
			val3.SetUVs(0, list2);
			val3.SetTriangles(list3, 0);
			val3.RecalculateNormals();
			val3.RecalculateBounds();
			return val3;
		}

		public static List<Vector3> Sag(Vector3 a, Vector3 b, float sag, int steps = 12)
		{
			//IL_0014: 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_0017: 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_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)
			List<Vector3> list = new List<Vector3>(steps + 1);
			for (int i = 0; i <= steps; i++)
			{
				float num = (float)i / (float)steps;
				list.Add(Vector3.Lerp(a, b, num) + Vector3.down * (sag * 4f * num * (1f - num)));
			}
			return list;
		}

		public static Bounds LocalBounds(Transform root)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0096: 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_009d: 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)
			bool flag = false;
			Bounds result = default(Bounds);
			MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>();
			foreach (MeshFilter val in componentsInChildren)
			{
				if ((Object)(object)val.sharedMesh == (Object)null)
				{
					continue;
				}
				Bounds bounds = val.sharedMesh.bounds;
				for (int j = 0; j < 8; j++)
				{
					Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1))));
					Vector3 val3 = root.InverseTransformPoint(((Component)val).transform.TransformPoint(val2));
					if (!flag)
					{
						((Bounds)(ref result))..ctor(val3, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref result)).Encapsulate(val3);
					}
				}
			}
			return result;
		}
	}
	internal static class Synth
	{
		private const int Rate = 44100;

		private static AudioClip _tick;

		private static AudioClip _win;

		private static AudioClip _bigWin;

		private static AudioClip _jackpot;

		private static AudioClip _lose;

		private static AudioClip _coin;

		private static AudioClip _alarm;

		private static AudioClip _buzz;

		private static AudioClip _music;

		private static AudioClip _whoosh;

		private static AudioClip _ding;

		private static AudioClip _pop;

		private static AudioClip _fuse;

		private static AudioClip _airHorn;

		private static AudioClip _squeak;

		private static AudioClip _slip;

		private static AudioClip _hiss;

		private static AudioClip _punch;

		private static AudioClip _zap;

		private static AudioClip _squelch;

		private static AudioClip _partyHorn;

		private static AudioClip _coin2;

		private static AudioClip _chomp;

		private static AudioClip _creak;

		private static AudioClip _fall;

		private static AudioClip _laugh;

		private static AudioClip _dice;

		private static AudioClip _warp;

		private static AudioClip _pinPull;

		private static AudioClip _caw;

		private static AudioClip _growl;

		private static AudioClip _disco;

		private static AudioClip _dingDing;

		private static AudioClip _giggle;

		private static readonly Random Rng = new Random(1234);

		private static AudioClip _calliope;

		private static AudioClip _deadOrgan;

		private static AudioClip _strikerBell;

		private static AudioClip _crystal;

		private static AudioClip _radio;

		private static AudioClip _thunk;

		private static AudioClip _clownHonk;

		private static AudioClip _wind;

		private static readonly int[] WaltzMelody = new int[48]
		{
			3, 7, 10, 12, 10, 7, 8, 12, 15, 12,
			-99, -99, 10, 8, 7, 5, 7, 8, 7, 3,
			5, 3, -99, -99, 3, 7, 10, 15, 14, 12,
			10, 12, 14, 15, -99, -99, 17, 15, 14, 12,
			10, 8, 7, 10, 5, 3, -99, -99
		};

		private static readonly int[] WaltzBass = new int[16]
		{
			-21, -14, -16, -14, -18, -11, -16, -21, -21, -14,
			-16, -9, -11, -14, -16, -21
		};

		private static AudioClip _morse;

		private static AudioClip _iceCrack;

		private static AudioClip _fire;

		private static AudioClip _groan;

		private static AudioClip _boing;

		private static AudioClip _puff;

		private static AudioClip _chime;

		private static AudioClip _snore;

		private static AudioClip _waterfall;

		private static AudioClip _forest;

		public static AudioClip Tick => _tick ?? (_tick = Make("mayhem_tick", 0.035f, (float t) => Square(t, 1400f) * Env(t, 0.001f, 0.03f) * 0.5f));

		public static AudioClip Coin => _coin ?? (_coin = Make("mayhem_coin", 0.35f, (float t) => ((t < 0.08f) ? Sine(t, 1318.5f) : Sine(t, 1975.5f)) * Env(t, 0.002f, 0.33f) * 0.55f));

		public static AudioClip Ding => _ding ?? (_ding = Make("mayhem_ding", 0.6f, (float t) => (Sine(t, 1760f) + 0.4f * Sine(t, 3520f)) * Env(t, 0.002f, 0.58f) * 0.4f));

		public static AudioClip Win => _win ?? (_win = Arpeggio("mayhem_win", new float[4] { 523.25f, 659.25f, 783.99f, 1046.5f }, 0.09f, 0.35f));

		public static AudioClip BigWin => _bigWin ?? (_bigWin = Arpeggio("mayhem_bigwin", new float[8] { 523.25f, 659.25f, 783.99f, 1046.5f, 783.99f, 1046.5f, 1318.5f, 1568f }, 0.08f, 0.6f));

		public static AudioClip Lose => _lose ?? (_lose = Make("mayhem_lose", 0.7f, delegate(float t)
		{
			float f = Mathf.Lerp(330f, 110f, t / 0.7f);
			return Square(t, f) * Env(t, 0.01f, 0.68f) * 0.25f;
		}));

		public static AudioClip Buzz => _buzz ?? (_buzz = Make("mayhem_buzz", 0.25f, (float t) => Saw(t, 110f) * Env(t, 0.005f, 0.24f) * 0.3f));

		public static AudioClip Whoosh => _whoosh ?? (_whoosh = Make("mayhem_whoosh", 0.8f, (float t) => Noise() * Mathf.Sin(MathF.PI * t / 0.8f) * 0.35f * (0.5f + 0.5f * Sine(t, 3f))));

		public static AudioClip Alarm => _alarm ?? (_alarm = Make("mayhem_alarm", 1.6f, delegate(float t)
		{
			float f = ((t % 0.4f < 0.2f) ? 880f : 660f);
			return Square(t, f) * 0.22f * Env(t, 0.01f, 1.58f);
		}));

		public static AudioClip Jackpot => _jackpot ?? (_jackpot = Make("mayhem_jackpot", 3.2f, delegate(float t)
		{
			float[] array = new float[7] { 523.25f, 659.25f, 783.99f, 1046.5f, 1318.5f, 1568f, 2093f };
			int num = Mathf.Min((int)(t / 0.12f), array.Length - 1);
			float num2 = Square(t, array[num]) * 0.18f + Sine(t, array[num] * 2f) * 0.1f;
			float num3 = ((t > 0.9f) ? (Sine(t, 2637f + 600f * Mathf.Sin(t * 40f)) * 0.12f * (float)((int)(t * 20f) % 2)) : 0f);
			return (num2 + num3) * Env(t, 0.005f, 3.1f);
		}));

		public static AudioClip Pop => _pop ?? (_pop = Make("mayhem_pop", 0.9f, (float t) => Noise() * Env(t, 0.001f, 0.5f) * 0.8f + Sine(t, 55f + 40f * Mathf.Exp((0f - t) * 8f)) * Env(t, 0.002f, 0.85f) * 0.9f));

		public static AudioClip PinPull => _pinPull ?? (_pinPull = Make("mayhem_pin", 0.25f, (float t) => (Square(t, 2200f) * 0.2f + Noise() * 0.3f) * Env(t, 0.001f, 0.08f) + Sine(t, 900f) * Env(t, 0.1f, 0.12f) * ((t > 0.1f) ? 0.3f : 0f)));

		public static AudioClip Fuse => _fuse ?? (_fuse = Make("mayhem_fuse", 3f, (float t) => Noise() * (0.15f + 0.1f * Mathf.Sin(t * 60f)) * ((Rng.NextDouble() < 0.03) ? 3f : 1f) * 0.5f));

		public static AudioClip AirHorn => _airHorn ?? (_airHorn = Make("mayhem_airhorn", 1.4f, delegate(float t)
		{
			float num = 1f + 0.004f * Mathf.Sin(t * 30f);
			return Mathf.Clamp((Saw(t, 466f * num) + Saw(t, 587f * num) * 0.8f + Saw(t, 698f * num) * 0.6f) * 0.5f, -0.9f, 0.9f) * Env(t, 0.02f, 1.35f) * 0.9f;
		}));

		public static AudioClip Squeak => _squeak ?? (_squeak = Make("mayhem_squeak", 0.6f, (float t) => Sine(t, 900f + 1400f * t + 60f * Mathf.Sin(t * 50f)) * Env(t, 0.01f, 0.58f) * 0.45f));

		public static AudioClip Slip => _slip ?? (_slip = Make("mayhem_slip", 1f, (float t) => (!(t < 0.55f)) ? ((Noise() * 0.6f + Sine(t, 60f) * 0.8f) * Env(t - 0.55f, 0.002f, 0.4f)) : (Sine(t, 300f + 2200f * t) * Env(t, 0.01f, 0.55f) * 0.5f)));

		public static AudioClip Hiss => _hiss ?? (_hiss = Make("mayhem_hiss", 1.8f, (float t) => Noise() * Env(t, 0.05f, 1.75f) * 0.45f * (0.7f + 0.3f * Mathf.Sin(t * 9f))));

		public static AudioClip Punch => _punch ?? (_punch = Make("mayhem_punch", 0.35f, (float t) => (Sine(t, 80f + 60f * Mathf.Exp((0f - t) * 30f)) * 0.9f + Noise() * 0.4f * Env(t, 0.001f, 0.04f)) * Env(t, 0.001f, 0.33f)));

		public static AudioClip Zap => _zap ?? (_zap = Make("mayhem_zap", 0.45f, (float t) => (Square(t, 1800f + 600f * Mathf.Sin(t * 90f)) * 0.25f + Noise() * 0.35f) * Env(t, 0.002f, 0.43f) * (((int)(t * 60f) % 2 == 0) ? 1f : 0.3f)));

		public static AudioClip Squelch => _squelch ?? (_squelch = Make("mayhem_squelch", 0.6f, (float t) => (Noise() * 0.5f * (0.5f + 0.5f * Mathf.Sin(t * 70f)) + Sine(t, 120f - 60f * t) * 0.5f) * Env(t, 0.01f, 0.58f)));

		public static AudioClip PartyHorn => _partyHorn ?? (_partyHorn = Make("mayhem_partyhorn", 0.9f, (float t) => Mathf.Clamp(Saw(t, 320f + 180f * Mathf.Min(t * 6f, 1f)) * 0.8f + Square(t, 640f) * 0.1f, -0.8f, 0.8f) * Env(t, 0.01f, 0.88f)));

		public static AudioClip CoinFlip => _coin2 ?? (_coin2 = Make("mayhem_coinflip", 0.9f, (float t) => (Sine(t, 2637f) * 0.25f + Sine(t, 3951f) * 0.15f) * Env(t, 0.001f, 0.85f) * (0.6f + 0.4f * Mathf.Sin(t * 45f))));

		public static AudioClip Chomp => _chomp ?? (_chomp = Make("mayhem_chomp", 0.5f, delegate(float t)
		{
			float num = ((t < 0.12f) ? Env(t, 0.001f, 0.1f) : (Env(t - 0.2f, 0.001f, 0.25f) * ((t > 0.2f) ? 1f : 0f)));
			return (Noise() * 0.6f + Sine(t, 140f) * 0.6f) * num;
		}));

		public static AudioClip Creak => _creak ?? (_creak = Make("mayhem_creak", 0.9f, (float t) => Saw(t, 90f + 40f * t + 8f * Mathf.Sin(t * 13f)) * 0.3f * Env(t, 0.05f, 0.85f) * (0.6f + 0.4f * Mathf.Sin(t * 37f))));

		public static AudioClip FallWhistle => _fall ?? (_fall = Make("mayhem_fall", 1.4f, (float t) => Sine(t, 1500f - 900f * t) * Env(t, 0.02f, 1.38f) * 0.4f));

		public static AudioClip Laugh => _laugh ?? (_laugh = Make("mayhem_laugh", 1.8f, delegate(float t)
		{
			float num = Mathf.Max(0f, Mathf.Sin(t * MathF.PI * 5f));
			float num2 = 190f - 50f * t;
			return (Saw(t, num2) * 0.4f + Sine(t, num2 * 3.2f) * 0.2f + Sine(t, num2 * 5.1f) * 0.1f) * num * Env(t, 0.02f, 1.75f) * 0.6f;
		}));

		public static AudioClip DiceRattle => _dice ?? (_dice = Make("mayhem_dice", 0.8f, delegate(float t)
		{
			float num = 0f;
			float[] array = new float[7] { 0.02f, 0.11f, 0.18f, 0.3f, 0.37f, 0.52f, 0.6f };
			foreach (float num2 in array)
			{
				if (t >= num2)
				{
					num += (Square(t - num2, 3000f - num2 * 2000f) * 0.3f + Noise() * 0.2f) * Env(t - num2, 0.001f, 0.04f);
				}
			}
			return num;
		}));

		public static AudioClip Warp => _warp ?? (_warp = Make("mayhem_warp", 1.1f, (float t) => (Sine(t, 200f + 1800f * Mathf.Sin(t * MathF.PI / 1.1f)) * 0.35f + Noise() * 0.1f) * Env(t, 0.03f, 1.05f)));

		public static AudioClip Caw => _caw ?? (_caw = Make("mayhem_caw", 0.55f, delegate(float t)
		{
			float f = 520f - 260f * t + 40f * Mathf.Sin(t * 70f);
			return (Saw(t, f) * 0.5f + Noise() * 0.35f) * Env(t, 0.01f, 0.52f) * 0.7f;
		}));

		public static AudioClip Growl => _growl ?? (_growl = Make("mayhem_growl", 1.3f, (float t) => (Saw(t, 55f + 8f * Mathf.Sin(t * 11f)) * 0.5f + Noise() * 0.25f * (0.5f + 0.5f * Mathf.Sin(t * 23f))) * Env(t, 0.08f, 1.2f) * 0.8f));

		public static AudioClip Giggle => _giggle ?? (_giggle = Make("mayhem_giggle", 1.1f, delegate(float t)
		{
			float num = Mathf.Max(0f, Mathf.Sin(t * MathF.PI * 9f));
			float num2 = 520f + 120f * Mathf.Sin(t * 7f);
			return (Saw(t, num2) * 0.3f + Sine(t, num2 * 2.4f) * 0.25f) * num * Env(t, 0.01f, 1.05f) * 0.7f;
		}));

		public static AudioClip DingDing => _dingDing ?? (_dingDing = Make("mayhem_dingding", 0.9f, (float t) => ((t < 0.3f) ? ((Sine(t, 1568f) + 0.4f * Sine(t, 3136f)) * Env(t, 0.002f, 0.28f)) : ((Sine(t - 0.3f, 2093f) + 0.4f * Sine(t - 0.3f, 4186f)) * Env(t - 0.3f, 0.002f, 0.58f))) * 0.4f));

		public static AudioClip DiscoLoop => _disco ?? (_disco = Make("mayhem_disco", 4f, delegate(float t)
		{
			float num = 0.5f;
			float num2 = t % num;
			float num3 = Sine(num2, 60f + 90f * Mathf.Exp((0f - num2) * 30f)) * Env(num2, 0.001f, 0.2f) * 0.8f;
			float t2 = (t + num / 2f) % num;
			float num4 = Noise() * Env(t2, 0.001f, 0.05f) * 0.25f;
			float[] array = (((int)(t / 2f) % 2 != 0) ? new float[4] { 98f, 98f, 196f, 146.8f } : new float[4] { 110f, 110f, 220f, 110f });
			int num5 = (int)(t / num) % 4;
			float num6 = Square(t, array[num5]) * 0.18f * Env(num2, 0.005f, 0.4f);
			float num7 = (((int)(t / num) % 2 == 1) ? ((Saw(t, 440f) + Saw(t, 554f) + Saw(t, 659f)) * 0.05f * Env(num2, 0.005f, 0.15f)) : 0f);
			return num3 + num4 + num6 + num7;
		}, loopFade: false));

		public static AudioClip LoungeMusic => _music ?? (_music = BuildMusic());

		public static AudioClip Calliope => _calliope ?? (_calliope = Waltz("mayhem_calliope", 165f, 1f, 1f, 1f));

		public static AudioClip DeadOrgan => _deadOrgan ?? (_deadOrgan = Waltz("mayhem_deadorgan", 92f, 0.94f, 5f, 0.7f));

		public static AudioClip StrikerBell => _strikerBell ?? (_strikerBell = Make("mayhem_strikerbell", 2.2f, (float t) => (Sine(t, 1318f) * 0.5f + Sine(t, 2647.5479f) * 0.25f + Sine(t, 3951f) * 0.12f + Sine(t, 659f) * 0.2f) * Env(t, 0.001f, 2.1f) * 0.5f));

		public static AudioClip Thunk => _thunk ?? (_thunk = Make("mayhem_thunk", 0.45f, (float t) => (Sine(t, 70f + 140f * Mathf.Exp((0f - t) * 18f)) * 0.8f + Noise() * 0.3f * Mathf.Exp((0f - t) * 40f)) * Env(t, 0.001f, 0.42f)));

		public static AudioClip Crystal => _crystal ?? (_crystal = Make("mayhem_crystal", 3f, (float t) => (Sine(t, 523f) * 0.3f + Sine(t, 785.568f) * 0.2f + Sine(t, 1046f) * 0.1f) * (0.6f + 0.4f * Mathf.Sin(MathF.PI * 6f * t)) * Env(t, 0.4f, 2.6f) * 0.5f));

		public static AudioClip Radio => _radio ?? (_radio = Make("mayhem_radio", 9.6f, delegate(float t)
		{
			float num = 0.3f;
			int num2 = (int)(t / num);
			int[] array = new int[32]
			{
				0, 4, 7, 9, 7, 4, 2, 5, 9, 12,
				9, 5, 4, 7, 11, 14, 11, 7, 0, 4,
				7, 12, 7, 4, 5, 9, 12, 9, 7, 4,
				2, 0
			};
			float num3 = Note(array[num2 % array.Length] - 12);
			float t2 = t - (float)num2 * num;
			float num4 = (Square(t, num3) * 0.3f + Saw(t, num3 * 0.5f) * 0.15f) * Env(t2, 0.01f, num * 1.1f);
			float num5 = Noise() * ((Rng.NextDouble() < 0.002) ? 0.8f : 0.05f);
			return (num4 * 0.35f + num5) * (0.85f + 0.15f * Mathf.Sin(MathF.PI * 4f / 5f * t));
		}, loopFade: false));

		public static AudioClip ClownHonk => _clownHonk ?? (_clownHonk = Make("mayhem_honk", 0.5f, (float t) => (Saw(t, 330f + 30f * Mathf.Sin(t * 40f)) * 0.4f + Square(t, 660f) * 0.1f) * Env(t, 0.01f, 0.45f)));

		public static AudioClip Morse => _morse ?? (_morse = BuildMorse());

		public static AudioClip IceCrack => _iceCrack ?? (_iceCrack = Make("mayhem_icecrack", 1.6f, (float t) => (Noise() * Mathf.Exp((0f - t) * 18f) * 0.7f + Sine(t, 1800f * Mathf.Exp((0f - t) * 2f) + 300f) * Mathf.Exp((0f - t) * 3f) * 0.25f + Noise() * 0.2f * Mathf.Exp((0f - (t - 0.35f)) * (t - 0.35f) * 400f)) * 0.8f));

		public static AudioClip Groan => _groan ?? (_groan = Make("mayhem_groan", 3.5f, (float t) => (Sine(t, 42f + 8f * Mathf.Sin(t * 1.3f)) * 0.6f + Saw(t, 63f + 5f * Mathf.Sin(t * 0.9f)) * 0.12f) * Env(t, 0.8f, 2.6f) * 0.7f));

		public static AudioClip Fire => _fire ?? (_fire = BuildFire());

		public static AudioClip Boing => _boing ?? (_boing = Make("mayhem_boing", 0.7f, (float t) => Sine(t, 180f + 520f * (1f - Mathf.Exp((0f - t) * 6f)) + 30f * Mathf.Sin(t * 60f)) * Env(t, 0.005f, 0.65f) * 0.5f));

		public static AudioClip Puff => _puff ?? (_puff = BuildPuff());

		public static AudioClip Chime => _chime ?? (_chime = Make("mayhem_chime", 2.4f, delegate(float t)
		{
			float num = 0f;
			float[] array = new float[5] { 1318.5f, 1568f, 1975.5f, 2637f, 3136f };
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = (float)i * 0.11f;
				if (t < num2)
				{
					break;
				}
				num += Sine(t - num2, array[i]) * Mathf.Exp((0f - (t - num2)) * 3f) * 0.12f;
			}
			return num;
		}));

		public static AudioClip Snore => _snore ?? (_snore = Make("mayhem_snore", 3.2f, delegate(float t)
		{
			float num = t % 3.2f;
			float num2 = ((num < 1.4f) ? Mathf.Sin(num / 1.4f * MathF.PI) : 0f);
			return (Saw(t, 55f + 10f * Mathf.Sin(t * 3f)) * 0.25f + Noise() * 0.1f) * num2 * 0.35f + ((num > 1.6f && num < 2.6f) ? (Noise() * 0.05f * Mathf.Sin((num - 1.6f) * MathF.PI)) : 0f);
		}, loopFade: false));

		public static AudioClip Waterfall => _waterfall ?? (_waterfall = BuildWaterfall());

		public static AudioClip ForestNight => _forest ?? (_forest = Make("mayhem_forestnight", 12f, delegate(float t)
		{
			float num = Sine(t, 4200f) * ((Mathf.Sin(t * 2f * MathF.PI * 18f) > 0.3f) ? 1f : 0f) * (0.5f + 0.5f * Mathf.Sin(t * 1.3f)) * 0.03f;
			float num2 = ((Mathf.Repeat(t, 2.7f) < 0.08f) ? (Sine(Mathf.Repeat(t, 2.7f), 900f + 400f * Mathf.Repeat(t * 0.37f, 1f)) * Mathf.Exp((0f - Mathf.Repeat(t, 2.7f)) * 40f) * 0.3f) : 0f);
			float num3 = Mathf.Repeat(t, 6.1f);
			float num4 = ((num3 < 0.9f) ? (Sine(num3, 300f + 200f * Mathf.Sin(num3 * 7f)) * Env(num3, 0.1f, 0.8f) * 0.05f) : 0f);
			return num + num2 + num4;
		}, loopFade: false));

		public static AudioClip Wind => _wind ?? (_wind = BuildWind());

		private static AudioClip BuildMusic()
		{
			float num = 96f;
			float beat = 60f / num;
			float barLen = beat * 4f;
			float[][] chords = new float[4][]
			{
				new float[4] { 261.63f, 329.63f, 392f, 493.88f },
				new float[4] { 220f, 261.63f, 329.63f, 392f },
				new float[4] { 293.66f, 349.23f, 440f, 523.25f },
				new float[4] { 196f, 246.94f, 293.66f, 349.23f }
			};
			float[][] bass = new float[4][]
			{
				new float[4] { 65.41f, 82.41f, 98f, 110f },
				new float[4] { 55f, 65.41f, 82.41f, 98f },
				new float[4] { 73.42f, 87.31f, 110f, 87.31f },
				new float[4] { 49f, 61.74f, 73.42f, 92.5f }
			};
			float seconds = barLen * 4f;
			return Make("mayhem_lounge", seconds, delegate(float t)
			{
				int num2 = Mathf.Min((int)(t / barLen), 3);
				float num3 = t - (float)num2 * barLen;
				int num4 = Mathf.Min((int)(num3 / beat), 3);
				float num5 = num3 - (float)num4 * beat;
				float num6 = 0f;
				float[] array = chords[num2];
				foreach (float num7 in array)
				{
					num6 += Sine(t, num7) * 0.05f + Sine(t, num7 * 1.003f) * 0.03f;
				}
				num6 *= 0.7f + 0.3f * Mathf.Sin(MathF.PI * 2f * t / barLen);
				float num8 = ((num4 == 1 || num4 == 3) ? (Env(num5, 0.005f, beat * 0.6f) * 0.6f) : 0f);
				float num9 = Sine(t, bass[num2][num4]) * 0.22f * Env(num5, 0.01f, beat * 0.95f);
				float num10 = (((int)(num5 / (beat / 2f)) % 2 == 1) ? 1f : 0f) * Noise() * 0.025f * Env(num5 % (beat / 2f), 0.001f, 0.05f);
				return num6 * (0.6f + num8) + num9 + num10;
			}, loopFade: false);
		}

		private static AudioClip Arpeggio(string name, float[] notes, float step, float tail)
		{
			float seconds = (float)notes.Length * step + tail;
			return Make(name, seconds, delegate(float t)
			{
				float num = 0f;
				for (int i = 0; i < notes.Length; i++)
				{
					float num2 = (float)i * step;
					if (t < num2)
					{
						break;
					}
					float t2 = t - num2;
					num += (Square(t2, notes[i]) * 0.12f + Sine(t2, notes[i]) * 0.18f) * Env(t2, 0.003f, tail + step);
				}
				return num;
			});
		}

		private static float Noise()
		{
			return (float)(Rng.NextDouble() * 2.0 - 1.0);
		}

		private static float Sine(float t, float f)
		{
			return Mathf.Sin(MathF.PI * 2f * f * t);
		}

		private static float Square(float t, float f)
		{
			if (!(Mathf.Sin(MathF.PI * 2f * f * t) >= 0f))
			{
				return -1f;
			}
			return 1f;
		}

		private static float Saw(float t, float f)
		{
			return 2f * (t * f - Mathf.Floor(0.5f + t * f));
		}

		private static float Env(float t, float attack, float decay)
		{
			if (t < attack)
			{
				return t / attack;
			}
			float num = (t - attack) / Mathf.Max(decay, 0.0001f);
			return Mathf.Clamp01(1f - num) * Mathf.Clamp01(1f - num);
		}

		private static AudioClip Make(string name, float seconds, Func<float, float> wave, bool loopFade = true)
		{
			int num = Mathf.CeilToInt(seconds * 44100f);
			float[] array = new float[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = Mathf.Clamp(wave((float)i / 44100f), -1f, 1f);
			}
			if (loopFade)
			{
				int num2 = Mathf.Min(256, num);
				for (int j = 0; j < num2; j++)
				{
					array[num - 1 - j] *= (float)j / (float)num2;
				}
			}
			AudioClip obj = AudioClip.Create(name, num, 1, 44100, false);
			obj.SetData(array, 0);
			return obj;
		}

		private static float Note(int semis)
		{
			return 440f * Mathf.Pow(2f, (float)semis / 12f);
		}

		private static float Pipe(float t, float f, float wobble)
		{
			float num = 1f + 0.006f * Mathf.Sin(MathF.PI * 11f * t) * wobble;
			float num2 = t * f * num;
			return Mathf.Sin(MathF.PI * 2f * num2) * 0.6f + Mathf.Sin(MathF.PI * 2f * num2 * 2f) * 0.25f + Mathf.Sin(MathF.PI * 2f * num2 * 3f) * 0.2f + Mathf.Sin(MathF.PI * 2f * num2 * 4f) * 0.08f;
		}

		private static AudioClip Waltz(string name, float bpm, float detune, float wobble, float volume)
		{
			float beat = 60f / bpm;
			int beats = WaltzMelody.Length;
			return Make(name, (float)beats * beat, delegate(float t)
			{
				int num = Mathf.Min((int)(t / beat), beats - 1);
				float num2 = t - (float)num * beat;
				float num3 = 0f;
				int num4 = WaltzMelody[num];
				if (num4 != -99)
				{
					num3 += Pipe(t, Note(num4) * detune, wobble) * Env(num2, 0.01f, beat * 1.4f) * 0.32f;
				}
				else
				{
					int num5 = num;
					while (num5 > 0 && WaltzMelody[num5] == -99)
					{
						num5--;
					}
					float t2 = t - (float)num5 * beat;
					num3 += Pipe(t, Note(WaltzMelody[num5]) * detune, wobble) * Env(t2, 0.01f, beat * 3f) * 0.32f;
				}
				int num6 = num / 3;
				int num7 = num % 3;
				float num8 = Note(WaltzBass[num6 % WaltzBass.Length]) * detune;
				num3 = ((num7 != 0) ? (num3 + (Pipe(t, num8 * 2f * 1.26f, wobble) + Pipe(t, num8 * 2f * 1.5f, wobble)) * Env(num2, 0.005f, beat * 0.5f) * 0.09f) : (num3