Decompiled source of Skate Park v1.0.0

Mods/WoodStudios.SkatePark.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using HarmonyLib;
using HoldTheFort;
using Il2CppFishNet;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.AvatarFramework;
using Il2CppScheduleOne.AvatarFramework.Animation;
using Il2CppScheduleOne.Core.Items.Framework;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Instancing;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Map;
using Il2CppScheduleOne.NPCs;
using Il2CppScheduleOne.Networking;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Skating;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.Weather;
using Il2CppSteamworks;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using S1API.Lifecycle;
using Schedule2;
using SkatePark;
using SkatePark.FybCommon;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(ParkCore), "Skate Park", "1.0.0", "Wood Studios", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonOptionalDependencies(new string[] { "HoldTheFort" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Schedule2
{
	internal static class FrameShare
	{
		private static int _frame = -1;

		private static Vector2 _mouse;

		private static bool _down;

		private static bool _legacyBroken;

		public static void Mouse(out Vector2 guiMouse, out bool leftDown)
		{
			//IL_009a: 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_0019: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			int frameCount = Time.frameCount;
			if (frameCount != _frame)
			{
				_frame = frameCount;
				Vector2 val = default(Vector2);
				bool flag = false;
				bool down = false;
				if (!_legacyBroken)
				{
					try
					{
						val = Vector2.op_Implicit(Input.mousePosition);
						down = Input.GetMouseButtonDown(0);
						flag = true;
					}
					catch
					{
						_legacyBroken = true;
					}
				}
				if (!flag)
				{
					try
					{
						Mouse current = Mouse.current;
						if (current != null)
						{
							val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue();
							down = current.leftButton.wasPressedThisFrame;
						}
					}
					catch
					{
					}
				}
				_mouse = new Vector2(val.x, (float)Screen.height - val.y);
				_down = down;
			}
			guiMouse = _mouse;
			leftDown = _down;
		}
	}
	internal static class PlayerSnap
	{
		private static readonly List<Player> _l = new List<Player>();

		private static int _f = -1;

		public static List<Player> List()
		{
			if (_f == Time.frameCount)
			{
				return _l;
			}
			_f = Time.frameCount;
			_l.Clear();
			try
			{
				List<Player> playerList = Player.PlayerList;
				int num = playerList?.Count ?? 0;
				for (int i = 0; i < num; i++)
				{
					Player val = playerList[i];
					if ((Object)(object)val != (Object)null)
					{
						_l.Add(val);
					}
				}
			}
			catch
			{
			}
			return _l;
		}
	}
	internal static class CamSnap
	{
		private static int _f = -1;

		private static bool _ok;

		private static Vector3 _p;

		public static bool Pos(out Vector3 p)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (_f != Time.frameCount)
			{
				_f = Time.frameCount;
				_ok = false;
				try
				{
					PlayerCamera instance = PlayerSingleton<PlayerCamera>.Instance;
					Transform val = (((Object)(object)instance != (Object)null && (Object)(object)instance.Camera != (Object)null) ? ((Component)instance.Camera).transform : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : null));
					if ((Object)(object)val != (Object)null)
					{
						_p = val.position;
						_ok = true;
					}
				}
				catch
				{
				}
			}
			p = _p;
			return _ok;
		}
	}
	internal static class Npcs
	{
		internal sealed class Info
		{
			public IntPtr Key;

			public NPC Npc;

			private NPCMovement _move;

			private NavMeshAgent _agent;

			private Transform _agentTr;

			private bool _haveMove;

			private string _id;

			private bool _haveId;

			public NPCMovement Move
			{
				get
				{
					if (!_haveMove)
					{
						_haveMove = true;
						try
						{
							_move = Npc.Movement;
							_agent = (((Object)(object)_move != (Object)null) ? _move._agent : null);
							_agentTr = (((Object)(object)_agent != (Object)null) ? ((Component)_agent).transform : null);
						}
						catch
						{
						}
					}
					return _move;
				}
			}

			public NavMeshAgent Agent
			{
				get
				{
					_ = Move;
					return _agent;
				}
			}

			public Transform AgentTr
			{
				get
				{
					_ = Move;
					return _agentTr;
				}
			}

			public string Id
			{
				get
				{
					if (!_haveId)
					{
						_haveId = true;
						try
						{
							_id = Npc.ID ?? "";
						}
						catch
						{
							_id = "";
						}
					}
					return _id;
				}
			}
		}

		private static readonly List<Info> _list = new List<Info>();

		private static readonly Dictionary<IntPtr, Info> _byKey = new Dictionary<IntPtr, Info>();

		private static readonly HashSet<IntPtr> _seen = new HashSet<IntPtr>();

		private static float _at = -10f;

		private static int _count = -1;

		public static List<Info> All
		{
			get
			{
				float unscaledTime = Time.unscaledTime;
				if (unscaledTime - _at < 1f && unscaledTime >= _at)
				{
					return _list;
				}
				_at = unscaledTime;
				try
				{
					List<NPC> nPCRegistry = NPCManager.NPCRegistry;
					int num = nPCRegistry?.Count ?? 0;
					_list.Clear();
					_seen.Clear();
					for (int i = 0; i < num; i++)
					{
						NPC val = nPCRegistry[i];
						if (!((Object)(object)val == (Object)null))
						{
							IntPtr pointer = ((Il2CppObjectBase)val).Pointer;
							if (!_byKey.TryGetValue(pointer, out var value) || (Object)(object)value.Npc == (Object)null)
							{
								value = new Info
								{
									Key = pointer,
									Npc = val
								};
								_byKey[pointer] = value;
							}
							_list.Add(value);
							_seen.Add(pointer);
						}
					}
					if (_byKey.Count > _list.Count + 32)
					{
						List<IntPtr> list = new List<IntPtr>();
						foreach (IntPtr key in _byKey.Keys)
						{
							if (!_seen.Contains(key))
							{
								list.Add(key);
							}
						}
						foreach (IntPtr item in list)
						{
							_byKey.Remove(item);
						}
					}
					_count = num;
				}
				catch
				{
				}
				return _list;
			}
		}

		public static void Reset()
		{
			_list.Clear();
			_byKey.Clear();
			_at = -10f;
		}
	}
	internal static class Res
	{
		private static readonly Assembly Asm = typeof(Res).Assembly;

		public static Stream Open(string name)
		{
			Stream manifestResourceStream = Asm.GetManifestResourceStream(name);
			if (manifestResourceStream == null)
			{
				return null;
			}
			int num = manifestResourceStream.ReadByte();
			int num2 = manifestResourceStream.ReadByte();
			manifestResourceStream.Position = 0L;
			if (num != 31 || num2 != 139)
			{
				return manifestResourceStream;
			}
			MemoryStream memoryStream = new MemoryStream();
			using (GZipStream gZipStream = new GZipStream(manifestResourceStream, CompressionMode.Decompress))
			{
				gZipStream.CopyTo(memoryStream);
			}
			memoryStream.Position = 0L;
			return memoryStream;
		}
	}
	internal static class Perf
	{
		internal const bool On = false;

		internal static long Start()
		{
			return 0L;
		}

		internal static void Stop(string k, long t0)
		{
		}
	}
}
namespace SkatePark
{
	internal static class Park
	{
		internal const float X0 = 26f;

		internal const float Z0 = 124f;

		internal const float W = 46f;

		internal const float D = 46f;

		private const float WalkX = 58f;

		private const float WalkW = 6f;

		private const float RoadZ = 102f;

		private const float Seabed = -12f;

		internal static float Top = -3.9f;

		internal static GameObject Root;

		internal static bool Built;

		private static int _layer;

		private static readonly List<Light> _lamps = new List<Light>();

		private static float _lampCheck;

		private static readonly List<GameObject> _hidden = new List<GameObject>();

		private static Material Concrete => FortifyApi.Mat("skp_concrete", new Color(0.4f, 0.4f, 0.39f), 0f, 0.12f);

		private static Material Smooth => FortifyApi.Mat("skp_smooth", new Color(0.5f, 0.5f, 0.49f), 0f, 0.25f);

		private static Material RampPaint => FortifyApi.Mat("skp_ramp", new Color(0.16f, 0.34f, 0.6f), 0f, 0.35f);

		private static Material Steel => FortifyApi.Mat("skp_steel", new Color(0.78f, 0.8f, 0.82f), 0.9f, 0.7f);

		private static Material Dark => FortifyApi.Mat("skp_dark", new Color(0.2f, 0.2f, 0.21f), 0.3f);

		private static Material Yellow => FortifyApi.Mat("skp_yellow", new Color(0.98f, 0.78f, 0.12f), 0.1f, 0.4f);

		internal static bool Inside(Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (p.x >= 25f && p.x <= 73f && p.z >= 101f && p.z <= 171f && p.y > Top - 3f)
			{
				return p.y < Top + 12f;
			}
			return false;
		}

		internal static void Build()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: 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_016e: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			Reset();
			try
			{
				Measure();
				Root = new GameObject("WoodStudios_SkatePark");
				Transform transform = Root.transform;
				transform.position = new Vector3(26f, Top, 124f);
				Solid(transform, "Slab", new Vector3(23f, (-12f - Top) * 0.5f, 23f), new Vector3(46f, Top - -12f, 46f), Concrete);
				Ramp(transform, "Walkway", new Vector3(32f, 0f, -22f), new Vector3(32f, 0f, 0f), 6f, Smooth);
				Solid(transform, "WalkwayBase", new Vector3(35f, (-12f - Top) * 0.5f - 0.15f, -11f), new Vector3(6f, Top - -12f - 0.3f, 22f), Concrete);
				for (int i = 0; i < 2; i++)
				{
					float num = 32f + ((i == 0) ? 0.15f : 5.85f);
					Cyl(transform, "WalkRail" + i, new Vector3(num, 1f, -21.5f), new Vector3(num, 1f, -0.3f), 0.03f, Steel, collider: true);
					for (float num2 = -21.5f; num2 <= 0f; num2 += 3f)
					{
						Solid(transform, "WalkPost", new Vector3(num, 0.5f, num2), new Vector3(0.06f, 1f, 0.06f), Dark);
					}
				}
				float num3 = 0.55f;
				Solid(transform, "WallN", new Vector3(23f, num3 * 0.5f, 45.85f), new Vector3(46f, num3, 0.3f), Concrete);
				Solid(transform, "WallE", new Vector3(45.85f, num3 * 0.5f, 23f), new Vector3(0.3f, num3, 46f), Concrete);
				Solid(transform, "WallW", new Vector3(0.15f, num3 * 0.5f, 23f), new Vector3(0.3f, num3, 46f), Concrete);
				float num4 = 32f;
				float num5 = num4 + 6f;
				Solid(transform, "WallS1", new Vector3(num4 * 0.5f, num3 * 0.5f, 0.15f), new Vector3(num4, num3, 0.3f), Concrete);
				Solid(transform, "WallS2", new Vector3((num5 + 46f) * 0.5f, num3 * 0.5f, 0.15f), new Vector3(46f - num5, num3, 0.3f), Concrete);
				QuarterPipe(transform, "QuarterNorth", new Vector3(23f, 0f, 44.100002f), 0f, 26f, 2.2f, 1.6f);
				QuarterPipe(transform, "QuarterWest", new Vector3(1.9000001f, 0f, 24f), -90f, 22f, 1.8f, 1.6f);
				Bank(transform, "BankEast", new Vector3(45.7f, 0f, 24f), 90f, 26f, 1.4f, 4.5f, 1.2f);
				Funbox(transform, new Vector3(23f, 0f, 25f));
				Pyramid(transform, "Pyramid", new Vector3(22f, 0f, 10f), 9f, 3.5f, 1.1f);
				Kicker(transform, "KickerA", new Vector3(30f, 0f, 15f), 0f);
				Kicker(transform, "KickerB", new Vector3(35f, 0f, 37f), 90f);
				Ledge(transform, "LedgeA", new Vector3(23f, 0f, 17.5f), 0f, 7f);
				Ledge(transform, "LedgeB", new Vector3(23f, 0f, 32.5f), 0f, 7f);
				Rail(transform, "FlatBar", new Vector3(11f, 0f, 30f), 90f, 6f, 0.35f, round: false);
				StairSet(transform, new Vector3(10f, 0f, 6f));
				Lamp(transform, new Vector3(2f, 0f, 2f));
				Lamp(transform, new Vector3(44f, 0f, 2f));
				Lamp(transform, new Vector3(2f, 0f, 44f));
				Lamp(transform, new Vector3(44f, 0f, 44f));
				Lamp(transform, new Vector3(35f, 0f, 25f));
				Sign(transform, new Vector3(35f, 0f, 0.3f));
				HidePierRail();
				SetLayer(transform, _layer);
				try
				{
					FortifyApi.AddTreeClearing("skatepark", new Vector3(49f, Top, 147f), 36f);
				}
				catch
				{
				}
				try
				{
					FortifyApi.ReserveArea("skatepark", new Vector3(49f, Top, 147f), 36f);
				}
				catch
				{
				}
				Built = true;
				ParkCore.Log.Msg($"Skate Park built at ({49f:0}, {Top:0.00}, {147f:0}), walkway from the pier at x {58f:0}.");
				Survey();
			}
			catch (Exception ex)
			{
				ParkCore.Log.Warning("Skate Park: couldn't build the park (" + ex.Message + ").");
			}
		}

		public static string DevGate()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder stringBuilder = new StringBuilder();
			Bounds val = default(Bounds);
			((Bounds)(ref val))..ctor(new Vector3(61f, Top + 0.8f, 113f), new Vector3(7f, 1.6f, 24f));
			Bounds bounds;
			Vector3 val3;
			foreach (Renderer item in Object.FindObjectsOfType<Renderer>())
			{
				if ((Object)(object)item == (Object)null || !item.enabled || ((Object)(object)Root != (Object)null && ((Component)item).transform.IsChildOf(Root.transform)))
				{
					continue;
				}
				bounds = item.bounds;
				if (((Bounds)(ref bounds)).Intersects(val))
				{
					string text = ((Object)item).name;
					Transform val2 = ((Component)item).transform;
					int num = 0;
					while ((Object)(object)val2.parent != (Object)null && num++ < 5)
					{
						val2 = val2.parent;
						text = ((Object)val2).name + "/" + text;
					}
					StringBuilder stringBuilder2 = stringBuilder;
					StringBuilder stringBuilder3 = stringBuilder2;
					StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(18, 4, stringBuilder2);
					handler.AppendLiteral("[");
					handler.AppendFormatted(text);
					handler.AppendLiteral(" size ");
					bounds = item.bounds;
					val3 = ((Bounds)(ref bounds)).size;
					handler.AppendFormatted(((Vector3)(ref val3)).ToString("0.0"));
					handler.AppendLiteral(" at ");
					bounds = item.bounds;
					val3 = ((Bounds)(ref bounds)).center;
					handler.AppendFormatted(((Vector3)(ref val3)).ToString("0.0"));
					handler.AppendLiteral(" col ");
					handler.AppendFormatted((Object)(object)((Component)item).GetComponent<Collider>() != (Object)null);
					handler.AppendLiteral("] ");
					stringBuilder3.Append(ref handler);
				}
			}
			foreach (Collider item2 in (Il2CppArrayBase<Collider>)(object)Physics.OverlapBox(((Bounds)(ref val)).center, ((Bounds)(ref val)).extents, Quaternion.identity, -1, (QueryTriggerInteraction)1))
			{
				if (!((Object)(object)item2 == (Object)null) && (!((Object)(object)Root != (Object)null) || !((Component)item2).transform.IsChildOf(Root.transform)))
				{
					StringBuilder stringBuilder2 = stringBuilder;
					StringBuilder stringBuilder4 = stringBuilder2;
					StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(8, 2, stringBuilder2);
					handler.AppendLiteral("COL ");
					handler.AppendFormatted(((Object)item2).name);
					handler.AppendLiteral(" (");
					bounds = item2.bounds;
					val3 = ((Bounds)(ref bounds)).size;
					handler.AppendFormatted(((Vector3)(ref val3)).ToString("0.0"));
					handler.AppendLiteral(") ");
					stringBuilder4.Append(ref handler);
				}
			}
			return stringBuilder.ToString();
		}

		private static void HidePierRail()
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (Transform item in Object.FindObjectsOfType<Transform>())
			{
				if ((Object)(object)item == (Object)null || !((Component)item).gameObject.activeInHierarchy)
				{
					continue;
				}
				string text = ((Object)item).name.ToLowerInvariant();
				if (!text.Contains("rail") && !text.Contains("fence") && !text.Contains("balust"))
				{
					continue;
				}
				bool flag = false;
				Transform parent = item.parent;
				int num2 = 0;
				while ((Object)(object)parent != (Object)null && num2++ < 6)
				{
					if (((Object)parent).name == "Pier")
					{
						flag = true;
						break;
					}
					parent = parent.parent;
				}
				if (!flag)
				{
					continue;
				}
				Renderer componentInChildren = ((Component)item).GetComponentInChildren<Renderer>();
				Collider componentInChildren2 = ((Component)item).GetComponentInChildren<Collider>();
				Bounds bounds;
				if ((Object)(object)componentInChildren != (Object)null)
				{
					bounds = componentInChildren.bounds;
				}
				else
				{
					if (!((Object)(object)componentInChildren2 != (Object)null))
					{
						continue;
					}
					bounds = componentInChildren2.bounds;
				}
				if (!(((Bounds)(ref bounds)).center.z < 100.5f) && !(((Bounds)(ref bounds)).center.z > 103.5f) && !(((Bounds)(ref bounds)).max.x < 58.2f) && !(((Bounds)(ref bounds)).min.x > 63.8f))
				{
					((Component)item).gameObject.SetActive(false);
					_hidden.Add(((Component)item).gameObject);
					num++;
				}
			}
			ParkCore.Log.Msg($"Skate Park: opened the pier railing for the walkway ({num} piece(s) taken down).");
		}

		internal static void Reset()
		{
			foreach (GameObject item in _hidden)
			{
				try
				{
					if ((Object)(object)item != (Object)null)
					{
						item.SetActive(true);
					}
				}
				catch
				{
				}
			}
			_hidden.Clear();
			if ((Object)(object)Root != (Object)null)
			{
				Object.Destroy((Object)(object)Root);
			}
			Root = null;
			Built = false;
			_lamps.Clear();
			Ride.Reset();
		}

		internal static void Tick()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!Built || Time.unscaledTime < _lampCheck)
			{
				return;
			}
			_lampCheck = Time.unscaledTime + 5f;
			bool enabled = false;
			try
			{
				Light sun = RenderSettings.sun;
				enabled = (Object)(object)sun == (Object)null || sun.intensity < 0.35f || Vector3.Dot(((Component)sun).transform.forward, Vector3.down) < 0.1f;
			}
			catch
			{
			}
			foreach (Light lamp in _lamps)
			{
				if ((Object)(object)lamp != (Object)null)
				{
					((Behaviour)lamp).enabled = enabled;
				}
			}
		}

		private static T Add<T>(GameObject go) where T : Component
		{
			return ((Il2CppObjectBase)go.AddComponent(Il2CppType.Of<T>())).Cast<T>();
		}

		private static void Measure()
		{
			//IL_001f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_008e: 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)
			Top = -3.9f;
			_layer = 0;
			Vector3 val = new Vector3(61f, 40f, 101f);
			float num = float.NegativeInfinity;
			foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(val, Vector3.down, 80f, -1, (QueryTriggerInteraction)1))
			{
				RaycastHit current = item;
				if (!((Object)(object)((RaycastHit)(ref current)).collider == (Object)null))
				{
					Bounds bounds = ((RaycastHit)(ref current)).collider.bounds;
					if (!(((Bounds)(ref bounds)).size.x < 4f) && !(((Bounds)(ref bounds)).size.z < 4f) && ((RaycastHit)(ref current)).point.y > num)
					{
						num = ((RaycastHit)(ref current)).point.y;
						_layer = ((Component)((RaycastHit)(ref current)).collider).gameObject.layer;
					}
				}
			}
			if (!float.IsNegativeInfinity(num))
			{
				Top = num + 0.02f;
			}
			Top = Mathf.Clamp(Top, -4.5f, 3f);
		}

		private static float Ground(float x, float z, float fallback)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_00a3: 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)
			float num = float.NegativeInfinity;
			foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(new Vector3(x, 40f, z), Vector3.down, 80f, -1, (QueryTriggerInteraction)1))
			{
				RaycastHit current = item;
				if (!((Object)(object)((RaycastHit)(ref current)).collider == (Object)null) && (!((Object)(object)Root != (Object)null) || !((Component)((RaycastHit)(ref current)).collider).transform.IsChildOf(Root.transform)))
				{
					Bounds bounds = ((RaycastHit)(ref current)).collider.bounds;
					if (!(((Bounds)(ref bounds)).size.x < 4f) && !(((Bounds)(ref bounds)).size.z < 4f) && ((RaycastHit)(ref current)).point.y > num)
					{
						num = ((RaycastHit)(ref current)).point.y;
					}
				}
			}
			if (!float.IsNegativeInfinity(num))
			{
				return num;
			}
			return fallback;
		}

		private static void Survey()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			HashSet<string> hashSet = new HashSet<string>();
			for (float num = 28f; num < 72f; num += 4f)
			{
				for (float num2 = 126f; num2 < 170f; num2 += 4f)
				{
					foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(new Vector3(num, Top + 30f, num2), Vector3.down, 29.5f, -1, (QueryTriggerInteraction)1))
					{
						RaycastHit current = item;
						if ((Object)(object)((RaycastHit)(ref current)).collider != (Object)null && !((Component)((RaycastHit)(ref current)).collider).transform.IsChildOf(Root.transform) && ((RaycastHit)(ref current)).point.y > Top + 0.3f)
						{
							hashSet.Add(((Object)((RaycastHit)(ref current)).collider).name);
						}
					}
				}
			}
			if (hashSet.Count > 0)
			{
				ParkCore.Log.Msg("Skate Park: things standing on the park: " + string.Join(", ", hashSet));
			}
		}

		private static void SetLayer(Transform t, int layer)
		{
			((Component)t).gameObject.layer = layer;
			for (int i = 0; i < t.childCount; i++)
			{
				SetLayer(t.GetChild(i), layer);
			}
		}

		private static GameObject Solid(Transform parent, string name, Vector3 centre, Vector3 size, Material m, bool collider = true)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = name;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = centre;
			val.transform.localScale = size;
			((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = m;
			if (!collider)
			{
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
			}
			return val;
		}

		private static GameObject Cyl(Transform parent, string name, Vector3 a, Vector3 b, float radius, Material m, bool collider)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)val).name = name;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = (a + b) * 0.5f;
			Transform transform = val.transform;
			Vector3 up = Vector3.up;
			Vector3 val2 = b - a;
			transform.localRotation = Quaternion.FromToRotation(up, ((Vector3)(ref val2)).normalized);
			Transform transform2 = val.transform;
			float num = radius * 2f;
			val2 = b - a;
			transform2.localScale = new Vector3(num, ((Vector3)(ref val2)).magnitude * 0.5f, radius * 2f);
			((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = m;
			if (!collider)
			{
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
			}
			return val;
		}

		private static GameObject MeshObj(Transform parent, string name, List<Vector3> v, List<int> tris, Material m, Vector3 pos, float yaw)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = pos;
			val.transform.localRotation = Quaternion.Euler(0f, yaw, 0f);
			Mesh val2 = new Mesh();
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			for (int i = 0; i < tris.Count; i++)
			{
				list.Add(v[tris[i]]);
				list2.Add(i);
			}
			val2.vertices = Il2CppStructArray<Vector3>.op_Implicit(list.ToArray());
			val2.SetTriangles(Il2CppStructArray<int>.op_Implicit(list2.ToArray()), 0);
			val2.RecalculateNormals();
			val2.RecalculateBounds();
			Add<MeshFilter>(val).sharedMesh = val2;
			((Renderer)Add<MeshRenderer>(val)).sharedMaterial = m;
			Add<MeshCollider>(val).sharedMesh = val2;
			return val;
		}

		private static GameObject Extrude(Transform parent, string name, List<Vector2> profile, float w, Material m, Vector3 pos, float yaw)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_001a: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = pos;
			val.transform.localRotation = Quaternion.Euler(0f, yaw, 0f);
			int count = profile.Count;
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			float num = w * 0.5f;
			for (int i = 0; i < count; i++)
			{
				list.Add(new Vector3(0f - num, profile[i].y, profile[i].x));
				list.Add(new Vector3(num, profile[i].y, profile[i].x));
			}
			for (int j = 0; j < count - 1; j++)
			{
				int num2 = j * 2;
				int item = num2 + 1;
				int item2 = num2 + 2;
				int item3 = num2 + 3;
				list2.Add(num2);
				list2.Add(item2);
				list2.Add(item);
				list2.Add(item);
				list2.Add(item2);
				list2.Add(item3);
			}
			int num3 = 0;
			for (int k = 1; k < count; k++)
			{
				if (profile[k].x > profile[num3].x + 0.001f || (Mathf.Abs(profile[k].x - profile[num3].x) <= 0.001f && profile[k].y < profile[num3].y))
				{
					num3 = k;
				}
			}
			float[] array = new float[2]
			{
				0f - num,
				num
			};
			foreach (float num4 in array)
			{
				int count2 = list.Count;
				for (int n = 0; n < count; n++)
				{
					list.Add(new Vector3(num4, profile[n].y, profile[n].x));
				}
				List<int> list3 = new List<int>();
				for (int num5 = 1; num5 < count - 1; num5++)
				{
					int num6 = (num3 + num5) % count;
					int num7 = (num3 + num5 + 1) % count;
					list3.Add(count2 + num3);
					list3.Add(count2 + num6);
					list3.Add(count2 + num7);
				}
				float num8 = 0f;
				int num9 = 0;
				for (int num10 = 0; num10 < list3.Count; num10 += 3)
				{
					Vector3 val2 = Vector3.Cross(list[list3[num10 + 1]] - list[list3[num10]], list[list3[num10 + 2]] - list[list3[num10]]);
					if (((Vector3)(ref val2)).magnitude > num8)
					{
						num8 = ((Vector3)(ref val2)).magnitude;
						num9 = num10;
					}
				}
				Vector3 val3 = Vector3.Cross(list[list3[num9 + 1]] - list[list3[num9]], list[list3[num9 + 2]] - list[list3[num9]]);
				bool flag = (num4 < 0f && val3.x > 0f) || (num4 > 0f && val3.x < 0f);
				for (int num11 = 0; num11 < list3.Count; num11 += 3)
				{
					if (flag)
					{
						list2.Add(list3[num11]);
						list2.Add(list3[num11 + 2]);
						list2.Add(list3[num11 + 1]);
					}
					else
					{
						list2.Add(list3[num11]);
						list2.Add(list3[num11 + 1]);
						list2.Add(list3[num11 + 2]);
					}
				}
			}
			Mesh val4 = new Mesh();
			val4.vertices = Il2CppStructArray<Vector3>.op_Implicit(list.ToArray());
			val4.SetTriangles(Il2CppStructArray<int>.op_Implicit(list2.ToArray()), 0);
			val4.RecalculateNormals();
			val4.RecalculateBounds();
			Add<MeshFilter>(val).sharedMesh = val4;
			((Renderer)Add<MeshRenderer>(val)).sharedMaterial = m;
			Add<MeshCollider>(val).sharedMesh = val4;
			return val;
		}

		private static void QuarterPipe(Transform t, string name, Vector3 pos, float yaw, float width, float height, float deck)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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)
			float num = height / (1f - Mathf.Cos((float)Math.PI * 2f / 5f));
			float num2 = num * Mathf.Sin((float)Math.PI * 2f / 5f);
			List<Vector2> list = new List<Vector2>();
			list.Add(new Vector2(-0.6f, 0f));
			int num3 = 18;
			for (int i = 0; i <= num3; i++)
			{
				float num4 = (float)Math.PI * 2f / 5f * (float)i / (float)num3;
				list.Add(new Vector2(num * Mathf.Sin(num4), num * (1f - Mathf.Cos(num4))));
			}
			list.Add(new Vector2(num2 + deck, height));
			list.Add(new Vector2(num2 + deck, -0.05f));
			list.Add(new Vector2(-0.6f, -0.05f));
			GameObject obj = Extrude(t, name, list, width, RampPaint, pos - Quaternion.Euler(0f, yaw, 0f) * new Vector3(0f, 0f, num2), yaw);
			Vector3 a = obj.transform.localPosition + Quaternion.Euler(0f, yaw, 0f) * new Vector3((0f - width) * 0.5f, height - 0.02f, num2);
			Vector3 b = obj.transform.localPosition + Quaternion.Euler(0f, yaw, 0f) * new Vector3(width * 0.5f, height - 0.02f, num2);
			Cyl(t, name + "Coping", a, b, 0.05f, Steel, collider: false);
		}

		private static void Bank(Transform t, string name, Vector3 backCentre, float yaw, float width, float height, float run, float top)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			List<Vector2> profile = new List<Vector2>
			{
				new Vector2(0f - run - top, 0f),
				new Vector2(0f - top, height),
				new Vector2(0f, height),
				new Vector2(0f, -0.05f),
				new Vector2(0f - run - top, -0.05f)
			};
			Extrude(t, name, profile, width, Smooth, backCentre, yaw);
		}

		private static void Kicker(Transform t, string name, Vector3 pos, float yaw)
		{
			//IL_0010: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			List<Vector2> list = new List<Vector2>
			{
				new Vector2(-1.2f, 0f)
			};
			int num = 8;
			for (int i = 1; i <= num; i++)
			{
				float num2 = (float)i / (float)num;
				list.Add(new Vector2(-1.2f + 2.4f * num2, 0.75f * (num2 * num2 * 0.55f + num2 * 0.45f)));
			}
			list.Add(new Vector2(1.2f, -0.05f));
			list.Add(new Vector2(-1.2f, -0.05f));
			Extrude(t, name, list, 2.2f, Yellow, pos, yaw);
		}

		private static void Funbox(Transform t, Vector3 c)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.9f;
			float num2 = 6f;
			float num3 = 4f;
			float num4 = 3.2f;
			Solid(t, "FunboxTop", c + new Vector3(0f, num * 0.5f, 0f), new Vector3(num2, num, num3), Smooth);
			List<Vector2> profile = new List<Vector2>
			{
				new Vector2(0f - num4, 0f),
				new Vector2(0f, num),
				new Vector2(0f, -0.05f),
				new Vector2(0f - num4, -0.05f)
			};
			Extrude(t, "FunboxRampW", profile, num3, RampPaint, c + new Vector3((0f - num2) * 0.5f, 0f, 0f), 90f);
			Extrude(t, "FunboxRampE", profile, num3, RampPaint, c + new Vector3(num2 * 0.5f, 0f, 0f), -90f);
			Rail(t, "FunboxBar", c + new Vector3(0f, num, 0f), 90f, num2 - 0.6f, 0.3f, round: false);
		}

		private static void Pyramid(Transform t, string name, Vector3 c, float baseSize, float topSize, float h)
		{
			//IL_0020: 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_0045: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			float num = baseSize * 0.5f;
			float num2 = topSize * 0.5f;
			List<Vector3> v = new List<Vector3>
			{
				new Vector3(0f - num, 0f, 0f - num),
				new Vector3(num, 0f, 0f - num),
				new Vector3(num, 0f, num),
				new Vector3(0f - num, 0f, num),
				new Vector3(0f - num2, h, 0f - num2),
				new Vector3(num2, h, 0f - num2),
				new Vector3(num2, h, num2),
				new Vector3(0f - num2, h, num2)
			};
			List<int> tris = new List<int>
			{
				4, 6, 5, 4, 7, 6, 0, 4, 1, 1,
				4, 5, 1, 5, 2, 2, 5, 6, 2, 6,
				3, 3, 6, 7, 3, 7, 0, 0, 7, 4,
				0, 1, 2, 0, 2, 3
			};
			MeshObj(t, name, v, tris, Smooth, c, 0f);
		}

		private static void Ledge(Transform t, string name, Vector3 c, float yaw, float len)
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.Euler(0f, yaw, 0f);
			Solid(t, name, c + new Vector3(0f, 0.225f, 0f), new Vector3(len, 0.45f, 0.7f), Concrete).transform.localRotation = val;
			Cyl(t, name + "CopingN", c + val * new Vector3((0f - len) * 0.5f, 0.45f, 0.33f), c + val * new Vector3(len * 0.5f, 0.45f, 0.33f), 0.03f, Steel, collider: false);
			Cyl(t, name + "CopingS", c + val * new Vector3((0f - len) * 0.5f, 0.45f, -0.33f), c + val * new Vector3(len * 0.5f, 0.45f, -0.33f), 0.03f, Steel, collider: false);
		}

		private static void Rail(Transform t, string name, Vector3 c, float yaw, float len, float h, bool round)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_005a: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.Euler(0f, yaw, 0f);
			Vector3 val2 = c + val * new Vector3(0f, h, (0f - len) * 0.5f);
			Vector3 val3 = c + val * new Vector3(0f, h, len * 0.5f);
			if (round)
			{
				Cyl(t, name, val2, val3, 0.035f, Steel, collider: true);
			}
			else
			{
				Solid(t, name, (val2 + val3) * 0.5f, new Vector3(0.06f, 0.06f, len), Steel).transform.localRotation = val;
			}
			float[] array = new float[2] { 0.12f, 0.88f };
			foreach (float num in array)
			{
				Vector3 val4 = Vector3.Lerp(val2, val3, num);
				Solid(t, name + "Post", new Vector3(val4.x, (val4.y - c.y) * 0.5f + c.y, val4.z), new Vector3(0.06f, val4.y - c.y, 0.06f), Dark);
			}
		}

		private static void StairSet(Transform t, Vector3 c)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f;
			float num2 = 8f;
			float num3 = 5f;
			Solid(t, "Platform", c + new Vector3(0f, num * 0.5f, 0f), new Vector3(num2, num, num3), Concrete);
			List<Vector2> profile = new List<Vector2>
			{
				new Vector2(-4f, 0f),
				new Vector2(0f, num),
				new Vector2(0f, -0.05f),
				new Vector2(-4f, -0.05f)
			};
			Extrude(t, "PlatformRamp", profile, num3, Smooth, c + new Vector3((0f - num2) * 0.5f, 0f, 0f), 90f);
			for (int i = 0; i < 3; i++)
			{
				float num4 = num - (float)(i + 1) * (num / 3f);
				if (num4 <= 0.01f)
				{
					break;
				}
				Solid(t, "Step" + i, c + new Vector3(1f, num4 * 0.5f, num3 * 0.5f + 0.2f + (float)i * 0.4f), new Vector3(num2 - 2f, num4, 0.4f), Concrete);
			}
			Vector3 val = c + new Vector3(num2 * 0.5f - 0.6f, num + 0.75f, num3 * 0.5f - 0.6f);
			Vector3 val2 = c + new Vector3(num2 * 0.5f - 0.6f, 0.75f, num3 * 0.5f + 1.6f);
			Cyl(t, "HandRail", val, val2, 0.035f, Steel, collider: true);
			Solid(t, "HandRailPostA", new Vector3(val.x, num + 0.375f, val.z), new Vector3(0.06f, 0.75f, 0.06f), Dark);
			Solid(t, "HandRailPostB", new Vector3(val2.x, 0.375f + c.y, val2.z), new Vector3(0.06f, 0.75f, 0.06f), Dark);
		}

		private static void Ramp(Transform t, string name, Vector3 from, Vector3 to, float width, Material m)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = from + new Vector3(width * 0.5f, 0f, 0f);
			Vector3 val2 = to + new Vector3(width * 0.5f, 0f, 0f);
			Vector3 val3 = val2 - val;
			Solid(t, name, (val + val2) * 0.5f + Vector3.down * 0.1f, new Vector3(width, 0.2f, ((Vector3)(ref val3)).magnitude + 0.4f), m).transform.localRotation = Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up);
		}

		private static void Lamp(Transform t, Vector3 at)
		{
			//IL_0006: 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_002f: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			Solid(t, "LampPole", at + new Vector3(0f, 3.5f, 0f), new Vector3(0.16f, 7f, 0.16f), Dark);
			Solid(t, "LampHead", at + new Vector3(0f, 7.05f, 0f), new Vector3(0.7f, 0.15f, 0.4f), Dark, collider: false);
			GameObject val = new GameObject("LampLight");
			val.transform.SetParent(t, false);
			val.transform.localPosition = at + new Vector3(0f, 6.8f, 0f);
			val.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
			Light val2 = Add<Light>(val);
			val2.type = (LightType)0;
			val2.spotAngle = 120f;
			val2.range = 22f;
			val2.intensity = 2.2f;
			val2.color = new Color(1f, 0.95f, 0.85f);
			val2.shadows = (LightShadows)0;
			((Behaviour)val2).enabled = false;
			_lamps.Add(val2);
		}

		private static void Sign(Transform t, Vector3 at)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			float num = 7f;
			Solid(t, "SignPostW", at + new Vector3((0f - num) * 0.5f, 1.8f, 0f), new Vector3(0.15f, 3.6f, 0.15f), Dark);
			Solid(t, "SignPostE", at + new Vector3(num * 0.5f, 1.8f, 0f), new Vector3(0.15f, 3.6f, 0.15f), Dark);
			Solid(t, "SignBoard", at + new Vector3(0f, 3.35f, 0f), new Vector3(num, 0.8f, 0.12f), Dark, collider: false);
			float[] array = new float[2] { -1f, 1f };
			foreach (float num2 in array)
			{
				try
				{
					GameObject val = new GameObject("SignText");
					val.transform.SetParent(t, false);
					val.transform.localPosition = at + new Vector3(0f, 3.35f, num2 * 0.07f);
					val.transform.localRotation = Quaternion.Euler(0f, (num2 < 0f) ? 0f : 180f, 0f);
					TextMeshPro obj = val.AddComponent<TextMeshPro>();
					((TMP_Text)obj).text = "SKATE PARK";
					((TMP_Text)obj).enableAutoSizing = true;
					((TMP_Text)obj).fontSizeMin = 0.3f;
					((TMP_Text)obj).fontSizeMax = 6f;
					((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
					((Graphic)obj).color = new Color(0.98f, 0.78f, 0.12f);
					((TMP_Text)obj).fontStyle = (FontStyles)1;
					((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(num - 0.4f, 0.7f);
					((TMP_Text)obj).ForceMeshUpdate(false, false);
				}
				catch (Exception ex)
				{
					ParkCore.Log.Msg("Skate Park: sign text skipped (" + ex.Message + ").");
				}
			}
		}
	}
	public sealed class ParkCore : MelonMod
	{
		internal static Instance Log;

		private static bool _ok;

		private static float _warnedAt = -100f;

		public override void OnInitializeMelon()
		{
			Log = ((MelonBase)this).LoggerInstance;
			try
			{
				FortifyApi.Init((MelonMod)(object)this, "SkatePark", "Skate Park");
				FortifyApi.AfterLoad += Park.Build;
				FortifyApi.Unloaded += Park.Reset;
				_ok = true;
				Log.Msg("Skate Park loaded: a public skate park on the water east of the shooting range, and smoother, faster skateboards.");
			}
			catch (Exception ex)
			{
				Log.Error("Skate Park couldn't start: " + ex.Message + ". It needs MelonLoader 0.7 and S1API (Bars fork) 3.2.3 or newer.");
			}
		}

		public override void OnUpdate()
		{
			if (!_ok || !FortifyApi.InGame)
			{
				return;
			}
			try
			{
				FortifyApi.Frame();
				Park.Tick();
			}
			catch (Exception ex)
			{
				if (Time.unscaledTime - _warnedAt > 30f)
				{
					_warnedAt = Time.unscaledTime;
					Log.Warning("Skate Park: " + ex.Message);
				}
			}
		}

		public override void OnFixedUpdate()
		{
			if (!_ok || !FortifyApi.InGame)
			{
				return;
			}
			try
			{
				Ride.Fixed();
			}
			catch (Exception ex)
			{
				if (Time.unscaledTime - _warnedAt > 30f)
				{
					_warnedAt = Time.unscaledTime;
					Log.Warning("Skate Park ride: " + ex.Message);
				}
			}
		}
	}
	internal static class Ride
	{
		private sealed class Defaults
		{
			public float TopSpeed;

			public float Push;

			public float Friction;

			public float Jump;
		}

		private static readonly Dictionary<IntPtr, Defaults> Saved = new Dictionary<IntPtr, Defaults>();

		private static Skateboard _board;

		private static bool _wasGrounded;

		private static float _carry;

		internal static void Reset()
		{
			Restore();
			Saved.Clear();
			_board = null;
		}

		private static void Restore()
		{
			try
			{
				if ((Object)(object)_board != (Object)null && Saved.TryGetValue(((Il2CppObjectBase)_board).Pointer, out var value))
				{
					_board.TopSpeed_Kmh = value.TopSpeed;
					_board.PushForceMultiplier = value.Push;
					_board.LongitudinalFrictionMultiplier = value.Friction;
					_board.JumpForce = value.Jump;
				}
			}
			catch
			{
			}
		}

		internal static void Fixed()
		{
			//IL_019c: 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)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: 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_030d: 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_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			Skateboard val = null;
			try
			{
				Player local = Player.Local;
				val = (((Object)(object)local != (Object)null) ? local.ActiveSkateboard : null);
			}
			catch
			{
			}
			if ((Object)(object)val != (Object)(object)_board)
			{
				Restore();
				_board = val;
				_carry = 0f;
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Rigidbody rb = val.Rb;
			if ((Object)(object)rb == (Object)null || rb.isKinematic)
			{
				return;
			}
			bool flag = Park.Built && Park.Inside(((Component)val).transform.position);
			if (!Saved.TryGetValue(((Il2CppObjectBase)val).Pointer, out var value))
			{
				value = new Defaults
				{
					TopSpeed = val.TopSpeed_Kmh,
					Push = val.PushForceMultiplier,
					Friction = val.LongitudinalFrictionMultiplier,
					Jump = val.JumpForce
				};
				Saved[((Il2CppObjectBase)val).Pointer] = value;
			}
			float num = (flag ? 1.45f : 1.25f);
			val.TopSpeed_Kmh = value.TopSpeed * num;
			val.PushForceMultiplier = value.Push * (flag ? 1.4f : 1.25f);
			val.LongitudinalFrictionMultiplier = value.Friction * (flag ? 0.45f : 0.65f);
			val.JumpForce = value.Jump * (flag ? 1.3f : 1.15f);
			_ = Time.fixedDeltaTime;
			float mass = rb.mass;
			Vector3 velocity = rb.velocity;
			bool flag2 = false;
			Vector3 val2 = Vector3.up;
			Transform val3 = null;
			try
			{
				val3 = (((Object)(object)Player.Local != (Object)null) ? ((Component)Player.Local).transform : null);
			}
			catch
			{
			}
			Vector3 val4 = ((Component)val).transform.position + ((Component)val).transform.up * 0.3f;
			float num2 = float.MaxValue;
			foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(val4, -((Component)val).transform.up, 0.85f, -1, (QueryTriggerInteraction)1))
			{
				RaycastHit current = item;
				if (!((Object)(object)((RaycastHit)(ref current)).collider == (Object)null))
				{
					Transform transform = ((Component)((RaycastHit)(ref current)).collider).transform;
					if (!transform.IsChildOf(((Component)val).transform) && (!((Object)(object)val3 != (Object)null) || !transform.IsChildOf(val3)) && ((RaycastHit)(ref current)).distance < num2)
					{
						num2 = ((RaycastHit)(ref current)).distance;
						val2 = ((RaycastHit)(ref current)).normal;
						flag2 = true;
					}
				}
			}
			if (flag2)
			{
				float num3 = Vector3.Angle(val2, Vector3.up);
				Vector3 val5 = Vector3.ProjectOnPlane(Vector3.down, val2);
				float magnitude = ((Vector3)(ref velocity)).magnitude;
				if (num3 > 3f && ((Vector3)(ref val5)).sqrMagnitude > 0.0001f && magnitude > 0.5f)
				{
					((Vector3)(ref val5)).Normalize();
					Vector3 gravity = Physics.gravity;
					float num4 = ((Vector3)(ref gravity)).magnitude * Mathf.Sin(num3 * ((float)Math.PI / 180f));
					float num5 = Vector3.Dot(((Vector3)(ref velocity)).normalized, val5);
					if (num5 < -0.2f)
					{
						float num6 = (flag ? 0.75f : 0.55f);
						rb.AddForce(-val5 * num4 * num6 * mass * Mathf.Clamp01(0f - num5), (ForceMode)0);
						if (num3 > 25f)
						{
							rb.AddForce(-val2 * magnitude * magnitude * 0.35f * mass, (ForceMode)0);
						}
					}
					else if (num5 > 0.2f)
					{
						float num7 = (flag ? 0.45f : 0.25f);
						rb.AddForce(val5 * num4 * num7 * mass * num5, (ForceMode)0);
					}
				}
				float num8 = val.TopSpeed_Kmh / 3.6f * (flag ? 1.25f : 1.1f);
				if (magnitude > num8)
				{
					rb.velocity = velocity * (num8 / magnitude);
				}
				_carry = magnitude;
			}
			else
			{
				float num9 = (flag ? 0.22f : 0.12f);
				rb.AddForce(-Physics.gravity * num9 * mass, (ForceMode)0);
				if (_wasGrounded && _carry > 1f)
				{
					Vector3 val6 = default(Vector3);
					((Vector3)(ref val6))..ctor(velocity.x, 0f, velocity.z);
					if (((Vector3)(ref val6)).magnitude < _carry * 0.6f)
					{
						_ = velocity.y;
						_ = 1f;
					}
				}
			}
			_wasGrounded = flag2;
		}
	}
	internal static class GltfLoader
	{
		public static GameObject LoadEmbedded(string fileName, Transform parent)
		{
			using Stream stream = Res.Open("SkatePark.models." + fileName);
			if (stream == null)
			{
				throw new FileNotFoundException("Embedded model missing: " + fileName);
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return Load(memoryStream.ToArray(), Path.GetFileNameWithoutExtension(fileName), parent);
		}

		public static GameObject Load(byte[] glb, string name, Transform parent)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			if (glb.Length < 20 || BitConverter.ToUInt32(glb, 0) != 1179937895)
			{
				throw new InvalidDataException("Not a GLB file");
			}
			int num = (int)BitConverter.ToUInt32(glb, 12);
			string json = Encoding.UTF8.GetString(glb, 20, num);
			int bin = 20 + num + 8;
			using JsonDocument jsonDocument = JsonDocument.Parse(json);
			JsonElement rootElement = jsonDocument.RootElement;
			Material[] materials = BuildMaterials(rootElement);
			Dictionary<int, (Mesh, Material[])> meshCache = new Dictionary<int, (Mesh, Material[])>();
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			JsonElement property = rootElement.GetProperty("nodes");
			HashSet<int> hashSet = new HashSet<int>();
			for (int i = 0; i < property.GetArrayLength(); i++)
			{
				if (!property[i].TryGetProperty("children", out var value))
				{
					continue;
				}
				foreach (JsonElement item in value.EnumerateArray())
				{
					hashSet.Add(item.GetInt32());
				}
			}
			for (int j = 0; j < property.GetArrayLength(); j++)
			{
				if (!hashSet.Contains(j))
				{
					BuildNode(rootElement, property, j, val.transform, glb, bin, materials, meshCache);
				}
			}
			return val;
		}

		private static void BuildNode(JsonElement root, JsonElement nodes, int index, Transform parent, byte[] glb, int bin, Material[] materials, Dictionary<int, (Mesh, Material[])> meshCache)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			JsonElement jsonElement = nodes[index];
			JsonElement value;
			GameObject val = new GameObject(jsonElement.TryGetProperty("name", out value) ? value.GetString() : ("node" + index));
			Transform transform = val.transform;
			transform.SetParent(parent, false);
			if (jsonElement.TryGetProperty("translation", out var value2))
			{
				transform.localPosition = new Vector3(value2[0].GetSingle(), value2[1].GetSingle(), 0f - value2[2].GetSingle());
			}
			if (jsonElement.TryGetProperty("rotation", out var value3))
			{
				transform.localRotation = new Quaternion(0f - value3[0].GetSingle(), 0f - value3[1].GetSingle(), value3[2].GetSingle(), value3[3].GetSingle());
			}
			if (jsonElement.TryGetProperty("scale", out var value4))
			{
				transform.localScale = new Vector3(value4[0].GetSingle(), value4[1].GetSingle(), value4[2].GetSingle());
			}
			if (jsonElement.TryGetProperty("mesh", out var value5))
			{
				int @int = value5.GetInt32();
				if (!meshCache.TryGetValue(@int, out var value6))
				{
					(Mesh, Material[]) tuple = (meshCache[@int] = BuildMesh(root, @int, glb, bin, materials));
					value6 = tuple;
				}
				val.AddComponent<MeshFilter>().sharedMesh = value6.Item1;
				MeshRenderer val2 = val.AddComponent<MeshRenderer>();
				Il2CppReferenceArray<Material> val3 = new Il2CppReferenceArray<Material>((long)value6.Item2.Length);
				for (int i = 0; i < value6.Item2.Length; i++)
				{
					((Il2CppArrayBase<Material>)(object)val3)[i] = value6.Item2[i];
				}
				((Renderer)val2).sharedMaterials = val3;
			}
			if (!jsonElement.TryGetProperty("children", out var value7))
			{
				return;
			}
			foreach (JsonElement item in value7.EnumerateArray())
			{
				BuildNode(root, nodes, item.GetInt32(), transform, glb, bin, materials, meshCache);
			}
		}

		private static (Mesh, Material[]) BuildMesh(JsonElement root, int meshIndex, byte[] glb, int bin, Material[] materials)
		{
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			JsonElement property = root.GetProperty("meshes")[meshIndex].GetProperty("primitives");
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Vector2> list3 = new List<Vector2>();
			List<int[]> list4 = new List<int[]>();
			List<Material> list5 = new List<Material>();
			foreach (JsonElement item in property.EnumerateArray())
			{
				JsonElement property2 = item.GetProperty("attributes");
				int count = list.Count;
				int count2;
				float[] array = ReadFloats(root, property2.GetProperty("POSITION").GetInt32(), glb, bin, out count2);
				for (int i = 0; i < count2; i++)
				{
					list.Add(new Vector3(array[i * 3], array[i * 3 + 1], 0f - array[i * 3 + 2]));
				}
				int count3;
				if (property2.TryGetProperty("NORMAL", out var value))
				{
					float[] array2 = ReadFloats(root, value.GetInt32(), glb, bin, out count3);
					for (int j = 0; j < count2; j++)
					{
						list2.Add(new Vector3(array2[j * 3], array2[j * 3 + 1], 0f - array2[j * 3 + 2]));
					}
				}
				else
				{
					for (int k = 0; k < count2; k++)
					{
						list2.Add(Vector3.up);
					}
				}
				if (property2.TryGetProperty("TEXCOORD_0", out var value2))
				{
					float[] array3 = ReadFloats(root, value2.GetInt32(), glb, bin, out count3);
					for (int l = 0; l < count2; l++)
					{
						list3.Add(new Vector2(array3[l * 2], 1f - array3[l * 2 + 1]));
					}
				}
				else
				{
					for (int m = 0; m < count2; m++)
					{
						list3.Add(Vector2.zero);
					}
				}
				int[] array4;
				if (item.TryGetProperty("indices", out var value3))
				{
					array4 = ReadIndices(root, value3.GetInt32(), glb, bin);
				}
				else
				{
					array4 = new int[count2];
					for (int n = 0; n < count2; n++)
					{
						array4[n] = n;
					}
				}
				for (int num = 0; num + 2 < array4.Length; num += 3)
				{
					int num2 = array4[num] + count;
					int num3 = array4[num + 1] + count;
					int num4 = array4[num + 2] + count;
					array4[num] = num2;
					array4[num + 1] = num4;
					array4[num + 2] = num3;
				}
				list4.Add(array4);
				JsonElement value4;
				int num5 = (item.TryGetProperty("material", out value4) ? value4.GetInt32() : (-1));
				list5.Add((num5 >= 0 && num5 < materials.Length) ? materials[num5] : Models.Mat("gltf_default", Color.gray));
			}
			Mesh val = new Mesh
			{
				name = "HTF_" + meshIndex
			};
			if (list.Count > 65000)
			{
				val.indexFormat = (IndexFormat)1;
			}
			val.vertices = new Il2CppStructArray<Vector3>(list.ToArray());
			val.normals = new Il2CppStructArray<Vector3>(list2.ToArray());
			val.uv = new Il2CppStructArray<Vector2>(list3.ToArray());
			val.subMeshCount = list4.Count;
			for (int num6 = 0; num6 < list4.Count; num6++)
			{
				val.SetTriangles(new Il2CppStructArray<int>(list4[num6]), num6);
			}
			val.RecalculateBounds();
			((Object)val).hideFlags = (HideFlags)32;
			return (val, list5.ToArray());
		}

		private static Material[] BuildMaterials(JsonElement root)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			if (!root.TryGetProperty("materials", out var value))
			{
				return Array.Empty<Material>();
			}
			Material[] array = (Material[])(object)new Material[value.GetArrayLength()];
			for (int i = 0; i < array.Length; i++)
			{
				JsonElement jsonElement = value[i];
				JsonElement value2;
				string text = (jsonElement.TryGetProperty("name", out value2) ? value2.GetString() : ("mat" + i));
				Color white = Color.white;
				float metallic = 1f;
				float num = 1f;
				if (jsonElement.TryGetProperty("pbrMetallicRoughness", out var value3))
				{
					if (value3.TryGetProperty("baseColorFactor", out var value4))
					{
						((Color)(ref white))..ctor(value4[0].GetSingle(), value4[1].GetSingle(), value4[2].GetSingle(), value4[3].GetSingle());
					}
					if (value3.TryGetProperty("metallicFactor", out var value5))
					{
						metallic = value5.GetSingle();
					}
					if (value3.TryGetProperty("roughnessFactor", out var value6))
					{
						num = value6.GetSingle();
					}
				}
				Color? emission = null;
				if (jsonElement.TryGetProperty("emissiveFactor", out var value7))
				{
					float num2 = 1f;
					if (jsonElement.TryGetProperty("extensions", out var value8) && value8.TryGetProperty("KHR_materials_emissive_strength", out var value9) && value9.TryGetProperty("emissiveStrength", out var value10))
					{
						num2 = value10.GetSingle();
					}
					Color value11 = new Color(value7[0].GetSingle(), value7[1].GetSingle(), value7[2].GetSingle()) * Mathf.Min(num2, 8f) * 0.5f;
					if (((Color)(ref value11)).maxColorComponent > 0.001f)
					{
						emission = value11;
					}
				}
				array[i] = Models.Mat("glb_" + text, white, metallic, 1f - num, emission);
			}
			return array;
		}

		private static float[] ReadFloats(JsonElement root, int accessor, byte[] glb, int bin, out int count)
		{
			JsonElement jsonElement = root.GetProperty("accessors")[accessor];
			count = jsonElement.GetProperty("count").GetInt32();
			int num = Components(jsonElement.GetProperty("type").GetString());
			JsonElement jsonElement2 = root.GetProperty("bufferViews")[jsonElement.GetProperty("bufferView").GetInt32()];
			JsonElement value;
			JsonElement value2;
			int num2 = bin + (jsonElement2.TryGetProperty("byteOffset", out value) ? value.GetInt32() : 0) + (jsonElement.TryGetProperty("byteOffset", out value2) ? value2.GetInt32() : 0);
			JsonElement value3;
			int num3 = (jsonElement2.TryGetProperty("byteStride", out value3) ? value3.GetInt32() : (num * 4));
			float[] array = new float[count * num];
			for (int i = 0; i < count; i++)
			{
				for (int j = 0; j < num; j++)
				{
					array[i * num + j] = BitConverter.ToSingle(glb, num2 + i * num3 + j * 4);
				}
			}
			return array;
		}

		private static int[] ReadIndices(JsonElement root, int accessor, byte[] glb, int bin)
		{
			JsonElement jsonElement = root.GetProperty("accessors")[accessor];
			int @int = jsonElement.GetProperty("count").GetInt32();
			int int2 = jsonElement.GetProperty("componentType").GetInt32();
			JsonElement value;
			JsonElement value2;
			int num = bin + (root.GetProperty("bufferViews")[jsonElement.GetProperty("bufferView").GetInt32()].TryGetProperty("byteOffset", out value) ? value.GetInt32() : 0) + (jsonElement.TryGetProperty("byteOffset", out value2) ? value2.GetInt32() : 0);
			int[] array = new int[@int];
			for (int i = 0; i < @int; i++)
			{
				int[] array2 = array;
				int num2 = i;
				int[] array3 = array2;
				int num3 = num2;
				array3[num3] = int2 switch
				{
					5121 => glb[num + i], 
					5123 => BitConverter.ToUInt16(glb, num + i * 2), 
					_ => (int)BitConverter.ToUInt32(glb, num + i * 4), 
				};
			}
			return array;
		}

		private static int Components(string type)
		{
			return type switch
			{
				"SCALAR" => 1, 
				"VEC2" => 2, 
				"VEC3" => 3, 
				"VEC4" => 4, 
				_ => 1, 
			};
		}
	}
	internal static class Kit
	{
		internal const string ModelResourcePrefix = "SkatePark.models.";

		internal const string Prefix = "np_";
	}
	internal static class Models
	{
		private static readonly Dictionary<string, Material> Mats = new Dictionary<string, Material>();

		private static Shader _lit;

		private static Shader LitShader()
		{
			if ((Object)(object)_lit == (Object)null)
			{
				_lit = Shader.Find("Universal Render Pipeline/Lit");
			}
			if ((Object)(object)_lit == (Object)null)
			{
				_lit = Shader.Find("Universal Render Pipeline/Simple Lit");
			}
			if ((Object)(object)_lit == (Object)null)
			{
				foreach (Material item in Resources.FindObjectsOfTypeAll<Material>())
				{
					if ((Object)(object)item != (Object)null && (Object)(object)item.shader != (Object)null && ((Object)item.shader).name.Contains("Lit"))
					{
						_lit = item.shader;
						break;
					}
				}
			}
			if ((Object)(object)_lit == (Object)null)
			{
				_lit = Shader.Find("Standard");
			}
			return _lit;
		}

		public static Material Mat(string key, Color color, float metallic = 0f, float smoothness = 0.3f, Color? emission = null)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_003d: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			if (Mats.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = new Material(LitShader())
			{
				name = "np_" + key,
				color = color
			};
			if (value.HasProperty("_BaseColor"))
			{
				value.SetColor("_BaseColor", color);
			}
			if (value.HasProperty("_Metallic"))
			{
				value.SetFloat("_Metallic", metallic);
			}
			if (value.HasProperty("_Smoothness"))
			{
				value.SetFloat("_Smoothness", smoothness);
			}
			if (emission.HasValue)
			{
				value.EnableKeyword("_EMISSION");
				if (value.HasProperty("_EmissionColor"))
				{
					value.SetColor("_EmissionColor", emission.Value);
				}
			}
			((Object)value).hideFlags = (HideFlags)32;
			Mats[key] = value;
			return value;
		}
	}
}
namespace SkatePark.FybCommon
{
	internal static class FortifyApi
	{
		private sealed class SaveDoc
		{
			public int Version { get; set; } = 1;

			public string Created { get; set; }

			public Dictionary<string, string> Data { get; set; } = new Dictionary<string, string>();
		}

		private static Instance _log;

		private static string _folder;

		private static MelonPreferences_Entry<bool> _devKeys;

		private static KeyCode _use = (KeyCode)101;

		private static readonly List<string> DrawnIds = new List<string>();

		private static Harmony _harmony;

		private static bool _loaded;

		private static int _inGameFrame = -1;

		private static bool _inGame;

		private static string _iconItem;

		private static Sprite _icon;

		private static Dictionary<string, string> _data = new Dictionary<string, string>();

		private static string _file;

		private static bool _readThisSession;

		private static bool _patched;

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

		private static Shader _lit;

		private static readonly HashSet<IntPtr> Drawn = new HashSet<IntPtr>();

		private static float _nextDraw;

		private static readonly List<(string label, AudioClip clip)> NoSongs = new List<(string, AudioClip)>();

		private static GUIStyle _hintStyle;

		public static bool Linked => FybLink.Present;

		public static string LinkedVersion
		{
			get
			{
				if (!FybLink.Present)
				{
					return null;
				}
				return Safe(FybLink.Version, "?");
			}
		}

		public static bool InGame
		{
			get
			{
				if (Time.frameCount == _inGameFrame)
				{
					return _inGame;
				}
				_inGameFrame = Time.frameCount;
				_inGame = false;
				if (_loaded)
				{
					try
					{
						LoadManager instance = Singleton<LoadManager>.Instance;
						_inGame = (Object)(object)instance != (Object)null && instance.IsGameLoaded;
					}
					catch
					{
					}
				}
				return _inGame;
			}
		}

		public static bool IsGuest
		{
			get
			{
				try
				{
					return InstanceFinder.IsClient && !InstanceFinder.IsServer;
				}
				catch
				{
					return false;
				}
			}
		}

		public static bool IsHost => !IsGuest;

		public static bool DevKeys
		{
			get
			{
				MelonPreferences_Entry<bool> devKeys = _devKeys;
				if (devKeys == null || !devKeys.Value)
				{
					if (FybLink.Present)
					{
						return Safe(FybLink.DevKeys, fallback: false);
					}
					return false;
				}
				return true;
			}
		}

		public static bool DataReady { get; private set; }

		public static KeyCode UseKey
		{
			get
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				if (!FybLink.Present)
				{
					return _use;
				}
				return Safe(FybLink.UseKey, _use);
			}
		}

		public static IReadOnlyList<(string label, AudioClip clip)> YourSongs
		{
			get
			{
				if (FybLink.Present)
				{
					try
					{
						return FybLink.Songs() ?? NoSongs;
					}
					catch
					{
					}
				}
				return NoSongs;
			}
		}

		public static event Action BeforeSave;

		public static event Action AfterLoad;

		public static event Action Unloaded;

		public static void Init(MelonMod mod, string folder, string title, params string[] keepDrawnIdPrefixes)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			_log = ((MelonBase)mod).LoggerInstance;
			_folder = folder;
			DrawnIds.AddRange(keepDrawnIdPrefixes);
			MelonPreferences_Category obj = MelonPreferences.CreateCategory(folder, title);
			_devKeys = obj.CreateEntry<bool>("DevKeys", false, "Developer keys", "Test keys (for the mod's author).", false, false, (ValueValidator)null, (string)null);
			_use = Keys.Parse(obj.CreateEntry<string>("UseKey", "E", "Use key", "Key for using things. With Fortify Your Base installed, its own use key is used instead.", false, false, (ValueValidator)null, (string)null).Value, (KeyCode)101);
			GameLifecycle.OnLoadComplete += OnLoaded;
			GameLifecycle.OnSaveStart += OnSaving;
			GameLifecycle.OnPreSceneChange += OnLeaving;
			_harmony = ((MelonBase)mod).HarmonyInstance;
		}

		public static void Log(string msg)
		{
			Instance log = _log;
			if (log != null)
			{
				log.Msg(msg);
			}
		}

		public static void Frame()
		{
			long num = 0L;
			Ui.Capture();
			Shared.Update();
			DrawPass();
			RainCover.Update();
			TreeCut.Update();
		}

		public static void SetNotifyIcon(string itemId)
		{
			_iconItem = itemId;
			_icon = null;
		}

		public static void Notify(string title, string text)
		{
			try
			{
				NotificationsManager instance = Singleton<NotificationsManager>.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					Log(title + ": " + text);
					return;
				}
				if ((Object)(object)_icon == (Object)null && !string.IsNullOrEmpty(_iconItem))
				{
					try
					{
						ItemDefinition item = Registry.GetItem<ItemDefinition>(_iconItem);
						_icon = ((item != null) ? ((BaseItemDefinition)item).Icon : null);
					}
					catch
					{
					}
				}
				instance.SendNotification(title, text, _icon, 6f, true);
			}
			catch (Exception ex)
			{
				Log($"{title}: {text} ({ex.Message})");
			}
		}

		public static void LogEvent(string kind, string place, int crew, string outcome)
		{
			if (FybLink.Present)
			{
				try
				{
					FybLink.LogEvent(kind, place, crew, outcome);
				}
				catch
				{
				}
			}
		}

		public static string GetData(string key)
		{
			if (key == null || !_data.TryGetValue(key, out var value))
			{
				return null;
			}
			return value;
		}

		public static void SetData(string key, string value)
		{
			if (key != null)
			{
				_data[key] = value ?? "";
			}
		}

		private static void OnLoaded()
		{
			_loaded = true;
			if (!_patched)
			{
				_patched = true;
				try
				{
					Pins.Patch(_harmony);
				}
				catch (Exception ex)
				{
					Log("Pins: " + ex.Message);
				}
			}
			_data = new Dictionary<string, string>();
			_file = FileFor(SavePath());
			try
			{
				if (_file != null && File.Exists(_file))
				{
					SaveDoc saveDoc = JsonSerializer.Deserialize<SaveDoc>(File.ReadAllText(_file));
					if (saveDoc != null && SaveStamp.IsStale(_file, saveDoc.Created))
					{
						Log("This is a new game in a save slot that was used before, so this mod starts fresh here (the old game's data was set aside).");
						SaveStamp.Retire(_file);
						saveDoc = null;
					}
					if (saveDoc?.Data != null)
					{
						_data = saveDoc.Data;
					}
				}
				else if (_file != null)
				{
					Migrate();
				}
			}
			catch (Exception ex2)
			{
				Log("Couldn't read the save (" + ex2.Message + "); starting fr