Decompiled source of SkateCompany v1.1.0

BepInEx/plugins/SkateCompany/SkateCompany.dll

Decompiled 37 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SkateCompany")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SkateCompany")]
[assembly: AssemblyTitle("SkateCompany")]
[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 SkateCompany
{
	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	internal static class SkateSpeedPatch
	{
		private const float VanillaSprintMultiplier = 2.25f;

		private static readonly FieldRef<PlayerControllerB, float> SprintMultiplier = AccessTools.FieldRefAccess<PlayerControllerB, float>("sprintMultiplier");

		private static PlayerControllerB _boostedPlayer;

		private static float _baseSpeed;

		private static readonly string[] SuppressedFlags = new string[5] { "Walking", "Sprinting", "Sideways", "Grab", "GrabValidated" };

		private static void Prefix(PlayerControllerB __instance)
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				return;
			}
			if (!SkateItems.IsSkating(__instance))
			{
				if ((Object)(object)_boostedPlayer == (Object)(object)__instance)
				{
					__instance.movementSpeed = _baseSpeed;
					_boostedPlayer = null;
					RestoreAnimator(__instance);
				}
				return;
			}
			if ((Object)(object)_boostedPlayer != (Object)(object)__instance)
			{
				_baseSpeed = __instance.movementSpeed;
				_boostedPlayer = __instance;
			}
			float deltaTime = Time.deltaTime;
			float num = SprintMultiplier.Invoke(__instance);
			float num2 = (__instance.isSprinting ? Mathf.Lerp(num, 2.25f, deltaTime) : Mathf.Lerp(num, 1f, 10f * deltaTime));
			float num3 = 2.25f * Mathf.Max(Plugin.SpeedMultiplier.Value, 0.1f);
			__instance.movementSpeed = _baseSpeed * num3 / Mathf.Max(num2, 0.1f);
		}

		private static void Postfix(PlayerControllerB __instance)
		{
			if (!((Object)(object)_boostedPlayer != (Object)(object)__instance) && !((Object)(object)__instance.playerBodyAnimator == (Object)null))
			{
				string[] suppressedFlags = SuppressedFlags;
				foreach (string flag in suppressedFlags)
				{
					Set(__instance.playerBodyAnimator, flag, value: false);
				}
			}
		}

		private static void RestoreAnimator(PlayerControllerB player)
		{
			Animator playerBodyAnimator = player.playerBodyAnimator;
			if (!((Object)(object)playerBodyAnimator == (Object)null))
			{
				Set(playerBodyAnimator, "Walking", player.isWalking);
				Set(playerBodyAnimator, "Sprinting", player.isSprinting);
				if (player.isHoldingObject && player.ItemSlots != null && player.currentItemSlot >= 0 && player.currentItemSlot < player.ItemSlots.Length && (Object)(object)player.ItemSlots[player.currentItemSlot] != (Object)null)
				{
					Set(playerBodyAnimator, "Grab", value: true);
					Set(playerBodyAnimator, "GrabValidated", value: true);
				}
			}
		}

		private static void Set(Animator animator, string flag, bool value)
		{
			if (animator.GetBool(flag) != value)
			{
				animator.SetBool(flag, value);
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject), "ItemActivate")]
	internal static class SkateTrickPatch
	{
		private static readonly MethodInfo PlayerJump = AccessTools.Method(typeof(PlayerControllerB), "PlayerJump", (Type[])null, (Type[])null);

		private static readonly FieldInfo IsJumping = AccessTools.Field(typeof(PlayerControllerB), "isJumping");

		private static readonly FieldInfo JumpCoroutine = AccessTools.Field(typeof(PlayerControllerB), "jumpCoroutine");

		private static void Postfix(GrabbableObject __instance, bool buttonDown)
		{
			if (buttonDown && SkateItems.IsSkateItem(__instance.itemProperties))
			{
				SkateVisual component = ((Component)__instance).GetComponent<SkateVisual>();
				if ((Object)(object)component != (Object)null)
				{
					component.DoTrick();
				}
				PlayerControllerB playerHeldBy = __instance.playerHeldBy;
				if ((Object)(object)playerHeldBy != (Object)null && (Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					Hop(playerHeldBy);
				}
			}
		}

		private static void Hop(PlayerControllerB player)
		{
			if (PlayerJump == null || IsJumping == null || !SkateItems.IsSkating(player) || !player.thisController.isGrounded || (bool)IsJumping.GetValue(player))
			{
				return;
			}
			player.playerSlidingTimer = 0f;
			IsJumping.SetValue(player, true);
			if ((Object)(object)player.movementAudio != (Object)null && (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.playerJumpSFX != (Object)null)
			{
				player.movementAudio.PlayOneShot(StartOfRound.Instance.playerJumpSFX);
			}
			if (JumpCoroutine != null)
			{
				object? value = JumpCoroutine.GetValue(player);
				Coroutine val = (Coroutine)((value is Coroutine) ? value : null);
				if (val != null)
				{
					((MonoBehaviour)player).StopCoroutine(val);
				}
			}
			Coroutine value2 = ((MonoBehaviour)player).StartCoroutine((IEnumerator)PlayerJump.Invoke(player, null));
			if (JumpCoroutine != null)
			{
				JumpCoroutine.SetValue(player, value2);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "Awake")]
	internal static class BorrowSoundsPatch
	{
		[HarmonyPriority(800)]
		private static void Postfix(StartOfRound __instance)
		{
			RiderPose.Clear();
			if ((Object)(object)__instance.allItemsList == (Object)null)
			{
				return;
			}
			Item val = null;
			foreach (Item items in __instance.allItemsList.itemsList)
			{
				if (!((Object)(object)items == (Object)null) && !SkateItems.IsSkateItem(items) && !((Object)(object)items.dropSFX == (Object)null))
				{
					if ((Object)(object)val == (Object)null)
					{
						val = items;
					}
					if (items.itemName == "Shovel")
					{
						val = items;
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Item[] array = (Item[])(object)new Item[2]
			{
				SkateItems.Skateboard,
				SkateItems.Rollerblades
			};
			foreach (Item val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					val2.grabSFX = val.grabSFX;
					val2.dropSFX = val.dropSFX;
					val2.pocketSFX = val.pocketSFX;
				}
			}
		}
	}
	internal static class ModelReplacementCompat
	{
		internal const string Guid = "meow.ModelReplacementAPI";

		private static MethodInfo _getController;

		internal static void TryPatch(Harmony harmony)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			if (!Chainloader.PluginInfos.ContainsKey("meow.ModelReplacementAPI"))
			{
				return;
			}
			try
			{
				Type type = AccessTools.TypeByName("ModelReplacement.BodyReplacementBase");
				MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "LateUpdate", (Type[])null, (Type[])null) : null);
				_getController = ((type != null) ? AccessTools.PropertyGetter(type, "controller") : null);
				if (methodInfo == null || _getController == null)
				{
					Plugin.Log.LogWarning((object)"ModelReplacementAPI found but its layout is not what was expected - custom models will not show the riding animation.");
					return;
				}
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ModelReplacementCompat), "BeforeModelCopy", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Plugin.Log.LogInfo((object)"ModelReplacementAPI detected - riding animation enabled for custom models.");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not hook ModelReplacementAPI: " + ex.Message));
			}
		}

		private static void BeforeModelCopy(object __instance)
		{
			object? obj = _getController.Invoke(__instance, null);
			RiderPose.Tick((PlayerControllerB)((obj is PlayerControllerB) ? obj : null));
		}
	}
	[BepInPlugin("sara.skatecompany", "SkateCompany", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "sara.skatecompany";

		public const string Name = "SkateCompany";

		public const string Version = "1.1.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<int> SkateboardPrice;

		internal static ConfigEntry<int> RollerbladePrice;

		internal static ConfigEntry<float> SpeedMultiplier;

		internal static ConfigEntry<bool> AllowIndoors;

		private void Awake()
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			SkateboardPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Store", "SkateboardPrice", 50, "Terminal price of the skateboard.");
			RollerbladePrice = ((BaseUnityPlugin)this).Config.Bind<int>("Store", "RollerbladePrice", 50, "Terminal price of the rollerblades.");
			SpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "SpeedMultiplier", 2f, "Skating speed as a multiple of vanilla sprint speed (2 = double running speed).");
			AllowIndoors = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "AllowIndoors", false, "If true, skating also works inside the facility. Off by default (too strong).");
			SkateItems.CreateAndRegister();
			Harmony val = new Harmony("sara.skatecompany");
			val.PatchAll();
			ModelReplacementCompat.TryPatch(val);
			Log.LogInfo((object)"SkateCompany 1.1.0 loaded - skateboard and rollerblades added to the store.");
		}
	}
	internal sealed class RiderPose
	{
		private sealed class Bone
		{
			public Transform T;

			public Quaternion Original;

			public Quaternion Written;

			public bool Dirty;

			public static Bone Of(Transform t)
			{
				if (!((Object)(object)t == (Object)null))
				{
					return new Bone
					{
						T = t
					};
				}
				return null;
			}

			public void Undo()
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				if (Dirty && (Object)(object)T != (Object)null && T.localRotation == Written)
				{
					T.localRotation = Original;
				}
				Dirty = false;
			}
		}

		private static readonly Dictionary<PlayerControllerB, RiderPose> Active = new Dictionary<PlayerControllerB, RiderPose>();

		private const float TrickDuration = 0.6f;

		private const float FlailDuration = 0.9f;

		private readonly PlayerControllerB _player;

		private int _frame = -1;

		private Bone _hips;

		private Bone _chest;

		private Bone _head;

		private Bone _armL;

		private Bone _armR;

		private Bone _foreL;

		private Bone _foreR;

		private Bone _thighL;

		private Bone _thighR;

		private Bone _shinL;

		private Bone _shinR;

		private Bone _footL;

		private Bone _footR;

		private Vector3 _lastPos;

		private float _move;

		private float _phase;

		private float _trickTime = 0.6f;

		private float _flailTime = 0.9f;

		private bool _wasStill = true;

		private readonly Vector3[] _skatePos = (Vector3[])(object)new Vector3[2];

		private readonly Quaternion[] _skateRot = (Quaternion[])(object)new Quaternion[2];

		private bool _skatesValid;

		private static readonly Vector3 AnkleInSkate = new Vector3(0f, 0.15f, -0.03f);

		private RiderPose(PlayerControllerB player)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			_player = player;
			_lastPos = ((Component)player).transform.position;
			Bind();
		}

		public static void Tick(PlayerControllerB player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			bool flag = SkateItems.IsSkating(player);
			if (!Active.TryGetValue(player, out var value))
			{
				if (!flag)
				{
					return;
				}
				value = new RiderPose(player);
				Active[player] = value;
			}
			if (value._frame != Time.frameCount)
			{
				value._frame = Time.frameCount;
				if (!flag)
				{
					value.Release();
					Active.Remove(player);
				}
				else
				{
					GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
					value.Apply((Object)(object)currentlyHeldObjectServer != (Object)null && (Object)(object)currentlyHeldObjectServer.itemProperties == (Object)(object)SkateItems.Skateboard);
				}
			}
		}

		public static void Trick(PlayerControllerB player)
		{
			if ((Object)(object)player != (Object)null && Active.TryGetValue(player, out var value))
			{
				value._trickTime = 0f;
			}
		}

		public static bool TryGetSkate(PlayerControllerB player, int side, out Vector3 position, out Quaternion rotation)
		{
			//IL_0047: 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_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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player != (Object)null && Active.TryGetValue(player, out var value) && value._skatesValid)
			{
				position = value._skatePos[side];
				rotation = value._skateRot[side];
				return true;
			}
			position = default(Vector3);
			rotation = default(Quaternion);
			return false;
		}

		public static void Clear()
		{
			Active.Clear();
		}

		private void Apply(bool board)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (_hips != null)
			{
				Transform transform = ((Component)_player).transform;
				float num = Mathf.Max(Time.deltaTime, 0.0001f);
				Vector3 val = transform.position - _lastPos;
				_lastPos = transform.position;
				val.y = 0f;
				float num2 = ((Vector3)(ref val)).magnitude / num;
				_move = Mathf.Lerp(_move, Mathf.Clamp01(num2 / 4f), Mathf.Clamp01(num * 6f));
				_phase += num * 6.5f * _move;
				if (_move < 0.05f)
				{
					_wasStill = true;
				}
				else if (_wasStill && _move > 0.2f)
				{
					_wasStill = false;
					_flailTime = 0f;
				}
				if (_flailTime < 0.9f)
				{
					_flailTime += num;
				}
				float trick = 0f;
				float num3 = 1f;
				if (_trickTime < 0.6f)
				{
					_trickTime += num;
					num3 = Mathf.Clamp01(_trickTime / 0.6f);
					trick = Mathf.Sin(num3 * MathF.PI);
				}
				if (board)
				{
					ApplySkateboard(transform, trick);
				}
				else
				{
					ApplyRollerblades(transform, trick, num3);
				}
			}
		}

		private void ApplySkateboard(Transform body, float trick)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_007d: 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_008a: 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_00a0: 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_00b7: 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_00cd: 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_00e3: 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_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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			_skatesValid = false;
			Vector3 up = body.up;
			Quaternion val = Quaternion.AngleAxis(70f, up);
			Vector3 val2 = val * body.right;
			Vector3 val3 = val * body.forward;
			float num = Mathf.Sin(Time.time * 2.2f) * 4f * _move;
			float num2 = Mathf.Lerp(55f, 140f, trick);
			Add(_hips, val);
			Add(_chest, Quaternion.AngleAxis(8f, val2) * Quaternion.AngleAxis(num, val3));
			Add(_head, Quaternion.AngleAxis(-60f, up));
			Add(_armL, Quaternion.AngleAxis(0f - num2 - num, val3));
			Add(_armR, Quaternion.AngleAxis(num2 - num, val3));
			Add(_thighL, Quaternion.AngleAxis(-14f, val3) * Quaternion.AngleAxis(-28f, val2));
			Add(_thighR, Quaternion.AngleAxis(14f, val3) * Quaternion.AngleAxis(-28f, val2));
			Add(_shinL, Quaternion.AngleAxis(48f, val2));
			Add(_shinR, Quaternion.AngleAxis(48f, val2));
			Add(_footL, Quaternion.AngleAxis(-20f, val2));
			Add(_footR, Quaternion.AngleAxis(-20f, val2));
		}

		private void ApplyRollerblades(Transform body, float trick, float trickT)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_0109: 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_0124: 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_015e: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: 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_031b: 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_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: 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_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: 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_053f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 up = body.up;
			float num = ((trick > 0f) ? (360f * trickT) : 0f);
			Quaternion val = Quaternion.AngleAxis(num, up);
			Vector3 val2 = val * body.right;
			Vector3 val3 = val * body.forward;
			float num2 = 1f - _move;
			float num3 = Mathf.Sin(_phase) * _move;
			float num4 = Mathf.Pow(Mathf.Max(0f, num3), 0.7f);
			float num5 = Mathf.Pow(Mathf.Max(0f, 0f - num3), 0.7f);
			float num6 = Mathf.Sin(Time.time * 9f) * num2 * (1f - trick);
			float num7 = Mathf.Sin(Time.time * 13f) * num2 * (1f - trick);
			float num8 = Mathf.Sin(Time.time * 1.7f) * num2;
			num4 = Mathf.Max(num4, trick);
			num5 *= 1f - trick;
			Add(_hips, val * Quaternion.AngleAxis(14f * num3, up) * Quaternion.AngleAxis(-7f * num3 + 6f * num8, val3));
			Add(_chest, Quaternion.AngleAxis(16f + 12f * _move - 26f * trick + 5f * num6, val2) * Quaternion.AngleAxis(-22f * num3, up) * Quaternion.AngleAxis(5f * num7, val3));
			Add(_head, Quaternion.AngleAxis(-8f - 12f * _move, val2) * Quaternion.AngleAxis(8f * num3, up));
			float num9 = -65f * num3;
			float num10 = 65f * num3;
			float num11 = 20f + 45f * num2 + 14f * num7;
			float num12 = 20f + 45f * num2 - 14f * num7;
			float num13 = 25f + 40f * Mathf.Max(0f, num3);
			float num14 = 25f + 40f * Mathf.Max(0f, 0f - num3);
			if (_flailTime < 0.9f)
			{
				float num15 = -720f * (_flailTime / 0.9f);
				num9 += num15;
				num10 += num15 + 180f * (1f - _flailTime / 0.9f);
				num11 = (num12 = 25f);
				num13 = (num14 = 8f);
			}
			num9 *= 1f - trick;
			num10 *= 1f - trick;
			num11 = Mathf.Lerp(num11, 150f, trick);
			num12 = Mathf.Lerp(num12, 150f, trick);
			num13 = Mathf.Lerp(num13, 10f, trick);
			num14 = Mathf.Lerp(num14, 10f, trick);
			Add(_armL, Quaternion.AngleAxis(0f - num12, val3) * Quaternion.AngleAxis(num10, val2));
			Add(_armR, Quaternion.AngleAxis(num11, val3) * Quaternion.AngleAxis(num9, val2));
			Add(_foreL, Quaternion.AngleAxis(0f - num14, val2));
			Add(_foreR, Quaternion.AngleAxis(0f - num13, val2));
			float num16 = -22f + 47f * num4 - 12f * num5 + 12f * num6;
			float num17 = -22f + 47f * num5 - 12f * num4 - 12f * num6;
			float num18 = 38f + 50f * num4 + 18f * num5;
			float num19 = 38f + 50f * num5 + 18f * num4;
			float num20 = -16f + 10f * num4 - 6f * num5;
			float num21 = -16f + 10f * num5 - 6f * num4;
			float num22 = 10f * num4 - 5f * num2;
			float num23 = 10f * num5 - 5f * num2;
			Add(_thighL, Quaternion.AngleAxis(0f - num23, val3) * Quaternion.AngleAxis(num17, val2));
			Add(_thighR, Quaternion.AngleAxis(num22, val3) * Quaternion.AngleAxis(num16, val2));
			Add(_shinL, Quaternion.AngleAxis(num19, val2));
			Add(_shinR, Quaternion.AngleAxis(num18, val2));
			Add(_footL, Quaternion.AngleAxis(num21, val2));
			Add(_footR, Quaternion.AngleAxis(num20, val2));
			_skatesValid = _footL != null && _footR != null && (Object)(object)_footL.T != (Object)null && (Object)(object)_footR.T != (Object)null;
			if (_skatesValid)
			{
				Quaternion baseRot = body.rotation * Quaternion.AngleAxis(num, Vector3.up);
				PlaceSkate(0, _footL.T, baseRot, num17 + num19 + num21);
				PlaceSkate(1, _footR.T, baseRot, num16 + num18 + num20);
			}
		}

		private void PlaceSkate(int side, Transform ankle, Quaternion baseRot, float pitch)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = baseRot * Quaternion.AngleAxis(pitch, Vector3.right);
			_skateRot[side] = val;
			_skatePos[side] = ankle.position - val * AnkleInSkate;
		}

		private void Bind()
		{
			Transform val = FindShallowest(((Object)(object)_player.playerBodyAnimator != (Object)null) ? ((Component)_player.playerBodyAnimator).transform : ((Component)_player).transform, "spine");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Player skeleton not found - riding pose disabled for this player.");
				return;
			}
			_hips = Bone.Of(val);
			_chest = Bone.Of(FindDeep(val, "spine.002"));
			_head = Bone.Of(FindDeep(val, "spine.004"));
			_armL = Bone.Of(FindDeep(val, "arm.L_upper"));
			_armR = Bone.Of(FindDeep(val, "arm.R_upper"));
			_foreL = Bone.Of(FindDeep(val, "arm.L_lower"));
			_foreR = Bone.Of(FindDeep(val, "arm.R_lower"));
			_thighL = Bone.Of(FindDeep(val, "thigh.L"));
			_thighR = Bone.Of(FindDeep(val, "thigh.R"));
			_shinL = Bone.Of(FindDeep(val, "shin.L"));
			_shinR = Bone.Of(FindDeep(val, "shin.R"));
			_footL = Bone.Of(FindDeep(val, "foot.L"));
			_footR = Bone.Of(FindDeep(val, "foot.R"));
		}

		private void Release()
		{
			_skatesValid = false;
			Bone[] array = new Bone[13]
			{
				_hips, _chest, _head, _armL, _armR, _foreL, _foreR, _thighL, _thighR, _shinL,
				_shinR, _footL, _footR
			};
			for (int i = 0; i < array.Length; i++)
			{
				array[i]?.Undo();
			}
		}

		private static void Add(Bone bone, Quaternion worldOffset)
		{
			//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_002f: 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_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)
			if (bone != null && !((Object)(object)bone.T == (Object)null))
			{
				bone.Undo();
				bone.Original = bone.T.localRotation;
				bone.T.rotation = worldOffset * bone.T.rotation;
				bone.Written = bone.T.localRotation;
				bone.Dirty = true;
			}
		}

		private static Transform FindDeep(Transform parent, string boneName)
		{
			for (int i = 0; i < parent.childCount; i++)
			{
				Transform child = parent.GetChild(i);
				if (((Object)child).name == boneName)
				{
					return child;
				}
				Transform val = FindDeep(child, boneName);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		private static Transform FindShallowest(Transform root, string boneName)
		{
			Queue<Transform> queue = new Queue<Transform>();
			queue.Enqueue(root);
			while (queue.Count > 0)
			{
				Transform val = queue.Dequeue();
				if (((Object)val).name == boneName)
				{
					return val;
				}
				for (int i = 0; i < val.childCount; i++)
				{
					queue.Enqueue(val.GetChild(i));
				}
			}
			return null;
		}
	}
	internal static class SkateItems
	{
		internal static Item Skateboard;

		internal static Item Rollerblades;

		private const int PropsLayer = 6;

		private const int ScanNodeLayer = 22;

		private static Shader _shader;

		internal static bool IsSkateItem(Item item)
		{
			if ((Object)(object)item != (Object)null)
			{
				if (!((Object)(object)item == (Object)(object)Skateboard))
				{
					return (Object)(object)item == (Object)(object)Rollerblades;
				}
				return true;
			}
			return false;
		}

		internal static bool IsSkating(PlayerControllerB player)
		{
			if ((Object)(object)player == (Object)null || !player.isPlayerControlled || player.isPlayerDead)
			{
				return false;
			}
			if (player.isCrouching || player.isClimbingLadder || player.inSpecialInteractAnimation || player.inTerminalMenu)
			{
				return false;
			}
			if (player.isInsideFactory && !Plugin.AllowIndoors.Value)
			{
				return false;
			}
			GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer;
			if ((Object)(object)currentlyHeldObjectServer != (Object)null && !currentlyHeldObjectServer.isPocketed)
			{
				return IsSkateItem(currentlyHeldObjectServer.itemProperties);
			}
			return false;
		}

		internal static void CreateAndRegister()
		{
			_shader = Shader.Find("HDRP/Lit") ?? Shader.Find("Standard");
			Skateboard = BuildSkateboard();
			Rollerblades = BuildRollerblades();
			Items.RegisterShopItem(Skateboard, (TerminalNode)null, (TerminalNode)null, InfoNode("SkateboardInfo", "SKATEBOARD\n\nHold it in your hand to ride it. You roll at twice your running speed.\nOutdoor use only.\nLeft click to kickflip.\n\nThe Company is not liable for broken ankles.\n\n"), Plugin.SkateboardPrice.Value);
			Items.RegisterShopItem(Rollerblades, (TerminalNode)null, (TerminalNode)null, InfoNode("RollerbladesInfo", "ROLLERBLADES\n\nHold them in your hand to skate. You roll at twice your running speed.\nOutdoor use only.\nLeft click to do a spin trick.\n\nNot rated for stairs.\n\n"), Plugin.RollerbladePrice.Value);
		}

		private static Item BuildSkateboard()
		{
			//IL_0019: 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_004b: 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_0080: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_0140: 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_01ac: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			PhysicsProp prop;
			SkateVisual visual;
			GameObject val = NewItemPrefab("SkateCompanySkateboard", "Skateboard", new Vector3(0f, 0.05f, 0f), new Vector3(0.24f, 0.1f, 0.84f), out prop, out visual);
			Material mat = Mat(new Color(0.75f, 0.12f, 0.12f));
			Material mat2 = Mat(new Color(0.55f, 0.55f, 0.58f));
			Material mat3 = Mat(new Color(0.93f, 0.9f, 0.8f));
			Transform val2 = NewPart(val.transform, "Board", Vector3.zero);
			Cube(val2, "Deck", new Vector3(0f, 0.07f, 0f), new Vector3(0.2f, 0.02f, 0.8f), mat);
			float[] array = new float[2] { -0.27f, 0.27f };
			foreach (float num in array)
			{
				Cube(val2, "Truck", new Vector3(0f, 0.05f, num), new Vector3(0.14f, 0.02f, 0.05f), mat2);
				Wheel(val2, new Vector3(-0.08f, 0.0275f, num), 0.055f, 0.04f, mat3);
				Wheel(val2, new Vector3(0.08f, 0.0275f, num), 0.055f, 0.04f, mat3);
			}
			visual.item = (GrabbableObject)(object)prop;
			visual.parts = (Transform[])(object)new Transform[1] { val2 };
			visual.restPositions = (Vector3[])(object)new Vector3[1] { Vector3.zero };
			visual.ridePositions = (Vector3[])(object)new Vector3[1]
			{
				new Vector3(0f, 0f, 0.05f)
			};
			visual.flipAroundForward = true;
			return ((GrabbableObject)prop).itemProperties = NewItem("Skateboard", val, "Kickflip : [LMB]", Icon(new Color(0.85f, 0.2f, 0.2f), pair: false));
		}

		private static Item BuildRollerblades()
		{
			//IL_0019: 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_004b: 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_0080: 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_0214: 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_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: 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_0271: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			PhysicsProp prop;
			SkateVisual visual;
			GameObject val = NewItemPrefab("SkateCompanyRollerblades", "Rollerblades", new Vector3(0f, 0.15f, 0f), new Vector3(0.3f, 0.3f, 0.3f), out prop, out visual);
			Material mat = Mat(new Color(0.1f, 0.35f, 0.8f));
			Material mat2 = Mat(new Color(0.15f, 0.15f, 0.17f));
			Material mat3 = Mat(new Color(0.95f, 0.8f, 0.2f));
			Transform[] array = (Transform[])(object)new Transform[2];
			for (int i = 0; i < 2; i++)
			{
				float num = ((i == 0) ? (-1f) : 1f);
				Transform val2 = NewPart(val.transform, (i == 0) ? "LeftSkate" : "RightSkate", new Vector3(0.08f * num, 0f, 0f));
				Cube(val2, "Boot", new Vector3(0f, 0.13f, 0f), new Vector3(0.1f, 0.14f, 0.26f), mat);
				Cube(val2, "Cuff", new Vector3(0f, 0.24f, -0.07f), new Vector3(0.1f, 0.12f, 0.11f), mat);
				Cube(val2, "Frame", new Vector3(0f, 0.055f, 0f), new Vector3(0.03f, 0.03f, 0.27f), mat2);
				float[] array2 = new float[4] { -0.1f, -0.033f, 0.033f, 0.1f };
				foreach (float num2 in array2)
				{
					Wheel(val2, new Vector3(0f, 0.025f, num2), 0.05f, 0.024f, mat3);
				}
				array[i] = val2;
			}
			visual.item = (GrabbableObject)(object)prop;
			visual.parts = array;
			visual.restPositions = (Vector3[])(object)new Vector3[2]
			{
				new Vector3(-0.08f, 0f, 0f),
				new Vector3(0.08f, 0f, 0f)
			};
			visual.ridePositions = (Vector3[])(object)new Vector3[2]
			{
				new Vector3(-0.14f, 0f, 0f),
				new Vector3(0.14f, 0f, 0f)
			};
			visual.flipAroundForward = false;
			return ((GrabbableObject)prop).itemProperties = NewItem("Rollerblades", val, "Spin trick : [LMB]", Icon(new Color(0.2f, 0.45f, 0.9f), pair: true));
		}

		private static GameObject NewItemPrefab(string prefabName, string displayName, Vector3 colliderCenter, Vector3 colliderSize, out PhysicsProp prop, out SkateVisual visual)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = NetworkPrefabs.CreateNetworkPrefab(prefabName);
			val.layer = 6;
			val.tag = "PhysicsProp";
			BoxCollider obj = val.AddComponent<BoxCollider>();
			obj.center = colliderCenter;
			obj.size = colliderSize;
			AudioSource obj2 = val.AddComponent<AudioSource>();
			obj2.playOnAwake = false;
			obj2.spatialBlend = 1f;
			obj2.maxDistance = 15f;
			obj2.rolloffMode = (AudioRolloffMode)1;
			prop = val.AddComponent<PhysicsProp>();
			((GrabbableObject)prop).grabbable = true;
			((GrabbableObject)prop).grabbableToEnemies = true;
			((GrabbableObject)prop).useCooldown = 0.9f;
			visual = val.AddComponent<SkateVisual>();
			GameObject val2 = new GameObject("ScanNode");
			val2.transform.SetParent(val.transform, false);
			val2.transform.localPosition = colliderCenter;
			val2.layer = 22;
			val2.AddComponent<BoxCollider>().size = Vector3.one * 0.4f;
			ScanNodeProperties obj3 = val2.AddComponent<ScanNodeProperties>();
			obj3.headerText = displayName;
			obj3.subText = "";
			obj3.minRange = 1;
			obj3.maxRange = 13;
			obj3.requiresLineOfSight = true;
			obj3.nodeType = 0;
			obj3.creatureScanID = -1;
			return val;
		}

		private static Item NewItem(string itemName, GameObject prefab, string tooltip, Sprite icon)
		{
			//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_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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			Item val = ScriptableObject.CreateInstance<Item>();
			((Object)val).name = itemName + "Item";
			((Object)val).hideFlags = (HideFlags)61;
			val.itemName = itemName;
			val.spawnPrefab = prefab;
			val.itemIcon = icon;
			val.isScrap = false;
			val.creditsWorth = 50;
			val.weight = 1.03f;
			val.twoHanded = false;
			val.twoHandedAnimation = false;
			val.requiresBattery = false;
			val.canBeGrabbedBeforeGameStart = true;
			val.itemSpawnsOnGround = true;
			val.isConductiveMetal = false;
			val.syncUseFunction = true;
			val.holdButtonUse = false;
			val.toolTips = new string[1] { tooltip };
			val.restingRotation = Vector3.zero;
			val.verticalOffset = 0f;
			val.rotationOffset = Vector3.zero;
			val.positionOffset = Vector3.zero;
			val.allowDroppingAheadOfPlayer = true;
			return val;
		}

		private static TerminalNode InfoNode(string name, string text)
		{
			TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
			((Object)obj).name = name;
			((Object)obj).hideFlags = (HideFlags)61;
			obj.displayText = text;
			obj.clearPreviousText = true;
			obj.maxCharactersToType = 25;
			return obj;
		}

		private static Transform NewPart(Transform parent, string name, Vector3 localPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0020: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = 6
			};
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			return val.transform;
		}

		private static void Cube(Transform parent, string name, Vector3 pos, Vector3 scale, Material mat)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Primitive((PrimitiveType)3, parent, name, pos, scale, Quaternion.identity, mat);
		}

		private static void Wheel(Transform parent, Vector3 pos, float diameter, float width, Material mat)
		{
			//IL_0007: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			Primitive((PrimitiveType)2, parent, "Wheel", pos, new Vector3(diameter, width * 0.5f, diameter), Quaternion.Euler(0f, 0f, 90f), mat);
		}

		private static void Primitive(PrimitiveType type, Transform parent, string name, Vector3 pos, Vector3 scale, Quaternion rot, Material mat)
		{
			//IL_0000: 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_0049: 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)
			GameObject obj = GameObject.CreatePrimitive(type);
			((Object)obj).name = name;
			obj.layer = 6;
			Collider component = obj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = pos;
			obj.transform.localRotation = rot;
			obj.transform.localScale = scale;
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = mat;
		}

		private static Material Mat(Color color)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_001a: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(_shader)
			{
				hideFlags = (HideFlags)61,
				color = color
			};
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", color);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", 0.35f);
			}
			return val;
		}

		private static Sprite Icon(Color color, bool pair)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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_005c: 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_009a: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_00dd: 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_00fb: 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)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)61,
				filterMode = (FilterMode)0
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.95f, 0.95f, 0.9f);
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					Color val4 = val2;
					if (!pair)
					{
						if (j >= 6 && j < 58 && i >= 30 && i < 37)
						{
							val4 = color;
						}
						if (Disc(j, i, 17, 23, 6) || Disc(j, i, 47, 23, 6))
						{
							val4 = val3;
						}
					}
					else
					{
						int[] array = new int[2] { 4, 34 };
						foreach (int num in array)
						{
							if (j >= num + 2 && j < num + 24 && i >= 20 && i < 34)
							{
								val4 = color;
							}
							if (j >= num + 2 && j < num + 13 && i >= 34 && i < 52)
							{
								val4 = color;
							}
							if (Disc(j, i, num + 5, 14, 4) || Disc(j, i, num + 13, 14, 4) || Disc(j, i, num + 21, 14, 4))
							{
								val4 = val3;
							}
						}
					}
					val.SetPixel(j, i, val4);
				}
			}
			val.Apply();
			Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f);
			((Object)obj).hideFlags = (HideFlags)61;
			return obj;
		}

		private static bool Disc(int x, int y, int cx, int cy, int r)
		{
			int num = x - cx;
			int num2 = y - cy;
			return num * num + num2 * num2 <= r * r;
		}
	}
	[DefaultExecutionOrder(1000)]
	public class SkateVisual : MonoBehaviour
	{
		public GrabbableObject item;

		public Transform[] parts;

		public Vector3[] restPositions;

		public Vector3[] ridePositions;

		public bool flipAroundForward;

		private const float TrickDuration = 0.6f;

		private float _trickTime = 0.6f;

		private PlayerControllerB _lastRider;

		public void DoTrick()
		{
			_trickTime = 0f;
			if ((Object)(object)item != (Object)null)
			{
				RiderPose.Trick(item.playerHeldBy);
			}
		}

		private void LateUpdate()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00cd: 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_0123: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null || parts == null)
			{
				return;
			}
			PlayerControllerB playerHeldBy = item.playerHeldBy;
			if ((Object)(object)_lastRider != (Object)null && (Object)(object)_lastRider != (Object)(object)playerHeldBy)
			{
				RiderPose.Tick(_lastRider);
			}
			_lastRider = playerHeldBy;
			if ((Object)(object)playerHeldBy != (Object)null)
			{
				RiderPose.Tick(playerHeldBy);
			}
			bool flag = (Object)(object)playerHeldBy != (Object)null && SkateItems.IsSkating(playerHeldBy);
			Quaternion val = Quaternion.identity;
			float num = 0f;
			if (_trickTime < 0.6f)
			{
				_trickTime += Time.deltaTime;
				float num2 = Mathf.Clamp01(_trickTime / 0.6f);
				val = Quaternion.AngleAxis(360f * num2, flipAroundForward ? Vector3.forward : Vector3.up);
				num = Mathf.Sin(num2 * MathF.PI) * (flipAroundForward ? 0.25f : 0.05f);
			}
			for (int i = 0; i < parts.Length; i++)
			{
				Transform val2 = parts[i];
				if (!((Object)(object)val2 == (Object)null))
				{
					Vector3 position;
					Quaternion rotation;
					if (!flag)
					{
						val2.localPosition = restPositions[i];
						val2.localRotation = Quaternion.identity;
					}
					else if (!flipAroundForward && RiderPose.TryGetSkate(playerHeldBy, i, out position, out rotation))
					{
						val2.SetPositionAndRotation(position, rotation);
					}
					else
					{
						Transform transform = ((Component)playerHeldBy).transform;
						val2.SetPositionAndRotation(transform.TransformPoint(ridePositions[i]) + Vector3.up * num, transform.rotation * val);
					}
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_lastRider != (Object)null)
			{
				RiderPose.Tick(_lastRider);
			}
		}
	}
}