Decompiled source of Halloween v0.1.12

BepInEx/patchers/SlipAndSkid.Halloween/SlipAndSkid.Halloween.AudioBootstrap.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx.Preloader.Core.Patching;
using Microsoft.CodeAnalysis;
using Mono.Cecil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SlipAndSkid.Halloween.AudioBootstrap
{
	[PatcherPluginInfo("slipandskid.halloween.audio", "Slip & Skid Halloween Audio Bootstrap", "0.1.0")]
	public sealed class HalloweenAudioPatcher : BasePatcher
	{
		[TargetType("UnityEngine.AudioModule.dll", "UnityEngine.AudioClip")]
		public bool RestoreAudioClip(TypeDefinition clip)
		{
			return RestoreClipBindings(clip);
		}

		public static bool RestoreClipBindings(TypeDefinition clip)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			TypeSystem typeSystem = ((MemberReference)clip).Module.TypeSystem;
			return (byte)(0u | (Add(clip, "Construct_Internal", true, (TypeReference)(object)clip) ? 1u : 0u) | (Add(clip, "CreateUserSound", false, typeSystem.Void, typeSystem.String, typeSystem.Int32, typeSystem.Int32, typeSystem.Int32, typeSystem.Boolean) ? 1u : 0u) | (Add(clip, "SetData", true, typeSystem.Boolean, (TypeReference)clip, (TypeReference)new ArrayType(typeSystem.Single), typeSystem.Int32, typeSystem.Int32) ? 1u : 0u)) != 0;
		}

		private static bool Add(TypeDefinition type, string name, bool isStatic, TypeReference result, params TypeReference[] parameters)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			if (((IEnumerable<MethodDefinition>)type.Methods).Any((MethodDefinition m) => ((MemberReference)m).Name == name && m.IsStatic == isStatic && ((IEnumerable<ParameterDefinition>)((MethodReference)m).Parameters).Select((ParameterDefinition p) => ((MemberReference)((ParameterReference)p).ParameterType).FullName).SequenceEqual(parameters.Select((TypeReference p) => ((MemberReference)p).FullName))))
			{
				return false;
			}
			MethodDefinition val = new MethodDefinition(name, (MethodAttributes)(1 | (isStatic ? 16 : 0) | 0x80), result)
			{
				ImplAttributes = ((IEnumerable<MethodDefinition>)type.Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "GetName").ImplAttributes
			};
			for (int num = 0; num < parameters.Length; num++)
			{
				((MethodReference)val).Parameters.Add(new ParameterDefinition("arg" + num, (ParameterAttributes)0, parameters[num]));
			}
			type.Methods.Add(val);
			return true;
		}
	}
}

BepInEx/plugins/SlipAndSkid.Halloween/SlipAndSkid.Halloween.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.Mono;
using Game;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Obstacles;
using Player;
using SlipAndSkid.ExtendedCore;
using SlipAndSkid.PickupLifecycle;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SlipAndSkid.PickupLifecycle
{
	internal sealed class PickupLives
	{
		private readonly Dictionary<int, int> deaths = new Dictionary<int, int>();

		internal bool Died(int player, int remaining)
		{
			if (deaths.TryGetValue(player, out var value) && remaining >= value)
			{
				return false;
			}
			deaths[player] = remaining;
			return true;
		}

		internal bool Allows(int player, int grantedLife)
		{
			if (deaths.TryGetValue(player, out var value))
			{
				return grantedLife <= value;
			}
			return true;
		}

		internal int Stamp(int player, int currentLife)
		{
			if (!deaths.TryGetValue(player, out var value))
			{
				return currentLife;
			}
			return Math.Min(value, currentLife);
		}

		internal void Clear()
		{
			deaths.Clear();
		}
	}
}
namespace SlipAndSkid.Halloween
{
	internal static class Art
	{
		internal static readonly Color Orange = new Color(0.93f, 0.34f, 0.04f);

		internal static readonly Color Purple = new Color(0.32f, 0.12f, 0.43f);

		internal static readonly Color Dark = new Color(0.06f, 0.045f, 0.085f);

		internal static readonly Color Green = new Color(0.36f, 0.77f, 0.31f);

		internal static readonly Color Bone = new Color(0.86f, 0.87f, 0.77f);

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

		internal static Material Material(Color c)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_003f: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard"));
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", c);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", c);
			}
			if (c.a < 0.999f)
			{
				if (val.HasProperty("_Surface"))
				{
					val.SetFloat("_Surface", 1f);
				}
				if (val.HasProperty("_Mode"))
				{
					val.SetFloat("_Mode", 3f);
				}
				val.SetInt("_SrcBlend", 5);
				val.SetInt("_DstBlend", 10);
				val.SetInt("_ZWrite", 0);
				val.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
				val.EnableKeyword("_ALPHABLEND_ON");
				val.renderQueue = 3000;
			}
			return val;
		}

		internal static void FaceViewer(Transform visual, Vector3 up)
		{
			//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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)visual) && Object.op_Implicit((Object)(object)Camera.main))
			{
				up = ((Vector3)(ref up)).normalized;
				Vector3 val = ((Component)Camera.main).transform.position - visual.position;
				val -= up * Vector3.Dot(val, up);
				if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
				{
					visual.rotation = Quaternion.LookRotation(val, up);
				}
			}
		}

		internal static GameObject Root(Transform p, string n, Vector3 pos)
		{
			//IL_000b: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			GameObject val = new GameObject("Halloween " + n);
			val.transform.SetParent(p, false);
			val.transform.localPosition = pos;
			val.AddComponent<OwnedArt>();
			return val;
		}

		internal static GameObject Shape(Transform p, PrimitiveType type, string n, Vector3 pos, Vector3 size, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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 obj = GameObject.CreatePrimitive(type);
			((Object)obj).name = "Halloween " + n;
			obj.transform.SetParent(p, false);
			obj.transform.localPosition = pos;
			obj.transform.localScale = size;
			Collider component = obj.GetComponent<Collider>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.enabled = false;
				Object.Destroy((Object)(object)component);
			}
			Material val = Material(color);
			obj.GetComponent<Renderer>().sharedMaterial = val;
			obj.AddComponent<OwnedArt>().materials.Add(val);
			return obj;
		}

		internal static GameObject Pumpkin(Transform p, Vector3 pos, float size, bool glowing = false)
		{
			//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_0068: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Root(p, "pumpkin", pos);
			val.transform.localScale = Vector3.one * size;
			for (int i = 0; i < 7; i++)
			{
				float num = (float)i * MathF.PI * 2f / 7f;
				Shape(val.transform, (PrimitiveType)0, "pumpkin lobe", new Vector3(Mathf.Sin(num) * 0.19f, 0f, Mathf.Cos(num) * 0.19f), new Vector3(0.65f, 0.75f, 0.65f), (Color)((i % 2 == 0) ? Orange : new Color(0.78f, 0.23f, 0.025f)));
			}
			Shape(val.transform, (PrimitiveType)2, "stem", new Vector3(0f, 0.43f, 0f), new Vector3(0.12f, 0.17f, 0.12f), new Color(0.25f, 0.3f, 0.08f)).transform.localRotation = Quaternion.Euler(0f, 0f, -16f);
			Shape(val.transform, (PrimitiveType)3, "left eye", new Vector3(-0.17f, 0.1f, 0.47f), new Vector3(0.15f, 0.13f, 0.03f), Dark).transform.localRotation = Quaternion.Euler(0f, 0f, -18f);
			Shape(val.transform, (PrimitiveType)3, "right eye", new Vector3(0.17f, 0.1f, 0.47f), new Vector3(0.15f, 0.13f, 0.03f), Dark).transform.localRotation = Quaternion.Euler(0f, 0f, 18f);
			Shape(val.transform, (PrimitiveType)3, "grin", new Vector3(0f, -0.15f, 0.48f), new Vector3(0.37f, 0.09f, 0.03f), Dark);
			Shape(val.transform, (PrimitiveType)3, "tooth", new Vector3(0.07f, -0.12f, 0.5f), new Vector3(0.07f, 0.06f, 0.03f), Orange);
			if (glowing)
			{
				Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
				Color val3 = default(Color);
				foreach (Renderer val2 in componentsInChildren)
				{
					if (((Object)val2).name.Contains("eye") || ((Object)val2).name.Contains("grin"))
					{
						Material sharedMaterial = val2.sharedMaterial;
						((Color)(ref val3))..ctor(1f, 0.68f, 0.08f);
						if (sharedMaterial.HasProperty("_BaseColor"))
						{
							sharedMaterial.SetColor("_BaseColor", val3);
						}
						if (sharedMaterial.HasProperty("_Color"))
						{
							sharedMaterial.SetColor("_Color", val3);
						}
						if (sharedMaterial.HasProperty("_EmissionColor"))
						{
							sharedMaterial.SetColor("_EmissionColor", val3 * 2.5f);
							sharedMaterial.EnableKeyword("_EMISSION");
						}
						Shape(val.transform, (PrimitiveType)0, "steady eye glow", ((Component)val2).transform.localPosition + Vector3.forward * 0.018f, ((Component)val2).transform.localScale * 1.65f, new Color(1f, 0.48f, 0.015f, 0.15f)).transform.localRotation = ((Component)val2).transform.localRotation;
					}
				}
			}
			return val;
		}

		internal static GameObject Ghost(Transform p, Vector3 pos, float size, bool spectral = false)
		{
			//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_0041: 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_0046: 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_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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Root(p, "ghost", pos);
			val.transform.localScale = Vector3.one * size;
			Color color = (Color)(spectral ? new Color(0.74f, 0.9f, 1f, 0.42f) : Bone);
			Shape(val.transform, (PrimitiveType)0, "head", new Vector3(0f, 0.2f, 0f), new Vector3(0.65f, 0.8f, 0.5f), color);
			for (int i = 0; i < 3; i++)
			{
				Shape(val.transform, (PrimitiveType)0, "sheet tail", new Vector3((float)(i - 1) * 0.2f, -0.15f, 0f), new Vector3(0.25f, 0.48f, 0.4f), color);
			}
			float[] array = new float[2] { -0.12f, 0.12f };
			foreach (float num in array)
			{
				Shape(val.transform, (PrimitiveType)0, "eye", new Vector3(num, 0.25f, 0.235f), new Vector3(0.09f, 0.13f, 0.05f), Dark);
			}
			if (spectral)
			{
				val.AddComponent<SpectralRibbon>().Init(0f, purple: false);
			}
			return val;
		}

		internal static void Gravestone(Transform p, Vector3 pos, float size)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Root(p, "crooked gravestone", pos);
			obj.transform.localScale = Vector3.one * size;
			obj.transform.localRotation = Quaternion.Euler(0f, 0f, 8f);
			Shape(obj.transform, (PrimitiveType)3, "stone", new Vector3(0f, 0.5f, 0f), new Vector3(0.65f, 1f, 0.18f), new Color(0.24f, 0.27f, 0.31f));
			Shape(obj.transform, (PrimitiveType)0, "stone arch", new Vector3(0f, 1f, 0f), new Vector3(0.65f, 0.5f, 0.18f), new Color(0.24f, 0.27f, 0.31f));
			Shape(obj.transform, (PrimitiveType)3, "cross vertical", new Vector3(0f, 0.7f, 0.1f), new Vector3(0.08f, 0.4f, 0.025f), Bone);
			Shape(obj.transform, (PrimitiveType)3, "cross horizontal", new Vector3(0f, 0.77f, 0.1f), new Vector3(0.28f, 0.08f, 0.025f), Bone);
		}

		internal static GameObject Wing(Transform p, float side, float span)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Root(p, "bat wing", Vector3.zero);
			Vector3[] array = (Vector3[])(object)new Vector3[8]
			{
				Vector3.zero,
				new Vector3(side * span * 0.35f, 0f, span * 0.5f),
				new Vector3(side * span * 1.2f, 0f, span * 0.25f),
				new Vector3(side * span * 0.92f, 0f, 0f),
				new Vector3(side * span * 0.82f, 0f, (0f - span) * 0.22f),
				new Vector3(side * span * 0.61f, 0f, (0f - span) * 0.08f),
				new Vector3(side * span * 0.4f, 0f, (0f - span) * 0.4f),
				new Vector3(side * span * 0.22f, 0f, (0f - span) * 0.16f)
			};
			List<int> list = new List<int>();
			for (int i = 1; i < array.Length - 1; i++)
			{
				list.Add(0);
				list.Add(i);
				list.Add(i + 1);
				list.Add(0);
				list.Add(i + 1);
				list.Add(i);
			}
			Mesh val2 = new Mesh
			{
				name = "Halloween bat membrane"
			};
			val2.vertices = array;
			val2.triangles = list.ToArray();
			val2.RecalculateNormals();
			val.AddComponent<MeshFilter>().sharedMesh = val2;
			Material val3 = Material(Purple);
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = val3;
			OwnedArt component = val.GetComponent<OwnedArt>();
			component.meshes.Add(val2);
			component.materials.Add(val3);
			return val;
		}

		internal static Texture2D Icon()
		{
			return Texture("card");
		}

		internal static Texture2D Texture(string kind)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			if (textures.TryGetValue(kind, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			value = new Texture2D(128, 128, (TextureFormat)4, false);
			((Object)value).name = "Halloween original " + kind;
			Color[] array = (Color[])(object)new Color[16384];
			for (int i = 0; i < 128; i++)
			{
				Color val;
				for (int j = 0; j < 128; array[i * 128 + j] = val, j++)
				{
					float num = (float)(j - 64) / 64f;
					float num2 = (float)(i - 64) / 64f;
					val = Color.clear;
					switch (kind)
					{
					case "bat":
					{
						float num3 = Mathf.Abs(num);
						if ((num3 < 0.13f && num2 > -0.3f && num2 < 0.35f) || (num3 > 0.1f && num3 < 0.95f && num2 < 0.45f - num3 * 0.28f && num2 > -0.2f + 0.17f * Mathf.Cos(num3 * 18f)))
						{
							val = Dark;
						}
						continue;
					}
					case "ghost":
						if (num * num / 0.36f + Mathf.Pow(num2 - 0.25f, 2f) / 0.3f < 1f || (Mathf.Abs(num) < 0.6f && num2 < 0.25f && num2 > -0.63f + 0.1f * Mathf.Cos(num * 18f)))
						{
							val = Bone;
						}
						if (Mathf.Pow(Mathf.Abs(num) - 0.23f, 2f) + Mathf.Pow(num2 - 0.23f, 2f) < 0.014f)
						{
							val = Dark;
						}
						continue;
					case "leaf":
						if (num * num / 0.16f + num2 * num2 / 0.65f < 1f)
						{
							((Color)(ref val))..ctor(0.7f, 0.26f, 0.055f);
						}
						continue;
					case "card":
						((Color)(ref val))..ctor(0.12f, 0.065f, 0.18f);
						break;
					}
					if (num * num / 0.7f + num2 * num2 / 0.45f < 1f)
					{
						val = Orange;
					}
					if (Mathf.Abs(num) < 0.09f && num2 > 0.55f && num2 < 0.82f)
					{
						val = Green;
					}
					if (Mathf.Abs(num) > 0.12f && Mathf.Abs(num) < 0.44f && num2 > 0.05f && num2 < 0.28f - Mathf.Abs(num) * 0.14f)
					{
						val = Dark;
					}
					if (num2 < -0.18f && num2 > -0.37f && Mathf.Abs(num) < 0.48f)
					{
						val = Dark;
					}
					if (Mathf.Abs(num - 0.12f) < 0.06f && num2 < -0.16f && num2 > -0.27f)
					{
						val = Orange;
					}
				}
			}
			value.SetPixels(array);
			value.Apply();
			textures[kind] = value;
			return value;
		}

		internal static void Dispose()
		{
			foreach (Texture2D value in textures.Values)
			{
				if (Object.op_Implicit((Object)(object)value))
				{
					Object.Destroy((Object)(object)value);
				}
			}
			textures.Clear();
		}
	}
	public sealed class OwnedArt : MonoBehaviour
	{
		internal readonly List<Material> materials = new List<Material>();

		internal readonly List<Mesh> meshes = new List<Mesh>();

		private void OnDestroy()
		{
			foreach (Material material in materials)
			{
				if (Object.op_Implicit((Object)(object)material))
				{
					Object.Destroy((Object)(object)material);
				}
			}
			foreach (Mesh mesh in meshes)
			{
				if (Object.op_Implicit((Object)(object)mesh))
				{
					Object.Destroy((Object)(object)mesh);
				}
			}
		}
	}
	internal static class CandyRules
	{
		internal const float BoostAcceleration = 18f;

		internal const float BoostSpeedLimit = 60f;

		internal const float BoostKick = 8f;

		internal static int Outcome(int roll, int chance, int trick)
		{
			if (roll < 0 || roll > 99)
			{
				throw new ArgumentOutOfRangeException("roll");
			}
			if (roll >= Math.Max(0, Math.Min(100, chance)))
			{
				return trick % 2 + 1;
			}
			return 0;
		}

		internal static double Duration(int kind)
		{
			return kind switch
			{
				1 => 4, 
				0 => 5, 
				_ => 5, 
			};
		}

		internal static bool CanCollect(bool placed, bool hit, bool alreadyTouching, double ready, double now)
		{
			if (placed && hit && !alreadyTouching)
			{
				return ready <= now;
			}
			return false;
		}

		internal static float StickyRetain(float delta)
		{
			return (float)Math.Exp(-1.5 * (double)Math.Max(0f, delta));
		}

		internal static bool AcceptSnapshot(bool fromServer, string expectedSession, string receivedSession, int previous, int sequence)
		{
			if (fromServer && !string.IsNullOrEmpty(receivedSession))
			{
				if (!(expectedSession != receivedSession))
				{
					return sequence > previous;
				}
				return true;
			}
			return false;
		}
	}
	public sealed class CauldronMotion : MonoBehaviour
	{
		private readonly Transform[] bubbles = (Transform[])(object)new Transform[11];

		private readonly Transform[] flames = (Transform[])(object)new Transform[7];

		private readonly Transform[] ghosts = (Transform[])(object)new Transform[3];

		private readonly float[] bubbleSizes = new float[11];

		internal void Build()
		{
			//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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < bubbles.Length; i++)
			{
				float num = 0.1f + (float)(i % 5) * 0.045f;
				bubbleSizes[i] = num;
				bubbles[i] = Art.Shape(((Component)this).transform, (PrimitiveType)0, "bobbing potion bubble", Vector3.zero, Vector3.one * num, (Color)((i % 2 == 0) ? Art.Green : new Color(0.57f, 0.94f, 0.15f, 0.75f))).transform;
			}
			for (int j = 0; j < 4; j++)
			{
				Art.Shape(((Component)this).transform, (PrimitiveType)2, "firewood log", new Vector3((j % 2 == 0) ? (-0.65f) : 0.65f, 0.04f, (j < 2) ? (-0.62f) : 0.62f), new Vector3(0.21f, 0.72f, 0.21f), new Color(0.29f, 0.14f, 0.065f)).transform.localRotation = Quaternion.Euler(90f, (float)(j * 45), 0f);
			}
			for (int k = 0; k < flames.Length; k++)
			{
				flames[k] = Art.Shape(((Component)this).transform, (PrimitiveType)0, "gentle fake flame", Vector3.zero, new Vector3(0.16f, 0.3f, 0.16f), (k % 2 == 0) ? new Color(1f, 0.25f, 0.015f, 0.58f) : new Color(1f, 0.68f, 0.08f, 0.55f)).transform;
			}
			for (int l = 0; l < 4; l++)
			{
				float num2 = (float)l * MathF.PI * 0.5f;
				GameObject obj = Art.Root(((Component)this).transform, "wafting cauldron aura", new Vector3(Mathf.Cos(num2) * 0.56f, 0.65f, Mathf.Sin(num2) * 0.56f));
				obj.transform.localScale = new Vector3(0.65f, 0.55f, 0.65f);
				obj.AddComponent<SpectralRibbon>().Init((float)l * 1.7f, purple: true);
			}
			for (int m = 0; m < ghosts.Length; m++)
			{
				ghosts[m] = Art.Ghost(((Component)this).transform, Vector3.zero, 0.36f, spectral: true).transform;
			}
		}

		private void LateUpdate()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			for (int i = 0; i < bubbles.Length; i++)
			{
				float num = (float)i * 2.39996f;
				float num2 = num + time * (0.13f + (float)i * 0.015f);
				float num3 = 0.12f + (float)(i % 4) * 0.12f;
				bubbles[i].localPosition = new Vector3(Mathf.Cos(num2) * num3, 1f + 0.15f * (1f + Mathf.Sin(time * (1.1f + (float)i * 0.12f) + num)), Mathf.Sin(num2) * num3);
				bubbles[i].localScale = Vector3.one * bubbleSizes[i] * (1f + Mathf.Sin(time * 0.8f + num) * 0.12f);
			}
			for (int j = 0; j < flames.Length; j++)
			{
				float num4 = (float)j * MathF.PI * 2f / (float)flames.Length;
				flames[j].localPosition = new Vector3(Mathf.Cos(num4) * 0.5f, 0.16f, Mathf.Sin(num4) * 0.5f);
				flames[j].localScale = new Vector3(0.19f, 0.24f + 0.12f * (1f + Mathf.Sin(time * 1.6f + (float)j)), 0.19f);
				flames[j].localRotation = Quaternion.Euler(Mathf.Sin(time + (float)j) * 12f, 0f, Mathf.Cos(time * 0.8f + (float)j) * 15f);
			}
			for (int k = 0; k < ghosts.Length; k++)
			{
				float num5 = time * (0.5f + (float)k * 0.12f) + (float)k * MathF.PI * 2f / (float)ghosts.Length;
				ghosts[k].localPosition = new Vector3(Mathf.Cos(num5) * 1.12f, 1.05f + Mathf.Sin(time * 1.3f + (float)k) * 0.28f, Mathf.Sin(num5) * 1.12f);
				ghosts[k].localRotation = Quaternion.Euler(0f, (0f - num5) * 57.29578f + 90f, Mathf.Sin(time + (float)k) * 12f);
			}
		}
	}
	internal static class ExpandedTypes
	{
		private static readonly Dictionary<string, Type> cache = new Dictionary<string, Type>();

		internal static Type Find(string name)
		{
			if (cache.TryGetValue(name, out var value))
			{
				return value;
			}
			value = FindInAssembly(AppDomain.CurrentDomain.GetAssemblies(), "SlipAndSkid.Expanded", name);
			cache[name] = value;
			return value;
		}

		internal static Type FindInAssembly(IEnumerable<Assembly> assemblies, string assemblyName, string name)
		{
			foreach (Assembly assembly in assemblies)
			{
				if (string.Equals(assembly.GetName().Name, assemblyName, StringComparison.Ordinal))
				{
					return assembly.GetType(name, throwOnError: false, ignoreCase: false);
				}
			}
			return null;
		}
	}
	internal static class Integration
	{
		private static readonly Dictionary<Type, string> types = new Dictionary<Type, string>();

		private static readonly string[,] hooks = new string[9, 3]
		{
			{ "SlipSkid.RaceWorkshop.WorkshopMailbox", "Awake", "mailbox" },
			{ "SlipSkid.RaceWorkshop.WorkshopObject", "Init", "depot" },
			{ "SlipSkid.RaceWorkshop.WorkshopDrawbridge", "Init", "bridge" },
			{ "SlipSkid.RaceWorkshop.WorkshopDispenserView", "Init", "cauldron" },
			{ "SlipSkid.ChaosSystems.ChaosGateGeometry", "Init", "gate" },
			{ "SlipSkid.ChaosSystems.ChaosPlaced", "Init", "potatoPad" },
			{ "SlipSkid.TankCards.MountedLaser", "Init", "eye" },
			{ "SlipSkid.TankCards.DroppedBlackHoleSize", "Init", "vortex" },
			{ "SlipSkid.TankCards.FiredTankMine", "Initialize", "mine" }
		};

		internal static object Field(object target, string name)
		{
			if (target != null)
			{
				return AccessTools.Field(target.GetType(), name)?.GetValue(target);
			}
			return null;
		}

		internal static void Install(Harmony harmony, ManualLogSource log)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			types.Clear();
			for (int i = 0; i < hooks.GetLength(0); i++)
			{
				Type type = ExpandedTypes.Find(hooks[i, 0]);
				if (type == null)
				{
					continue;
				}
				types[type] = hooks[i, 2];
				MethodInfo methodInfo = AccessTools.Method(type, hooks[i, 1], (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					log.LogWarning((object)("Halloween: no " + hooks[i, 0] + "." + hooks[i, 1] + "; existing-object fallback active."));
				}
				else
				{
					try
					{
						harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Integration), "AfterInit", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					}
					catch (Exception ex)
					{
						log.LogWarning((object)("Halloween skin hook skipped: " + type.Name + ": " + ex.Message));
					}
				}
			}
			Patch(harmony, "SlipSkid.RaceWorkshop.WorkshopWorld", "PresentCargo", "AfterCargo", log);
			Patch(harmony, "SlipSkid.RaceWorkshop.WorkshopObject", "SetDepotKind", "AfterInit", log);
			Patch(harmony, "SlipSkid.RaceWorkshop.WorkshopFlight", "Make", "AfterWings", log);
			Patch(harmony, "SlipSkid.ChaosSystems.ChaosVisual", "Bomb", "AfterBomb", log);
			Patch(harmony, "SlipSkid.ChaosSystems.ChaosGateGeometry", "SetSpent", "AfterSpent", log);
			Type type2 = ExpandedTypes.Find("SlipSkid.ChaosSystems.ChaosPotatoDisplay");
			if (type2 != null)
			{
				types[type2] = "pumpkin";
			}
		}

		private static void Patch(Harmony h, string typeName, string method, string callback, ManualLogSource log)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			Type type = ExpandedTypes.Find(typeName);
			if (type == null)
			{
				return;
			}
			MethodInfo methodInfo = AccessTools.Method(type, method, (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				return;
			}
			try
			{
				h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Integration), callback, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				log.LogWarning((object)("Halloween hook skipped: " + method + ": " + ex.Message));
			}
		}

		private static void AfterInit(Component __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance) && types.TryGetValue(((object)__instance).GetType(), out var value))
			{
				Apply(__instance.transform, value, __instance);
			}
		}

		private static void AfterBomb(GameObject __result)
		{
			if (Object.op_Implicit((Object)(object)__result) && (((Object)__result).name == "Hot Potato bomb" || ((Object)__result).name == "Holographic pickup bomb"))
			{
				Apply(__result.transform, "pumpkin", null);
			}
		}

		private static void AfterWings(object __result)
		{
			object obj = Field(__result, "root");
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				Apply(val.transform, "wings", null);
			}
		}

		private static void AfterSpent(Component __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance))
			{
				HalloweenSkin component = __instance.GetComponent<HalloweenSkin>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.SetSpent((bool)(Field(__instance, "isSpent") ?? ((object)false)));
				}
			}
		}

		private static void AfterCargo(object __instance)
		{
			if (!Object.op_Implicit((Object)(object)Plugin.Instance) || !Plugin.Instance.Cosmetics || !(Field(__instance, "cargoVisuals") is IDictionary dictionary))
			{
				return;
			}
			foreach (object value in dictionary.Values)
			{
				GameObject val = (GameObject)((value is GameObject) ? value : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					Apply(val.transform, "cargo", null);
				}
			}
		}

		internal static void FindExisting()
		{
			Object[] array;
			foreach (KeyValuePair<Type, string> type3 in types)
			{
				array = Object.FindObjectsOfType(type3.Key);
				foreach (Object obj in array)
				{
					Component val = (Component)(object)((obj is Component) ? obj : null);
					if (Object.op_Implicit((Object)(object)val))
					{
						Apply(val.transform, type3.Value, val);
					}
				}
			}
			Type type = ExpandedTypes.Find("SlipSkid.RaceWorkshop.WorkshopPlugin");
			if (type != null)
			{
				array = Object.FindObjectsOfType(type);
				for (int i = 0; i < array.Length; i++)
				{
					AfterCargo(Field(array[i], "World"));
				}
			}
			Type type2 = ExpandedTypes.Find("SlipSkid.RaceWorkshop.WorkshopFlight");
			if (!(type2 != null))
			{
				return;
			}
			array = Object.FindObjectsOfType(type2);
			for (int i = 0; i < array.Length; i++)
			{
				if (!(Field(array[i], "visuals") is IDictionary dictionary))
				{
					continue;
				}
				foreach (object value in dictionary.Values)
				{
					object obj2 = Field(value, "root");
					GameObject val2 = (GameObject)((obj2 is GameObject) ? obj2 : null);
					if (Object.op_Implicit((Object)(object)val2))
					{
						Apply(val2.transform, "wings", null);
					}
				}
			}
		}

		private static void Apply(Transform t, string kind, Component source)
		{
			if (!Object.op_Implicit((Object)(object)Plugin.Instance) || !Plugin.Instance.Cosmetics || !Object.op_Implicit((Object)(object)t))
			{
				return;
			}
			if (kind == "potatoPad")
			{
				if ((int)(Field(source, "card") ?? ((object)(-1))) == 0)
				{
					object obj = Field(source, "hologram");
					GameObject val = (GameObject)((obj is GameObject) ? obj : null);
					if (Object.op_Implicit((Object)(object)val))
					{
						Apply(val.transform, "pumpkin", null);
					}
				}
			}
			else
			{
				if (Object.op_Implicit((Object)(object)((Component)t).GetComponent<HalloweenSkin>()))
				{
					return;
				}
				if (kind == "depot")
				{
					int num = (int)(Field(source, "kind") ?? ((object)(-1)));
					if (num != 0 && num != 1)
					{
						return;
					}
				}
				HalloweenSkin halloweenSkin = ((Component)t).gameObject.AddComponent<HalloweenSkin>();
				try
				{
					halloweenSkin.Build(kind, source);
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("Halloween decoration failed (" + kind + "): " + ex.Message));
					Object.Destroy((Object)(object)halloweenSkin);
				}
			}
		}
	}
	[DefaultExecutionOrder(32500)]
	public sealed class HalloweenSkin : MonoBehaviour
	{
		private sealed class Original
		{
			internal Renderer renderer;

			internal Material[] materials;

			internal bool enabled;

			internal bool hidden;

			internal bool forceOff;
		}

		private readonly List<Original> originals = new List<Original>();

		private readonly List<Material> allocated = new List<Material>();

		private readonly List<GameObject> roots = new List<GameObject>();

		private GameObject decoration;

		private GameObject escape;

		private string kind;

		private Obstacle eyeObstacle;

		private SphereCarController eyeCar;

		private Obstacle mineObstacle;

		private bool spent;

		private float escapedAt;

		private GameObject Root(Transform p, string name, Vector3 pos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Art.Root(p, name, pos);
			roots.Add(val);
			return val;
		}

		private void Tint(Renderer r, Color color, bool hide = false)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)r) || Object.op_Implicit((Object)(object)((Component)r).GetComponent<OwnedArt>()))
			{
				return;
			}
			originals.Add(new Original
			{
				renderer = r,
				materials = r.sharedMaterials,
				enabled = r.enabled,
				hidden = hide,
				forceOff = r.forceRenderingOff
			});
			if (hide)
			{
				r.enabled = false;
				return;
			}
			Material[] array = (Material[])(object)new Material[r.sharedMaterials.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Art.Material(color);
				allocated.Add(array[i]);
			}
			r.sharedMaterials = array;
		}

		internal void Build(string value, Component source)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: 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_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0620: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_068f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_087c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_088e: Unknown result type (might be due to invalid IL or missing references)
			//IL_08aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a39: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0850: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab1: Unknown result type (might be due to invalid IL or missing references)
			//IL_098e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0993: Unknown result type (might be due to invalid IL or missing references)
			//IL_0997: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad6: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0778: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bcf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c10: Unknown result type (might be due to invalid IL or missing references)
			kind = value;
			decoration = Root(((Component)this).transform, value + " decoration", Vector3.zero);
			Transform transform = decoration.transform;
			if (kind == "pumpkin")
			{
				Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
				foreach (Renderer val in componentsInChildren)
				{
					if (((Object)val).name == "Bomb" || ((Object)val).name == "Fuse" || ((Object)val).name == "Fuse spark")
					{
						Tint(val, Art.Orange, hide: true);
					}
				}
				Art.Pumpkin(transform, Vector3.zero, 0.78f);
				return;
			}
			if (kind == "wings")
			{
				Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
				foreach (Renderer val2 in componentsInChildren)
				{
					if (((Object)val2).name == "Left wing" || ((Object)val2).name == "Right wing" || ((Object)val2).name == "Wing tip")
					{
						Tint(val2, Art.Purple, hide: true);
					}
				}
				Transform[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Transform>();
				foreach (Transform val3 in componentsInChildren2)
				{
					if (!(((Object)val3).name != "Left wing pivot") || !(((Object)val3).name != "Right wing pivot"))
					{
						float span = Mathf.Abs(val3.localPosition.x) / 0.32f;
						GameObject item = Art.Wing(val3, (!((Object)val3).name.StartsWith("Left")) ? 1 : (-1), span);
						roots.Add(item);
					}
				}
				return;
			}
			if (kind == "mailbox")
			{
				Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
				foreach (Renderer val4 in componentsInChildren)
				{
					if (((Object)val4).name.Contains("wall") || ((Object)val4).name.Contains("roof") || ((Object)val4).name.Contains("door ramp"))
					{
						Tint(val4, Art.Purple);
					}
				}
				Art.Pumpkin(transform, new Vector3(-3.05f, 0.55f, -3.7f), 0.7f);
				Art.Gravestone(transform, new Vector3(3.05f, 0.4f, -3.8f), 1f);
				Art.Ghost(transform, new Vector3(0f, 4.65f, 0f), 0.8f);
				{
					foreach (Transform item2 in transform)
					{
						Transform val5 = item2;
						val5.localRotation = Quaternion.Euler(0f, 180f, 0f) * val5.localRotation;
					}
					return;
				}
			}
			if (kind == "cauldron")
			{
				Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
				foreach (Renderer val6 in componentsInChildren)
				{
					if (((Object)val6).name == "Dispenser pedestal" || ((Object)val6).name == "Warning stripe" || ((Object)val6).name == "Glowing dispenser rim")
					{
						Tint(val6, Art.Dark, hide: true);
					}
				}
				Art.Shape(transform, (PrimitiveType)0, "cauldron", new Vector3(0f, 0.58f, 0f), new Vector3(1.65f, 0.76f, 1.65f), Art.Dark);
				Art.Shape(transform, (PrimitiveType)2, "potion surface", new Vector3(0f, 0.96f, 0f), new Vector3(1.35f, 0.04f, 1.35f), Art.Green);
				decoration.AddComponent<CauldronMotion>().Build();
			}
			else if (kind == "bridge")
			{
				Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
				foreach (Renderer val7 in componentsInChildren)
				{
					if (((Object)val7).name.Contains("rail") || ((Object)val7).name.Contains("girder") || ((Object)val7).name.Contains("housing"))
					{
						Tint(val7, new Color(0.25f, 0.18f, 0.13f));
					}
				}
				int num = 0;
				Transform[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Transform>();
				foreach (Transform val8 in componentsInChildren2)
				{
					if (((Object)val8).name == "Drawbridge guardrail" && num++ < 4)
					{
						Art.Pumpkin(Root(val8.parent, "cemetery rail marker", val8.localPosition + Vector3.up * 0.18f).transform, Vector3.zero, 0.4f);
						if (num <= 2)
						{
							float num2 = Mathf.Sign(val8.localPosition.x);
							GameObject obj = Root(val8.parent, "deck gravestone", new Vector3(val8.localPosition.x - num2 * 0.25f, 0.25f, val8.localPosition.z + 0.6f));
							obj.transform.localRotation = Quaternion.Euler(0f, (float)((num2 > 0f) ? (-90) : 90), 0f);
							Art.Gravestone(obj.transform, Vector3.zero, 0.45f);
						}
					}
				}
			}
			else if (kind == "depot")
			{
				TMP_Text[] componentsInChildren3 = ((Component)this).GetComponentsInChildren<TMP_Text>(true);
				foreach (TMP_Text val9 in componentsInChildren3)
				{
					if (((Object)((Component)val9).gameObject).name == "Depot label")
					{
						Tint(((Component)val9).GetComponent<Renderer>(), Art.Bone, hide: true);
					}
				}
			}
			else if (kind == "cargo")
			{
				Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer r in componentsInChildren)
				{
					Tint(r, Art.Orange, hide: true);
				}
				float num3 = Mathf.Clamp(Mathf.Abs(((Component)this).transform.lossyScale.x) * 2.5f, 1.8f, 2.5f);
				Vector3 lossyScale = ((Component)this).transform.lossyScale;
				transform.localScale = new Vector3(num3 / Mathf.Max(0.001f, Mathf.Abs(lossyScale.x)), num3 / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y)), num3 / Mathf.Max(0.001f, Mathf.Abs(lossyScale.z)));
				Art.Pumpkin(transform, Vector3.zero, 1f, glowing: true);
			}
			else if (kind == "eye")
			{
				Ray[] array = Integration.Field(source, "rays") as Ray[];
				ref Obstacle reference = ref eyeObstacle;
				object obj2 = Integration.Field(source, "obstacle");
				reference = (Obstacle)((obj2 is Obstacle) ? obj2 : null);
				Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val10 in componentsInChildren)
				{
					if (!(val10 is MeshRenderer) && !(val10 is SkinnedMeshRenderer))
					{
						continue;
					}
					bool flag = false;
					if (array != null)
					{
						Ray[] array2 = array;
						for (int j = 0; j < array2.Length; j++)
						{
							object obj3 = Integration.Field(array2[j], "rayHitObject");
							Transform val11 = ((obj3 is GameObject) ? ((GameObject)obj3).transform : ((obj3 is Component) ? ((Component)obj3).transform : null));
							if (Object.op_Implicit((Object)(object)val11) && ((Object)(object)((Component)val10).transform == (Object)(object)val11 || ((Component)val10).transform.IsChildOf(val11)))
							{
								flag = true;
							}
						}
					}
					if (!flag)
					{
						Tint(val10, Art.Bone, hide: true);
					}
				}
				BuildEye(transform);
			}
			else if (kind == "mine")
			{
				ref Obstacle reference2 = ref mineObstacle;
				object obj4 = Integration.Field(source, "mine");
				reference2 = (Obstacle)((obj4 is Obstacle) ? obj4 : null);
				Renderer[] componentsInChildren4 = ((Component)this).GetComponentsInChildren<Renderer>(true);
				Renderer[] componentsInChildren = componentsInChildren4;
				foreach (Renderer val12 in componentsInChildren)
				{
					if (val12 is MeshRenderer || val12 is SkinnedMeshRenderer)
					{
						bool enabled = val12.enabled;
						Tint(val12, Art.Orange, hide: true);
						val12.enabled = enabled;
						val12.forceRenderingOff = true;
					}
				}
				Vector3 lossyScale2 = ((Component)this).transform.lossyScale;
				transform.localScale = new Vector3(1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale2.x)), 1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale2.y)), 1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale2.z)));
				GameObject obj5 = Art.Pumpkin(transform, Vector3.up * 0.38f, 1.25f, glowing: true);
				Renderer val13 = null;
				componentsInChildren = obj5.GetComponentsInChildren<Renderer>();
				foreach (Renderer val14 in componentsInChildren)
				{
					if (((Object)val14).name == "Halloween stem")
					{
						val13 = val14;
						break;
					}
				}
				if (Object.op_Implicit((Object)(object)val13))
				{
					decoration.AddComponent<MineWarning>().Init(componentsInChildren4, val13);
				}
			}
			else if (kind == "vortex")
			{
				float num4 = 3f;
				Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
				foreach (Renderer val15 in componentsInChildren)
				{
					if (!Object.op_Implicit((Object)(object)((Component)val15).GetComponent<OwnedArt>()))
					{
						float num5 = num4;
						Bounds bounds = val15.bounds;
						float x = ((Bounds)(ref bounds)).extents.x;
						bounds = val15.bounds;
						num4 = Mathf.Max(num5, Mathf.Max(x, ((Bounds)(ref bounds)).extents.z));
					}
				}
				decoration.AddComponent<VortexGhosts>().Init(num4);
			}
			else
			{
				if (!(kind == "gate"))
				{
					return;
				}
				object obj6 = Integration.Field(source, "aperture");
				BoxCollider val16 = (BoxCollider)((obj6 is BoxCollider) ? obj6 : null);
				if (!Object.op_Implicit((Object)(object)val16))
				{
					return;
				}
				Transform transform2 = source.transform;
				Bounds val17 = VisibleGateBounds(transform2, val16);
				Vector3 size = ((Bounds)(ref val17)).size;
				Vector3 lossyScale3 = transform2.lossyScale;
				Vector3 val18 = default(Vector3);
				((Vector3)(ref val18))..ctor(size.x * Mathf.Abs(lossyScale3.x), size.y * Mathf.Abs(lossyScale3.y), size.z * Mathf.Abs(lossyScale3.z));
				bool flag2 = val18.z > val18.x;
				transform.SetParent(transform2, false);
				transform.localPosition = ((Bounds)(ref val17)).center;
				transform.localScale = new Vector3(1f / Mathf.Max(0.001f, Mathf.Abs(flag2 ? lossyScale3.z : lossyScale3.x)), 1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale3.y)), 1f / Mathf.Max(0.001f, Mathf.Abs(flag2 ? lossyScale3.x : lossyScale3.z)));
				transform.rotation = transform2.rotation * Quaternion.Euler(0f, (float)(flag2 ? 90 : 0), 0f);
				float num6 = (flag2 ? val18.z : val18.x) * 0.5f + 0.4f;
				float num7 = (0f - val18.y) * 0.5f;
				float[] array3 = new float[2] { -1f, 1f };
				Vector3 val19 = default(Vector3);
				foreach (float num8 in array3)
				{
					((Vector3)(ref val19))..ctor(num8 * num6, num7, 0f);
					Art.Gravestone(transform, val19, 1f);
					Art.Pumpkin(transform, val19 + new Vector3(0f, 0.23f, 0.4f), 0.5f);
					for (int k = 0; k < 4; k++)
					{
						Art.Root(transform, "malignant purple aura", val19 + new Vector3(((float)k - 1.5f) * 0.18f, 0.05f, 0f)).AddComponent<SpectralRibbon>().Init((float)k * 1.7f + num8 * 2f, purple: true);
					}
				}
				escape = Art.Ghost(transform, new Vector3(0f, val18.y * 0.5f + 0.8f, 0f), 1.1f, spectral: true);
				SetSpent((bool)(Integration.Field(source, "isSpent") ?? ((object)false)));
			}
		}

		private static void BuildEye(Transform parent)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_008a: 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)
			Art.Shape(parent, (PrimitiveType)0, "eyeball", Vector3.zero, Vector3.one * 1.2f, Art.Bone);
			Art.Shape(parent, (PrimitiveType)0, "iris", new Vector3(0f, 0f, 0.56f), new Vector3(0.6f, 0.6f, 0.12f), Art.Green);
			Art.Shape(parent, (PrimitiveType)0, "pupil", new Vector3(0f, 0f, 0.64f), new Vector3(0.19f, 0.44f, 0.07f), Art.Dark);
		}

		private static Bounds VisibleGateBounds(Transform frame, BoxCollider fallback)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			Bounds result = default(Bounds);
			bool flag = false;
			MeshFilter[] componentsInChildren = ((Component)frame).GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				Renderer component = ((Component)val).GetComponent<Renderer>();
				if (!Object.op_Implicit((Object)(object)val.sharedMesh) || !Object.op_Implicit((Object)(object)component) || !component.enabled || Object.op_Implicit((Object)(object)((Component)val).GetComponent<OwnedArt>()))
				{
					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 = frame.InverseTransformPoint(((Component)val).transform.TransformPoint(val2));
					if (!flag)
					{
						((Bounds)(ref result))..ctor(val3, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref result)).Encapsulate(val3);
					}
				}
			}
			if (flag)
			{
				return result;
			}
			for (int k = 0; k < 8; k++)
			{
				Vector3 val4 = fallback.center + Vector3.Scale(fallback.size * 0.5f, new Vector3((float)(((k & 1) != 0) ? 1 : (-1)), (float)(((k & 2) != 0) ? 1 : (-1)), (float)(((k & 4) != 0) ? 1 : (-1))));
				Vector3 val5 = frame.InverseTransformPoint(((Component)fallback).transform.TransformPoint(val4));
				if (k == 0)
				{
					((Bounds)(ref result))..ctor(val5, Vector3.zero);
				}
				else
				{
					((Bounds)(ref result)).Encapsulate(val5);
				}
			}
			return result;
		}

		internal void SetSpent(bool value)
		{
			if (value && !spent)
			{
				escapedAt = Time.unscaledTime;
				if (Object.op_Implicit((Object)(object)escape))
				{
					escape.transform.SetParent(((Component)this).transform, true);
					roots.Add(escape);
				}
			}
			spent = value;
			if (Object.op_Implicit((Object)(object)decoration))
			{
				decoration.SetActive(!value);
			}
		}

		private void LateUpdate()
		{
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Plugin.Instance) || !Plugin.Instance.Cosmetics)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			if (kind == "eye" || kind == "cargo" || kind == "depot" || kind == "mine" || kind == "pumpkin" || kind == "cauldron")
			{
				foreach (Original original in originals)
				{
					if (original.hidden && Object.op_Implicit((Object)(object)original.renderer))
					{
						if (kind == "mine")
						{
							original.renderer.forceRenderingOff = true;
						}
						else
						{
							original.renderer.enabled = false;
						}
					}
				}
			}
			if (Object.op_Implicit((Object)(object)decoration) && (kind == "cargo" || (kind == "pumpkin" && ((Object)((Component)this).gameObject).name == "Holographic pickup bomb")))
			{
				Art.FaceViewer(decoration.transform, ((Component)this).transform.up);
			}
			if (kind == "mine" && Object.op_Implicit((Object)(object)decoration))
			{
				if (Object.op_Implicit((Object)(object)mineObstacle))
				{
					decoration.SetActive(!mineObstacle.Destroyed);
				}
				Art.FaceViewer(decoration.transform, ((Component)this).transform.up);
				Vector3 lossyScale = ((Component)this).transform.lossyScale;
				decoration.transform.localScale = new Vector3(1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.x)), 1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y)), 1f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.z)));
			}
			if (kind == "eye" && !Object.op_Implicit((Object)(object)decoration) && Object.op_Implicit((Object)(object)eyeObstacle) && !eyeObstacle.Destroyed)
			{
				decoration = Root(((Component)this).transform, "eye decoration", Vector3.zero);
				BuildEye(decoration.transform);
			}
			if (kind == "eye" && Object.op_Implicit((Object)(object)decoration) && Object.op_Implicit((Object)(object)eyeObstacle))
			{
				int value = eyeObstacle.playerInfosIndex.Value;
				if (!Object.op_Implicit((Object)(object)eyeCar) || !Object.op_Implicit((Object)(object)eyeCar.player) || eyeCar.player.playerIndex.Value != value)
				{
					eyeCar = null;
					if (Object.op_Implicit((Object)(object)GameManager.instance) && GameManager.Players != null)
					{
						foreach (PlayerData player in GameManager.Players)
						{
							if (Object.op_Implicit((Object)(object)player) && player.playerIndex.Value == value)
							{
								eyeCar = player.controller;
								break;
							}
						}
					}
				}
				if (Object.op_Implicit((Object)(object)eyeCar) && Object.op_Implicit((Object)(object)eyeCar.car))
				{
					Transform car = eyeCar.car;
					if ((Object)(object)decoration.transform.parent != (Object)(object)car)
					{
						decoration.transform.SetParent(car, false);
					}
					Vector3 val = car.up * (eyeCar.SphereRadius * 1.3f) + car.forward * (eyeCar.SphereRadius + 0.5f - 0.675f);
					decoration.transform.localPosition = car.InverseTransformVector(val);
					decoration.transform.localRotation = Quaternion.identity;
					Vector3 lossyScale2 = car.lossyScale;
					decoration.transform.localScale = new Vector3(1f / SafeScale(lossyScale2.x), 1f / SafeScale(lossyScale2.y), 1f / SafeScale(lossyScale2.z));
					decoration.SetActive(!eyeObstacle.Destroyed && Object.op_Implicit((Object)(object)eyeCar.player) && !eyeCar.player.isDead.Value && !eyeCar.player.finishedRace.Value);
				}
				else
				{
					decoration.SetActive(false);
				}
			}
			if (spent && Object.op_Implicit((Object)(object)escape))
			{
				Transform transform = escape.transform;
				transform.position += Vector3.up * Time.unscaledDeltaTime * 1.3f;
				if (Time.unscaledTime - escapedAt > 2.5f)
				{
					Object.Destroy((Object)(object)escape);
					escape = null;
				}
			}
		}

		private static float SafeScale(float value)
		{
			if (!(Mathf.Abs(value) < 0.001f))
			{
				return value;
			}
			if (!(value < 0f))
			{
				return 0.001f;
			}
			return -0.001f;
		}

		private void OnDestroy()
		{
			foreach (Original original in originals)
			{
				if (Object.op_Implicit((Object)(object)original.renderer))
				{
					original.renderer.sharedMaterials = original.materials;
					original.renderer.enabled = original.enabled;
					original.renderer.forceRenderingOff = original.forceOff;
				}
			}
			foreach (GameObject root in roots)
			{
				if (Object.op_Implicit((Object)(object)root))
				{
					Object.Destroy((Object)(object)root);
				}
			}
			foreach (Material item in allocated)
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					Object.Destroy((Object)(object)item);
				}
			}
		}
	}
	public sealed class MenuFlair : MonoBehaviour
	{
		private AudioSource ambience;

		private AudioClip clip;

		private bool attempted;

		private GameObject canvas;

		private readonly RawImage[] pictures = (RawImage[])(object)new RawImage[19];

		private void Build()
		{
			canvas = UI.Canvas("Halloween menu edges", 29990);
			for (int i = 0; i < pictures.Length; i++)
			{
				pictures[i] = UI.Picture(canvas.transform, "Halloween decoration", (i < 2) ? "pumpkin" : ((i < 5) ? "bat" : ((i < 7) ? "ghost" : "leaf")));
			}
		}

		private void LoadAmbience()
		{
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			attempted = true;
			try
			{
				float[] array = new float[264600];
				for (int i = 0; i < array.Length; i++)
				{
					double num = (double)i / 22050.0;
					double num2 = 0.55 + 0.25 * Math.Sin(Math.PI * 2.0 * num / 12.0);
					array[i] = (float)(num2 * (0.17 * Math.Sin(Math.PI * 220.0 * num) + 0.07 * Math.Sin(922.5810426042026 * num) + 0.035 * Math.Sin(Math.PI * 440.0 * num)));
				}
				BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
				MethodInfo method = typeof(AudioClip).GetMethod("Construct_Internal", bindingAttr);
				MethodInfo method2 = typeof(AudioClip).GetMethod("CreateUserSound", bindingAttr);
				MethodInfo method3 = typeof(AudioClip).GetMethod("SetData", bindingAttr, null, new Type[4]
				{
					typeof(AudioClip),
					typeof(float[]),
					typeof(int),
					typeof(int)
				}, null);
				if (method == null || method2 == null || method3 == null)
				{
					throw new InvalidOperationException("Install the included Halloween AudioBootstrap DLL under BepInEx/patchers and restart for optional ambience.");
				}
				clip = (AudioClip)method.Invoke(null, null);
				method2.Invoke(clip, new object[5] { "Halloween original soft ambience", array.Length, 1, 22050, false });
				if (!(bool)method3.Invoke(null, new object[4] { clip, array, array.Length, 0 }))
				{
					throw new InvalidOperationException("Ambience upload failed.");
				}
			}
			catch (Exception ex)
			{
				if (Object.op_Implicit((Object)(object)clip))
				{
					Object.Destroy((Object)(object)clip);
				}
				clip = null;
				Debug.LogWarning((object)("Halloween optional ambience: " + ex.Message));
			}
		}

		private void Update()
		{
			Plugin instance = Plugin.Instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return;
			}
			bool flag = instance.Enabled.Value && instance.MenuDecorations.Value && instance.IsMenu;
			if (flag && !Object.op_Implicit((Object)(object)canvas))
			{
				Build();
			}
			if (Object.op_Implicit((Object)(object)canvas))
			{
				canvas.SetActive(flag);
			}
			bool flag2 = instance.Enabled.Value && instance.Music.Value && instance.IsMenu;
			if (flag2 && !attempted)
			{
				LoadAmbience();
			}
			if (flag2 && Object.op_Implicit((Object)(object)clip) && !Object.op_Implicit((Object)(object)ambience))
			{
				ambience = ((Component)this).gameObject.AddComponent<AudioSource>();
				ambience.clip = clip;
				ambience.loop = true;
				ambience.volume = 0.08f;
				ambience.spatialBlend = 0f;
				ambience.Play();
			}
			if (Object.op_Implicit((Object)(object)ambience) && !flag2)
			{
				ambience.Stop();
				Object.Destroy((Object)(object)ambience);
				ambience = null;
			}
			if (flag)
			{
				float num = Mathf.Clamp((float)Screen.height / 900f, 0.6f, 1.8f);
				float unscaledTime = Time.unscaledTime;
				Place(0, 14f, (float)Screen.height - 100f * num, 86f * num, 86f * num, 0.82f);
				Place(1, (float)Screen.width - 104f * num, (float)Screen.height - 91f * num, 72f * num, 72f * num, 0.82f);
				for (int i = 0; i < 3; i++)
				{
					Place(2 + i, (i == 1) ? ((float)Screen.width - 100f * num) : (28f * num + (float)(i * 65) * num), 32f * num + Mathf.Sin(unscaledTime * 0.5f + (float)i) * 9f * num, 66f * num, 48f * num, 0.82f);
				}
				for (int j = 0; j < 2; j++)
				{
					Place(5 + j, (j == 0) ? (18f * num) : ((float)Screen.width - 69f * num), (float)Screen.height * (0.38f + 0.08f * Mathf.Sin(unscaledTime * 0.23f + (float)(j * 3))), 48f * num, 64f * num, 0.36f);
				}
				for (int k = 0; k < 12; k++)
				{
					Place(7 + k, (float)((k % 2 == 0) ? 10 : (Screen.width - 42)) + Mathf.Sin(unscaledTime * 0.3f + (float)k) * 12f, (unscaledTime * (float)(12 + k % 3 * 4) + (float)(k * 79)) % (float)(Screen.height + 30) - 30f, 18f * num, 26f * num, 0.65f);
				}
			}
		}

		private void Place(int i, float x, float y, float w, float h, float alpha)
		{
			//IL_0010: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)pictures[i]).rectTransform.anchoredPosition = new Vector2(x, 0f - y);
			((Graphic)pictures[i]).rectTransform.sizeDelta = new Vector2(w, h);
			((Graphic)pictures[i]).color = new Color(1f, 1f, 1f, alpha);
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)ambience))
			{
				Object.Destroy((Object)(object)ambience);
			}
			if (Object.op_Implicit((Object)(object)clip))
			{
				Object.Destroy((Object)(object)clip);
			}
			if (Object.op_Implicit((Object)(object)canvas))
			{
				Object.Destroy((Object)(object)canvas);
			}
		}
	}
	[DefaultExecutionOrder(32600)]
	public sealed class MineWarning : MonoBehaviour
	{
		private Renderer indicator;

		private Renderer stem;

		private int slot;

		private readonly MaterialPropertyBlock properties = new MaterialPropertyBlock();

		internal void Init(Renderer[] native, Renderer target)
		{
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			stem = target;
			float num = float.NegativeInfinity;
			foreach (Renderer val in native)
			{
				if (!Object.op_Implicit((Object)(object)val) || (!(val is MeshRenderer) && !(val is SkinnedMeshRenderer)))
				{
					continue;
				}
				Material[] sharedMaterials = val.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					Material val2 = sharedMaterials[j];
					if (Object.op_Implicit((Object)(object)val2))
					{
						string text = (((Object)val).name + " " + ((Object)val2).name).ToLowerInvariant();
						float num2 = 0f;
						if (text.Contains("button"))
						{
							num2 += 100f;
						}
						if (text.Contains("blink") || text.Contains("flash"))
						{
							num2 += 90f;
						}
						if (text.Contains("warning") || text.Contains("indicator"))
						{
							num2 += 80f;
						}
						if (text.Contains("light") || text.Contains("lamp"))
						{
							num2 += 40f;
						}
						Color val3 = (val2.HasProperty("_BaseColor") ? val2.GetColor("_BaseColor") : (val2.HasProperty("_Color") ? val2.GetColor("_Color") : Color.gray));
						num2 += Mathf.Max(0f, val3.r - Mathf.Max(val3.g, val3.b)) * 30f;
						if (val2.HasProperty("_EmissionColor"))
						{
							Color color = val2.GetColor("_EmissionColor");
							num2 += Mathf.Max(0f, color.r - Mathf.Max(color.g, color.b)) * 10f;
						}
						if (!(num2 <= num))
						{
							num = num2;
							indicator = val;
							slot = j;
						}
					}
				}
			}
			if (Object.op_Implicit((Object)(object)indicator))
			{
				Debug.Log((object)("Halloween mine stem follows native warning: " + ((Object)indicator).name + " / " + ((Object)indicator.sharedMaterials[slot]).name));
			}
		}

		private void LateUpdate()
		{
			if (!Object.op_Implicit((Object)(object)stem) || !Object.op_Implicit((Object)(object)indicator))
			{
				return;
			}
			Material[] sharedMaterials = indicator.sharedMaterials;
			if (slot < sharedMaterials.Length && Object.op_Implicit((Object)(object)sharedMaterials[slot]))
			{
				stem.sharedMaterial = sharedMaterials[slot];
				properties.Clear();
				indicator.GetPropertyBlock(properties, slot);
				if (properties.isEmpty)
				{
					indicator.GetPropertyBlock(properties);
				}
				stem.SetPropertyBlock(properties);
				stem.enabled = indicator.enabled && ((Component)indicator).gameObject.activeInHierarchy;
			}
		}
	}
	[BepInPlugin("slipandskid.halloween", "SlipAndSkid.Halloween", "0.1.12")]
	[BepInDependency("slipandskid.extendedcore", ">=1.0.3 <2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "slipandskid.halloween";

		internal static Plugin Instance;

		internal ConfigEntry<bool> Enabled;

		internal ConfigEntry<bool> Decorations;

		internal ConfigEntry<bool> MenuDecorations;

		internal ConfigEntry<bool> Music;

		internal ConfigEntry<bool> Gameplay;

		internal ConfigEntry<int> TreatChance;

		internal ConfigEntry<float> Cooldown;

		internal TreatNetwork Treats;

		internal MenuFlair Menu;

		private Harmony harmony;

		private bool show;

		private GameObject settingsCanvas;

		private readonly List<Action> refresh = new List<Action>();

		private float scanAt;

		internal bool Cosmetics
		{
			get
			{
				if (Enabled.Value)
				{
					return Decorations.Value;
				}
				return false;
			}
		}

		internal bool IsMenu => CoreGame.IsState((GameState)0);

		private void Awake()
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			Instance = this;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Halloween", "Enabled", true, "Local decoration switch; on the host also controls candy gameplay. F8 opens controls.");
			Decorations = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "CardDecorations", true, "Local cosmetic skins for Expanded. Does not change collision or gameplay.");
			MenuDecorations = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "MenuDecorations", true, "Pumpkins, bats, leaves and drifting ghosts in the menu margins.");
			Music = ((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "SpookyMenuAmbience", false, "Optional original synthesized ambience. Plays quietly alongside menu audio; disable other menu music if preferred.");
			Gameplay = ((BaseUnityPlugin)this).Config.Bind<bool>("Trick or Treat", "Enabled", true, "Host switch for candy bucket collection. Card remains in the catalog to keep all clients compatible.");
			TreatChance = ((BaseUnityPlugin)this).Config.Bind<int>("Trick or Treat", "TreatChancePercent", 65, new ConfigDescription("Host: chance of a treat. Remaining chance gives a harmless trick.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			Cooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Trick or Treat", "RefillSeconds", 10f, new ConfigDescription("Host: bucket refill time. Drivers must leave and re-enter.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 60f), Array.Empty<object>()));
			CorePlugin.Instance.RegisterModule("slipandskid.halloween", "0.1.12");
			Treats = ((Component)this).gameObject.AddComponent<TreatNetwork>();
			Menu = ((Component)this).gameObject.AddComponent<MenuFlair>();
			CoreCards.Register(new CardDefinition
			{
				Id = "b84b7910-bace-46c0-9fe2-0d8b0c017001",
				ModuleId = "slipandskid.halloween",
				Name = "Trick or Treat",
				Description = "Place a candy bucket. Drive through for a short sugar rush, a gentle sticky slowdown, or a ghostly costume. Refills between visits.",
				Template = (CardTemplate)0,
				Rarity = (ObstacleRarity)1,
				LoadArtwork = () => Art.Icon(),
				Attach = delegate(CorePlacedObject item)
				{
					((Component)item.Obstacle).gameObject.AddComponent<CandyBucket>().Init(item.Obstacle, item.Visual);
				}
			});
			harmony = new Harmony("slipandskid.halloween");
			Integration.Install(harmony, ((BaseUnityPlugin)this).Logger);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Halloween 0.1.12 loaded. F8: controls. Expanded cosmetics optional; ExtendedCore required.");
		}

		private void Update()
		{
			if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f8Key).wasPressedThisFrame)
			{
				show = !show;
			}
			if (show && !Object.op_Implicit((Object)(object)settingsCanvas))
			{
				BuildSettings();
			}
			if (Object.op_Implicit((Object)(object)settingsCanvas))
			{
				settingsCanvas.SetActive(show);
				if (show)
				{
					foreach (Action item in refresh)
					{
						item();
					}
				}
			}
			if (Time.unscaledTime < scanAt)
			{
				return;
			}
			scanAt = Time.unscaledTime + 2f;
			if (Cosmetics)
			{
				Integration.FindExisting();
				return;
			}
			HalloweenSkin[] array = Object.FindObjectsOfType<HalloweenSkin>();
			for (int i = 0; i < array.Length; i++)
			{
				Object.Destroy((Object)(object)array[i]);
			}
		}

		private void BuildSettings()
		{
			//IL_003d: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			settingsCanvas = UI.Canvas("Halloween controls", 31000, clickable: true);
			RectTransform val = UI.Rect(settingsCanvas.transform, "Halloween panel", new Vector2(0f, 1f), new Vector2(24f, -90f), new Vector2(400f, 440f));
			((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(0.06f, 0.035f, 0.09f, 0.98f);
			UI.Label((Transform)(object)val, "HALLOWEEN 0.1.12 — F8", new Vector2(0.5f, 1f), new Vector2(0f, -10f), new Vector2(380f, 30f), 22f);
			Toggle((Transform)(object)val, "Halloween enabled", Enabled, -50f);
			Toggle((Transform)(object)val, "Expanded card decorations", Decorations, -85f);
			Toggle((Transform)(object)val, "Menu decorations", MenuDecorations, -120f);
			Toggle((Transform)(object)val, "Quiet menu ambience", Music, -155f);
			Button game = Toggle((Transform)(object)val, "Trick or Treat (host)", Gameplay, -190f);
			Button chance = UI.Button((Transform)(object)val, "", -225f, (UnityAction)delegate
			{
				TreatChance.Value = ((TreatChance.Value + 5 <= 100) ? (TreatChance.Value + 5) : 0);
			});
			Button delay = UI.Button((Transform)(object)val, "", -260f, (UnityAction)delegate
			{
				Cooldown.Value = ((Cooldown.Value >= 60f) ? 3f : (Cooldown.Value + 1f));
			});
			refresh.Add(delegate
			{
				bool flag = Object.op_Implicit((Object)(object)Treats) && Treats.IsHost;
				Button obj = game;
				Button obj2 = chance;
				bool flag2 = (((Selectable)delay).interactable = flag);
				bool interactable = (((Selectable)obj2).interactable = flag2);
				((Selectable)obj).interactable = interactable;
				((Component)chance).GetComponentInChildren<TMP_Text>().text = "Treat chance: " + TreatChance.Value + "%  (+5 / wrap)";
				((Component)delay).GetComponentInChildren<TMP_Text>().text = "Bucket refill: " + Cooldown.Value.ToString("0") + "s  (+1 / wrap)";
			});
			UI.Label((Transform)(object)val, "Decorations are local. Candy rules belong to the host.\nSugar rush 5s · Sticky wheels 4s · Ghost costume 5s", new Vector2(0.5f, 1f), new Vector2(0f, -304f), new Vector2(380f, 60f), 15f);
			UI.Button((Transform)(object)val, "Save and close", -385f, (UnityAction)delegate
			{
				((BaseUnityPlugin)this).Config.Save();
				show = false;
			});
		}

		private Button Toggle(Transform parent, string title, ConfigEntry<bool> setting, float y)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Button button = UI.Button(parent, "", y, (UnityAction)delegate
			{
				setting.Value = !setting.Value;
			});
			refresh.Add(delegate
			{
				((Component)button).GetComponentInChildren<TMP_Text>().text = title + ": " + (setting.Value ? "ON" : "OFF");
			});
			return button;
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			HalloweenSkin[] array = Object.FindObjectsOfType<HalloweenSkin>();
			for (int i = 0; i < array.Length; i++)
			{
				Object.Destroy((Object)(object)array[i]);
			}
			if (Object.op_Implicit((Object)(object)Treats))
			{
				Object.Destroy((Object)(object)Treats);
			}
			if (Object.op_Implicit((Object)(object)Menu))
			{
				Object.Destroy((Object)(object)Menu);
			}
			if (Object.op_Implicit((Object)(object)settingsCanvas))
			{
				Object.Destroy((Object)(object)settingsCanvas);
			}
			Art.Dispose();
			Instance = null;
		}
	}
	public sealed class SpectralRibbon : MonoBehaviour
	{
		private Mesh mesh;

		private Vector3[] vertices;

		private float phase;

		private bool aura;

		internal void Init(float offset, bool purple)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			phase = offset;
			aura = purple;
			GameObject val = Art.Root(((Component)this).transform, "flowing spectral ribbon", Vector3.zero);
			mesh = new Mesh
			{
				name = "Halloween wispy ribbon"
			};
			vertices = (Vector3[])(object)new Vector3[34];
			int[] array = new int[192];
			int num = 0;
			for (int i = 0; i < 16; i++)
			{
				int num2 = i * 2;
				int num3 = num2 + 1;
				int num4 = num2 + 2;
				int num5 = num2 + 3;
				int[] array2 = new int[12]
				{
					num2, num3, num4, num3, num5, num4, num4, num3, num2, num4,
					num5, num3
				};
				foreach (int num6 in array2)
				{
					array[num++] = num6;
				}
			}
			mesh.vertices = vertices;
			mesh.triangles = array;
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			Material val2 = Art.Material(purple ? new Color(0.55f, 0.1f, 0.9f, 0.17f) : new Color(0.65f, 0.84f, 1f, 0.13f));
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = val2;
			OwnedArt component = val.GetComponent<OwnedArt>();
			component.meshes.Add(mesh);
			component.materials.Add(val2);
		}

		private void LateUpdate()
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)mesh))
			{
				float time = Time.time;
				for (int i = 0; i <= 16; i++)
				{
					float num = (float)i / 16f;
					Vector3 val = (aura ? new Vector3(Mathf.Sin(time * 0.9f + num * 5f + phase) * (0.28f + num * 0.5f), num * 2.6f, Mathf.Cos(time * 0.7f + num * 6f + phase) * (0.25f + num * 0.45f)) : new Vector3(Mathf.Sin(time * 2.1f + num * 5f + phase) * num * 0.48f, -0.05f - num * 1.65f, Mathf.Cos(time * 1.7f + num * 4f + phase) * num * 0.33f));
					float num2 = (aura ? 0.24f : 0.29f) * (1f - num) * (aura ? Mathf.Sin(MathF.PI * num) : 1f);
					vertices[i * 2] = val + Vector3.right * num2;
					vertices[i * 2 + 1] = val - Vector3.right * num2;
				}
				mesh.vertices = vertices;
				mesh.RecalculateBounds();
			}
		}
	}
	public sealed class VortexGhosts : MonoBehaviour
	{
		private readonly Transform[] ghosts = (Transform[])(object)new Transform[7];

		private float radius;

		private float size;

		internal void Init(float nativeRadius)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			radius = Mathf.Clamp(nativeRadius, 3f, 14f);
			size = Mathf.Clamp(radius * 0.24f, 1.2f, 3.2f);
			for (int i = 0; i < ghosts.Length; i++)
			{
				ghosts[i] = Art.Ghost(((Component)this).transform, Vector3.zero, size, spectral: true).transform;
			}
		}

		private void LateUpdate()
		{
			//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_0027: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: 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_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Component)this).transform.parent;
			if (!Object.op_Implicit((Object)(object)parent))
			{
				return;
			}
			Vector3 lossyScale = parent.lossyScale;
			((Component)this).transform.localScale = new Vector3(1f / Nonzero(lossyScale.x), 1f / Nonzero(lossyScale.y), 1f / Nonzero(lossyScale.z));
			((Component)this).transform.rotation = Quaternion.identity;
			float time = Time.time;
			Vector3 val = default(Vector3);
			for (int i = 0; i < ghosts.Length; i++)
			{
				float num = (float)i * 2.39996f;
				float num2 = time * ((i % 2 == 0) ? 0.7f : (-0.55f)) + num + Mathf.Sin(time * 0.83f + num) * 0.75f;
				float num3 = radius * (0.65f + 0.23f * Mathf.Sin(time * 0.77f + num) + 0.1f * Mathf.Sin(time * 1.61f + (float)i));
				((Vector3)(ref val))..ctor(Mathf.Cos(num2) * num3, size * (0.65f + 0.65f * Mathf.Sin(time * (0.9f + (float)i * 0.07f) + num)), Mathf.Sin(num2) * num3);
				Transform val2 = ghosts[i];
				Vector3 localPosition = val2.localPosition;
				val2.localPosition = val;
				Vector3 val3 = val - localPosition;
				if (Object.op_Implicit((Object)(object)Camera.main))
				{
					val3 = ((Component)Camera.main).transform.position - val2.position;
				}
				val3.y = 0f;
				if (((Vector3)(ref val3)).sqrMagnitude > 0.001f)
				{
					val2.rotation = Quaternion.LookRotation(val3, Vector3.up);
				}
				val2.localRotation *= Quaternion.Euler(0f, 0f, Mathf.Sin(time * 1.5f + num) * 18f);
			}
		}

		private static float Nonzero(float f)
		{
			if (!(Mathf.Abs(f) < 0.001f))
			{
				return f;
			}
			return 0.001f;
		}
	}
	[Serializable]
	public sealed class CandyEffect
	{
		public int player;

		public int kind;

		public int life;

		public double until;
	}
	[Serializable]
	public sealed class BucketState
	{
		public ulong id;

		public double until;
	}
	[Serializable]
	public sealed class CandyPacket
	{
		public string kind;

		public string version;

		public string session;

		public int sequence;

		public int epoch;

		public int player;

		public int life;

		public bool enabled;

		public bool racing;

		public CandyEffect[] effects;

		public BucketState[] buckets;
	}
	public sealed class TreatNetwork : MonoBehaviour
	{
		private sealed class DeathWatch
		{
			internal PlayerData player;

			internal OnValueChangedDelegate<int> changed;
		}

		private const string Channel = "slipandskid.halloween.v1";

		private NetworkManager network;

		private string session;

		private int sequence;

		private int lastSequence = -1;

		private int epoch;

		private int closedEpoch = -1;

		private int remoteEpoch;

		private readonly HashSet<ulong> peers = new HashSet<ulong>();

		private readonly Dictionary<int, DeathWatch> deathWatches = new Dictionary<int, DeathWatch>();

		private readonly PickupLives lives = new PickupLives();

		private readonly Dictionary<int, CandyEffect> effects = new Dictionary<int, CandyEffect>();

		private readonly Dictionary<ulong, double> cooldowns = new Dictionary<ulong, double>();

		private readonly Dictionary<int, Vector3> previous = new Dictionary<int, Vector3>();

		private readonly Dictionary<int, GameObject> hats = new Dictionary<int, GameObject>();

		private readonly Dictionary<ulong, float> helloTimes = new Dictionary<ulong, f