Decompiled source of Hoverboard v1.0.1

Hoverboard_Mono_1.0.1.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Hoverboard;
using Hoverboard.Config;
using Hoverboard.Factory;
using Hoverboard.TemplateUtils;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using ScheduleOne;
using ScheduleOne.AvatarFramework.Equipping;
using ScheduleOne.Core.Items.Framework;
using ScheduleOne.DevUtilities;
using ScheduleOne.Dialogue;
using ScheduleOne.Equipping;
using ScheduleOne.Experimental;
using ScheduleOne.ItemFramework;
using ScheduleOne.NPCs.CharacterClasses;
using ScheduleOne.Persistence;
using ScheduleOne.Skating;
using ScheduleOne.Storage;
using ScheduleOne.Weather;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "Hoverboard", "1.0.1", "OverweightUnicorn", null)]
[assembly: MelonColor(255, 191, 0, 255)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ScheduleOne.Core")]
[assembly: AssemblyCompany("Hoverboard_Mono_1.0.1")]
[assembly: AssemblyConfiguration("MONO")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyInformationalVersion("1.0.0+c8c4a866a913699a437e6f1195f4deeafae9d65e")]
[assembly: AssemblyProduct("Hoverboard_Mono_1.0.1")]
[assembly: AssemblyTitle("Hoverboard_Mono_1.0.1")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Hoverboard
{
	public static class BuildInfo
	{
		public const string Name = "Hoverboard";

		public const string Description = "Adds a hoverboard to the game...because why not?";

		public const string Author = "OverweightUnicorn";

		public const string Company = "UnicornsCanMod";

		public const string Version = "1.0.1";

		public const string DownloadLink = null;
	}
	public class Core : MelonMod
	{
		public override void OnInitializeMelon()
		{
			AssetBundleUtils.Initialize(this);
			HoverboardConfig.Initialize();
		}

		public override void OnLateInitializeMelon()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(InitMod));
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Main" && (Object)(object)HoverboardFactory.hoverboardPrefab == (Object)null)
			{
				HoverboardFactory.Init();
			}
			else
			{
				HoverboardFactory.Reset();
			}
		}

		public void InitMod()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00a4: 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_00ca: Expected O, but got Unknown
			Jeff val = Object.FindObjectOfType<Jeff>();
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			GameObject gameObject = ((Component)val).gameObject;
			Transform val2 = gameObject.transform.Find("Dialogue");
			if ((Object)(object)val2 != (Object)null)
			{
				DialogueController_SkateboardSeller component = ((Component)val2).gameObject.GetComponent<DialogueController_SkateboardSeller>();
				if ((Object)(object)component != (Object)null && Registry.ItemExists("hoverboard"))
				{
					ItemDefinition item = Registry.GetItem<ItemDefinition>("hoverboard");
					Option item2 = new Option
					{
						Name = "Hoverboard",
						Price = HoverboardConfig.Price.Value,
						IsAvailable = ((Object)(object)item != (Object)null),
						NotAvailableReason = (((Object)(object)item != (Object)null) ? "You aren't cool enough" : "Item definition not found"),
						Item = item
					};
					component.Options.Add(item2);
					Utility.Success("Added hoverboard to seller options");
				}
				else
				{
					Utility.Log("Dialogue Controller doesn't exist");
				}
			}
			else
			{
				Utility.Error("Could not find Dialogue child on Jeff");
			}
		}
	}
	public static class Utility
	{
		public static void PrintException(Exception e)
		{
			MelonLogger.Msg(ConsoleColor.Red, e.Source);
			MelonLogger.Msg(ConsoleColor.DarkRed, e.Message);
		}

		public static void Error(string msg)
		{
			MelonLogger.Msg(ConsoleColor.Red, msg);
		}

		public static void Log(string msg)
		{
			MelonLogger.Msg(ConsoleColor.DarkMagenta, msg);
		}

		public static void Success(string msg)
		{
			MelonLogger.Msg(ConsoleColor.Green, msg);
		}

		public static void ListHierarchy(Transform transform, int depth)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			string text = new string(' ', depth * 2);
			MelonLogger.Msg(text + "- " + ((Object)transform).name);
			foreach (Transform item in transform)
			{
				Transform transform2 = item;
				ListHierarchy(transform2, depth + 1);
			}
		}
	}
}
namespace Hoverboard.TemplateUtils
{
	public static class AssetBundleUtils
	{
		private static Core mod;

		private static MelonAssembly melonAssembly;

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

		public static void Initialize(Core coreMod)
		{
			mod = coreMod;
			melonAssembly = ((MelonBase)mod).MelonAssembly;
		}

		public static AssetBundle LoadAssetBundle(string bundleFileName)
		{
			if (assetBundles.ContainsKey(bundleFileName))
			{
				return assetBundles[bundleFileName];
			}
			try
			{
				string text = typeof(Core).Namespace + ".Assets." + bundleFileName;
				Stream manifestResourceStream = melonAssembly.Assembly.GetManifestResourceStream(text ?? "");
				if (manifestResourceStream == null)
				{
					((MelonBase)mod).Unregister("AssetBundle: '" + text + "' not found. \nOpen .csproj file and search for '" + bundleFileName + "'.\nIf it doesn't exist,\nCopy your asset to Assets/ folder then look for 'your.assetbundle' in .csproj file.", false);
					return null;
				}
				AssetBundle val = AssetBundle.LoadFromStream(manifestResourceStream);
				assetBundles.Add(bundleFileName, val);
				return val;
			}
			catch (Exception arg)
			{
				((MelonBase)mod).Unregister($"Failed to load AssetBundle. Please report to dev: {arg}", false);
				return null;
			}
		}

		public static AssetBundle GetLoadedAssetBundle(string bundleName)
		{
			if (assetBundles.ContainsKey(bundleName))
			{
				return assetBundles[bundleName];
			}
			((MelonBase)mod).Unregister("Failed to get " + bundleName, false);
			throw new Exception("Asset '" + bundleName + "' has not been loaded in yet");
		}

		public static T LoadAssetFromBundle<T>(string assetName, string bundleName) where T : Object
		{
			AssetBundle loadedAssetBundle = GetLoadedAssetBundle(bundleName);
			if ((Object)(object)loadedAssetBundle == (Object)null)
			{
				throw new Exception("Couldn't find " + bundleName + ", Did you load it?");
			}
			T val = loadedAssetBundle.LoadAsset<T>(assetName);
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception(assetName + " not found in bundle");
			}
			return val;
		}
	}
}
namespace Hoverboard.Factory
{
	public static class HoverboardFactory
	{
		public const string ITEM_ID = "hoverboard";

		private const string ITEM_NAME = "Hoverboard";

		private const string SOURCE_SKATEBOARD_ID = "goldenskateboard";

		public static GameObject refStorage;

		public static GameObject hoverboardPrefab;

		public static GameObject visualPrefab;

		public static Skateboard hoverSkateboard;

		public static SkateboardVisuals hoverVisuals;

		public static SkateboardEffects hoverEffects;

		private static AvatarEquippable hoverAvatar;

		private static Skateboard_Equippable hoverEquippable;

		private static StoredItem hoverStored;

		private static SkateboardData hoverData;

		private static Sprite hoverIcon;

		public static MeshFilter hoverBoardFilter;

		public static MeshRenderer hoverBoardRenderer;

		public static AudioClip rollingAudio;

		private static Vector3? _trail0OriginalLocalPosition;

		private static Vector3? _trailMidpointLocalPosition;

		public static void Init()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			refStorage = new GameObject("HoverboardReferenceStorage");
			refStorage.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)refStorage);
			try
			{
				LoadCustomAssets();
				if ((Object)(object)hoverBoardFilter != (Object)null && (Object)(object)hoverBoardRenderer != (Object)null)
				{
					hoverSkateboard = CreateSkateboardPrefab();
					if ((Object)(object)hoverSkateboard == (Object)null)
					{
						Utility.Error("Failed to create Skateboard prefab");
					}
					hoverAvatar = CreateAvatarEquippablePrefab();
					if ((Object)(object)hoverAvatar == (Object)null)
					{
						Utility.Error("Failed to create AvatarEquippable prefab");
					}
					hoverEquippable = CreateEquippablePrefab();
					if ((Object)(object)hoverEquippable == (Object)null)
					{
						Utility.Error("Failed to create Equippable prefab");
					}
					hoverStored = CreateStoredPrefab();
					if ((Object)(object)hoverStored == (Object)null)
					{
						Utility.Error("Failed to create Stored prefab");
					}
					CreateVisualPrefab();
					if ((Object)(object)hoverSkateboard != (Object)null && (Object)(object)hoverAvatar != (Object)null && (Object)(object)hoverEquippable != (Object)null && (Object)(object)hoverStored != (Object)null)
					{
						((Equippable_Viewmodel)hoverEquippable).AvatarEquippable = hoverAvatar;
						hoverEquippable.SkateboardPrefab = hoverSkateboard;
						hoverSkateboard.Equippable = hoverEquippable;
						hoverSkateboard.SlowOnTerrain = false;
						SkateboardData val = Object.Instantiate<SkateboardData>(hoverSkateboard._defaultData, refStorage.transform);
						if ((Object)(object)val != (Object)null)
						{
							hoverData = val;
							hoverSkateboard._defaultData = val;
						}
						ApplyHoverSettings();
						NeutralizeRainOverride();
						SkateboardAudio componentInChildren = ((Component)hoverSkateboard).gameObject.GetComponentInChildren<SkateboardAudio>();
						if ((Object)(object)componentInChildren != (Object)null)
						{
							Transform obj = ((Component)componentInChildren).transform.Find("Audio Source (Skateboard rolling, FX)");
							AudioSource val2 = ((obj != null) ? ((Component)obj).GetComponent<AudioSource>() : null);
							Transform obj2 = ((Component)componentInChildren).transform.Find("Audio Source (Skateboard rolling, FX) (1)");
							AudioSource val3 = ((obj2 != null) ? ((Component)obj2).GetComponent<AudioSource>() : null);
							Transform obj3 = ((Component)componentInChildren).transform.Find("Audio Source (, FX)");
							AudioSource val4 = ((obj3 != null) ? ((Component)obj3).GetComponent<AudioSource>() : null);
							Transform obj4 = ((Component)componentInChildren).transform.Find("Audio Source (, FX)");
							AudioSource val5 = ((obj4 != null) ? ((Component)obj4).GetComponent<AudioSource>() : null);
							if ((Object)(object)componentInChildren.JumpAudio != (Object)null)
							{
								((UnityEventBase)hoverSkateboard.OnJump).RemoveAllListeners();
								AudioClip clip = ((Component)componentInChildren.JumpAudio).gameObject.GetComponent<AudioSource>().clip;
								((Component)componentInChildren.JumpAudio).gameObject.SetActive(false);
								if ((Object)(object)clip == (Object)null)
								{
									((Component)componentInChildren.JumpAudio).gameObject.GetComponent<AudioSource>().clip = null;
								}
							}
							if ((Object)(object)componentInChildren.LandAudio != (Object)null)
							{
								((Component)componentInChildren.LandAudio).gameObject.SetActive(false);
							}
							if ((Object)(object)rollingAudio != (Object)null)
							{
								if ((Object)(object)val2 != (Object)null)
								{
									val2.clip = rollingAudio;
								}
								else
								{
									Utility.Error("Rolling FX is NULL");
								}
								if ((Object)(object)val3 != (Object)null)
								{
									val3.clip = rollingAudio;
									Utility.Log("Dirt rolling audio clip assigned successfully");
								}
								else
								{
									Utility.Error("audioController.DirtRollingAudio is NULL");
								}
							}
							else
							{
								Utility.Error("rollingAudio clip is NULL");
							}
						}
						else
						{
							Utility.Error("Audio controller is NULL");
						}
						Utility.Log("11. Configuring Visuals");
						SkateboardVisuals componentInChildren2 = ((Component)hoverSkateboard).gameObject.GetComponentInChildren<SkateboardVisuals>();
						if ((Object)(object)componentInChildren2 != (Object)null)
						{
							hoverVisuals = componentInChildren2;
							hoverVisuals.MaxBoardLean = HoverboardConfig.MaxBoardLean.Value;
							hoverVisuals.BoardLeanRate = HoverboardConfig.BoardLeanRate.Value;
						}
						Utility.Log("12. Configuring Effects");
						SkateboardEffects componentInChildren3 = ((Component)hoverSkateboard).gameObject.GetComponentInChildren<SkateboardEffects>();
						if ((Object)(object)componentInChildren3 != (Object)null)
						{
							hoverEffects = componentInChildren3;
							ApplyTrailSettings();
						}
						Utility.Log("13. Creating Storable");
						CreateStorableDefinition();
					}
					else
					{
						Utility.Error("Failed to create one or more hoverboard prefabs - initialization incomplete");
					}
				}
				else
				{
					if ((Object)(object)hoverBoardFilter == (Object)null)
					{
						Utility.Error("HoverBoardFilter is null - failed to load mesh");
					}
					if ((Object)(object)hoverBoardRenderer == (Object)null)
					{
						Utility.Error("HoverBoardRenderer is null - failed to load renderer");
					}
					Utility.Error("Initialization aborted due to missing mesh or renderer");
				}
			}
			catch (Exception ex)
			{
				Utility.Error("=== CRITICAL ERROR during Hoverboard Factory Initialization ===");
				Utility.Log(ex.ToString());
			}
		}

		public static SkateboardSettings GetDefaultSettings()
		{
			if ((Object)(object)hoverSkateboard == (Object)null)
			{
				return null;
			}
			if (hoverSkateboard.DefaultSettings == null)
			{
				return null;
			}
			return hoverSkateboard.DefaultSettings;
		}

		public static void ApplyHoverSettings()
		{
			SkateboardSettings defaultSettings = GetDefaultSettings();
			if (defaultSettings == null)
			{
				Utility.Error("ApplyHoverSettings: could not get default settings");
				return;
			}
			defaultSettings.HoverHeight = HoverboardConfig.HoverHeight.Value;
			defaultSettings.TopSpeed_Kmh = HoverboardConfig.TopSpeed.Value;
			defaultSettings.HoverRayLength = HoverboardConfig.HoverHeight.Value + 0.05f;
			defaultSettings.Hover_P = HoverboardConfig.Proportional.Value;
			defaultSettings.Hover_I = HoverboardConfig.Integral.Value;
			defaultSettings.Hover_D = HoverboardConfig.Derivative.Value;
			RefreshActiveSettings();
			Utility.Log($"ApplyHoverSettings: HoverHeight={defaultSettings.HoverHeight}, P={defaultSettings.Hover_P}, I={defaultSettings.Hover_I}, D={defaultSettings.Hover_D}");
		}

		public static void RefreshActiveSettings()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (!((Object)(object)hoverSkateboard == (Object)null))
			{
				hoverSkateboard.OnWeatherChange(new WeatherConditions());
			}
		}

		private static void NeutralizeRainOverride()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_008f: 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_00a5: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			if (!((Object)(object)hoverSkateboard == (Object)null))
			{
				if ((Object)(object)hoverSkateboard._rainOverrideData == (Object)null)
				{
					Utility.Error("NeutralizeRainOverride: _rainOverrideData is null on hoverSkateboard - cannot neutralize rain override");
					return;
				}
				SkateboardOverrideData val = ScriptableObject.CreateInstance<SkateboardOverrideData>();
				val.Categories = (OverrideCategory)5;
				val.Settings = new SkateboardSettings
				{
					TurnForce = -1f,
					TurnChangeRate = -1f,
					TurnReturnToRestRate = -1f,
					TurnSpeedBoost = -1f,
					Gravity = -1f,
					BrakeForce = -1f,
					ReverseTopSpeed_Kmh = -1f,
					RotationClampForce = -1f,
					LongitudinalFrictionMultiplier = 0.8f,
					LateralFrictionForceMultiplier = 0.8f,
					JumpForce = -1f,
					JumpDuration_Min = -1f,
					JumpDuration_Max = -1f,
					JumpForwardBoost = -1f,
					HoverForce = -1f,
					HoverRayLength = -1f,
					HoverHeight = -1f,
					Hover_P = -1f,
					Hover_I = -1f,
					Hover_D = -1f,
					TopSpeed_Kmh = -1f,
					PushForceMultiplier = -1f,
					PushForceDuration = -1f,
					PushDelay = -1f,
					AirMovementForce = -1f,
					AirMovementJumpReductionDuration = -1f
				};
				hoverSkateboard._rainOverrideData = val;
				Utility.Log("NeutralizeRainOverride: rain override replaced - hover fields protected");
			}
		}

		public static void ApplyTrailSettings()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: 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_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hoverEffects == (Object)null)
			{
				Utility.Error("ApplyTrailSettings: hoverEffects is null");
				return;
			}
			TrailRenderer[] trails = hoverEffects.Trails;
			if (trails == null || trails.Length == 0)
			{
				Utility.Error("ApplyTrailSettings: no trails found on hoverEffects");
				return;
			}
			if (!_trail0OriginalLocalPosition.HasValue)
			{
				_trail0OriginalLocalPosition = ((Component)trails[0]).transform.localPosition;
				Vector3 val = Vector3.zero;
				for (int i = 0; i < trails.Length; i++)
				{
					val += ((Component)trails[i]).transform.localPosition;
				}
				val /= (float)trails.Length;
				_trailMidpointLocalPosition = val;
			}
			int num = Mathf.Clamp(HoverboardConfig.TrailCount.Value, 0, trails.Length);
			float value = HoverboardConfig.TrailWidth.Value;
			float value2 = HoverboardConfig.TrailSpread.Value;
			switch (num)
			{
			case 0:
			{
				TrailRenderer[] array = trails;
				foreach (TrailRenderer val2 in array)
				{
					((Component)val2).gameObject.SetActive(false);
				}
				return;
			}
			case 1:
			{
				((Component)trails[0]).gameObject.SetActive(true);
				((Component)trails[0]).transform.localPosition = _trailMidpointLocalPosition.Value;
				ApplyTrailAppearance(trails[0], value, HoverboardConfig.TrailColors[0].Value);
				for (int k = 1; k < trails.Length; k++)
				{
					((Component)trails[k]).gameObject.SetActive(false);
				}
				return;
			}
			}
			float x = _trailMidpointLocalPosition.Value.x;
			float num2 = value2 / 2f;
			((Component)trails[0]).gameObject.SetActive(true);
			((Component)trails[0]).transform.localPosition = _trail0OriginalLocalPosition.Value;
			ApplyTrailAppearance(trails[0], value, HoverboardConfig.TrailColors[0].Value);
			if (trails.Length > 1)
			{
				((Component)trails[1]).gameObject.SetActive(true);
				float num3 = _trail0OriginalLocalPosition.Value.x - x;
				Vector3 value3 = _trailMidpointLocalPosition.Value;
				value3.x = x - num3;
				((Component)trails[0]).transform.localPosition = new Vector3(x - num2, _trail0OriginalLocalPosition.Value.y, _trail0OriginalLocalPosition.Value.z);
				((Component)trails[1]).transform.localPosition = new Vector3(x + num2, value3.y, value3.z);
				ApplyTrailAppearance(trails[1], value, HoverboardConfig.TrailColors[1].Value);
			}
		}

		private static void ApplyTrailAppearance(TrailRenderer trail, float width, Color color)
		{
			//IL_0016: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			trail.startWidth = width;
			trail.endWidth = 0f;
			float a = trail.startColor.a;
			trail.startColor = new Color(color.r, color.g, color.b, a);
			trail.endColor = new Color(color.r, color.g, color.b, 0f);
		}

		public static void LoadCustomAssets()
		{
			AssetBundleUtils.LoadAssetBundle("hoverboard");
			GameObject val = AssetBundleUtils.LoadAssetFromBundle<GameObject>("hoverboard.prefab", "hoverboard");
			if ((Object)(object)val != (Object)null && (Object)(object)hoverboardPrefab == (Object)null)
			{
				hoverboardPrefab = Object.Instantiate<GameObject>(val, refStorage.transform);
				Object.DontDestroyOnLoad((Object)(object)hoverboardPrefab);
				Sprite val2 = AssetBundleUtils.LoadAssetFromBundle<Sprite>("hoverboardvisual_icon.png", "hoverboard");
				if ((Object)(object)val2 != (Object)null)
				{
					hoverIcon = val2;
					Object.DontDestroyOnLoad((Object)(object)hoverIcon);
				}
				else
				{
					Utility.Error("Failed to load icon sprite - icon will be missing");
				}
				AudioClip val3 = AssetBundleUtils.LoadAssetFromBundle<AudioClip>("hoverloop1.mp3", "hoverboard");
				if ((Object)(object)val3 != (Object)null)
				{
					rollingAudio = val3;
					Object.DontDestroyOnLoad((Object)(object)rollingAudio);
				}
				else
				{
					Utility.Error("Failed to load jump audio 1 clip - jump sound will be missing");
				}
				MeshFilter component = hoverboardPrefab.GetComponent<MeshFilter>();
				if ((Object)(object)component != (Object)null)
				{
					hoverBoardFilter = component;
				}
				else
				{
					Utility.Error("MeshFilter component not found on hoverboard prefab");
				}
				MeshRenderer component2 = hoverboardPrefab.GetComponent<MeshRenderer>();
				if ((Object)(object)component2 != (Object)null)
				{
					hoverBoardRenderer = component2;
				}
				else
				{
					Utility.Error("MeshRenderer component not found on hoverboard prefab");
				}
			}
			else if ((Object)(object)val == (Object)null)
			{
				Utility.Error("Failed to load hoverboard prefab from asset bundle - asset is null");
			}
			else if ((Object)(object)hoverboardPrefab != (Object)null)
			{
				Utility.Error("Hoverboard prefab already exists - skipping instantiation");
			}
		}

		private static void HideTrucks(Transform prefab, string path)
		{
			Transform val = prefab.Find(path);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if ((Object)(object)val != (Object)null)
			{
				Transform val2 = val.Find("Truck");
				if ((Object)(object)val2 != (Object)null)
				{
					((Component)val2).gameObject.SetActive(false);
				}
				else
				{
					Utility.Error("Truck (1) not found in BoardContainer");
				}
				Transform val3 = val.Find("Truck (1)");
				if ((Object)(object)val3 != (Object)null)
				{
					((Component)val3).gameObject.SetActive(false);
				}
				else
				{
					Utility.Error("Truck (2) not found in BoardContainer");
				}
			}
			else
			{
				Utility.Error("BoardContainer not found - unable to hide trucks");
			}
		}

		public static Skateboard CreateSkateboardPrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboard");
			GameObject val2 = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)val2).name = "Hoverboard";
			HideTrucks(val2.transform, "Model/Skateboard");
			Transform val3 = val2.transform.Find("Model/Skateboard/BoardContainer/Board");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val3).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
				Transform val4 = val3.Find("BoardModel");
				if ((Object)(object)val4 != (Object)null)
				{
					((Component)val4).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
					((Renderer)((Component)val4).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
					Transform val5 = val4.Find("GoldSkateboardVisual/GoldSkateboard/BoardContainer/Board");
					if ((Object)(object)val5 != (Object)null)
					{
						((Component)val5).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
						((Renderer)((Component)val5).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
					}
				}
				return val2.GetComponent<Skateboard>();
			}
			return null;
		}

		public static AvatarEquippable CreateAvatarEquippablePrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboard_AvatarEquippable");
			GameObject val2 = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)val2).name = "Hoverboard_AvatarEquippable";
			HideTrucks(val2.transform, "GoldSkateboardVisual/GoldSkateboard");
			Transform val3 = val2.transform.Find("GoldSkateboardVisual/GoldSkateboard/BoardContainer/Board");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val3).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
				return val2.GetComponent<AvatarEquippable>();
			}
			return null;
		}

		public static Skateboard_Equippable CreateEquippablePrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboard_Equippable");
			GameObject val2 = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)val2).name = "Hoverboard_Equippable";
			Skateboard_Equippable component = val2.GetComponent<Skateboard_Equippable>();
			HideTrucks(val2.transform, "GoldSkateboardVisual/GoldSkateboard");
			component.SkateboardPrefab = null;
			Transform val3 = val2.transform.Find("GoldSkateboardVisual/GoldSkateboard/BoardContainer/Board");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val3).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
				return component;
			}
			return null;
		}

		public static StoredItem CreateStoredPrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboard_Stored");
			GameObject val2 = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)val2).name = "Hoverboard_Stored";
			HideTrucks(val2.transform, "GoldSkateboardVisual/GoldSkateboard");
			Transform val3 = val2.transform.Find("GoldSkateboardVisual/GoldSkateboard/BoardContainer/Board");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val3).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
				return val2.GetComponent<StoredItem>();
			}
			return null;
		}

		public static StorableItemDefinition CreateStorableDefinition()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			ItemDefinition item = Registry.GetItem<ItemDefinition>("goldenskateboard");
			if ((Object)(object)item != (Object)null)
			{
				StorableItemDefinition val = (StorableItemDefinition)(object)((item is StorableItemDefinition) ? item : null);
				StorableItemDefinition val2 = Object.Instantiate<StorableItemDefinition>(val);
				if ((Object)(object)val2 != (Object)null)
				{
					((BaseItemDefinition)val2).ID = "hoverboard";
					((Object)val2).name = "Hoverboard";
					((BaseItemDefinition)val2).Name = "Hoverboard";
					((BaseItemDefinition)val2).Description = "A futuristic skateboard that hovers above the ground.";
					((BaseItemDefinition)val2).StackLimit = 1;
					((ItemDefinition)val2).Equippable = (Equippable)(object)hoverEquippable;
					val2.StoredItem = hoverStored;
					((BaseItemDefinition)val2).legalStatus = (ELegalStatus)0;
					((BaseItemDefinition)val2).Category = (EItemCategory)3;
					((ItemDefinition)val2).AvailableInDemo = true;
					val2.BasePurchasePrice = HoverboardConfig.Price.Value;
					val2.ResellMultiplier = HoverboardConfig.ResellMultiplier.Value;
					if ((Object)(object)hoverIcon != (Object)null)
					{
						((BaseItemDefinition)val2).Icon = hoverIcon;
					}
					Singleton<Registry>.Instance.AddToRegistry((ItemDefinition)(object)val2);
					return val2;
				}
			}
			return null;
		}

		public static void CreateVisualPrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboardVisual");
			visualPrefab = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)visualPrefab).name = "Hoverboard_Visuals";
			Transform val2 = visualPrefab.transform.Find("GoldSkateboard/BoardContainer/Board");
			if ((Object)(object)val2 != (Object)null)
			{
				((Component)val2).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val2).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
			}
		}

		public static void Reset()
		{
			refStorage = null;
			visualPrefab = null;
			hoverboardPrefab = null;
			hoverSkateboard = null;
			hoverVisuals = null;
			hoverEffects = null;
			hoverAvatar = null;
			hoverEquippable = null;
			hoverStored = null;
			_trail0OriginalLocalPosition = null;
			_trailMidpointLocalPosition = null;
			Utility.Log("HoverboardFactory.Reset: scene state cleared");
		}
	}
}
namespace Hoverboard.Config
{
	public static class HoverboardConfig
	{
		private static MelonPreferences_Category _category;

		public static MelonPreferences_Entry<float> Price;

		public static MelonPreferences_Entry<float> ResellMultiplier;

		public static MelonPreferences_Entry<float> HoverHeight;

		public static MelonPreferences_Entry<float> TopSpeed;

		public static MelonPreferences_Entry<float> Proportional;

		public static MelonPreferences_Entry<float> Integral;

		public static MelonPreferences_Entry<float> Derivative;

		public static MelonPreferences_Entry<float> MaxBoardLean;

		public static MelonPreferences_Entry<float> BoardLeanRate;

		public static MelonPreferences_Entry<int> TrailCount;

		public static MelonPreferences_Entry<float> TrailWidth;

		public static MelonPreferences_Entry<float> TrailSpread;

		public static MelonPreferences_Entry<Color>[] TrailColors;

		private const int MaxTrails = 2;

		public static void Initialize()
		{
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			_category = MelonPreferences.CreateCategory("Hoverboard");
			Price = _category.CreateEntry<float>("Price", 2000f, "(Requires Save Reload) The price of the hoverboard in the in-game shop.\nDefault: 2000", (string)null, false, false, (ValueValidator)null, (string)null);
			ResellMultiplier = _category.CreateEntry<float>("Resell Multiplier", 0.6f, "(Requires Save Reload) The resell price multiplier.\nDefault: 0.6", (string)null, false, false, (ValueValidator)null, (string)null);
			HoverHeight = _category.CreateEntry<float>("Hover Height", 2f, "The height at which the hoverboard hovers above the ground.\nDefault: 2", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)HoverHeight.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings5 = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings5 != null)
				{
					defaultSettings5.HoverHeight = newValue;
					defaultSettings5.HoverRayLength = newValue + 0.05f;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			TopSpeed = _category.CreateEntry<float>("Top Speed", 32f, "The maximum speed of the hoverboard.\nDefault: 32", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)TopSpeed.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings4 = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings4 != null)
				{
					defaultSettings4.TopSpeed_Kmh = newValue;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			MaxBoardLean = _category.CreateEntry<float>("Max Board Lean", 8f, "The maximum angle the board leans when turning.\nDefault: 8", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)MaxBoardLean.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				if ((Object)(object)HoverboardFactory.hoverVisuals != (Object)null)
				{
					HoverboardFactory.hoverVisuals.MaxBoardLean = newValue;
				}
			}, 0, false);
			BoardLeanRate = _category.CreateEntry<float>("Board Lean Rate", 2f, "How quickly the board leans when turning.\nDefault: 2", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)BoardLeanRate.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				if ((Object)(object)HoverboardFactory.hoverVisuals != (Object)null)
				{
					HoverboardFactory.hoverVisuals.BoardLeanRate = newValue;
				}
			}, 0, false);
			Proportional = _category.CreateEntry<float>("Proportional", 2.7f, "How strongly the board reacts to height errors.\nHigher = Snappier response | Lower = Sluggish response\nDefault: 2.7", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)Proportional.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings3 = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings3 != null)
				{
					defaultSettings3.Hover_P = newValue;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			Integral = _category.CreateEntry<float>("Integral", 0.1f, "How much the board corrects over time to reach exact height.\nHigher = Rigid, locked height | Lower = Floaty, drifty feel\nDefault: 0.1", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)Integral.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings2 = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings2 != null)
				{
					defaultSettings2.Hover_I = newValue;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			Derivative = _category.CreateEntry<float>("Derivative", 0.5f, "How much the board resists sudden height changes.\nHigher = Smooth over bumps, less bounce | Lower = Bouncy, reactive\nDefault: 0.5", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)Derivative.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings != null)
				{
					defaultSettings.Hover_D = newValue;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			TrailCount = _category.CreateEntry<int>("Trail Count", 2, "Number of active trails. 0 = none, 2 = max", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<int, int>>)(object)TrailCount.OnEntryValueChanged).Subscribe((LemonAction<int, int>)delegate
			{
				HoverboardFactory.ApplyTrailSettings();
			}, 0, false);
			TrailWidth = _category.CreateEntry<float>("Trail Width", 0.05f, "Width of each trail renderer.\n Default: 0.05", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)TrailWidth.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate
			{
				HoverboardFactory.ApplyTrailSettings();
			}, 0, false);
			TrailSpread = _category.CreateEntry<float>("Trail Spread", 0.15f, "Lateral spacing between trails when using multiple.\n0 = stacked on centre, higher = further apart.\n Default: 0.15", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)TrailSpread.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate
			{
				HoverboardFactory.ApplyTrailSettings();
			}, 0, false);
			Color[] array = (Color[])(object)new Color[2]
			{
				Color.white,
				Color.white
			};
			TrailColors = new MelonPreferences_Entry<Color>[2];
			for (int i = 0; i < 2; i++)
			{
				int num = i;
				TrailColors[i] = _category.CreateEntry<Color>($"Trail {i + 1} Color", array[i], $"Color for trail {i + 1}.", (string)null, false, false, (ValueValidator)null, (string)null);
				((MelonEventBase<LemonAction<Color, Color>>)(object)TrailColors[i].OnEntryValueChanged).Subscribe((LemonAction<Color, Color>)delegate
				{
					HoverboardFactory.ApplyTrailSettings();
				}, 0, false);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

Hoverboard_IL2Cpp_1.0.1.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Hoverboard;
using Hoverboard.Config;
using Hoverboard.Factory;
using Hoverboard.TemplateUtils;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.AvatarFramework.Equipping;
using Il2CppScheduleOne.Core.Items.Framework;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Dialogue;
using Il2CppScheduleOne.Equipping;
using Il2CppScheduleOne.Experimental;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.NPCs.CharacterClasses;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.Skating;
using Il2CppScheduleOne.Storage;
using Il2CppScheduleOne.Weather;
using Il2CppSystem.Collections;
using Il2CppSystem.IO;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "Hoverboard", "1.0.1", "OverweightUnicorn", null)]
[assembly: MelonColor(255, 191, 0, 255)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Hoverboard_IL2Cpp_1.0.1")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyInformationalVersion("1.0.0+c8c4a866a913699a437e6f1195f4deeafae9d65e")]
[assembly: AssemblyProduct("Hoverboard_IL2Cpp_1.0.1")]
[assembly: AssemblyTitle("Hoverboard_IL2Cpp_1.0.1")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Hoverboard
{
	public static class BuildInfo
	{
		public const string Name = "Hoverboard";

		public const string Description = "Adds a hoverboard to the game...because why not?";

		public const string Author = "OverweightUnicorn";

		public const string Company = "UnicornsCanMod";

		public const string Version = "1.0.1";

		public const string DownloadLink = null;
	}
	public class Core : MelonMod
	{
		public override void OnInitializeMelon()
		{
			AssetBundleUtils.Initialize(this);
			HoverboardConfig.Initialize();
		}

		public override void OnLateInitializeMelon()
		{
			Singleton<LoadManager>.Instance.onLoadComplete.AddListener(UnityAction.op_Implicit((Action)InitMod));
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Main" && (Object)(object)HoverboardFactory.hoverboardPrefab == (Object)null)
			{
				HoverboardFactory.Init();
			}
			else
			{
				HoverboardFactory.Reset();
			}
		}

		public void InitMod()
		{
			//IL_0079: 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_008a: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			Jeff val = Object.FindObjectOfType<Jeff>();
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			GameObject gameObject = ((Component)val).gameObject;
			Transform val2 = gameObject.transform.Find("Dialogue");
			if ((Object)(object)val2 != (Object)null)
			{
				DialogueController_SkateboardSeller component = ((Component)val2).gameObject.GetComponent<DialogueController_SkateboardSeller>();
				if ((Object)(object)component != (Object)null && Registry.ItemExists("hoverboard"))
				{
					ItemDefinition item = Registry.GetItem<ItemDefinition>("hoverboard");
					Option val3 = new Option
					{
						Name = "Hoverboard",
						Price = HoverboardConfig.Price.Value,
						IsAvailable = ((Object)(object)item != (Object)null),
						NotAvailableReason = (((Object)(object)item != (Object)null) ? "You aren't cool enough" : "Item definition not found"),
						Item = item
					};
					component.Options.Add(val3);
					Utility.Success("Added hoverboard to seller options");
				}
				else
				{
					Utility.Log("Dialogue Controller doesn't exist");
				}
			}
			else
			{
				Utility.Error("Could not find Dialogue child on Jeff");
			}
		}
	}
	public static class Utility
	{
		public static void PrintException(Exception e)
		{
			MelonLogger.Msg(ConsoleColor.Red, e.Source);
			MelonLogger.Msg(ConsoleColor.DarkRed, e.Message);
		}

		public static void Error(string msg)
		{
			MelonLogger.Msg(ConsoleColor.Red, msg);
		}

		public static void Log(string msg)
		{
			MelonLogger.Msg(ConsoleColor.DarkMagenta, msg);
		}

		public static void Success(string msg)
		{
			MelonLogger.Msg(ConsoleColor.Green, msg);
		}

		public static void ListHierarchy(Transform transform, int depth)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			string text = new string(' ', depth * 2);
			MelonLogger.Msg(text + "- " + ((Object)transform).name);
			IEnumerator enumerator = transform.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Transform transform2 = (Transform)enumerator.Current;
					ListHierarchy(transform2, depth + 1);
				}
			}
			finally
			{
				if (enumerator is IDisposable disposable)
				{
					disposable.Dispose();
				}
			}
		}
	}
}
namespace Hoverboard.TemplateUtils
{
	public static class AssetBundleUtils
	{
		private static Core mod;

		private static MelonAssembly melonAssembly;

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

		public static void Initialize(Core coreMod)
		{
			mod = coreMod;
			melonAssembly = ((MelonBase)mod).MelonAssembly;
		}

		public static Il2CppAssetBundle LoadAssetBundle(string bundleFileName)
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			if (assetBundles.ContainsKey(bundleFileName))
			{
				return assetBundles[bundleFileName];
			}
			try
			{
				string text = typeof(Core).Namespace + ".Assets." + bundleFileName;
				Stream manifestResourceStream = melonAssembly.Assembly.GetManifestResourceStream(text ?? "");
				if (manifestResourceStream == null)
				{
					((MelonBase)mod).Unregister($"AssetBundle: '{text}' not found. \nOpen .csproj file and search for '{bundleFileName}'.\nIf it doesn't exist,\nCopy your asset to Assets/ folder then look for 'your.assetbundle' in .csproj file.", false);
					return null;
				}
				byte[] array;
				using (MemoryStream memoryStream = new MemoryStream())
				{
					manifestResourceStream.CopyTo(memoryStream);
					array = memoryStream.ToArray();
				}
				Stream val = (Stream)new MemoryStream(Il2CppStructArray<byte>.op_Implicit(array));
				Il2CppAssetBundle val2 = Il2CppAssetBundleManager.LoadFromStream(val);
				assetBundles.Add(bundleFileName, val2);
				return val2;
			}
			catch (Exception value)
			{
				((MelonBase)mod).Unregister($"Failed to load AssetBundle. Please report to dev: {value}", false);
				return null;
			}
		}

		public static Il2CppAssetBundle GetLoadedAssetBundle(string bundleName)
		{
			if (assetBundles.ContainsKey(bundleName))
			{
				return assetBundles[bundleName];
			}
			((MelonBase)mod).Unregister("Failed to get " + bundleName, false);
			throw new Exception("Asset '" + bundleName + "' has not been loaded in yet");
		}

		public static T LoadAssetFromBundle<T>(string assetName, string bundleName) where T : Object
		{
			Il2CppAssetBundle loadedAssetBundle = GetLoadedAssetBundle(bundleName);
			if (loadedAssetBundle == null)
			{
				throw new Exception("Couldn't find " + bundleName + ", Did you load it?");
			}
			T val = loadedAssetBundle.LoadAsset<T>(assetName);
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception(assetName + " not found in bundle");
			}
			return val;
		}
	}
}
namespace Hoverboard.Factory
{
	public static class HoverboardFactory
	{
		public const string ITEM_ID = "hoverboard";

		private const string ITEM_NAME = "Hoverboard";

		private const string SOURCE_SKATEBOARD_ID = "goldenskateboard";

		public static GameObject refStorage;

		public static GameObject hoverboardPrefab;

		public static GameObject visualPrefab;

		public static Skateboard hoverSkateboard;

		public static SkateboardVisuals hoverVisuals;

		public static SkateboardEffects hoverEffects;

		private static AvatarEquippable hoverAvatar;

		private static Skateboard_Equippable hoverEquippable;

		private static StoredItem hoverStored;

		private static SkateboardData hoverData;

		private static Sprite hoverIcon;

		public static MeshFilter hoverBoardFilter;

		public static MeshRenderer hoverBoardRenderer;

		public static AudioClip rollingAudio;

		private static Vector3? _trail0OriginalLocalPosition;

		private static Vector3? _trailMidpointLocalPosition;

		public static void Init()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			refStorage = new GameObject("HoverboardReferenceStorage");
			refStorage.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)refStorage);
			try
			{
				LoadCustomAssets();
				if ((Object)(object)hoverBoardFilter != (Object)null && (Object)(object)hoverBoardRenderer != (Object)null)
				{
					hoverSkateboard = CreateSkateboardPrefab();
					if ((Object)(object)hoverSkateboard == (Object)null)
					{
						Utility.Error("Failed to create Skateboard prefab");
					}
					hoverAvatar = CreateAvatarEquippablePrefab();
					if ((Object)(object)hoverAvatar == (Object)null)
					{
						Utility.Error("Failed to create AvatarEquippable prefab");
					}
					hoverEquippable = CreateEquippablePrefab();
					if ((Object)(object)hoverEquippable == (Object)null)
					{
						Utility.Error("Failed to create Equippable prefab");
					}
					hoverStored = CreateStoredPrefab();
					if ((Object)(object)hoverStored == (Object)null)
					{
						Utility.Error("Failed to create Stored prefab");
					}
					CreateVisualPrefab();
					if ((Object)(object)hoverSkateboard != (Object)null && (Object)(object)hoverAvatar != (Object)null && (Object)(object)hoverEquippable != (Object)null && (Object)(object)hoverStored != (Object)null)
					{
						((Equippable_Viewmodel)hoverEquippable).AvatarEquippable = hoverAvatar;
						hoverEquippable.SkateboardPrefab = hoverSkateboard;
						hoverSkateboard.Equippable = hoverEquippable;
						hoverSkateboard.SlowOnTerrain = false;
						SkateboardData val = Object.Instantiate<SkateboardData>(hoverSkateboard._defaultData, refStorage.transform);
						if ((Object)(object)val != (Object)null)
						{
							hoverData = val;
							hoverSkateboard._defaultData = val;
						}
						ApplyHoverSettings();
						NeutralizeRainOverride();
						SkateboardAudio componentInChildren = ((Component)hoverSkateboard).gameObject.GetComponentInChildren<SkateboardAudio>();
						if ((Object)(object)componentInChildren != (Object)null)
						{
							Transform obj = ((Component)componentInChildren).transform.Find("Audio Source (Skateboard rolling, FX)");
							AudioSource val2 = ((obj != null) ? ((Component)obj).GetComponent<AudioSource>() : null);
							Transform obj2 = ((Component)componentInChildren).transform.Find("Audio Source (Skateboard rolling, FX) (1)");
							AudioSource val3 = ((obj2 != null) ? ((Component)obj2).GetComponent<AudioSource>() : null);
							Transform obj3 = ((Component)componentInChildren).transform.Find("Audio Source (, FX)");
							AudioSource val4 = ((obj3 != null) ? ((Component)obj3).GetComponent<AudioSource>() : null);
							Transform obj4 = ((Component)componentInChildren).transform.Find("Audio Source (, FX)");
							AudioSource val5 = ((obj4 != null) ? ((Component)obj4).GetComponent<AudioSource>() : null);
							if ((Object)(object)componentInChildren.JumpAudio != (Object)null)
							{
								((UnityEventBase)hoverSkateboard.OnJump).RemoveAllListeners();
								AudioClip clip = ((Component)componentInChildren.JumpAudio).gameObject.GetComponent<AudioSource>().clip;
								((Component)componentInChildren.JumpAudio).gameObject.SetActive(false);
								if ((Object)(object)clip == (Object)null)
								{
									((Component)componentInChildren.JumpAudio).gameObject.GetComponent<AudioSource>().clip = null;
								}
							}
							if ((Object)(object)componentInChildren.LandAudio != (Object)null)
							{
								((Component)componentInChildren.LandAudio).gameObject.SetActive(false);
							}
							if ((Object)(object)rollingAudio != (Object)null)
							{
								if ((Object)(object)val2 != (Object)null)
								{
									val2.clip = rollingAudio;
								}
								else
								{
									Utility.Error("Rolling FX is NULL");
								}
								if ((Object)(object)val3 != (Object)null)
								{
									val3.clip = rollingAudio;
									Utility.Log("Dirt rolling audio clip assigned successfully");
								}
								else
								{
									Utility.Error("audioController.DirtRollingAudio is NULL");
								}
							}
							else
							{
								Utility.Error("rollingAudio clip is NULL");
							}
						}
						else
						{
							Utility.Error("Audio controller is NULL");
						}
						Utility.Log("11. Configuring Visuals");
						SkateboardVisuals componentInChildren2 = ((Component)hoverSkateboard).gameObject.GetComponentInChildren<SkateboardVisuals>();
						if ((Object)(object)componentInChildren2 != (Object)null)
						{
							hoverVisuals = componentInChildren2;
							hoverVisuals.MaxBoardLean = HoverboardConfig.MaxBoardLean.Value;
							hoverVisuals.BoardLeanRate = HoverboardConfig.BoardLeanRate.Value;
						}
						Utility.Log("12. Configuring Effects");
						SkateboardEffects componentInChildren3 = ((Component)hoverSkateboard).gameObject.GetComponentInChildren<SkateboardEffects>();
						if ((Object)(object)componentInChildren3 != (Object)null)
						{
							hoverEffects = componentInChildren3;
							ApplyTrailSettings();
						}
						Utility.Log("13. Creating Storable");
						CreateStorableDefinition();
					}
					else
					{
						Utility.Error("Failed to create one or more hoverboard prefabs - initialization incomplete");
					}
				}
				else
				{
					if ((Object)(object)hoverBoardFilter == (Object)null)
					{
						Utility.Error("HoverBoardFilter is null - failed to load mesh");
					}
					if ((Object)(object)hoverBoardRenderer == (Object)null)
					{
						Utility.Error("HoverBoardRenderer is null - failed to load renderer");
					}
					Utility.Error("Initialization aborted due to missing mesh or renderer");
				}
			}
			catch (Exception ex)
			{
				Utility.Error("=== CRITICAL ERROR during Hoverboard Factory Initialization ===");
				Utility.Log(ex.ToString());
			}
		}

		public static SkateboardSettings GetDefaultSettings()
		{
			if ((Object)(object)hoverSkateboard == (Object)null)
			{
				return null;
			}
			if (hoverSkateboard.DefaultSettings == null)
			{
				return null;
			}
			return hoverSkateboard.DefaultSettings;
		}

		public static void ApplyHoverSettings()
		{
			SkateboardSettings defaultSettings = GetDefaultSettings();
			if (defaultSettings == null)
			{
				Utility.Error("ApplyHoverSettings: could not get default settings");
				return;
			}
			defaultSettings.HoverHeight = HoverboardConfig.HoverHeight.Value;
			defaultSettings.TopSpeed_Kmh = HoverboardConfig.TopSpeed.Value;
			defaultSettings.HoverRayLength = HoverboardConfig.HoverHeight.Value + 0.05f;
			defaultSettings.Hover_P = HoverboardConfig.Proportional.Value;
			defaultSettings.Hover_I = HoverboardConfig.Integral.Value;
			defaultSettings.Hover_D = HoverboardConfig.Derivative.Value;
			RefreshActiveSettings();
			Utility.Log($"ApplyHoverSettings: HoverHeight={defaultSettings.HoverHeight}, P={defaultSettings.Hover_P}, I={defaultSettings.Hover_I}, D={defaultSettings.Hover_D}");
		}

		public static void RefreshActiveSettings()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (!((Object)(object)hoverSkateboard == (Object)null))
			{
				hoverSkateboard.OnWeatherChange(new WeatherConditions());
			}
		}

		private static void NeutralizeRainOverride()
		{
			//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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_008a: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_011a: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_0162: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			if (!((Object)(object)hoverSkateboard == (Object)null))
			{
				if ((Object)(object)hoverSkateboard._rainOverrideData == (Object)null)
				{
					Utility.Error("NeutralizeRainOverride: _rainOverrideData is null on hoverSkateboard - cannot neutralize rain override");
					return;
				}
				SkateboardOverrideData val = ScriptableObject.CreateInstance<SkateboardOverrideData>();
				val.Categories = (OverrideCategory)5;
				val.Settings = new SkateboardSettings
				{
					TurnForce = -1f,
					TurnChangeRate = -1f,
					TurnReturnToRestRate = -1f,
					TurnSpeedBoost = -1f,
					Gravity = -1f,
					BrakeForce = -1f,
					ReverseTopSpeed_Kmh = -1f,
					RotationClampForce = -1f,
					LongitudinalFrictionMultiplier = 0.8f,
					LateralFrictionForceMultiplier = 0.8f,
					JumpForce = -1f,
					JumpDuration_Min = -1f,
					JumpDuration_Max = -1f,
					JumpForwardBoost = -1f,
					HoverForce = -1f,
					HoverRayLength = -1f,
					HoverHeight = -1f,
					Hover_P = -1f,
					Hover_I = -1f,
					Hover_D = -1f,
					TopSpeed_Kmh = -1f,
					PushForceMultiplier = -1f,
					PushForceDuration = -1f,
					PushDelay = -1f,
					AirMovementForce = -1f,
					AirMovementJumpReductionDuration = -1f
				};
				hoverSkateboard._rainOverrideData = val;
				Utility.Log("NeutralizeRainOverride: rain override replaced - hover fields protected");
			}
		}

		public static void ApplyTrailSettings()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: 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_0174: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00c1: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: 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_027b: 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)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hoverEffects == (Object)null)
			{
				Utility.Error("ApplyTrailSettings: hoverEffects is null");
				return;
			}
			TrailRenderer[] array = Il2CppArrayBase<TrailRenderer>.op_Implicit((Il2CppArrayBase<TrailRenderer>)(object)hoverEffects.Trails);
			if (array == null || array.Length == 0)
			{
				Utility.Error("ApplyTrailSettings: no trails found on hoverEffects");
				return;
			}
			if (!_trail0OriginalLocalPosition.HasValue)
			{
				_trail0OriginalLocalPosition = ((Component)array[0]).transform.localPosition;
				Vector3 val = Vector3.zero;
				for (int i = 0; i < array.Length; i++)
				{
					val += ((Component)array[i]).transform.localPosition;
				}
				val /= (float)array.Length;
				_trailMidpointLocalPosition = val;
			}
			int num = Mathf.Clamp(HoverboardConfig.TrailCount.Value, 0, array.Length);
			float value = HoverboardConfig.TrailWidth.Value;
			float value2 = HoverboardConfig.TrailSpread.Value;
			switch (num)
			{
			case 0:
			{
				TrailRenderer[] array2 = array;
				foreach (TrailRenderer val2 in array2)
				{
					((Component)val2).gameObject.SetActive(false);
				}
				return;
			}
			case 1:
			{
				((Component)array[0]).gameObject.SetActive(true);
				((Component)array[0]).transform.localPosition = _trailMidpointLocalPosition.Value;
				ApplyTrailAppearance(array[0], value, HoverboardConfig.TrailColors[0].Value);
				for (int k = 1; k < array.Length; k++)
				{
					((Component)array[k]).gameObject.SetActive(false);
				}
				return;
			}
			}
			float x = _trailMidpointLocalPosition.Value.x;
			float num2 = value2 / 2f;
			((Component)array[0]).gameObject.SetActive(true);
			((Component)array[0]).transform.localPosition = _trail0OriginalLocalPosition.Value;
			ApplyTrailAppearance(array[0], value, HoverboardConfig.TrailColors[0].Value);
			if (array.Length > 1)
			{
				((Component)array[1]).gameObject.SetActive(true);
				float num3 = _trail0OriginalLocalPosition.Value.x - x;
				Vector3 value3 = _trailMidpointLocalPosition.Value;
				value3.x = x - num3;
				((Component)array[0]).transform.localPosition = new Vector3(x - num2, _trail0OriginalLocalPosition.Value.y, _trail0OriginalLocalPosition.Value.z);
				((Component)array[1]).transform.localPosition = new Vector3(x + num2, value3.y, value3.z);
				ApplyTrailAppearance(array[1], value, HoverboardConfig.TrailColors[1].Value);
			}
		}

		private static void ApplyTrailAppearance(TrailRenderer trail, float width, Color color)
		{
			//IL_0016: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			trail.startWidth = width;
			trail.endWidth = 0f;
			float a = trail.startColor.a;
			trail.startColor = new Color(color.r, color.g, color.b, a);
			trail.endColor = new Color(color.r, color.g, color.b, 0f);
		}

		public static void LoadCustomAssets()
		{
			AssetBundleUtils.LoadAssetBundle("hoverboard");
			GameObject val = AssetBundleUtils.LoadAssetFromBundle<GameObject>("hoverboard.prefab", "hoverboard");
			if ((Object)(object)val != (Object)null && (Object)(object)hoverboardPrefab == (Object)null)
			{
				hoverboardPrefab = Object.Instantiate<GameObject>(val, refStorage.transform);
				Object.DontDestroyOnLoad((Object)(object)hoverboardPrefab);
				Sprite val2 = AssetBundleUtils.LoadAssetFromBundle<Sprite>("hoverboardvisual_icon.png", "hoverboard");
				if ((Object)(object)val2 != (Object)null)
				{
					hoverIcon = val2;
					Object.DontDestroyOnLoad((Object)(object)hoverIcon);
				}
				else
				{
					Utility.Error("Failed to load icon sprite - icon will be missing");
				}
				AudioClip val3 = AssetBundleUtils.LoadAssetFromBundle<AudioClip>("hoverloop1.mp3", "hoverboard");
				if ((Object)(object)val3 != (Object)null)
				{
					rollingAudio = val3;
					Object.DontDestroyOnLoad((Object)(object)rollingAudio);
				}
				else
				{
					Utility.Error("Failed to load jump audio 1 clip - jump sound will be missing");
				}
				MeshFilter component = hoverboardPrefab.GetComponent<MeshFilter>();
				if ((Object)(object)component != (Object)null)
				{
					hoverBoardFilter = component;
				}
				else
				{
					Utility.Error("MeshFilter component not found on hoverboard prefab");
				}
				MeshRenderer component2 = hoverboardPrefab.GetComponent<MeshRenderer>();
				if ((Object)(object)component2 != (Object)null)
				{
					hoverBoardRenderer = component2;
				}
				else
				{
					Utility.Error("MeshRenderer component not found on hoverboard prefab");
				}
			}
			else if ((Object)(object)val == (Object)null)
			{
				Utility.Error("Failed to load hoverboard prefab from asset bundle - asset is null");
			}
			else if ((Object)(object)hoverboardPrefab != (Object)null)
			{
				Utility.Error("Hoverboard prefab already exists - skipping instantiation");
			}
		}

		private static void HideTrucks(Transform prefab, string path)
		{
			Transform val = prefab.Find(path);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if ((Object)(object)val != (Object)null)
			{
				Transform val2 = val.Find("Truck");
				if ((Object)(object)val2 != (Object)null)
				{
					((Component)val2).gameObject.SetActive(false);
				}
				else
				{
					Utility.Error("Truck (1) not found in BoardContainer");
				}
				Transform val3 = val.Find("Truck (1)");
				if ((Object)(object)val3 != (Object)null)
				{
					((Component)val3).gameObject.SetActive(false);
				}
				else
				{
					Utility.Error("Truck (2) not found in BoardContainer");
				}
			}
			else
			{
				Utility.Error("BoardContainer not found - unable to hide trucks");
			}
		}

		public static Skateboard CreateSkateboardPrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboard");
			GameObject val2 = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)val2).name = "Hoverboard";
			HideTrucks(val2.transform, "Model/Skateboard");
			Transform val3 = val2.transform.Find("Model/Skateboard/BoardContainer/Board");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val3).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
				Transform val4 = val3.Find("BoardModel");
				if ((Object)(object)val4 != (Object)null)
				{
					((Component)val4).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
					((Renderer)((Component)val4).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
					Transform val5 = val4.Find("GoldSkateboardVisual/GoldSkateboard/BoardContainer/Board");
					if ((Object)(object)val5 != (Object)null)
					{
						((Component)val5).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
						((Renderer)((Component)val5).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
					}
				}
				return val2.GetComponent<Skateboard>();
			}
			return null;
		}

		public static AvatarEquippable CreateAvatarEquippablePrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboard_AvatarEquippable");
			GameObject val2 = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)val2).name = "Hoverboard_AvatarEquippable";
			HideTrucks(val2.transform, "GoldSkateboardVisual/GoldSkateboard");
			Transform val3 = val2.transform.Find("GoldSkateboardVisual/GoldSkateboard/BoardContainer/Board");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val3).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
				return val2.GetComponent<AvatarEquippable>();
			}
			return null;
		}

		public static Skateboard_Equippable CreateEquippablePrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboard_Equippable");
			GameObject val2 = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)val2).name = "Hoverboard_Equippable";
			Skateboard_Equippable component = val2.GetComponent<Skateboard_Equippable>();
			HideTrucks(val2.transform, "GoldSkateboardVisual/GoldSkateboard");
			component.SkateboardPrefab = null;
			Transform val3 = val2.transform.Find("GoldSkateboardVisual/GoldSkateboard/BoardContainer/Board");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val3).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
				return component;
			}
			return null;
		}

		public static StoredItem CreateStoredPrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboard_Stored");
			GameObject val2 = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)val2).name = "Hoverboard_Stored";
			HideTrucks(val2.transform, "GoldSkateboardVisual/GoldSkateboard");
			Transform val3 = val2.transform.Find("GoldSkateboardVisual/GoldSkateboard/BoardContainer/Board");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val3).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
				return val2.GetComponent<StoredItem>();
			}
			return null;
		}

		public static StorableItemDefinition CreateStorableDefinition()
		{
			ItemDefinition item = Registry.GetItem<ItemDefinition>("goldenskateboard");
			if ((Object)(object)item != (Object)null)
			{
				StorableItemDefinition val = ((Il2CppObjectBase)item).TryCast<StorableItemDefinition>();
				StorableItemDefinition val2 = Object.Instantiate<StorableItemDefinition>(val);
				if ((Object)(object)val2 != (Object)null)
				{
					((BaseItemDefinition)val2).ID = "hoverboard";
					((Object)val2).name = "Hoverboard";
					((BaseItemDefinition)val2).Name = "Hoverboard";
					((BaseItemDefinition)val2).Description = "A futuristic skateboard that hovers above the ground.";
					((BaseItemDefinition)val2).StackLimit = 1;
					((ItemDefinition)val2).Equippable = (Equippable)(object)hoverEquippable;
					val2.StoredItem = hoverStored;
					((BaseItemDefinition)val2).legalStatus = (ELegalStatus)0;
					((BaseItemDefinition)val2).Category = (EItemCategory)3;
					((ItemDefinition)val2).AvailableInDemo = true;
					val2.BasePurchasePrice = HoverboardConfig.Price.Value;
					val2.ResellMultiplier = HoverboardConfig.ResellMultiplier.Value;
					if ((Object)(object)hoverIcon != (Object)null)
					{
						((BaseItemDefinition)val2).Icon = hoverIcon;
					}
					Singleton<Registry>.Instance.AddToRegistry((ItemDefinition)(object)val2);
					return val2;
				}
			}
			return null;
		}

		public static void CreateVisualPrefab()
		{
			GameObject val = Resources.Load<GameObject>("skateboards/goldenskateboard/GoldSkateboardVisual");
			visualPrefab = Object.Instantiate<GameObject>(val, refStorage.transform);
			((Object)visualPrefab).name = "Hoverboard_Visuals";
			Transform val2 = visualPrefab.transform.Find("GoldSkateboard/BoardContainer/Board");
			if ((Object)(object)val2 != (Object)null)
			{
				((Component)val2).GetComponent<MeshFilter>().mesh = hoverBoardFilter.mesh;
				((Renderer)((Component)val2).GetComponent<MeshRenderer>()).materials = ((Renderer)hoverBoardRenderer).materials;
			}
		}

		public static void Reset()
		{
			refStorage = null;
			visualPrefab = null;
			hoverboardPrefab = null;
			hoverSkateboard = null;
			hoverVisuals = null;
			hoverEffects = null;
			hoverAvatar = null;
			hoverEquippable = null;
			hoverStored = null;
			_trail0OriginalLocalPosition = null;
			_trailMidpointLocalPosition = null;
			Utility.Log("HoverboardFactory.Reset: scene state cleared");
		}
	}
}
namespace Hoverboard.Config
{
	public static class HoverboardConfig
	{
		private static MelonPreferences_Category _category;

		public static MelonPreferences_Entry<float> Price;

		public static MelonPreferences_Entry<float> ResellMultiplier;

		public static MelonPreferences_Entry<float> HoverHeight;

		public static MelonPreferences_Entry<float> TopSpeed;

		public static MelonPreferences_Entry<float> Proportional;

		public static MelonPreferences_Entry<float> Integral;

		public static MelonPreferences_Entry<float> Derivative;

		public static MelonPreferences_Entry<float> MaxBoardLean;

		public static MelonPreferences_Entry<float> BoardLeanRate;

		public static MelonPreferences_Entry<int> TrailCount;

		public static MelonPreferences_Entry<float> TrailWidth;

		public static MelonPreferences_Entry<float> TrailSpread;

		public static MelonPreferences_Entry<Color>[] TrailColors;

		private const int MaxTrails = 2;

		public static void Initialize()
		{
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: 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)
			_category = MelonPreferences.CreateCategory("Hoverboard");
			Price = _category.CreateEntry<float>("Price", 2000f, "(Requires Save Reload) The price of the hoverboard in the in-game shop.\nDefault: 2000", (string)null, false, false, (ValueValidator)null, (string)null);
			ResellMultiplier = _category.CreateEntry<float>("Resell Multiplier", 0.6f, "(Requires Save Reload) The resell price multiplier.\nDefault: 0.6", (string)null, false, false, (ValueValidator)null, (string)null);
			HoverHeight = _category.CreateEntry<float>("Hover Height", 2f, "The height at which the hoverboard hovers above the ground.\nDefault: 2", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)HoverHeight.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings5 = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings5 != null)
				{
					defaultSettings5.HoverHeight = newValue;
					defaultSettings5.HoverRayLength = newValue + 0.05f;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			TopSpeed = _category.CreateEntry<float>("Top Speed", 32f, "The maximum speed of the hoverboard.\nDefault: 32", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)TopSpeed.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings4 = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings4 != null)
				{
					defaultSettings4.TopSpeed_Kmh = newValue;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			MaxBoardLean = _category.CreateEntry<float>("Max Board Lean", 8f, "The maximum angle the board leans when turning.\nDefault: 8", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)MaxBoardLean.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				if ((Object)(object)HoverboardFactory.hoverVisuals != (Object)null)
				{
					HoverboardFactory.hoverVisuals.MaxBoardLean = newValue;
				}
			}, 0, false);
			BoardLeanRate = _category.CreateEntry<float>("Board Lean Rate", 2f, "How quickly the board leans when turning.\nDefault: 2", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)BoardLeanRate.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				if ((Object)(object)HoverboardFactory.hoverVisuals != (Object)null)
				{
					HoverboardFactory.hoverVisuals.BoardLeanRate = newValue;
				}
			}, 0, false);
			Proportional = _category.CreateEntry<float>("Proportional", 2.7f, "How strongly the board reacts to height errors.\nHigher = Snappier response | Lower = Sluggish response\nDefault: 2.7", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)Proportional.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings3 = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings3 != null)
				{
					defaultSettings3.Hover_P = newValue;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			Integral = _category.CreateEntry<float>("Integral", 0.1f, "How much the board corrects over time to reach exact height.\nHigher = Rigid, locked height | Lower = Floaty, drifty feel\nDefault: 0.1", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)Integral.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings2 = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings2 != null)
				{
					defaultSettings2.Hover_I = newValue;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			Derivative = _category.CreateEntry<float>("Derivative", 0.5f, "How much the board resists sudden height changes.\nHigher = Smooth over bumps, less bounce | Lower = Bouncy, reactive\nDefault: 0.5", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)Derivative.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float oldValue, float newValue)
			{
				SkateboardSettings defaultSettings = HoverboardFactory.GetDefaultSettings();
				if (defaultSettings != null)
				{
					defaultSettings.Hover_D = newValue;
					HoverboardFactory.RefreshActiveSettings();
				}
			}, 0, false);
			TrailCount = _category.CreateEntry<int>("Trail Count", 2, "Number of active trails. 0 = none, 2 = max", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<int, int>>)(object)TrailCount.OnEntryValueChanged).Subscribe((LemonAction<int, int>)delegate
			{
				HoverboardFactory.ApplyTrailSettings();
			}, 0, false);
			TrailWidth = _category.CreateEntry<float>("Trail Width", 0.05f, "Width of each trail renderer.\n Default: 0.05", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)TrailWidth.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate
			{
				HoverboardFactory.ApplyTrailSettings();
			}, 0, false);
			TrailSpread = _category.CreateEntry<float>("Trail Spread", 0.15f, "Lateral spacing between trails when using multiple.\n0 = stacked on centre, higher = further apart.\n Default: 0.15", (string)null, false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<float, float>>)(object)TrailSpread.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate
			{
				HoverboardFactory.ApplyTrailSettings();
			}, 0, false);
			Color[] array = (Color[])(object)new Color[2]
			{
				Color.white,
				Color.white
			};
			TrailColors = new MelonPreferences_Entry<Color>[2];
			for (int i = 0; i < 2; i++)
			{
				int num = i;
				TrailColors[i] = _category.CreateEntry<Color>($"Trail {i + 1} Color", array[i], $"Color for trail {i + 1}.", (string)null, false, false, (ValueValidator)null, (string)null);
				((MelonEventBase<LemonAction<Color, Color>>)(object)TrailColors[i].OnEntryValueChanged).Subscribe((LemonAction<Color, Color>)delegate
				{
					HoverboardFactory.ApplyTrailSettings();
				}, 0, false);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}