Decompiled source of UllrSkiAndSnowboard v1.0.3

plugins/UllrSkiAndSnowboard.dll

Decompiled 6 hours ago
using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Splatform;
using UllrSkiAndSnowboard.Assets;
using UllrSkiAndSnowboard.Physics;
using UllrSkiAndSnowboard.Structures;
using UllrSkiAndSnowboard.Visuals;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("UllrSkiAndSnowboard")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+b644f9b779568916155ae28731d65bf9cb98da9f")]
[assembly: AssemblyProduct("UllrSkiAndSnowboard")]
[assembly: AssemblyTitle("UllrSkiAndSnowboard")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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 UllrSkiAndSnowboard
{
	[BepInPlugin("com.jimmylab.ullrski", "Ullr's Peak: Mythic Ski & Snowboard", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class UllrPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.jimmylab.ullrski";

		public const string PluginName = "Ullr's Peak: Mythic Ski & Snowboard";

		public const string PluginVersion = "1.0.3";

		public const string ToggleRideButtonName = "Ullr_ToggleRide";

		public const string PieceCategoryName = "Ullr's Peak";

		private Harmony _harmony;

		private ButtonConfig _toggleRideButton;

		private bool _contentRegistered;

		public static ManualLogSource Log { get; private set; }

		public static ConfigEntry<float> MaxSpeedMultiplier { get; private set; }

		public static ConfigEntry<float> SlopeAccelerationMultiplier { get; private set; }

		public static ConfigEntry<bool> GrantFrostResistance { get; private set; }

		public static ConfigEntry<bool> AllowNonSnowRiding { get; private set; }

		public static ConfigEntry<string> DefaultNewWorldSeed { get; private set; }

		public static ConfigEntry<KeyCode> ToggleRideKey { get; private set; }

		public static ConfigEntry<bool> AutoEngageOnSlope { get; private set; }

		public static ConfigEntry<bool> AutoMarkNearestPeak { get; private set; }

		public static ConfigEntry<bool> ShowRidingHud { get; private set; }

		public static ConfigEntry<bool> ShowStowedGearOnBack { get; private set; }

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			BindConfiguration();
			RegisterInputs();
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.jimmylab.ullrski");
			PrefabManager.OnVanillaPrefabsAvailable += RegisterAllContent;
			Log.LogInfo((object)"Ullr's Peak: Mythic Ski & Snowboard v1.0.3 loaded — Praise Ullr & Moder!");
		}

		private void OnDestroy()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterAllContent;
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void BindConfiguration()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			};
			MaxSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Physics (Server Synced)", "MaxSpeedMultiplier", 1f, new ConfigDescription("Multiplier on top downhill speed (~25 m/s / 90 km/h at 1.0).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), new object[1] { val }));
			SlopeAccelerationMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Physics (Server Synced)", "SlopeAccelerationMultiplier", 1f, new ConfigDescription("Multiplier on downhill slope gravity acceleration.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), new object[1] { val }));
			GrantFrostResistance = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - Physics (Server Synced)", "GrantFrostResistance", true, new ConfigDescription("Grant Ullr's Frost Ward (Frost Resistance) while Mythic Skis or Snowboard are equipped.", (AcceptableValueBase)null, new object[1] { val }));
			AllowNonSnowRiding = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - Physics (Server Synced)", "AllowNonSnowRiding", false, new ConfigDescription("If true, allows full-speed skiing/snowboarding on grass/dirt outside Mountain/Snow too.", (AcceptableValueBase)null, new object[1] { val }));
			DefaultNewWorldSeed = ((BaseUnityPlugin)this).Config.Bind<string>("2 - World Seed (Server)", "DefaultNewWorldSeed", "", new ConfigDescription("Optional curated world seed applied when creating a brand new world (overridden by ULLR_WORLD_SEED env var).", (AcceptableValueBase)null, new object[1] { val }));
			ToggleRideKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("3 - Controls & HUD (Client)", "ToggleRideKey", (KeyCode)120, "Hotkey to click into / unclip from your equipped Skis or Snowboard.");
			AutoEngageOnSlope = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Controls & HUD (Client)", "AutoEngageOnSlope", true, "Automatically click into riding mode when sprinting onto a snowy slope (>8.5 deg) or Jump Ramp.");
			AutoMarkNearestPeak = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Controls & HUD (Client)", "AutoMarkNearestPeak", true, "Automatically place a 'Ullr's Summit' minimap pin on the tallest nearby Mountain peak on first equip.");
			ShowRidingHud = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Controls & HUD (Client)", "ShowRidingHud", true, "Display the compact speedometer, hop-charge, and slalom timer widget while actively riding.");
			ShowStowedGearOnBack = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Controls & HUD (Client)", "ShowStowedGearOnBack", true, "Show equipped Skis or Snowboard strapped diagonally across your Viking's back when walking.");
		}

		private void RegisterInputs()
		{
			//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_0011: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			_toggleRideButton = new ButtonConfig
			{
				Name = "Ullr_ToggleRide",
				Config = ToggleRideKey,
				ActiveInCustomGUI = false,
				ActiveInGUI = false,
				Hint = "Toggle Ski / Snowboard"
			};
			InputManager.Instance.AddButton("com.jimmylab.ullrski", _toggleRideButton);
		}

		private void RegisterAllContent()
		{
			if (!_contentRegistered)
			{
				_contentRegistered = true;
				ProceduralAssets.Initialize();
				StatusEffect frostWard = RegisterFrostWardStatusEffect();
				RegisterMythicSkis(frostWard);
				RegisterModerSnowboard(frostWard);
				RegisterJumpRampPiece();
				RegisterSlalomGatePiece();
				RegisterRopeTowPiece();
				Log.LogInfo((object)"Registered Ullr's Skis, Moder's Snowboard, and 3 Mountain Park build pieces.");
			}
		}

		private static StatusEffect RegisterFrostWardStatusEffect()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0059: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "SE_UllrFrostWard";
			((StatusEffect)val).m_name = "Ullr's Frost Ward";
			((StatusEffect)val).m_tooltip = "Mythic frost runes woven by Ullr and Moder shield your bones from freezing mountain winds.";
			((StatusEffect)val).m_startMessageType = (MessageType)1;
			((StatusEffect)val).m_startMessage = "";
			((StatusEffect)val).m_icon = ProceduralAssets.FrostWardIcon;
			if (GrantFrostResistance.Value)
			{
				val.m_mods = new List<DamageModPair>
				{
					new DamageModPair
					{
						m_type = (DamageType)64,
						m_modifier = (DamageModifier)1
					}
				};
			}
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false));
			return (StatusEffect)(object)val;
		}

		private static void RegisterMythicSkis(StatusEffect frostWard)
		{
			//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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00c4: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("UllrSkis", "BeltStrength");
			StripClonedItemVisuals(val);
			GameObject val2 = new GameObject("DroppedSkisVisual");
			val2.transform.SetParent(val.transform, false);
			BuildDroppedSkiPair(val2.transform);
			BoxCollider obj = val.GetComponent<BoxCollider>() ?? val.AddComponent<BoxCollider>();
			obj.center = new Vector3(0f, 0.05f, 0f);
			obj.size = new Vector3(0.38f, 0.12f, 1.85f);
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared.m_itemType = (ItemType)18;
			shared.m_maxStackSize = 1;
			shared.m_maxQuality = 4;
			shared.m_useDurability = false;
			shared.m_teleportable = true;
			shared.m_equipStatusEffect = frostWard;
			ItemConfig val3 = new ItemConfig();
			val3.Name = "Ullr's Frost-Rune Skis";
			val3.Description = "Twin carved ash skis edged in boreal silver and etched with Ullr's glowing frost runes. Includes Skadi's Runic Poles.\n<color=#44EEFF>Equip in Utility slot • Press [X] on snow to shred!</color>";
			val3.Icon = ProceduralAssets.SkisIcon;
			val3.CraftingStation = CraftingStations.Workbench;
			val3.MinStationLevel = 1;
			val3.Weight = 2f;
			val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig("Wood", 6, 2, true),
				new RequirementConfig("LeatherScraps", 2, 1, true)
			};
			ItemConfig val4 = val3;
			ItemManager.Instance.AddItem(new CustomItem(val, false, val4));
		}

		private static void RegisterModerSnowboard(StatusEffect frostWard)
		{
			//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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00c4: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("ModerSnowboard", "BeltStrength");
			StripClonedItemVisuals(val);
			GameObject val2 = new GameObject("DroppedBoardVisual");
			val2.transform.SetParent(val.transform, false);
			BuildDroppedSnowboard(val2.transform);
			BoxCollider obj = val.GetComponent<BoxCollider>() ?? val.AddComponent<BoxCollider>();
			obj.center = new Vector3(0f, 0.05f, 0f);
			obj.size = new Vector3(0.34f, 0.12f, 1.66f);
			SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
			shared.m_itemType = (ItemType)18;
			shared.m_maxStackSize = 1;
			shared.m_maxQuality = 4;
			shared.m_useDurability = false;
			shared.m_teleportable = true;
			shared.m_equipStatusEffect = frostWard;
			ItemConfig val3 = new ItemConfig();
			val3.Name = "Moder's Drakkar Snowboard";
			val3.Description = "A wide twin-tip drakkar snowboard channeled with Moder's frost-crystal runes for deep carves, lofty bunny-hops, and stylish grabs.\n<color=#44EEFF>Equip in Utility slot • Press [X] on snow to shred!</color>";
			val3.Icon = ProceduralAssets.SnowboardIcon;
			val3.CraftingStation = CraftingStations.Workbench;
			val3.MinStationLevel = 1;
			val3.Weight = 2f;
			val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig("Wood", 6, 2, true),
				new RequirementConfig("LeatherScraps", 2, 1, true)
			};
			ItemConfig val4 = val3;
			ItemManager.Instance.AddItem(new CustomItem(val, false, val4));
		}

		private static void RegisterJumpRampPiece()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_009e: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("ullr_jump_ramp", "wood_stair");
			int num = LayerMask.NameToLayer("piece");
			if (num < 0)
			{
				num = 10;
			}
			GameObject val2 = ResetPieceVisualAndWear(val, num, 400f);
			GameObject val3 = new GameObject("RampDeck")
			{
				layer = num
			};
			val3.transform.SetParent(val2.transform, false);
			val3.AddComponent<MeshFilter>().sharedMesh = ProceduralAssets.RampDeckMesh;
			((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.SnowDeckMat;
			MeshCollider obj = val3.AddComponent<MeshCollider>();
			obj.sharedMesh = ProceduralAssets.RampDeckMesh;
			obj.convex = false;
			GameObject val4 = new GameObject("RampRuneRails")
			{
				layer = num
			};
			val4.transform.SetParent(val2.transform, false);
			val4.AddComponent<MeshFilter>().sharedMesh = ProceduralAssets.RampRailMesh;
			((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.FrostRuneMat;
			Piece component = val.GetComponent<Piece>();
			component.m_groundPiece = false;
			component.m_groundOnly = false;
			component.m_allowAltGroundPlacement = true;
			component.m_clipEverything = true;
			val.AddComponent<RunicJumpRamp>();
			PieceConfig val5 = new PieceConfig();
			val5.Name = "Ullr's Frost-Rune Kicker Ramp";
			val5.Description = "Smooth curved snow & timber launch kicker infused with frost boost runes. Buildable anywhere on the mountain without a Workbench.";
			val5.PieceTable = PieceTables.Hammer;
			val5.Category = "Ullr's Peak";
			val5.CraftingStation = CraftingStations.None;
			val5.Icon = ProceduralAssets.RampIcon;
			val5.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig("Wood", 8, 0, true)
			};
			PieceConfig val6 = val5;
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val6));
		}

		private static void RegisterSlalomGatePiece()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Expected O, but got Unknown
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Expected O, but got Unknown
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Expected O, but got Unknown
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("ullr_slalom_gate", "wood_pole2");
			int num = LayerMask.NameToLayer("piece");
			if (num < 0)
			{
				num = 10;
			}
			GameObject val2 = ResetPieceVisualAndWear(val, num, 250f);
			float[] array = new float[2] { -2.1f, 2.1f };
			for (int i = 0; i < array.Length; i++)
			{
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
				((Object)obj).name = $"SlalomPole_{i}";
				obj.layer = num;
				obj.transform.SetParent(val2.transform, false);
				obj.transform.localPosition = new Vector3(array[i], 1.35f, 0f);
				obj.transform.localScale = new Vector3(0.14f, 2.15f, 0.14f);
				((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.SilverEdgeMat;
				Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>());
				obj.AddComponent<BoxCollider>().size = new Vector3(1.4f, 2f, 1.4f);
				GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)0);
				Object.DestroyImmediate((Object)(object)obj2.GetComponent<Collider>());
				((Object)obj2).name = $"GateAccentOrb_{i}";
				obj2.transform.SetParent(val2.transform, false);
				obj2.transform.localPosition = new Vector3(array[i], 3.58f, 0f);
				obj2.transform.localScale = Vector3.one * 0.28f;
				((Renderer)obj2.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.FrostRuneMat;
			}
			GameObject obj3 = GameObject.CreatePrimitive((PrimitiveType)3);
			Object.DestroyImmediate((Object)(object)obj3.GetComponent<Collider>());
			((Object)obj3).name = "GateAccentBanner";
			obj3.transform.SetParent(val2.transform, false);
			obj3.transform.localPosition = new Vector3(0f, 3.22f, 0f);
			obj3.transform.localScale = new Vector3(4.32f, 0.42f, 0.08f);
			((Renderer)obj3.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.FrostRuneMat;
			if (!ProceduralAssets.IsHeadless)
			{
				GameObject val3 = new GameObject("GateLight");
				val3.transform.SetParent(val2.transform, false);
				val3.transform.localPosition = new Vector3(0f, 3.1f, 0f);
				Light obj4 = val3.AddComponent<Light>();
				obj4.type = (LightType)2;
				obj4.range = 7.5f;
				obj4.intensity = 1.15f;
				obj4.color = new Color(0.28f, 0.85f, 1f);
				obj4.shadows = (LightShadows)0;
			}
			Piece component = val.GetComponent<Piece>();
			component.m_groundPiece = false;
			component.m_groundOnly = false;
			component.m_allowAltGroundPlacement = true;
			component.m_clipEverything = true;
			val.AddComponent<SlalomGate>();
			PieceConfig val4 = new PieceConfig();
			val4.Name = "Ullr's Slalom Race Gate";
			val4.Description = "Runic mountain race gate. Press [E] to cycle between Start, Checkpoint, and Finish gates to time downhill races with friends!";
			val4.PieceTable = PieceTables.Hammer;
			val4.Category = "Ullr's Peak";
			val4.CraftingStation = CraftingStations.None;
			val4.Icon = ProceduralAssets.GateIcon;
			val4.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig("Wood", 4, 0, true)
			};
			PieceConfig val5 = val4;
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val5));
		}

		private static void RegisterRopeTowPiece()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: 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_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: 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_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Expected O, but got Unknown
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Expected O, but got Unknown
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Expected O, but got Unknown
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("ullr_rope_tow", "wood_pole2");
			int num = LayerMask.NameToLayer("piece");
			if (num < 0)
			{
				num = 10;
			}
			GameObject val2 = ResetPieceVisualAndWear(val, num, 500f);
			float[] array = new float[2] { -0.45f, 0.45f };
			float[] array2 = new float[2] { -11f, 11f };
			for (int i = 0; i < 2; i++)
			{
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
				Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>());
				((Object)obj).name = $"PylonLeg_{i}";
				obj.layer = num;
				obj.transform.SetParent(val2.transform, false);
				obj.transform.localPosition = new Vector3(array[i], 0.85f, 0f);
				obj.transform.localRotation = Quaternion.Euler(0f, 0f, array2[i]);
				obj.transform.localScale = new Vector3(0.18f, 3.4f, 0.18f);
				((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.DarkWoodMat;
			}
			GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)3);
			Object.DestroyImmediate((Object)(object)obj2.GetComponent<Collider>());
			((Object)obj2).name = "Crossbeam";
			obj2.layer = num;
			obj2.transform.SetParent(val2.transform, false);
			obj2.transform.localPosition = new Vector3(0f, 2.2f, 0f);
			obj2.transform.localScale = new Vector3(1.1f, 0.18f, 0.24f);
			((Renderer)obj2.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.DarkWoodMat;
			BoxCollider obj3 = val2.AddComponent<BoxCollider>();
			obj3.center = new Vector3(0f, 1.15f, 0f);
			obj3.size = new Vector3(1.25f, 2.5f, 0.65f);
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)2);
			Object.DestroyImmediate((Object)(object)val3.GetComponent<Collider>());
			((Object)val3).name = "Bullwheel";
			val3.transform.SetParent(val.transform, false);
			val3.transform.localPosition = new Vector3(0f, 2.34f, 0f);
			val3.transform.localScale = new Vector3(0.95f, 0.06f, 0.95f);
			((Renderer)val3.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.SilverEdgeMat;
			GameObject obj4 = GameObject.CreatePrimitive((PrimitiveType)3);
			Object.DestroyImmediate((Object)(object)obj4.GetComponent<Collider>());
			((Object)obj4).name = "RuneCross";
			obj4.transform.SetParent(val3.transform, false);
			obj4.transform.localScale = new Vector3(0.92f, 1.3f, 0.16f);
			((Renderer)obj4.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.FrostRuneMat;
			GameObject val4 = new GameObject("CableAnchor");
			val4.transform.SetParent(val.transform, false);
			val4.transform.localPosition = new Vector3(0f, 2.34f, 0f);
			GameObject obj5 = GameObject.CreatePrimitive((PrimitiveType)0);
			Object.DestroyImmediate((Object)(object)obj5.GetComponent<Collider>());
			((Object)obj5).name = "EnergyOrb";
			obj5.transform.SetParent(val.transform, false);
			obj5.transform.localPosition = new Vector3(0f, 2.34f, 0f);
			obj5.transform.localScale = Vector3.one * 0.24f;
			((Renderer)obj5.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.FrostRuneMat;
			obj5.SetActive(false);
			Piece component = val.GetComponent<Piece>();
			component.m_groundPiece = false;
			component.m_groundOnly = false;
			component.m_allowAltGroundPlacement = true;
			component.m_clipEverything = true;
			val.AddComponent<RunicRopeTow>();
			PieceConfig val5 = new PieceConfig();
			val5.Name = "Ullr's Runic Rope Tow";
			val5.Description = "Chain two or more pylons up a mountain (up to 85m per span) to create a frost-powered uphill ski lift! Press [E] to ride to the summit.";
			val5.PieceTable = PieceTables.Hammer;
			val5.Category = "Ullr's Peak";
			val5.CraftingStation = CraftingStations.None;
			val5.Icon = ProceduralAssets.RopeTowIcon;
			val5.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig("Wood", 10, 0, true),
				new RequirementConfig("LeatherScraps", 2, 0, true)
			};
			PieceConfig val6 = val5;
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val6));
		}

		private static void StripClonedItemVisuals(GameObject prefab)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			prefab.transform.localScale = Vector3.one;
			for (int num = prefab.transform.childCount - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)((Component)prefab.transform.GetChild(num)).gameObject);
			}
			Collider[] components = prefab.GetComponents<Collider>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components[i]);
			}
			Renderer[] components2 = prefab.GetComponents<Renderer>();
			for (int i = 0; i < components2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components2[i]);
			}
		}

		private static GameObject ResetPieceVisualAndWear(GameObject prefab, int pieceLayer, float health)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			prefab.layer = pieceLayer;
			for (int num = prefab.transform.childCount - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)((Component)prefab.transform.GetChild(num)).gameObject);
			}
			Collider[] components = prefab.GetComponents<Collider>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components[i]);
			}
			GameObject val = new GameObject("VisualRoot");
			val.layer = pieceLayer;
			val.transform.SetParent(prefab.transform, false);
			WearNTear component = prefab.GetComponent<WearNTear>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_new = val;
				component.m_worn = val;
				component.m_broken = val;
				component.m_wet = null;
				component.m_snow = null;
				component.m_snowWorn = null;
				component.m_snowBroken = null;
				component.m_noRoofWear = false;
				component.m_noSupportWear = false;
				component.m_snowDamageImmune = true;
				component.m_health = health;
			}
			return val;
		}

		private static void BuildDroppedSkiPair(Transform parent)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			float[] array = new float[2] { -0.1f, 0.1f };
			foreach (float num in array)
			{
				GameObject val = new GameObject("Ski");
				val.transform.SetParent(parent, false);
				val.transform.localPosition = new Vector3(num, 0f, 0f);
				GameObject val2 = new GameObject("Deck");
				val2.transform.SetParent(val.transform, false);
				val2.AddComponent<MeshFilter>().sharedMesh = ProceduralAssets.SkiMesh;
				((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.DarkWoodMat;
				GameObject val3 = new GameObject("Rune");
				val3.transform.SetParent(val.transform, false);
				val3.AddComponent<MeshFilter>().sharedMesh = ProceduralAssets.SkiRuneMesh;
				((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.FrostRuneMat;
			}
		}

		private static void BuildDroppedSnowboard(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Deck");
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = ProceduralAssets.SnowboardMesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.SilverEdgeMat;
			GameObject val2 = new GameObject("Rune");
			val2.transform.SetParent(parent, false);
			val2.AddComponent<MeshFilter>().sharedMesh = ProceduralAssets.SnowboardRuneMesh;
			((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.FrostRuneMat;
		}
	}
}
namespace UllrSkiAndSnowboard.Visuals
{
	public class SkiVisualRig : MonoBehaviour
	{
		private static readonly Quaternion StowedBackLocalRot = Quaternion.Euler(8f, 0f, 22f) * Quaternion.Euler(-90f, 0f, 0f);

		private Player _player;

		private VisEquipment _visEquip;

		private PlayerSkiController _controller;

		private GameObject _activeRoot;

		private GameObject _skisGroup;

		private GameObject _snowboardGroup;

		private TrailRenderer _leftTrail;

		private TrailRenderer _rightTrail;

		private ParticleSystem _snowSpray;

		private Light _frostAuraLight;

		private GameObject _leftPoleObj;

		private GameObject _rightPoleObj;

		private GameObject _stowedBackRoot;

		private GameObject _stowedSkis;

		private GameObject _stowedBoard;

		private float _carveStepTimer;

		private Quaternion _smoothedSlopeAlign = Quaternion.identity;

		private bool _wasRidingVisualApplied;

		private void Awake()
		{
			_player = ((Component)this).GetComponent<Player>();
			_visEquip = ((Component)this).GetComponent<VisEquipment>();
			_controller = ((Component)this).GetComponent<PlayerSkiController>();
		}

		private void Start()
		{
			if (!ProceduralAssets.IsHeadless)
			{
				BuildVisualHierarchy();
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_activeRoot != (Object)null)
			{
				Object.Destroy((Object)(object)_activeRoot);
			}
			if ((Object)(object)_leftPoleObj != (Object)null)
			{
				Object.Destroy((Object)(object)_leftPoleObj);
			}
			if ((Object)(object)_rightPoleObj != (Object)null)
			{
				Object.Destroy((Object)(object)_rightPoleObj);
			}
			if ((Object)(object)_stowedBackRoot != (Object)null)
			{
				Object.Destroy((Object)(object)_stowedBackRoot);
			}
		}

		private void BuildVisualHierarchy()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0050: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_activeRoot != (Object)null))
			{
				_activeRoot = new GameObject("UllrActiveRideRig");
				_activeRoot.transform.SetParent(((Component)this).transform, false);
				_activeRoot.transform.localPosition = new Vector3(0f, 0.03f, 0f);
				_activeRoot.transform.localScale = Vector3.one;
				_skisGroup = new GameObject("TwinSkisGroup");
				_skisGroup.transform.SetParent(_activeRoot.transform, false);
				CreateSingleSkiVisual(_skisGroup.transform, new Vector3(-0.19f, 0f, 0.04f));
				CreateSingleSkiVisual(_skisGroup.transform, new Vector3(0.19f, 0f, 0.04f));
				_snowboardGroup = new GameObject("SnowboardGroup");
				_snowboardGroup.transform.SetParent(_activeRoot.transform, false);
				CreateSnowboardVisual(_snowboardGroup.transform, new Vector3(0f, 0f, 0.02f));
				_leftTrail = CreateFrostTrail(_activeRoot.transform, new Vector3(-0.18f, 0.04f, -0.78f));
				_rightTrail = CreateFrostTrail(_activeRoot.transform, new Vector3(0.18f, 0.04f, -0.78f));
				_snowSpray = CreateSnowSpraySystem(_activeRoot.transform);
				GameObject val = new GameObject("UllrFrostGlow");
				val.transform.SetParent(_activeRoot.transform, false);
				val.transform.localPosition = new Vector3(0f, 0.35f, 0.1f);
				_frostAuraLight = val.AddComponent<Light>();
				_frostAuraLight.type = (LightType)2;
				_frostAuraLight.color = new Color(0.3f, 0.9f, 1f);
				_frostAuraLight.range = 4.4f;
				_frostAuraLight.intensity = 0.85f;
				_frostAuraLight.shadows = (LightShadows)0;
				_leftPoleObj = CreatePoleInstance("UllrLeftSkiPole", ((Component)this).transform);
				_rightPoleObj = CreatePoleInstance("UllrRightSkiPole", ((Component)this).transform);
				BuildStowedBackRig();
				_activeRoot.SetActive(false);
			}
		}

		private void BuildStowedBackRig()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_008c: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			_stowedBackRoot = new GameObject("UllrStowedBackGear");
			_stowedBackRoot.transform.SetParent(((Component)this).transform, false);
			_stowedBackRoot.transform.localScale = Vector3.one * 0.68f;
			_stowedSkis = new GameObject("StowedSkis");
			_stowedSkis.transform.SetParent(_stowedBackRoot.transform, false);
			CreateSingleSkiVisual(_stowedSkis.transform, new Vector3(-0.07f, 0f, 0f));
			CreateSingleSkiVisual(_stowedSkis.transform, new Vector3(0.07f, 0.025f, 0f));
			_stowedBoard = new GameObject("StowedBoard");
			_stowedBoard.transform.SetParent(_stowedBackRoot.transform, false);
			CreateSnowboardVisual(_stowedBoard.transform, Vector3.zero);
			_stowedBackRoot.SetActive(false);
		}

		private static void CreateSingleSkiVisual(Transform parent, Vector3 localPos)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("MythicSki");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			AddMeshChild(val.transform, "Deck", ProceduralAssets.SkiMesh, ProceduralAssets.DarkWoodMat);
			AddMeshChild(val.transform, "RuneInlay", ProceduralAssets.SkiRuneMesh, ProceduralAssets.FrostRuneMat);
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			((Object)obj).name = "Binding";
			obj.transform.SetParent(val.transform, false);
			obj.transform.localPosition = new Vector3(0f, 0.032f, -0.04f);
			obj.transform.localScale = new Vector3(0.088f, 0.028f, 0.26f);
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.SilverEdgeMat;
		}

		private static void CreateSnowboardVisual(Transform parent, Vector3 localPos)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ModerDrakkarBoard");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			AddMeshChild(val.transform, "Deck", ProceduralAssets.SnowboardMesh, ProceduralAssets.SilverEdgeMat);
			AddMeshChild(val.transform, "RuneSpine", ProceduralAssets.SnowboardRuneMesh, ProceduralAssets.FrostRuneMat);
			float[] array = new float[2] { -0.26f, 0.26f };
			float[] array2 = new float[2] { -12f, 15f };
			for (int i = 0; i < 2; i++)
			{
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
				Object.Destroy((Object)(object)obj.GetComponent<Collider>());
				((Object)obj).name = "BoardBinding";
				obj.transform.SetParent(val.transform, false);
				obj.transform.localPosition = new Vector3(0f, 0.034f, array[i]);
				obj.transform.localRotation = Quaternion.Euler(0f, array2[i], 0f);
				obj.transform.localScale = new Vector3(0.24f, 0.032f, 0.13f);
				((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.LeatherMat;
			}
		}

		private static GameObject CreatePoleInstance(string name, Transform rootParent)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(rootParent, false);
			val.transform.localScale = Vector3.one;
			AddMeshChild(val.transform, "PoleShaft", ProceduralAssets.PoleMesh, ProceduralAssets.SilverEdgeMat);
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
			Object.Destroy((Object)(object)obj.GetComponent<Collider>());
			((Object)obj).name = "RunePommel";
			obj.transform.SetParent(val.transform, false);
			obj.transform.localPosition = new Vector3(0f, 0.13f, 0f);
			obj.transform.localScale = Vector3.one * 0.045f;
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = ProceduralAssets.FrostRuneMat;
			val.SetActive(false);
			return val;
		}

		private static GameObject AddMeshChild(Transform parent, string name, Mesh mesh, Material mat)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = mat;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			return val;
		}

		private static TrailRenderer CreateFrostTrail(Transform parent, Vector3 localPos)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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)
			GameObject val = new GameObject("FrostRibbonTrail");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			TrailRenderer obj = val.AddComponent<TrailRenderer>();
			obj.time = 0.65f;
			obj.minVertexDistance = 0.15f;
			obj.startWidth = 0.11f;
			obj.endWidth = 0.01f;
			((Renderer)obj).sharedMaterial = ProceduralAssets.TrailRibbonMat;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			obj.startColor = new Color(0.45f, 0.94f, 1f, 0.72f);
			obj.endColor = new Color(0.75f, 0.98f, 1f, 0f);
			obj.emitting = false;
			return obj;
		}

		private static ParticleSystem CreateSnowSpraySystem(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_002d: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("SnowCarveSpray");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = new Vector3(0f, 0.08f, -0.55f);
			val.transform.localRotation = Quaternion.Euler(-25f, 180f, 0f);
			ParticleSystem obj = val.AddComponent<ParticleSystem>();
			MainModule main = obj.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.35f, 0.75f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(1.8f, 5.2f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.1f, 0.34f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.9f, 0.97f, 1f, 0.8f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.65f);
			((MainModule)(ref main)).maxParticles = 220;
			EmissionModule emission = obj.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 32f;
			((ShapeModule)(ref shape)).radius = 0.22f;
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = ProceduralAssets.SnowParticleMat;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			return obj;
		}

		private void LateUpdate()
		{
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: 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_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: 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_01dd: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: 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_065d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			if (ProceduralAssets.IsHeadless || (Object)(object)_controller == (Object)null || (Object)(object)_player == (Object)null)
			{
				return;
			}
			if ((Object)(object)_activeRoot == (Object)null)
			{
				BuildVisualHierarchy();
			}
			if ((Object)(object)_activeRoot == (Object)null)
			{
				return;
			}
			RideGearType equippedGear = _controller.EquippedGear;
			RideGearType syncedRideMode = _controller.SyncedRideMode;
			if (((Character)_player).IsDead() || equippedGear == RideGearType.None)
			{
				SetAllVisualsOff();
				return;
			}
			if (syncedRideMode == RideGearType.None)
			{
				if (_activeRoot.activeSelf)
				{
					_activeRoot.SetActive(false);
				}
				if ((Object)(object)_leftPoleObj != (Object)null && _leftPoleObj.activeSelf)
				{
					_leftPoleObj.SetActive(false);
				}
				if ((Object)(object)_rightPoleObj != (Object)null && _rightPoleObj.activeSelf)
				{
					_rightPoleObj.SetActive(false);
				}
				RestorePlayerBodyStanceIfNeeded();
				UpdateStowedBackGear(equippedGear);
				return;
			}
			if ((Object)(object)_stowedBackRoot != (Object)null && _stowedBackRoot.activeSelf)
			{
				_stowedBackRoot.SetActive(false);
			}
			if (!_activeRoot.activeSelf)
			{
				_activeRoot.SetActive(true);
			}
			bool flag = syncedRideMode == RideGearType.Snowboard;
			_skisGroup.SetActive(!flag);
			_snowboardGroup.SetActive(flag);
			float syncedLeanAngle = _controller.SyncedLeanAngle;
			float syncedSpinYaw = _controller.SyncedSpinYaw;
			RideSyncFlags syncedFlags = _controller.SyncedFlags;
			float syncedSpeed = _controller.SyncedSpeed;
			bool flag2 = (syncedFlags & RideSyncFlags.Airborne) != 0;
			bool flag3 = (syncedFlags & RideSyncFlags.Grabbing) != 0;
			bool flag4 = (syncedFlags & RideSyncFlags.Braking) != 0;
			bool flag5 = (syncedFlags & RideSyncFlags.Tucking) != 0;
			bool flag6 = (syncedFlags & RideSyncFlags.WipedOut) != 0;
			bool poling = (syncedFlags & RideSyncFlags.Poling) != 0;
			Quaternion val = Quaternion.identity;
			RaycastHit val2 = default(RaycastHit);
			if (!flag2 && Physics.Raycast(((Component)this).transform.position + Vector3.up * 0.7f, Vector3.down, ref val2, 1.4f, LayerMask.GetMask(new string[4] { "terrain", "Default", "static_solid", "piece" }), (QueryTriggerInteraction)1))
			{
				Vector3 val3 = ((Component)this).transform.InverseTransformDirection(((RaycastHit)(ref val2)).normal);
				Vector3 val4 = Vector3.ProjectOnPlane(Vector3.forward, val3);
				Vector3 normalized = ((Vector3)(ref val4)).normalized;
				if (((Vector3)(ref normalized)).sqrMagnitude > 0.01f)
				{
					val = Quaternion.LookRotation(normalized, val3);
				}
			}
			_smoothedSlopeAlign = Quaternion.Slerp(_smoothedSlopeAlign, val, Time.deltaTime * 14f);
			float num = syncedSpinYaw + ((!flag4) ? 0f : (flag ? 58f : 26f));
			float num2 = (flag3 ? (-16f) : 0f);
			float num3 = (flag6 ? 72f : 0f);
			_activeRoot.transform.localRotation = _smoothedSlopeAlign * Quaternion.Euler(num2, num, syncedLeanAngle + num3);
			if ((Object)(object)_leftTrail != (Object)null && (Object)(object)_rightTrail != (Object)null)
			{
				float num4 = (flag ? 0.11f : 0.19f);
				((Component)_leftTrail).transform.localPosition = new Vector3(0f - num4, 0.04f, -0.76f);
				((Component)_rightTrail).transform.localPosition = new Vector3(num4, 0.04f, -0.76f);
				bool emitting = (!flag2 && syncedSpeed > 2.2f) || flag3;
				_leftTrail.emitting = emitting;
				_rightTrail.emitting = emitting;
			}
			Quaternion rotation = ((Component)this).transform.rotation;
			if ((Object)(object)((Character)_player).m_visual != (Object)null)
			{
				_wasRidingVisualApplied = true;
				float num5 = num + (flag ? 72f : 0f);
				float num6 = (flag5 ? 18f : (flag3 ? 24f : (flag ? 8f : 6f)));
				float num7 = syncedLeanAngle * 0.78f + (flag6 ? 68f : 0f);
				float num8 = ((flag5 || flag3) ? (-0.14f) : (-0.04f));
				((Character)_player).m_visual.transform.localPosition = new Vector3(0f, num8, 0f);
				((Character)_player).m_visual.transform.localRotation = _smoothedSlopeAlign * Quaternion.Euler(num6, num5, num7);
				rotation = ((Character)_player).m_visual.transform.rotation;
			}
			bool show = !flag && !flag6;
			UpdateHandPole(_leftPoleObj, show, isLeft: true, rotation, poling, flag5);
			UpdateHandPole(_rightPoleObj, show, isLeft: false, rotation, poling, flag5);
			if ((Object)(object)_snowSpray != (Object)null)
			{
				EmissionModule emission = _snowSpray.emission;
				if (!flag2 && syncedSpeed > 2.5f)
				{
					if (!_snowSpray.isPlaying)
					{
						_snowSpray.Play();
					}
					float num9 = 1f + Mathf.Abs(syncedLeanAngle) * 0.06f + (flag4 ? 2.6f : 0f) + (flag6 ? 3f : 0f);
					((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(Mathf.Clamp(syncedSpeed * 3.8f * num9, 0f, 160f));
				}
				else
				{
					((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
				}
			}
			if ((Object)(object)_frostAuraLight != (Object)null)
			{
				_frostAuraLight.intensity = Mathf.Lerp(0.65f, 1.55f, Mathf.Clamp01(syncedSpeed / 24f)) + (flag3 ? 0.5f : 0f);
			}
			if (!flag2 && syncedSpeed > 3.2f && (Object)(object)ProceduralAssets.SnowStepClip != (Object)null)
			{
				_carveStepTimer -= Time.deltaTime * Mathf.Lerp(1.2f, 4.2f, Mathf.Clamp01(syncedSpeed / 24f));
				if (_carveStepTimer <= 0f)
				{
					_carveStepTimer = 0.42f;
					float num10 = Mathf.Lerp(0.08f, 0.28f, Mathf.Clamp01(syncedSpeed / 24f)) + (flag4 ? 0.18f : 0f);
					AudioSource.PlayClipAtPoint(ProceduralAssets.SnowStepClip, ((Component)this).transform.position, num10);
				}
			}
		}

		private void UpdateStowedBackGear(RideGearType equipped)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0104: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_stowedBackRoot == (Object)null)
			{
				return;
			}
			if ((UllrPlugin.ShowStowedGearOnBack != null && !UllrPlugin.ShowStowedGearOnBack.Value) || ((Character)_player).IsSwimming() || ((Character)_player).IsAttached())
			{
				if (_stowedBackRoot.activeSelf)
				{
					_stowedBackRoot.SetActive(false);
				}
				return;
			}
			if (!_stowedBackRoot.activeSelf)
			{
				_stowedBackRoot.SetActive(true);
			}
			_stowedSkis.SetActive(equipped == RideGearType.Skis);
			_stowedBoard.SetActive(equipped == RideGearType.Snowboard);
			Quaternion val = (((Object)(object)((Character)_player).m_visual != (Object)null) ? ((Character)_player).m_visual.transform.rotation : ((Component)this).transform.rotation);
			bool flag = ((Character)_player).IsCrouching();
			Vector3 val2 = ((Component)this).transform.position + val * new Vector3(0f, flag ? 0.9f : 1.18f, -0.22f);
			Vector3 position = val2;
			if ((Object)(object)_visEquip != (Object)null && (Object)(object)_visEquip.m_backShield != (Object)null)
			{
				Vector3 val3 = _visEquip.m_backShield.position - val * Vector3.forward * 0.06f;
				Vector3 val4 = val3 - val2;
				if (((Vector3)(ref val4)).sqrMagnitude < 0.45f)
				{
					position = val3;
				}
			}
			Quaternion val5 = (flag ? Quaternion.Euler(20f, 0f, 0f) : Quaternion.identity);
			_stowedBackRoot.transform.position = position;
			_stowedBackRoot.transform.rotation = val * val5 * StowedBackLocalRot;
			_stowedBackRoot.transform.localScale = Vector3.one * 0.68f;
		}

		private void UpdateHandPole(GameObject poleObj, bool show, bool isLeft, Quaternion visualRot, bool poling, bool tucking)
		{
			//IL_0034: 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_0057: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)poleObj == (Object)null)
			{
				return;
			}
			if (poleObj.activeSelf != show)
			{
				poleObj.SetActive(show);
			}
			if (!show)
			{
				return;
			}
			float num = (isLeft ? (-1f) : 1f);
			Vector3 val = ((Component)this).transform.position + visualRot * new Vector3(num * 0.34f, tucking ? 0.78f : 0.94f, 0.16f);
			Vector3 position = val;
			Transform val2 = ((!((Object)(object)_visEquip != (Object)null)) ? null : (isLeft ? _visEquip.m_leftHand : _visEquip.m_rightHand));
			if ((Object)(object)val2 != (Object)null)
			{
				Vector3 val3 = val2.position - val;
				if (((Vector3)(ref val3)).sqrMagnitude < 1.5f)
				{
					position = val2.position;
				}
			}
			float num2 = (isLeft ? 0f : ((float)Math.PI));
			float num3 = (poling ? (Mathf.Sin(Time.time * 16f + num2) * 28f) : (tucking ? 22f : 0f));
			poleObj.transform.position = position;
			poleObj.transform.rotation = visualRot * Quaternion.Euler(52f + num3, num * 8f, num * -6f);
			poleObj.transform.localScale = Vector3.one;
		}

		private void SetAllVisualsOff()
		{
			if ((Object)(object)_activeRoot != (Object)null && _activeRoot.activeSelf)
			{
				_activeRoot.SetActive(false);
			}
			if ((Object)(object)_stowedBackRoot != (Object)null && _stowedBackRoot.activeSelf)
			{
				_stowedBackRoot.SetActive(false);
			}
			if ((Object)(object)_leftPoleObj != (Object)null && _leftPoleObj.activeSelf)
			{
				_leftPoleObj.SetActive(false);
			}
			if ((Object)(object)_rightPoleObj != (Object)null && _rightPoleObj.activeSelf)
			{
				_rightPoleObj.SetActive(false);
			}
			RestorePlayerBodyStanceIfNeeded();
		}

		private void RestorePlayerBodyStanceIfNeeded()
		{
			//IL_0041: 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)
			if (_wasRidingVisualApplied)
			{
				_wasRidingVisualApplied = false;
				if ((Object)(object)_player != (Object)null && (Object)(object)((Character)_player).m_visual != (Object)null)
				{
					((Character)_player).m_visual.transform.localPosition = Vector3.zero;
					((Character)_player).m_visual.transform.localRotation = Quaternion.identity;
				}
			}
		}
	}
}
namespace UllrSkiAndSnowboard.Structures
{
	public class RunicJumpRamp : MonoBehaviour
	{
		public static readonly HashSet<RunicJumpRamp> ActiveRamps = new HashSet<RunicJumpRamp>();

		private static readonly Dictionary<int, RunicJumpRamp> ColliderLookup = new Dictionary<int, RunicJumpRamp>();

		private Collider[] _colliders;

		private void Awake()
		{
			_colliders = ((Component)this).GetComponentsInChildren<Collider>(true);
			ActiveRamps.Add(this);
			if (_colliders == null)
			{
				return;
			}
			Collider[] colliders = _colliders;
			foreach (Collider val in colliders)
			{
				if ((Object)(object)val != (Object)null)
				{
					ColliderLookup[((Object)val).GetInstanceID()] = this;
				}
			}
		}

		private void OnDestroy()
		{
			ActiveRamps.Remove(this);
			if (_colliders == null)
			{
				return;
			}
			Collider[] colliders = _colliders;
			foreach (Collider val in colliders)
			{
				if ((Object)(object)val != (Object)null)
				{
					ColliderLookup.Remove(((Object)val).GetInstanceID());
				}
			}
		}

		public static bool TryGetRamp(Collider col, out RunicJumpRamp ramp)
		{
			if ((Object)(object)col == (Object)null)
			{
				ramp = null;
				return false;
			}
			if (ColliderLookup.TryGetValue(((Object)col).GetInstanceID(), out ramp))
			{
				return (Object)(object)ramp != (Object)null;
			}
			return false;
		}
	}
	public enum SlalomGateMode
	{
		Start,
		Checkpoint,
		Finish
	}
	public class SlalomGate : MonoBehaviour, Hoverable, Interactable
	{
		public static readonly List<SlalomGate> ActiveGates = new List<SlalomGate>();

		private static readonly int GateModeHash = StringExtensionMethods.GetStableHashCode("ullr_gate_mode");

		private ZNetView _nview;

		private MeshRenderer[] _accentRenderers;

		private Light _gateLight;

		private SlalomGateMode _cachedMode = (SlalomGateMode)(-1);

		public SlalomGateMode Mode
		{
			get
			{
				if ((Object)(object)_nview != (Object)null && _nview.IsValid() && _nview.GetZDO() != null)
				{
					return (SlalomGateMode)Mathf.Clamp(_nview.GetZDO().GetInt(GateModeHash, 1), 0, 2);
				}
				return SlalomGateMode.Checkpoint;
			}
		}

		private void Awake()
		{
			_nview = ((Component)this).GetComponent<ZNetView>();
			ActiveGates.Add(this);
			List<MeshRenderer> list = new List<MeshRenderer>();
			MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null && ((Object)((Component)val).gameObject).name.StartsWith("GateAccent"))
				{
					list.Add(val);
				}
			}
			_accentRenderers = list.ToArray();
			_gateLight = ((Component)this).GetComponentInChildren<Light>(true);
			RefreshVisuals(force: true);
		}

		private void OnDestroy()
		{
			ActiveGates.Remove(this);
		}

		private void Update()
		{
			RefreshVisuals(force: false);
		}

		private void RefreshVisuals(bool force)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			SlalomGateMode mode = Mode;
			if (!force && mode == _cachedMode)
			{
				return;
			}
			_cachedMode = mode;
			if (ProceduralAssets.IsHeadless)
			{
				return;
			}
			Color val = default(Color);
			Color emissionColor;
			switch (mode)
			{
			case SlalomGateMode.Start:
				((Color)(ref val))..ctor(0.18f, 1f, 0.78f);
				emissionColor = new Color(0.15f, 0.95f, 0.72f) * 2.6f;
				break;
			case SlalomGateMode.Finish:
				((Color)(ref val))..ctor(1f, 0.62f, 0.18f);
				emissionColor = new Color(1f, 0.48f, 0.12f) * 2.8f;
				break;
			default:
				((Color)(ref val))..ctor(0.28f, 0.8f, 1f);
				emissionColor = new Color(0.22f, 0.75f, 1f) * 2.4f;
				break;
			}
			Material sharedMaterial = ProceduralAssets.CreateGateBannerMaterial(val, emissionColor);
			if (_accentRenderers != null)
			{
				MeshRenderer[] accentRenderers = _accentRenderers;
				foreach (MeshRenderer val2 in accentRenderers)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						((Renderer)val2).sharedMaterial = sharedMaterial;
					}
				}
			}
			if ((Object)(object)_gateLight != (Object)null)
			{
				_gateLight.color = val;
			}
		}

		public string GetHoverText()
		{
			SlalomGateMode mode = Mode;
			return Localization.instance.Localize("Ullr's Slalom Gate (" + mode switch
			{
				SlalomGateMode.Start => "<color=#33FFCC>START GATE</color>", 
				SlalomGateMode.Finish => "<color=#FFAA33>FINISH GATE</color>", 
				_ => "<color=#55CCFF>CHECKPOINT GATE</color>", 
			} + ")\n[<color=yellow><b>$KEY_Use</b></color>] Cycle Gate Type");
		}

		public string GetHoverName()
		{
			return "Ullr's Slalom Gate";
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold || (Object)(object)_nview == (Object)null || !_nview.IsValid())
			{
				return false;
			}
			_nview.ClaimOwnership();
			int num = (int)(Mode + 1) % 3;
			_nview.GetZDO().Set(GateModeHash, num, false);
			RefreshVisuals(force: true);
			((Character)user).Message((MessageType)2, "Slalom Gate set to " + (SlalomGateMode)num switch
			{
				SlalomGateMode.Start => "START Gate", 
				SlalomGateMode.Finish => "FINISH Gate", 
				_ => "CHECKPOINT Gate", 
			}, 0, (Sprite)null, false);
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}
	}
	public class RunicRopeTow : MonoBehaviour, Hoverable, Interactable
	{
		public static readonly List<RunicRopeTow> ActivePylons = new List<RunicRopeTow>();

		public const float MaxSpanMeters = 85f;

		private Transform _bullwheel;

		private Transform _cableAnchor;

		private LineRenderer _cableLine;

		private Transform _energyOrb;

		private RunicRopeTow _uphillTarget;

		private float _relinkTimer;

		private float _orbProgress;

		public RunicRopeTow UphillTarget => _uphillTarget;

		public Vector3 AnchorWorldPos
		{
			get
			{
				//IL_0034: 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_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)_cableAnchor != (Object)null))
				{
					return ((Component)this).transform.position + Vector3.up * 2.1f;
				}
				return _cableAnchor.position;
			}
		}

		private void Awake()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			ActivePylons.Add(this);
			_bullwheel = ((Component)this).transform.Find("Bullwheel");
			_cableAnchor = ((Component)this).transform.Find("CableAnchor");
			_energyOrb = ((Component)this).transform.Find("EnergyOrb");
			if (!ProceduralAssets.IsHeadless)
			{
				GameObject val = new GameObject("RunicTowCable");
				val.transform.SetParent(((Component)this).transform, false);
				_cableLine = val.AddComponent<LineRenderer>();
				_cableLine.useWorldSpace = true;
				_cableLine.positionCount = 2;
				_cableLine.startWidth = 0.085f;
				_cableLine.endWidth = 0.085f;
				((Renderer)_cableLine).sharedMaterial = ProceduralAssets.FrostRuneMat;
				((Renderer)_cableLine).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)_cableLine).enabled = false;
			}
			_relinkTimer = 0.1f;
		}

		private void OnDestroy()
		{
			ActivePylons.Remove(this);
		}

		private void Update()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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)
			_relinkTimer -= Time.deltaTime;
			if (_relinkTimer <= 0f)
			{
				_relinkTimer = 1f;
				RefreshUphillLink();
			}
			if (ProceduralAssets.IsHeadless)
			{
				return;
			}
			if ((Object)(object)_uphillTarget != (Object)null)
			{
				Vector3 anchorWorldPos = AnchorWorldPos;
				Vector3 anchorWorldPos2 = _uphillTarget.AnchorWorldPos;
				if ((Object)(object)_cableLine != (Object)null)
				{
					((Renderer)_cableLine).enabled = true;
					_cableLine.SetPosition(0, anchorWorldPos);
					_cableLine.SetPosition(1, anchorWorldPos2);
				}
				if ((Object)(object)_bullwheel != (Object)null)
				{
					_bullwheel.Rotate(Vector3.up, 160f * Time.deltaTime, (Space)1);
				}
				if ((Object)(object)_energyOrb != (Object)null)
				{
					((Component)_energyOrb).gameObject.SetActive(true);
					_orbProgress = (_orbProgress + Time.deltaTime * 0.45f) % 1f;
					_energyOrb.position = Vector3.Lerp(anchorWorldPos, anchorWorldPos2, _orbProgress);
				}
			}
			else
			{
				if ((Object)(object)_cableLine != (Object)null)
				{
					((Renderer)_cableLine).enabled = false;
				}
				if ((Object)(object)_energyOrb != (Object)null)
				{
					((Component)_energyOrb).gameObject.SetActive(false);
				}
			}
		}

		public void RefreshUphillLink()
		{
			//IL_000e: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			RunicRopeTow uphillTarget = null;
			float num = 85f;
			Vector3 position = ((Component)this).transform.position;
			for (int i = 0; i < ActivePylons.Count; i++)
			{
				RunicRopeTow runicRopeTow = ActivePylons[i];
				if (!((Object)(object)runicRopeTow == (Object)null) && !((Object)(object)runicRopeTow == (Object)(object)this) && !(((Component)runicRopeTow).transform.position.y - position.y < 1f))
				{
					float num2 = Vector3.Distance(position, ((Component)runicRopeTow).transform.position);
					if (num2 <= num)
					{
						num = num2;
						uphillTarget = runicRopeTow;
					}
				}
			}
			_uphillTarget = uphillTarget;
		}

		public static bool TryFindNearestTowSpan(Vector3 playerPos, float maxCaptureRadius, out RunicRopeTow startPylon, out float tAlongSpan, out Vector3 closestPoint)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_008d: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00cc: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			startPylon = null;
			tAlongSpan = 0f;
			closestPoint = Vector3.zero;
			float num = maxCaptureRadius;
			for (int i = 0; i < ActivePylons.Count; i++)
			{
				RunicRopeTow runicRopeTow = ActivePylons[i];
				if ((Object)(object)runicRopeTow == (Object)null || (Object)(object)runicRopeTow._uphillTarget == (Object)null)
				{
					continue;
				}
				Vector3 val = ((Component)runicRopeTow).transform.position + Vector3.up * 0.35f;
				Vector3 val2 = ((Component)runicRopeTow._uphillTarget).transform.position + Vector3.up * 0.35f - val;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude < 1f)
				{
					continue;
				}
				float num2 = Mathf.Clamp01(Vector3.Dot(playerPos - val, val2) / sqrMagnitude);
				if (!(num2 > 0.98f))
				{
					Vector3 val3 = val + val2 * num2;
					float num3 = Vector3.Distance(playerPos, val3);
					if (num3 < num)
					{
						num = num3;
						startPylon = runicRopeTow;
						tAlongSpan = num2;
						closestPoint = val3;
					}
				}
			}
			return (Object)(object)startPylon != (Object)null;
		}

		public string GetHoverText()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			string text = (((Object)(object)_uphillTarget != (Object)null) ? $"<color=#44EEFF>Active Uphill Span ({Vector3.Distance(((Component)this).transform.position, ((Component)_uphillTarget).transform.position):0}m)</color>\n[<color=yellow><b>$KEY_Use</b></color>] Latch onto Runic Tow" : "<color=#FFCC66>Top Summit Pylon</color> (Place another pylon uphill within 85m to extend)");
			return Localization.instance.Localize("Ullr's Runic Rope Tow\n" + text);
		}

		public string GetHoverName()
		{
			return "Ullr's Runic Rope Tow";
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold)
			{
				return false;
			}
			Player val = (Player)(object)((user is Player) ? user : null);
			if (val != null)
			{
				PlayerSkiController component = ((Component)val).GetComponent<PlayerSkiController>();
				if ((Object)(object)component != (Object)null && component.TryLatchOntoTowFromPylon(this))
				{
					return true;
				}
			}
			if ((Object)(object)_uphillTarget == (Object)null)
			{
				((Character)user).Message((MessageType)2, "Summit station! Place another Rope Tow higher uphill (up to 85m) to extend.", 0, (Sprite)null, false);
			}
			else
			{
				((Character)user).Message((MessageType)2, "Equip Ullr's Skis or Moder's Snowboard first to ride the Runic Tow!", 0, (Sprite)null, false);
			}
			return false;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}
	}
	public static class SlalomRaceTracker
	{
		private static bool _raceActive;

		private static float _raceStartTime;

		private static float _peakSpeedMps;

		private static readonly HashSet<int> _clearedGateIds = new HashSet<int>();

		private static readonly Dictionary<int, float> _gateCooldowns = new Dictionary<int, float>();

		public static bool IsRaceActive => _raceActive;

		public static float CurrentElapsed
		{
			get
			{
				if (!_raceActive)
				{
					return 0f;
				}
				return Time.time - _raceStartTime;
			}
		}

		public static int CheckpointsCleared => _clearedGateIds.Count;

		public static float PeakSpeedKmh => _peakSpeedMps * 3.6f;

		public static void UpdateForLocalRider(Player player, Vector3 velocity, string gearDisplayName)
		{
			//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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			float magnitude = ((Vector3)(ref velocity)).magnitude;
			if (_raceActive && magnitude > _peakSpeedMps)
			{
				_peakSpeedMps = magnitude;
			}
			Vector3 val = ((Component)player).transform.position + Vector3.up * 0.9f;
			float time = Time.time;
			for (int i = 0; i < SlalomGate.ActiveGates.Count; i++)
			{
				SlalomGate slalomGate = SlalomGate.ActiveGates[i];
				if ((Object)(object)slalomGate == (Object)null)
				{
					continue;
				}
				int instanceID = ((Object)slalomGate).GetInstanceID();
				if (!_gateCooldowns.TryGetValue(instanceID, out var value) || !(time < value))
				{
					Vector3 val2 = ((Component)slalomGate).transform.InverseTransformPoint(val);
					if (Mathf.Abs(val2.x) <= 2.25f && val2.y >= -0.8f && val2.y <= 3.9f && Mathf.Abs(val2.z) <= 1.25f)
					{
						_gateCooldowns[instanceID] = time + 2f;
						OnPassGate(player, slalomGate, instanceID, magnitude, gearDisplayName);
					}
				}
			}
		}

		public static void CancelRace()
		{
			_raceActive = false;
			_clearedGateIds.Clear();
		}

		private static void OnPassGate(Player player, SlalomGate gate, int gateId, float speedMps, string gearName)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			PlayGateChime(((Component)gate).transform.position, (gate.Mode == SlalomGateMode.Finish) ? 1.32f : 1.08f);
			switch (gate.Mode)
			{
			case SlalomGateMode.Start:
				_raceActive = true;
				_raceStartTime = Time.time;
				_peakSpeedMps = speedMps;
				_clearedGateIds.Clear();
				((Character)player).Message((MessageType)2, "SLALOM RACE STARTED! Shred through the gates!", 0, (Sprite)null, false);
				break;
			case SlalomGateMode.Checkpoint:
				if (!_raceActive)
				{
					((Character)player).Message((MessageType)1, $"Slalom Gate! ({speedMps * 3.6f:0} km/h)", 0, (Sprite)null, false);
				}
				else if (_clearedGateIds.Add(gateId))
				{
					float num3 = Time.time - _raceStartTime;
					((Character)player).Message((MessageType)1, $"Gate {_clearedGateIds.Count} — {num3:0.00}s ({speedMps * 3.6f:0} km/h)", 0, (Sprite)null, false);
				}
				break;
			case SlalomGateMode.Finish:
				if (_raceActive)
				{
					float num = Mathf.Max(0.05f, Time.time - _raceStartTime);
					int count = _clearedGateIds.Count;
					float num2 = Mathf.Max(_peakSpeedMps, speedMps) * 3.6f;
					_raceActive = false;
					_clearedGateIds.Clear();
					((Character)player).Message((MessageType)2, $"FINISH! {num:0.00}s ({count} gates | Peak {num2:0} km/h)", 0, (Sprite)null, false);
					if (ZRoutedRpc.instance != null)
					{
						ZRoutedRpc.instance.InvokeRoutedRPC(0L, "Ullr_RaceBroadcast", new object[5]
						{
							player.GetPlayerName(),
							gearName,
							num,
							count,
							num2
						});
					}
				}
				break;
			}
		}

		private static void PlayGateChime(Vector3 pos, float pitch)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (!ProceduralAssets.IsHeadless && !((Object)(object)ProceduralAssets.FrostChimeClip == (Object)null))
			{
				AudioSource.PlayClipAtPoint(ProceduralAssets.FrostChimeClip, pos, 0.85f);
			}
		}
	}
}
namespace UllrSkiAndSnowboard.Physics
{
	public enum RideGearType
	{
		None,
		Skis,
		Snowboard
	}
	[Flags]
	public enum RideSyncFlags
	{
		None = 0,
		Airborne = 1,
		Tucking = 2,
		Braking = 4,
		Grabbing = 8,
		WipedOut = 0x10,
		Poling = 0x20,
		OnRopeTow = 0x40
	}
	public class PlayerSkiController : MonoBehaviour
	{
		public const string SkisPrefabName = "UllrSkis";

		public const string SnowboardPrefabName = "ModerSnowboard";

		private static readonly int ZdoRideMode = StringExtensionMethods.GetStableHashCode("ullr_mode");

		private static readonly int ZdoLean = StringExtensionMethods.GetStableHashCode("ullr_lean");

		private static readonly int ZdoSpin = StringExtensionMethods.GetStableHashCode("ullr_spin");

		private static readonly int ZdoFlags = StringExtensionMethods.GetStableHashCode("ullr_flags");

		private static readonly int ZdoSpeed = StringExtensionMethods.GetStableHashCode("ullr_speed");

		private static readonly int AnimForwardSpeed = ZSyncAnimation.GetHash("forward_speed");

		private static readonly int AnimSidewaySpeed = ZSyncAnimation.GetHash("sideway_speed");

		private static readonly int AnimTurnSpeed = ZSyncAnimation.GetHash("turn_speed");

		private static readonly int AnimOnGround = ZSyncAnimation.GetHash("onGround");

		private static readonly int AnimInWater = ZSyncAnimation.GetHash("inWater");

		private static readonly int AnimEncumbered = ZSyncAnimation.GetHash("encumbered");

		private static readonly int AnimFalling = ZSyncAnimation.GetHash("falling");

		private Player _player;

		private ZNetView _nview;

		private RideGearType _equippedGear;

		private bool _ridingActive;

		private float _headingYaw;

		private Vector3 _smoothedNormal = Vector3.up;

		private Vector3 _prevPlanarVel;

		private float _leanAngle;

		private float _trickSpinYaw;

		private float _accumulatedSpin;

		private float _airTime;

		private bool _wasAirborne;

		private float _hopCharge;

		private bool _chargingHop;

		private float _poleCooldown;

		private float _poleAnimTimer;

		private float _wipeoutTimer;

		private float _rampBoostCooldown;

		private float _autoEngageTimer;

		private float _nonSnowGraceTimer;

		private bool _peakMarkedThisSession;

		private RunicRopeTow _activeTowStart;

		private float _towProgress;

		private float _towDetachCooldown;

		private float _zdoSyncTimer;

		private GUIStyle _hudBoxStyle;

		private GUIStyle _hudTitleStyle;

		private GUIStyle _hudSubStyle;

		public RideGearType EquippedGear => _equippedGear;

		public RideGearType SyncedRideMode { get; private set; }

		public float SyncedLeanAngle { get; private set; }

		public float SyncedSpinYaw { get; private set; }

		public RideSyncFlags SyncedFlags { get; private set; }

		public float SyncedSpeed { get; private set; }

		public float HopChargeRatio => Mathf.Clamp01(_hopCharge / 0.45f);

		public float CurrentAirSpinDegrees => Mathf.Abs(_accumulatedSpin);

		public bool IsOwnerActiveRider
		{
			get
			{
				if (_ridingActive && _equippedGear != RideGearType.None)
				{
					return IsOwner();
				}
				return false;
			}
		}

		private void Awake()
		{
			_player = ((Component)this).GetComponent<Player>();
			_nview = ((Component)this).GetComponent<ZNetView>();
		}

		private bool IsOwner()
		{
			if ((Object)(object)_nview != (Object)null && _nview.IsValid())
			{
				return _nview.IsOwner();
			}
			return false;
		}

		private void Update()
		{
			if (!((Object)(object)_player == (Object)null) && !((Object)(object)_nview == (Object)null) && _nview.IsValid())
			{
				if (IsOwner() && (Object)(object)_player == (Object)(object)Player.m_localPlayer)
				{
					UpdateLocalOwnerInput(Time.deltaTime);
					SyncOwnerToZdo(Time.deltaTime, force: false);
				}
				else
				{
					ReadRemoteFromZdo(Time.deltaTime);
				}
			}
		}

		private void UpdateLocalOwnerInput(float dt)
		{
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			RideGearType equippedGear = _equippedGear;
			_equippedGear = DetectEquippedGearFromPlayer();
			if (_equippedGear != equippedGear)
			{
				if (_equippedGear == RideGearType.None)
				{
					SetRidingActive(active: false, silent: true);
				}
				else
				{
					OnGearNewlyEquipped(_equippedGear);
				}
			}
			if (_towDetachCooldown > 0f)
			{
				_towDetachCooldown -= dt;
			}
			if (_poleCooldown > 0f)
			{
				_poleCooldown -= dt;
			}
			if (_poleAnimTimer > 0f)
			{
				_poleAnimTimer -= dt;
			}
			if (_rampBoostCooldown > 0f)
			{
				_rampBoostCooldown -= dt;
			}
			if (_equippedGear == RideGearType.None)
			{
				return;
			}
			if (((Character)_player).IsDead() || ((Character)_player).IsSwimming() || ((Character)_player).InPlaceMode() || ((Character)_player).IsAttached() || ((Character)_player).IsTeleporting())
			{
				if (_ridingActive)
				{
					SetRidingActive(active: false, silent: true);
				}
				return;
			}
			bool flag = ((Character)_player).TakeInput();
			if (flag && (ZInput.GetButtonDown("Ullr_ToggleRide") || Input.GetKeyDown(UllrPlugin.ToggleRideKey.Value)))
			{
				string reason;
				if (_ridingActive)
				{
					SetRidingActive(active: false, silent: false);
				}
				else if (CanStartRidingHere(out reason))
				{
					SetRidingActive(active: true, silent: false);
				}
				else
				{
					((Character)_player).Message((MessageType)2, reason, 0, (Sprite)null, false);
				}
			}
			if (!_ridingActive && UllrPlugin.AutoEngageOnSlope.Value && IsOnSnowOrRamp(out var slopeDeg) && slopeDeg >= 8.5f && ((Character)_player).IsRunning())
			{
				_autoEngageTimer += dt;
				if (_autoEngageTimer >= 0.25f)
				{
					_autoEngageTimer = 0f;
					SetRidingActive(active: true, silent: false);
				}
			}
			else
			{
				_autoEngageTimer = 0f;
			}
			if (!_ridingActive)
			{
				return;
			}
			if ((Object)(object)_activeTowStart == (Object)null && _towDetachCooldown <= 0f && flag && ZInput.GetButtonDown("Use") && RunicRopeTow.TryFindNearestTowSpan(((Component)_player).transform.position, 3.2f, out var startPylon, out var tAlongSpan, out var _))
			{
				_activeTowStart = startPylon;
				_towProgress = tAlongSpan;
				((Character)_player).Message((MessageType)2, "Latched onto Ullr's Runic Tow! ([Space] to hop off)", 0, (Sprite)null, false);
			}
			if (_wipeoutTimer <= 0f && flag)
			{
				if ((Object)(object)_activeTowStart != (Object)null)
				{
					if (ZInput.GetButtonDown("Jump") || ZInput.GetButtonDown("JoyJump"))
					{
						DetachFromTow(jumpPop: true);
					}
				}
				else
				{
					bool flag2 = ZInput.GetButton("Jump") || ZInput.GetButton("JoyJump");
					if (flag2 && IsGroundedForSki())
					{
						_chargingHop = true;
						_hopCharge = Mathf.Min(0.45f, _hopCharge + dt);
					}
					else if (_chargingHop && !flag2)
					{
						_chargingHop = false;
						if (IsGroundedForSki())
						{
							PerformBunnyHop();
						}
						_hopCharge = 0f;
					}
				}
			}
			else
			{
				_chargingHop = false;
				_hopCharge = 0f;
			}
			string gearDisplayName = ((_equippedGear == RideGearType.Snowboard) ? "Moder's Snowboard" : "Ullr's Skis");
			SlalomRaceTracker.UpdateForLocalRider(_player, ((Object)(object)((Character)_player).m_body != (Object)null) ? ((Character)_player).m_body.linearVelocity : Vector3.zero, gearDisplayName);
		}

		public bool TryLatchOntoTowFromPylon(RunicRopeTow pylon)
		{
			if ((Object)(object)pylon == (Object)null || (Object)(object)pylon.UphillTarget == (Object)null)
			{
				return false;
			}
			if (_equippedGear == RideGearType.None)
			{
				return false;
			}
			if (!_ridingActive)
			{
				SetRidingActive(active: true, silent: true);
			}
			_activeTowStart = pylon;
			_towProgress = 0.02f;
			_wipeoutTimer = 0f;
			((Character)_player).Message((MessageType)2, "Riding Ullr's Runic Tow uphill! ([Space] to hop off)", 0, (Sprite)null, false);
			return true;
		}

		private void DetachFromTow(bool jumpPop)
		{
			//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_003b: 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)
			_activeTowStart = null;
			_towDetachCooldown = 0.8f;
			if (jumpPop && (Object)(object)((Character)_player).m_body != (Object)null)
			{
				Vector3 linearVelocity = ((Character)_player).m_body.linearVelocity;
				linearVelocity.y = Mathf.Max(linearVelocity.y, 4.8f);
				((Character)_player).m_body.linearVelocity = linearVelocity;
				PlayClip(ProceduralAssets.JumpPopClip, 0.7f, 1.05f);
			}
		}

		public void SetRidingActive(bool active, bool silent)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_0139: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if (_ridingActive == active)
			{
				return;
			}
			_ridingActive = active;
			_chargingHop = false;
			_hopCharge = 0f;
			_trickSpinYaw = 0f;
			_accumulatedSpin = 0f;
			_wipeoutTimer = 0f;
			_activeTowStart = null;
			Vector3 val;
			if (active)
			{
				if ((Object)(object)((Character)_player).m_body != (Object)null)
				{
					Vector3 linearVelocity = ((Character)_player).m_body.linearVelocity;
					if (((Vector3)(ref linearVelocity)).sqrMagnitude > 2.2f)
					{
						val = Vector3.ProjectOnPlane(((Character)_player).m_body.linearVelocity, Vector3.up);
						goto IL_00b4;
					}
				}
				val = Vector3.ProjectOnPlane(((Character)_player).GetLookDir(), Vector3.up);
				goto IL_00b4;
			}
			SyncedRideMode = RideGearType.None;
			SyncedLeanAngle = 0f;
			SyncedSpinYaw = 0f;
			SyncedFlags = RideSyncFlags.None;
			if (!silent)
			{
				((Character)_player).Message((MessageType)1, "Skis unclipped — walking mode", 0, (Sprite)null, false);
			}
			goto IL_01c3;
			IL_01c3:
			SyncOwnerToZdo(0f, force: true);
			return;
			IL_00b4:
			Vector3 val2 = val;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = ((Component)_player).transform.forward;
			}
			Quaternion val3 = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up);
			_headingYaw = ((Quaternion)(ref val3)).eulerAngles.y;
			_smoothedNormal = Vector3.up;
			_nonSnowGraceTimer = 2.5f;
			_prevPlanarVel = (((Object)(object)((Character)_player).m_body != (Object)null) ? Vector3.ProjectOnPlane(((Character)_player).m_body.linearVelocity, Vector3.up) : Vector3.zero);
			if (!silent)
			{
				string text = ((_equippedGear == RideGearType.Snowboard) ? "Clicked into Moder's Drakkar Snowboard!" : "Clicked into Ullr's Frost-Rune Skis!");
				((Character)_player).Message((MessageType)2, text, 0, (Sprite)null, false);
				PlayClip(ProceduralAssets.FrostChimeClip, 0.65f, 1.15f);
			}
			goto IL_01c3;
		}

		public void FixedUpdateRidePhysics(float dt)
		{
			//IL_0046: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing referen