Decompiled source of Glider v0.1.26

plugins/Glider.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Angell.KiteGlider
{
	[BepInPlugin("angell.kiteglider", "Glider", "0.1.26")]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		private static class DbAwake
		{
			private static void Postfix(ObjectDB __instance)
			{
				Register(__instance);
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		private static class DbCopy
		{
			private static void Postfix(ObjectDB __instance)
			{
				Register(__instance);
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class SceneAwake
		{
			private static void Postfix(ZNetScene __instance)
			{
				if (Object.op_Implicit((Object)(object)ObjectDB.instance))
				{
					Register(ObjectDB.instance);
				}
				RegisterNetwork(__instance);
			}
		}

		[HarmonyPatch(typeof(Player), "SetControls")]
		private static class Controls
		{
			private static void Prefix(Player __instance, Vector3 movedir, ref bool jump, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool crouch, ref bool dodge)
			{
				//IL_0024: 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)
				if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
				{
					return;
				}
				Flight flight = Get(__instance);
				movedir.y = (crouch ? 1 : 0);
				flight.Input = movedir;
				if (jump && !((Character)__instance).IsOnGround())
				{
					if (flight.Active)
					{
						flight.Stop();
						jump = false;
					}
					else if (Allowed(__instance) && HasKite(__instance) && ((Character)__instance).HaveStamina(0.1f) && !((Character)__instance).InAttack())
					{
						flight.Begin();
						jump = false;
					}
				}
				if (flight.Active)
				{
					attack = (attackHold = (secondaryAttack = (secondaryAttackHold = (block = (blockHold = (crouch = (dodge = false)))))));
				}
			}
		}

		[HarmonyPatch(typeof(Character), "UpdateWalking")]
		private static class Walking
		{
			private static bool Prefix(Character __instance, float dt)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (!Object.op_Implicit((Object)(object)val) || (Object)(object)val != (Object)(object)Player.m_localPlayer)
				{
					return true;
				}
				if (!Flights.TryGetValue(val, out var value) || !value.Active)
				{
					return true;
				}
				return !value.Tick(dt);
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateStats", new Type[] { typeof(float) })]
		private static class Stats
		{
			private static void Prefix(Player __instance, float dt)
			{
				if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && Allowed(__instance) && !((Character)__instance).IsOnGround() && HasKite(__instance))
				{
					Regen.SetValue(__instance, Mathf.Max((float)Regen.GetValue(__instance), dt + 0.1f));
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Update")]
		private static class PlayerUpdate
		{
			private static void Postfix(Player __instance)
			{
				Get(__instance);
			}
		}

		[HarmonyPatch(typeof(Fireplace), "Awake")]
		private static class FireAwake
		{
			private static void Postfix(Fireplace __instance)
			{
				if (!Fires.Contains(__instance))
				{
					Fires.Add(__instance);
				}
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__38_0;

			public static Predicate<Recipe> <>9__43_0;

			internal void <Awake>b__38_0(ConsoleEventArgs args)
			{
				Player localPlayer = Player.m_localPlayer;
				if (!Object.op_Implicit((Object)(object)localPlayer) || !Object.op_Implicit((Object)(object)Item))
				{
					args.Context.AddString("Enter a world first.");
				}
				else
				{
					args.Context.AddString(((Humanoid)localPlayer).GetInventory().AddItem(Item, 1) ? "Glider added. Equip it in the utility slot, then jump again in midair to glide." : "No room in inventory.");
				}
			}

			internal bool <Register>b__43_0(Recipe r)
			{
				if (Object.op_Implicit((Object)(object)r))
				{
					return ((Object)r).name == "Recipe_Angell_WoodKite";
				}
				return false;
			}
		}

		public const string Guid = "angell.kiteglider";

		public const string PrefabName = "Angell_WoodKite";

		internal static Plugin Instance;

		internal static ConfigEntry<float> Drain;

		internal static ConfigEntry<float> Cruise;

		internal static ConfigEntry<float> MaxSpeed;

		internal static ConfigEntry<float> Descent;

		internal static ConfigEntry<float> ForwardSink;

		internal static ConfigEntry<float> ThermalHeight;

		internal static ConfigEntry<float> ThermalRadius;

		internal static ConfigEntry<float> Recovery;

		internal static ConfigEntry<float> ThermalLift;

		internal static ConfigEntry<float> Acceleration;

		internal static ConfigEntry<float> Braking;

		internal static ConfigEntry<float> BrakeSpeed;

		internal static ConfigEntry<float> CanopyScale;

		internal static ConfigEntry<bool> Thermals;

		internal static ConfigEntry<bool> Pose;

		internal static ConfigEntry<bool> Trails;

		internal static ConfigEntry<bool> LevelShield;

		internal static ConfigEntry<bool> FlightReadout;

		internal static ConfigEntry<bool> RaisedArms;

		internal static ConfigEntry<Vector3> VisualOffset;

		internal static ConfigEntry<Vector3> VisualRotation;

		internal static ConfigEntry<Vector3> VisualScale;

		internal static ConfigEntry<Vector3> GripOffset;

		internal static ConfigEntry<Vector3> CanopyOffset;

		internal static readonly Dictionary<Player, Flight> Flights = new Dictionary<Player, Flight>();

		internal static readonly List<Fireplace> Fires = new List<Fireplace>();

		internal static GameObject Item;

		internal static GameObject Root;

		internal static Material WindMaterial;

		private Harmony harmony;

		private static readonly FieldInfo Utility = AccessTools.Field(typeof(Humanoid), "m_utilityItem");

		private static readonly FieldInfo Altitude = AccessTools.Field(typeof(Character), "m_maxAirAltitude");

		internal static readonly FieldInfo Regen = AccessTools.Field(typeof(Player), "m_staminaRegenTimer");

		private static readonly FieldInfo Named = AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs");

		private static readonly MethodInfo Registers = AccessTools.Method(typeof(ObjectDB), "UpdateRegisters", (Type[])null, (Type[])null);

		private void Awake()
		{
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Expected O, but got Unknown
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Expected O, but got Unknown
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Expected O, but got Unknown
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f7: Expected O, but got Unknown
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Drain = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "StaminaPerSecond", 4f, "Stamina used per second while gliding.");
			Cruise = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "CruiseSpeed", 8f, "Coasting target speed in metres per second.");
			MaxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "MaximumSpeed", 16f, "Maximum controlled horizontal glide speed.");
			Acceleration = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "ForwardAcceleration", 10f, "Horizontal acceleration while holding forward, metres per second squared.");
			Braking = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "BrakingDeceleration", 16f, "Horizontal deceleration while holding backward.");
			BrakeSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "BrakingSpeed", 1.5f, "Low forward speed while braking; never reverses flight.");
			FlightReadout = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "ShowFlightReadout", true, "Show current W/S flight mode and measured horizontal speed while gliding.");
			Descent = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "DescentSpeed", 0.4f, "Normal downward glide target speed. Lower values extend glide distance.");
			ForwardSink = ((BaseUnityPlugin)this).Config.Bind<float>("Flight", "ForwardExtraDescent", 0.15f, "Extra downward speed when holding forward. Keep small for long-distance gliding.");
			ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("Internal", "TuningRevision", 0, "Tracks one-time default tuning migrations.");
			if (val.Value < 1)
			{
				if (Mathf.Abs(Descent.Value - 2.5f) < 0.001f)
				{
					Descent.Value = 0.6f;
				}
				val.Value = 1;
				((BaseUnityPlugin)this).Config.Save();
			}
			Thermals = ((BaseUnityPlugin)this).Config.Bind<bool>("Thermals", "Enabled", true, "Active campfires, hearths and bonfires provide thermals.");
			ThermalHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Thermals", "Height", 24f, "Thermal height above each fire, blocked by roofs.");
			ThermalRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Thermals", "Radius", 5f, "Radius of the lift column.");
			ThermalLift = ((BaseUnityPlugin)this).Config.Bind<float>("Thermals", "LiftSpeed", 6f, "Upward target speed while inside an active fire column.");
			LevelShield = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "AutoLevelShield", true, "Level the main shield mesh horizontally, correcting nested prefab tilt.");
			Recovery = ((BaseUnityPlugin)this).Config.Bind<float>("Thermals", "NetStaminaRecoveryPerSecond", 6f, "Net recovery inside a thermal after glide drain.");
			CanopyOffset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Windweaver", "Offset", new Vector3(0f, 2.55f, 0.1f), "New canopy position relative to player. Grip targets follow its handles.");
			CanopyScale = ((BaseUnityPlugin)this).Config.Bind<float>("Windweaver", "Scale", 1f, "Uniform scale of the embedded Windweaver model, including hand targets.");
			RaisedArms = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "RaisedArms", true, "Experimental procedural raised-arm pose during gliding. Overrides the headbang option without freezing the animator.");
			GripOffset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Visuals", "GripOffset", new Vector3(0.22f, -0.2f, 0f), "Hand targets relative to shield center: X is half the grip spacing, Y/Z adjust height and forward offset.");
			Pose = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "ExperimentalHeadbangPose", false, "Experimental existing emote trigger; disable if it interferes with flight. Not a frozen pose.");
			Trails = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "WindTrails", true, "Show left and right shield trails.");
			VisualOffset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Visuals", "ShieldOffset", new Vector3(0f, 2.15f, 0.1f), "Position relative to the player; tune in game.");
			VisualRotation = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Visuals", "ShieldRotation", new Vector3(180f, 0f, 0f), "Shield visual rotation in degrees; tune in game.");
			Vector3 val2;
			if (val.Value < 2)
			{
				val2 = VisualRotation.Value - new Vector3(90f, 0f, 0f);
				if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
				{
					VisualRotation.Value = Vector3.zero;
				}
				val.Value = 2;
				((BaseUnityPlugin)this).Config.Save();
			}
			if (val.Value < 3)
			{
				if (Mathf.Abs(Descent.Value - 0.6f) < 0.001f)
				{
					Descent.Value = 0.4f;
				}
				if (Mathf.Abs(ForwardSink.Value - 0.25f) < 0.001f)
				{
					ForwardSink.Value = 0.15f;
				}
				if (Mathf.Abs(ThermalHeight.Value - 18f) < 0.001f)
				{
					ThermalHeight.Value = 24f;
				}
				if (Mathf.Abs(ThermalRadius.Value - 3.5f) < 0.001f)
				{
					ThermalRadius.Value = 5f;
				}
				val2 = VisualRotation.Value;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
				{
					VisualRotation.Value = new Vector3(180f, 0f, 0f);
				}
				val.Value = 3;
				((BaseUnityPlugin)this).Config.Save();
			}
			VisualScale = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Visuals", "ShieldScale", new Vector3(1.6f, 1.6f, 1.6f), "Scale of the shield visual.");
			LaunchPad.Bind(((BaseUnityPlugin)this).Config);
			Root = new GameObject("KiteGlider_Prefabs");
			Root.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)Root);
			Shader val3 = Shader.Find("Sprites/Default") ?? Shader.Find("Particles/Standard Unlit");
			if (Object.op_Implicit((Object)(object)val3))
			{
				WindMaterial = new Material(val3);
			}
			harmony = new Harmony("angell.kiteglider");
			harmony.PatchAll();
			object obj = <>c.<>9__38_0;
			if (obj == null)
			{
				ConsoleEvent val4 = delegate(ConsoleEventArgs args)
				{
					Player localPlayer = Player.m_localPlayer;
					if (!Object.op_Implicit((Object)(object)localPlayer) || !Object.op_Implicit((Object)(object)Item))
					{
						args.Context.AddString("Enter a world first.");
					}
					else
					{
						args.Context.AddString(((Humanoid)localPlayer).GetInventory().AddItem(Item, 1) ? "Glider added. Equip it in the utility slot, then jump again in midair to glide." : "No room in inventory.");
					}
				};
				<>c.<>9__38_0 = val4;
				obj = (object)val4;
			}
			new ConsoleCommand("kite", "Add a wooden glider for testing (devcommands required).", (ConsoleEvent)obj, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Glider 0.1.26 loaded. Flight prototype; in-game validation required.");
		}

		internal static void LogPose(string message)
		{
			if (Object.op_Implicit((Object)(object)Instance))
			{
				((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
			}
		}

		internal static Flight Get(Player p)
		{
			if (!Flights.TryGetValue(p, out var value))
			{
				value = ((Component)p).gameObject.AddComponent<Flight>();
				value.Player = p;
				Flights[p] = value;
			}
			return value;
		}

		internal static bool HasKite(Player p)
		{
			if (!Object.op_Implicit((Object)(object)p))
			{
				return false;
			}
			object? value = Utility.GetValue(p);
			ItemData val = (ItemData)((value is ItemData) ? value : null);
			if (val != null && Object.op_Implicit((Object)(object)val.m_dropPrefab) && ((Object)val.m_dropPrefab).name == "Angell_WoodKite")
			{
				return ((Humanoid)p).GetInventory().GetAllItems().Contains(val);
			}
			return false;
		}

		internal static bool Allowed(Player p)
		{
			if (Object.op_Implicit((Object)(object)p) && !((Character)p).IsDead() && !((Character)p).IsTeleporting() && !((Character)p).InCutscene() && !((Character)p).IsAttached() && !((Character)p).IsSwimming() && !((Character)p).InWater() && !((Character)p).IsDebugFlying() && !((Character)p).InDodge())
			{
				return !((Character)p).IsStaggering();
			}
			return false;
		}

		internal static void Register(ObjectDB db)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Expected O, but got Unknown
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Expected O, but got Unknown
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Expected O, but got Unknown
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Expected O, but got Unknown
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Expected O, but got Unknown
			GameObject itemPrefab = db.GetItemPrefab("ShieldWood");
			if (!Object.op_Implicit((Object)(object)itemPrefab))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)Item))
			{
				Item = Object.Instantiate<GameObject>(itemPrefab, Root.transform);
				((Object)Item).name = "Angell_WoodKite";
				ItemDrop component = Item.GetComponent<ItemDrop>();
				component.m_itemData = component.m_itemData.Clone();
				component.m_itemData.m_shared = (SharedData)typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(component.m_itemData.m_shared, null);
				SharedData shared = component.m_itemData.m_shared;
				shared.m_name = "Glider";
				shared.m_description = "A wood-and-canvas glider carried by the wind. Equip in the utility slot and press jump while airborne to glide. Jump again to close. Gliding consumes stamina; rising air above fires restores stamina and lifts you.";
				shared.m_itemType = (ItemType)18;
				shared.m_weight = 3f;
				shared.m_maxStackSize = 1;
				shared.m_maxQuality = 1;
				shared.m_useDurability = false;
				shared.m_movementModifier = 0f;
				shared.m_equipStatusEffect = null;
				shared.m_icons = (Sprite[])(object)new Sprite[1] { WindweaverModel.GetIcon() };
				WindweaverModel.ReplaceDroppedVisual(Item);
				component.m_itemData.m_dropPrefab = Item;
				Item.SetActive(true);
			}
			if (!db.m_items.Contains(Item))
			{
				db.m_items.Add(Item);
				Registers.Invoke(db, null);
			}
			if (!db.m_recipes.Exists((Recipe r) => Object.op_Implicit((Object)(object)r) && ((Object)r).name == "Recipe_Angell_WoodKite"))
			{
				GameObject itemPrefab2 = db.GetItemPrefab("LeatherScraps");
				GameObject itemPrefab3 = db.GetItemPrefab("Wood");
				GameObject itemPrefab4 = db.GetItemPrefab("Feathers");
				GameObject itemPrefab5 = db.GetItemPrefab("DeerHide");
				GameObject itemPrefab6 = db.GetItemPrefab("SurtlingCore");
				CraftingStation val = null;
				if (Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					GameObject prefab = ZNetScene.instance.GetPrefab("piece_workbench");
					if (Object.op_Implicit((Object)(object)prefab))
					{
						val = prefab.GetComponent<CraftingStation>();
					}
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					foreach (Recipe recipe in db.m_recipes)
					{
						if (Object.op_Implicit((Object)(object)recipe) && Object.op_Implicit((Object)(object)recipe.m_craftingStation) && ((Object)recipe.m_craftingStation).name.StartsWith("piece_workbench", StringComparison.Ordinal))
						{
							val = recipe.m_craftingStation;
							break;
						}
					}
				}
				if (Object.op_Implicit((Object)(object)itemPrefab2) && Object.op_Implicit((Object)(object)itemPrefab3) && Object.op_Implicit((Object)(object)itemPrefab4) && Object.op_Implicit((Object)(object)itemPrefab5) && Object.op_Implicit((Object)(object)itemPrefab6) && Object.op_Implicit((Object)(object)val))
				{
					Recipe val2 = ScriptableObject.CreateInstance<Recipe>();
					((Object)val2).name = "Recipe_Angell_WoodKite";
					val2.m_item = Item.GetComponent<ItemDrop>();
					val2.m_amount = 1;
					val2.m_enabled = true;
					val2.m_craftingStation = val;
					val2.m_minStationLevel = 3;
					val2.m_resources = (Requirement[])(object)new Requirement[5]
					{
						new Requirement
						{
							m_resItem = itemPrefab3.GetComponent<ItemDrop>(),
							m_amount = 20
						},
						new Requirement
						{
							m_resItem = itemPrefab4.GetComponent<ItemDrop>(),
							m_amount = 10
						},
						new Requirement
						{
							m_resItem = itemPrefab5.GetComponent<ItemDrop>(),
							m_amount = 6
						},
						new Requirement
						{
							m_resItem = itemPrefab2.GetComponent<ItemDrop>(),
							m_amount = 8
						},
						new Requirement
						{
							m_resItem = itemPrefab6.GetComponent<ItemDrop>(),
							m_amount = 2
						}
					};
					db.m_recipes.Add(val2);
				}
			}
			RegisterNetwork(ZNetScene.instance);
			WindborneWard.Register(db);
			LaunchPad.Register(db, ZNetScene.instance);
		}

		internal static void RegisterNetwork(ZNetScene scene)
		{
			if (Object.op_Implicit((Object)(object)scene) && Object.op_Implicit((Object)(object)Item))
			{
				Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)Named.GetValue(scene);
				int stableHashCode = StringExtensionMethods.GetStableHashCode("Angell_WoodKite");
				if (!dictionary.ContainsKey(stableHashCode))
				{
					dictionary.Add(stableHashCode, Item);
				}
				if (!scene.m_prefabs.Contains(Item))
				{
					scene.m_prefabs.Add(Item);
				}
			}
		}

		internal static void SafeGlideAltitude(Player p)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (((Character)p).GetVelocity().y >= -5f)
			{
				Altitude.SetValue(p, ((Component)p).transform.position.y);
			}
		}

		private void OnDestroy()
		{
			foreach (Flight item in new List<Flight>(Flights.Values))
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					Object.Destroy((Object)(object)item);
				}
			}
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			LaunchPad.Release();
			WindweaverModel.Release();
			if (Object.op_Implicit((Object)(object)Root))
			{
				Object.Destroy((Object)(object)Root);
			}
			if (Object.op_Implicit((Object)(object)WindMaterial))
			{
				Object.Destroy((Object)(object)WindMaterial);
			}
			Instance = null;
		}
	}
	[DefaultExecutionOrder(10000)]
	public sealed class Flight : MonoBehaviour
	{
		private sealed class Arm
		{
			internal Transform Upper;

			internal Transform Lower;

			internal Transform Hand;

			internal Quaternion UpperRest;

			internal Quaternion LowerRest;

			internal bool Applied;

			internal void Restore()
			{
				//IL_001d: 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)
				if (Applied)
				{
					if (Object.op_Implicit((Object)(object)Upper))
					{
						Upper.localRotation = UpperRest;
					}
					if (Object.op_Implicit((Object)(object)Lower))
					{
						Lower.localRotation = LowerRest;
					}
					Applied = false;
				}
			}

			internal void Aim(Vector3 target, Vector3 pole)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: 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_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0124: 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_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_0170: Unknown result type (might be due to invalid IL or missing references)
				//IL_0171: Unknown result type (might be due to invalid IL or missing references)
				//IL_0175: Unknown result type (might be due to invalid IL or missing references)
				//IL_017a: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0183: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: 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_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_0194: Unknown result type (might be due to invalid IL or missing references)
				//IL_0199: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_0207: Unknown result type (might be due to invalid IL or missing references)
				//IL_020c: 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_021c: 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_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_016e: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)Upper) || !Object.op_Implicit((Object)(object)Lower) || !Object.op_Implicit((Object)(object)Hand))
				{
					return;
				}
				UpperRest = Upper.localRotation;
				LowerRest = Lower.localRotation;
				Applied = true;
				Vector3 position = Upper.position;
				float num = Vector3.Distance(position, Lower.position);
				float num2 = Vector3.Distance(Lower.position, Hand.position);
				if (num < 0.01f || num2 < 0.01f)
				{
					return;
				}
				Vector3 val = target - position;
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
				{
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					float num3 = Mathf.Clamp(((Vector3)(ref val)).magnitude, Mathf.Abs(num - num2) + 0.001f, (num + num2) * 0.995f);
					float num4 = (num * num - num2 * num2 + num3 * num3) / (2f * num3);
					float num5 = Mathf.Sqrt(Mathf.Max(0f, num * num - num4 * num4));
					Vector3 val2 = Vector3.ProjectOnPlane(pole, normalized);
					Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
					if (((Vector3)(ref normalized2)).sqrMagnitude < 0.01f)
					{
						val2 = Vector3.Cross(normalized, Vector3.forward);
						normalized2 = ((Vector3)(ref val2)).normalized;
					}
					if (((Vector3)(ref normalized2)).sqrMagnitude < 0.01f)
					{
						val2 = Vector3.Cross(normalized, Vector3.right);
						normalized2 = ((Vector3)(ref val2)).normalized;
					}
					Vector3 val3 = position + normalized * num4 + normalized2 * num5;
					Vector3 val4 = position + normalized * num3;
					Upper.rotation = Quaternion.FromToRotation(Lower.position - position, val3 - position) * Upper.rotation;
					Lower.rotation = Quaternion.FromToRotation(Hand.position - Lower.position, val4 - Lower.position) * Lower.rotation;
				}
			}
		}

		internal Player Player;

		internal bool Active;

		internal Vector3 Input;

		internal float NextLaunch;

		internal float LaunchAscentUntil;

		private Vector3 horizontal;

		private GameObject canopy;

		private Transform leftGrip;

		private Transform rightGrip;

		private TrailRenderer left;

		private TrailRenderer right;

		private float nextThermalCheck;

		private bool inThermal;

		private bool startedPose;

		private readonly Dictionary<Fireplace, LineRenderer> currents = new Dictionary<Fireplace, LineRenderer>();

		private const string NetFlag = "angell_kite_active";

		private Arm leftArm;

		private Arm rightArm;

		private bool armSearchDone;

		private GUIStyle flightStyle;

		private ZNetView View => ((Component)this).GetComponent<ZNetView>();

		internal void Begin()
		{
			//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_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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Active = true;
			horizontal = ((Character)Player).GetVelocity();
			horizontal.y = 0f;
			if (((Vector3)(ref horizontal)).sqrMagnitude < 1f)
			{
				Vector3 val = Vector3.ProjectOnPlane(((Character)Player).GetLookDir(), Vector3.up);
				horizontal = ((Vector3)(ref val)).normalized;
			}
			ZNetView view = View;
			if (Object.op_Implicit((Object)(object)view) && view.IsValid())
			{
				view.GetZDO().Set("angell_kite_active", true);
			}
			if (Plugin.Pose.Value && !Plugin.RaisedArms.Value)
			{
				((Character)Player).GetZAnim().SetTrigger("emote_headbang");
				startedPose = true;
			}
			((Character)Player).Message((MessageType)2, "Gliding — jump to close", 0, (Sprite)null, false);
		}

		internal void Stop()
		{
			if (Active)
			{
				RestoreArms();
				Active = false;
				inThermal = false;
				ZNetView view = View;
				if (Object.op_Implicit((Object)(object)view) && view.IsValid() && view.IsOwner())
				{
					view.GetZDO().Set("angell_kite_active", false);
				}
				if (startedPose && Object.op_Implicit((Object)(object)Player))
				{
					((Character)Player).GetZAnim().SetTrigger("emote_stop");
					startedPose = false;
				}
				ClearVisuals();
			}
		}

		internal bool Tick(float dt)
		{
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: 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_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: 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_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.Allowed(Player) || ((Character)Player).IsOnGround() || !Plugin.HasKite(Player) || !((Character)Player).HaveStamina(0.001f))
			{
				Stop();
				return false;
			}
			if (Time.time >= nextThermalCheck)
			{
				UpdateThermals();
				nextThermalCheck = Time.time + 0.2f;
			}
			float num = Mathf.Clamp(Plugin.Drain.Value, 0.1f, 50f);
			if (inThermal)
			{
				((Character)Player).AddStamina(Mathf.Clamp(Plugin.Recovery.Value, 0f, 50f) * dt);
			}
			else
			{
				((Character)Player).UseStamina(num * dt);
			}
			if (!((Character)Player).HaveStamina(0.001f))
			{
				Stop();
				return false;
			}
			float num2 = Mathf.Clamp(Plugin.MaxSpeed.Value, 2f, 40f);
			float num3 = Mathf.Clamp(Plugin.Cruise.Value, 2f, num2);
			Vector3 val = ((((Vector3)(ref horizontal)).sqrMagnitude > 0.01f) ? ((Vector3)(ref horizontal)).normalized : ((Component)Player).transform.forward);
			Camera mainCamera = Utils.GetMainCamera();
			Vector3 val2 = (Object.op_Implicit((Object)(object)mainCamera) ? ((Component)mainCamera).transform.forward : ((Character)Player).GetLookDir());
			val2.y = 0f;
			((Vector3)(ref val2)).Normalize();
			Vector3 val3 = val2 * Input.z + Vector3.Cross(Vector3.up, val2) * Input.x;
			float num4 = Mathf.Clamp(Input.z, -1f, 1f);
			float num5 = Mathf.Clamp(Plugin.BrakeSpeed.Value, 0.5f, num3);
			float num6 = ((num4 > 0.1f) ? num2 : ((num4 < -0.1f) ? num5 : num3));
			Vector3 val4 = ((num4 < -0.1f) ? val : ((((Vector3)(ref val3)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val3)).normalized : val));
			float num7 = Vector3.Angle(val, val4);
			Vector3 val5 = Vector3.RotateTowards(val, val4, 1.8f * dt, 0f);
			val = ((Vector3)(ref val5)).normalized;
			float num8 = ((num4 < -0.1f) ? Mathf.Clamp(Plugin.Braking.Value, 0.5f, 60f) : ((((Vector3)(ref horizontal)).magnitude > num6) ? 1.25f : ((!(num4 <= 0.1f)) ? Mathf.Clamp(Plugin.Acceleration.Value, 0.5f, 40f) : 3f)));
			float num9 = Mathf.MoveTowards(((Vector3)(ref horizontal)).magnitude, num6, num8 * dt);
			num9 = Mathf.Max(num5, num9 - ((num7 > 45f) ? (0.5f * dt) : 0f));
			horizontal = val * num9;
			float num10 = Mathf.Clamp(Plugin.Descent.Value, 0.1f, 8f);
			float num11 = (inThermal ? Mathf.Clamp(Plugin.ThermalLift.Value, 0.5f, 15f) : (0f - ((num4 > 0.1f) ? (num10 + Mathf.Clamp(Plugin.ForwardSink.Value, 0f, 8f)) : ((num4 < -0.1f) ? Mathf.Lerp(num10, Mathf.Min(num10, 0.35f), Mathf.InverseLerp(num5, num3, num9)) : num10))));
			float y = ((Character)Player).GetVelocity().y;
			if (y <= 0f)
			{
				LaunchAscentUntil = 0f;
			}
			float num12 = ((Time.time < LaunchAscentUntil && y > 0f) ? y : Mathf.MoveTowards(y, num11, (inThermal ? 30f : 18f) * dt));
			((Character)Player).SetVelocity(horizontal + Vector3.up * num12);
			((Component)Player).transform.rotation = Quaternion.RotateTowards(((Component)Player).transform.rotation, Quaternion.LookRotation(val), 160f * dt);
			Plugin.SafeGlideAltitude(Player);
			return true;
		}

		private float ColumnHeight(Fireplace fire)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)fire).transform.position + Vector3.up * 0.8f;
			float num = Mathf.Clamp(Plugin.ThermalHeight.Value, 1f, 60f);
			int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" });
			RaycastHit[] array = Physics.RaycastAll(val, Vector3.up, num, mask, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val2 = array[i];
				if (!((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)fire).transform) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Character>()) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<ItemDrop>()))
				{
					num = Mathf.Min(num, Mathf.Max(0f, ((RaycastHit)(ref val2)).distance - 0.3f));
				}
			}
			return num;
		}

		private bool Eligible(Fireplace fire)
		{
			string name = ((Object)fire).name;
			if (name.StartsWith("fire_pit") || name.StartsWith("hearth") || name.StartsWith("bonfire") || name.StartsWith("piece_hearth") || name.StartsWith("piece_bonfire"))
			{
				return fire.IsBurning();
			}
			return false;
		}

		private void UpdateThermals()
		{
			//IL_005f: 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_0079: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_0129: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: 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_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			bool flag = inThermal;
			inThermal = false;
			HashSet<Fireplace> hashSet = new HashSet<Fireplace>();
			if (Plugin.Thermals.Value)
			{
				for (int num = Plugin.Fires.Count - 1; num >= 0; num--)
				{
					Fireplace val = Plugin.Fires[num];
					if (!Object.op_Implicit((Object)(object)val))
					{
						Plugin.Fires.RemoveAt(num);
					}
					else
					{
						Vector3 val2 = ((Component)val).transform.position - ((Component)Player).transform.position;
						if (!(((Vector3)(ref val2)).sqrMagnitude > 6400f) && Eligible(val))
						{
							float num2 = ColumnHeight(val);
							if (!(num2 < 1f))
							{
								Vector3 val3 = ((Component)val).transform.position + Vector3.up * 0.8f;
								Vector3 val4 = ((Component)Player).transform.position - val3;
								float num3 = Mathf.Clamp(Plugin.ThermalRadius.Value, 0.5f, 12f);
								int num4;
								if (val4.y >= 0f && val4.y <= num2)
								{
									Vector2 val5 = new Vector2(val4.x, val4.z);
									num4 = ((((Vector2)(ref val5)).sqrMagnitude <= num3 * num3) ? 1 : 0);
									if (num4 != 0)
									{
										inThermal = true;
									}
								}
								else
								{
									num4 = 0;
								}
								hashSet.Add(val);
								if (!currents.TryGetValue(val, out var value))
								{
									value = new GameObject("KiteThermal").AddComponent<LineRenderer>();
									((Renderer)value).sharedMaterial = Plugin.WindMaterial;
									value.useWorldSpace = true;
									value.positionCount = 36;
									value.widthMultiplier = 0.07f;
									currents.Add(val, value);
								}
								Color val6 = ((num4 != 0) ? new Color(1f, 0.8f, 0.35f, 0.7f) : new Color(1f, 0.8f, 0.5f, 0.3f));
								Color val7 = (value.startColor = val6);
								value.endColor = new Color(val7.r, val7.g, val7.b, 0f);
								for (int i = 0; i < 36; i++)
								{
									float num5 = (float)i / 35f;
									float num6 = num5 * MathF.PI * 5f - Time.time * 2f;
									value.SetPosition(i, val3 + new Vector3(Mathf.Cos(num6) * num3, num5 * num2, Mathf.Sin(num6) * num3));
								}
							}
						}
					}
				}
			}
			if (inThermal && !flag)
			{
				((Character)Player).Message((MessageType)2, "Updraft — lift + stamina", 0, (Sprite)null, false);
			}
			foreach (Fireplace item in new List<Fireplace>(currents.Keys))
			{
				if (!hashSet.Contains(item))
				{
					if (Object.op_Implicit((Object)(object)currents[item]))
					{
						Object.Destroy((Object)(object)((Component)currents[item]).gameObject);
					}
					currents.Remove(item);
				}
			}
		}

		private void Update()
		{
			RestoreArms();
			if (!Object.op_Implicit((Object)(object)Player))
			{
				return;
			}
			if ((Object)(object)Player == (Object)(object)Player.m_localPlayer)
			{
				if (Active && (!Plugin.Allowed(Player) || ((Character)Player).IsOnGround() || !Plugin.HasKite(Player)))
				{
					Stop();
				}
			}
			else
			{
				ZNetView view = View;
				Active = Object.op_Implicit((Object)(object)view) && view.IsValid() && view.GetZDO().GetBool("angell_kite_active", false) && !((Character)Player).IsDead();
			}
			if (Active)
			{
				if (!Object.op_Implicit((Object)(object)canopy))
				{
					CreateVisual();
				}
				UpdateVisual();
			}
			else if (Object.op_Implicit((Object)(object)canopy))
			{
				ClearVisuals();
			}
		}

		private void CreateVisual()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_004e: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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)
			if (Object.op_Implicit((Object)(object)Plugin.Item))
			{
				WindweaverModel.EnsureLoaded();
				canopy = new GameObject("Windweaver_Visual");
				canopy.transform.SetParent(((Component)Player).transform, false);
				canopy.transform.localPosition = Plugin.CanopyOffset.Value;
				canopy.transform.localScale = Vector3.one * Mathf.Clamp(Plugin.CanopyScale.Value, 0.25f, 2f);
				WindweaverModel.Populate(canopy.transform);
				leftGrip = new GameObject("Grip_Left").transform;
				leftGrip.SetParent(canopy.transform, false);
				leftGrip.localPosition = new Vector3(-0.32f, -0.6f, 0f);
				rightGrip = new GameObject("Grip_Right").transform;
				rightGrip.SetParent(canopy.transform, false);
				rightGrip.localPosition = new Vector3(0.32f, -0.6f, 0f);
				left = MakeTrail(-1.45f);
				right = MakeTrail(1.45f);
			}
		}

		private static void LevelModel(Transform model)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0107: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			MeshFilter val = null;
			float num = 0f;
			MeshFilter[] componentsInChildren = ((Component)model).GetComponentsInChildren<MeshFilter>(true);
			Bounds bounds;
			foreach (MeshFilter val2 in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val2.sharedMesh))
				{
					bounds = val2.sharedMesh.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					float num2 = Mathf.Max(size.x * size.y, Mathf.Max(size.x * size.z, size.y * size.z));
					if (num2 > num)
					{
						num = num2;
						val = val2;
					}
				}
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				bounds = val.sharedMesh.bounds;
				Vector3 size2 = ((Bounds)(ref bounds)).size;
				Vector3 val3 = ((size2.x <= size2.y && size2.x <= size2.z) ? Vector3.right : ((size2.y <= size2.z) ? Vector3.up : Vector3.forward));
				Vector3 val4 = ((Component)val).transform.TransformDirection(val3);
				Vector3 val5 = ((Vector3)(ref val4)).normalized;
				if (Vector3.Dot(val5, Vector3.up) < 0f)
				{
					val5 = -val5;
				}
				model.rotation = Quaternion.FromToRotation(val5, Vector3.up) * model.rotation;
			}
		}

		private TrailRenderer MakeTrail(float x)
		{
			//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_0030: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject((x < 0f) ? "LeftWind" : "RightWind");
			val.transform.SetParent(canopy.transform, false);
			val.transform.localPosition = new Vector3(x, 0f, 0f);
			TrailRenderer obj = val.AddComponent<TrailRenderer>();
			((Renderer)obj).sharedMaterial = Plugin.WindMaterial;
			obj.time = 0.45f;
			obj.minVertexDistance = 0.08f;
			obj.startWidth = 0.08f;
			obj.endWidth = 0f;
			obj.startColor = new Color(0.8f, 0.95f, 1f, 0.5f);
			obj.endColor = new Color(0.8f, 0.95f, 1f, 0f);
			return obj;
		}

		private void UpdateVisual()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			if (!Object.op_Implicit((Object)(object)canopy))
			{
				return;
			}
			canopy.transform.localPosition = Plugin.CanopyOffset.Value;
			canopy.transform.localScale = Vector3.one * Mathf.Clamp(Plugin.CanopyScale.Value, 0.25f, 2f);
			Vector3 velocity = ((Character)Player).GetVelocity();
			float magnitude = ((Vector3)(ref velocity)).magnitude;
			TrailRenderer[] array = (TrailRenderer[])(object)new TrailRenderer[2] { left, right };
			foreach (TrailRenderer val in array)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					val.emitting = Plugin.Trails.Value;
					val.time = Mathf.Lerp(0.15f, 0.6f, Mathf.Clamp01(magnitude / 16f));
				}
			}
		}

		private static Transform FindBone(Transform root, params string[] names)
		{
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				string text = ((Object)val).name.ToLowerInvariant().Replace("mixamorig:", "").Replace("mixamorig", "")
					.Replace(" ", "");
				foreach (string text2 in names)
				{
					if (text == text2)
					{
						return val;
					}
				}
			}
			return null;
		}

		private Arm ResolveArm(Animator animator, bool left)
		{
			Transform val = null;
			Transform val2 = null;
			Transform val3 = null;
			if (Object.op_Implicit((Object)(object)animator) && animator.isHuman)
			{
				val = animator.GetBoneTransform((HumanBodyBones)(left ? 13 : 14));
				val2 = animator.GetBoneTransform((HumanBodyBones)(left ? 15 : 16));
				val3 = animator.GetBoneTransform((HumanBodyBones)(left ? 17 : 18));
			}
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3))
			{
				Transform root = (Object.op_Implicit((Object)(object)animator) ? ((Component)animator).transform : ((Component)Player).transform);
				val = FindBone(root, left ? "leftarm" : "rightarm", left ? "upperarm_l" : "upperarm_r", left ? "l_upperarm" : "r_upperarm", left ? "bip01lupperarm" : "bip01rupperarm");
				val2 = FindBone(root, left ? "leftforearm" : "rightforearm", left ? "lowerarm_l" : "lowerarm_r", left ? "l_forearm" : "r_forearm", left ? "bip01lforearm" : "bip01rforearm");
				val3 = FindBone(root, left ? "lefthand" : "righthand", left ? "hand_l" : "hand_r", left ? "l_hand" : "r_hand", left ? "bip01lhand" : "bip01rhand");
			}
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3))
			{
				return null;
			}
			return new Arm
			{
				Upper = val,
				Lower = val2,
				Hand = val3
			};
		}

		private void LateUpdate()
		{
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			if (!Active || !Object.op_Implicit((Object)(object)Player) || !Object.op_Implicit((Object)(object)canopy) || !Plugin.RaisedArms.Value || ((Character)Player).IsDead())
			{
				RestoreArms();
				return;
			}
			if (!armSearchDone)
			{
				Animator componentInChildren = ((Component)Player).GetComponentInChildren<Animator>();
				leftArm = ResolveArm(componentInChildren, left: true);
				rightArm = ResolveArm(componentInChildren, left: false);
				armSearchDone = true;
				string text = "Raised-arm rig: left=" + (leftArm != null) + ", right=" + (rightArm != null);
				if (leftArm == null || rightArm == null)
				{
					List<string> list = new List<string>();
					Transform[] componentsInChildren = ((Component)Player).GetComponentsInChildren<Transform>(true);
					foreach (Transform val in componentsInChildren)
					{
						if (((Object)val).name.ToLowerInvariant().Contains("arm") || ((Object)val).name.ToLowerInvariant().Contains("hand"))
						{
							list.Add(((Object)val).name);
						}
					}
					text = text + "; candidate bones: " + string.Join(", ", list.ToArray());
				}
				Plugin.LogPose(text);
			}
			if (Object.op_Implicit((Object)(object)leftGrip))
			{
				leftArm?.Aim(leftGrip.position, -((Component)Player).transform.right + ((Component)Player).transform.forward * 0.3f);
			}
			if (Object.op_Implicit((Object)(object)rightGrip))
			{
				rightArm?.Aim(rightGrip.position, ((Component)Player).transform.right + ((Component)Player).transform.forward * 0.3f);
			}
		}

		private void RestoreArms()
		{
			leftArm?.Restore();
			rightArm?.Restore();
		}

		private void OnDisable()
		{
			RestoreArms();
		}

		private void OnGUI()
		{
		}

		private void ClearVisuals()
		{
			if (Object.op_Implicit((Object)(object)canopy))
			{
				Object.Destroy((Object)(object)canopy);
			}
			canopy = null;
			foreach (LineRenderer value in currents.Values)
			{
				if (Object.op_Implicit((Object)(object)value))
				{
					Object.Destroy((Object)(object)((Component)value).gameObject);
				}
			}
			currents.Clear();
		}

		private void OnDestroy()
		{
			RestoreArms();
			Stop();
			ClearVisuals();
			if (Player != null)
			{
				Plugin.Flights.Remove(Player);
			}
		}
	}
	public sealed class LaunchPad : MonoBehaviour, Hoverable, Interactable
	{
		internal const string PrefabName = "Angell_GliderLaunchPad";

		private static GameObject prefab;

		private static ConfigEntry<float> speed;

		private static ConfigEntry<float> cooldown;

		private static readonly int[] Angles = new int[4] { 45, 60, 75, 90 };

		private const string AngleKey = "angell_windstone_angle";

		private const string AngleRPC = "WindstoneSetAngle";

		private ZNetView view;

		private bool registered;

		private int visibleAngle = -1;

		private static readonly FieldInfo Named = AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs");

		private static ConfigEntry<int> powerTier1;

		private static ConfigEntry<int> powerTier2;

		private static ConfigEntry<int> powerTier3;

		private static ConfigEntry<int> powerTier4;

		private static ConfigEntry<int> powerTier5;

		private int Angle
		{
			get
			{
				int num = ((Object.op_Implicit((Object)(object)view) && view.IsValid()) ? view.GetZDO().GetInt("angell_windstone_angle", 90) : 90);
				if (num >= 1000)
				{
					num %= 100;
				}
				if (Array.IndexOf(Angles, num) < 0)
				{
					return 90;
				}
				return num;
			}
		}

		internal static void Bind(ConfigFile config)
		{
			speed = config.Bind<float>("LaunchPad", "LaunchForce", 30f, "Legacy fallback launch speed retained for config compatibility. New pads use PowerTier3 by default.");
			cooldown = config.Bind<float>("LaunchPad", "CooldownSeconds", 3f, "Cooldown per player across all launch pads (1-30 seconds).");
			powerTier1 = config.Bind<int>("LaunchPad", "PowerTier1", 20, "Selectable launch power tier 1 in metres/second. Supported range 10-100. Use the same tier values on all multiplayer clients.");
			powerTier2 = config.Bind<int>("LaunchPad", "PowerTier2", 25, "Selectable launch power tier 2 in metres/second. Supported range 10-100. Use the same tier values on all multiplayer clients.");
			powerTier3 = config.Bind<int>("LaunchPad", "PowerTier3", 30, "Selectable launch power tier 3 in metres/second. Supported range 10-100. Use the same tier values on all multiplayer clients.");
			powerTier4 = config.Bind<int>("LaunchPad", "PowerTier4", 35, "Selectable launch power tier 4 in metres/second. Supported range 10-100. Use the same tier values on all multiplayer clients.");
			powerTier5 = config.Bind<int>("LaunchPad", "PowerTier5", 40, "Selectable launch power tier 5 in metres/second. Supported range 10-100. Use the same tier values on all multiplayer clients.");
		}

		internal static void Register(ObjectDB db, ZNetScene scene)
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: 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_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)db) || !Object.op_Implicit((Object)(object)scene))
			{
				return;
			}
			GameObject itemPrefab = db.GetItemPrefab("Hammer");
			GameObject val = scene.GetPrefab("wood_floor");
			GameObject val2 = scene.GetPrefab("piece_workbench");
			if (!Object.op_Implicit((Object)(object)itemPrefab) || !Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
			{
				return;
			}
			PieceTable buildPieces = itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces;
			if (!Object.op_Implicit((Object)(object)buildPieces))
			{
				return;
			}
			GameObject itemPrefab2 = db.GetItemPrefab("Wood");
			GameObject itemPrefab3 = db.GetItemPrefab("Stone");
			GameObject itemPrefab4 = db.GetItemPrefab("SurtlingCore");
			if (!Object.op_Implicit((Object)(object)itemPrefab2) || !Object.op_Implicit((Object)(object)itemPrefab3) || !Object.op_Implicit((Object)(object)itemPrefab4))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				prefab = Object.Instantiate<GameObject>(val, Plugin.Root.transform);
				((Object)prefab).name = "Angell_GliderLaunchPad";
				foreach (Transform item in prefab.transform)
				{
					Transform val3 = item;
					if (((Component)val3).CompareTag("snappoint"))
					{
						Vector3 localPosition = val3.localPosition;
						localPosition.z *= 2f;
						val3.localPosition = localPosition;
					}
				}
				Piece component = prefab.GetComponent<Piece>();
				component.m_name = "Windstone Launch Pad";
				component.m_description = "Stand on the pad and interact to launch. Alternate interact changes angle. Grants fall protection until landing. Requires an equipped Glider and a clear launch path.";
				component.m_category = (PieceCategory)0;
				component.m_enabled = true;
				component.m_craftingStation = val2.GetComponent<CraftingStation>();
				component.m_resources = (Requirement[])(object)new Requirement[4]
				{
					new Requirement
					{
						m_resItem = itemPrefab2.GetComponent<ItemDrop>(),
						m_amount = 10,
						m_recover = true
					},
					new Requirement
					{
						m_resItem = itemPrefab3.GetComponent<ItemDrop>(),
						m_amount = 20,
						m_recover = true
					},
					new Requirement
					{
						m_resItem = itemPrefab4.GetComponent<ItemDrop>(),
						m_amount = 2,
						m_recover = true
					},
					new Requirement
					{
						m_resItem = db.GetItemPrefab("GreydwarfEye").GetComponent<ItemDrop>(),
						m_amount = 10,
						m_recover = true
					}
				};
				WearNTear component2 = prefab.GetComponent<WearNTear>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.m_health = 300f;
					component2.m_noRoofWear = true;
				}
				WindstoneModel.Populate(prefab, db, scene);
				Plugin.LogPose("Windstone Launch Pad registered: hammer Misc; 10 Wood, 20 Stone, 2 Surtling Cores, 10 Greydwarf Eyes.");
				prefab.AddComponent<LaunchPad>();
				prefab.SetActive(true);
			}
			Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)Named.GetValue(scene);
			int stableHashCode = StringExtensionMethods.GetStableHashCode("Angell_GliderLaunchPad");
			if (!dictionary.ContainsKey(stableHashCode))
			{
				dictionary.Add(stableHashCode, prefab);
			}
			if (!scene.m_prefabs.Contains(prefab))
			{
				scene.m_prefabs.Add(prefab);
			}
			if (!buildPieces.m_pieces.Contains(prefab))
			{
				buildPieces.m_pieces.Add(prefab);
			}
		}

		private void Awake()
		{
			view = ((Component)this).GetComponent<ZNetView>();
			Initialize();
		}

		private void Initialize()
		{
			if (!registered && Object.op_Implicit((Object)(object)view) && view.IsValid())
			{
				view.Register<int>("WindstoneSetAngle", (Action<long, int>)RPC_SetAngle);
				registered = true;
			}
		}

		private void Update()
		{
			Initialize();
			if (Object.op_Implicit((Object)(object)view) && view.IsValid())
			{
				int num = view.GetZDO().GetInt("angell_windstone_angle", 90);
				if (num != visibleAngle)
				{
					WindstoneModel.SetAngle(((Component)this).transform, num);
					visibleAngle = num;
				}
			}
		}

		private void RPC_SetAngle(long sender, int angle)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)view) || !view.IsValid() || !view.IsOwner())
			{
				return;
			}
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				ZNetView component = ((Component)allPlayer).GetComponent<ZNetView>();
				if (Object.op_Implicit((Object)(object)component) && component.IsValid() && component.GetZDO().GetOwner() == sender && !((Character)allPlayer).IsDead())
				{
					Vector3 val = ((Component)allPlayer).transform.position - ((Component)this).transform.position;
					if (((Vector3)(ref val)).sqrMagnitude < 36f)
					{
						view.GetZDO().Set("angell_windstone_angle", angle);
						break;
					}
				}
			}
		}

		private void OnDestroy()
		{
			if (registered && Object.op_Implicit((Object)(object)view))
			{
				view.Unregister("WindstoneSetAngle");
			}
		}

		public string GetHoverName()
		{
			return "Windstone Launch Pad";
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public string GetHoverText()
		{
			return Localization.instance.Localize("Windstone Launch Pad — " + Angle + "°\n[<color=yellow><b>$KEY_Use</b></color>] Launch\n[<color=yellow>$KEY_AltPlace+$KEY_Use</color>] Angle 45/60/75/90\n[<color=yellow>Left Alt+$KEY_Use</color>] Power tier 1/2/3/4/5 (configurable)     ");
		}

		private bool Reject(Player p, string message)
		{
			((Character)p).Message((MessageType)2, message, 0, (Sprite)null, false);
			return false;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: 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_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: 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_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: 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_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0570: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			if (hold)
			{
				return false;
			}
			Player val = (Player)(object)((user is Player) ? user : null);
			if (!Object.op_Implicit((Object)(object)val) || (Object)(object)val != (Object)(object)Player.m_localPlayer)
			{
				return false;
			}
			if (!Object.op_Implicit((Object)(object)view) || !view.IsValid())
			{
				return false;
			}
			int current;
			if (Input.GetKey("left alt") || alt)
			{
				if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
				{
					return Reject(val, "You do not have access to change this pad");
				}
				int num;
				if (Input.GetKey("left alt"))
				{
					num = view.GetZDO().GetInt("angell_windstone_angle", 90);
					current = ((num < 1000) ? powerTier3.Value : (num / 100));
					current = GetNextPower(current);
					num = current * 100 + Angle;
					view.InvokeRPC("WindstoneSetAngle", new object[1] { num });
					((Character)val).Message((MessageType)2, "Windstone power: " + current, 0, (Sprite)null, false);
					return true;
				}
				num = Angles[(Array.IndexOf(Angles, Angle) + 1) % Angles.Length];
				current = view.GetZDO().GetInt("angell_windstone_angle", 90);
				current = ((current < 1000) ? powerTier3.Value : (current / 100));
				num = current * 100 + num;
				view.InvokeRPC("WindstoneSetAngle", new object[1] { num });
				return true;
			}
			if (!Plugin.Allowed(val) || ((Character)val).InAttack())
			{
				return false;
			}
			if (!Plugin.HasKite(val))
			{
				return Reject(val, "Equip your Glider in the utility slot first");
			}
			if (!((Character)val).HaveStamina(1f))
			{
				return Reject(val, "Recover some stamina before launching");
			}
			Collider lastGroundCollider = ((Character)val).GetLastGroundCollider();
			Vector3 val2 = ((Component)this).transform.InverseTransformPoint(((Component)val).transform.position);
			if (!((Character)val).IsOnGround() || !Object.op_Implicit((Object)(object)lastGroundCollider) || !((Component)lastGroundCollider).transform.IsChildOf(((Component)this).transform) || Mathf.Abs(val2.x) > 1.35f || Mathf.Abs(val2.z) > 2.1f)
			{
				return Reject(val, "Stand on the launch pad to use it");
			}
			if (Vector3.Dot(((Component)this).transform.up, Vector3.up) < 0.95f)
			{
				return Reject(val, "The launch pad must be level");
			}
			Flight flight = Plugin.Get(val);
			if (Time.time < flight.NextLaunch)
			{
				return Reject(val, "Launch recharging");
			}
			current = view.GetZDO().GetInt("angell_windstone_angle", 90);
			float num2 = Mathf.Clamp((current < 1000) ? ((float)powerTier3.Value) : ((float)(current / 100)), 10f, 100f);
			float num3 = (float)Angle * (MathF.PI / 180f);
			Vector3 val3 = Vector3.ProjectOnPlane(((Component)this).transform.forward, Vector3.up);
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			Vector3 val4 = Vector3.up * (num2 * Mathf.Sin(num3)) + normalized * ((Angle == 90) ? 0f : (num2 * Mathf.Cos(num3)));
			int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" });
			Vector3 position = ((Component)val).transform.position;
			Collider[] array = Physics.OverlapCapsule(position + Vector3.up * 0.45f, position + Vector3.up * 1.6f, 0.4f, mask, (QueryTriggerInteraction)1);
			foreach (Collider obstacle in array)
			{
				if (BlocksLaunch(obstacle, val))
				{
					return Reject(val, "Not enough headroom above the launch pad");
				}
			}
			float num4 = Mathf.Max(1f, Mathf.Abs(Physics.gravity.y));
			float num5 = val4.y / num4;
			current = Mathf.CeilToInt(num5 / 0.12f);
			Vector3 val5 = position;
			for (int j = 1; j <= current; j++)
			{
				float num6 = num5 * (float)j / (float)current;
				Vector3 val6 = position + val4 * num6 + Vector3.down * (0.5f * num4 * num6 * num6);
				Vector3 val7 = val6 - val5;
				RaycastHit[] array2 = Physics.CapsuleCastAll(val5 + Vector3.up * 0.45f, val5 + Vector3.up * 1.6f, 0.4f, ((Vector3)(ref val7)).normalized, ((Vector3)(ref val7)).magnitude, mask, (QueryTriggerInteraction)1);
				for (int i = 0; i < array2.Length; i++)
				{
					RaycastHit val8 = array2[i];
					if (BlocksLaunch(((RaycastHit)(ref val8)).collider, val))
					{
						return Reject(val, "The selected launch path is blocked");
					}
				}
				val5 = val6;
			}
			flight.Stop();
			flight.NextLaunch = Time.time + Mathf.Clamp(cooldown.Value, 1f, 30f);
			flight.LaunchAscentUntil = Time.time + 8f;
			((Character)val).ForceJump(val4, true);
			WindborneWard.Grant(val);
			((Character)val).Message((MessageType)2, "Windborne! Press jump to glide — landing protected", 0, (Sprite)null, false);
			return true;
		}

		private bool BlocksLaunch(Collider obstacle, Player player)
		{
			if (!((Component)obstacle).transform.IsChildOf(((Component)this).transform) && !((Component)obstacle).transform.IsChildOf(((Component)player).transform) && !Object.op_Implicit((Object)(object)((Component)obstacle).GetComponentInParent<ItemDrop>()))
			{
				return !Object.op_Implicit((Object)(object)((Component)obstacle).GetComponentInParent<Character>());
			}
			return false;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		internal static void Release()
		{
			prefab = null;
			WindstoneModel.Release();
			WindborneWard.Release();
		}

		private static int GetNextPower(int current)
		{
			if (current == powerTier1.Value)
			{
				return powerTier2.Value;
			}
			if (current == powerTier2.Value)
			{
				return powerTier3.Value;
			}
			if (current == powerTier3.Value)
			{
				return powerTier4.Value;
			}
			if (current == powerTier4.Value)
			{
				return powerTier5.Value;
			}
			if (current == powerTier5.Value)
			{
				return powerTier1.Value;
			}
			return powerTier1.Value;
		}
	}
	public sealed class WindborneWard : StatusEffect
	{
		[HarmonyPatch(typeof(SEMan), "ModifyFallDamage")]
		private static class FallOnly
		{
			private static void Postfix(SEMan __instance, ref float __1)
			{
				if (__instance.HaveStatusEffect(Hash))
				{
					__1 = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(Character), "UpdateGroundContact")]
		private static class Landing
		{
			private static readonly FieldInfo Ground = AccessTools.Field(typeof(Character), "m_groundContact");

			private static void Prefix(Character __instance, out bool __state)
			{
				__state = (bool)Ground.GetValue(__instance);
			}

			private static void Postfix(Character __instance, bool __state)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (__state && Object.op_Implicit((Object)(object)val) && !((Object)(object)val != (Object)(object)Player.m_localPlayer))
				{
					WindborneWard windborneWard = ((Character)val).GetSEMan().GetStatusEffect(Hash) as WindborneWard;
					if (Object.op_Implicit((Object)(object)windborneWard) && Time.time - windborneWard.Started > 0.12f)
					{
						((Character)val).GetSEMan().RemoveStatusEffect(Hash, true);
					}
				}
			}
		}

		internal const string EffectName = "Angell_Windborne";

		internal static readonly int Hash = StringExtensionMethods.GetStableHashCode("Angell_Windborne");

		private static WindborneWard template;

		internal float Started;

		private bool ended;

		internal static void Register(ObjectDB db)
		{
			if (!Object.op_Implicit((Object)(object)template))
			{
				template = ScriptableObject.CreateInstance<WindborneWard>();
				((Object)template).name = "Angell_Windborne";
				((StatusEffect)template).m_name = "Windborne";
				((StatusEffect)template).m_tooltip = "Immune to fall damage until your next landing. Does not prevent other damage.";
				((StatusEffect)template).m_ttl = 0f;
				GameObject itemPrefab = db.GetItemPrefab("Feathers");
				if (Object.op_Implicit((Object)(object)itemPrefab))
				{
					Sprite[] icons = itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons;
					if (icons.Length != 0)
					{
						((StatusEffect)template).m_icon = icons[0];
					}
				}
			}
			if (!db.m_StatusEffects.Contains((StatusEffect)(object)template))
			{
				db.m_StatusEffects.Add((StatusEffect)(object)template);
				AccessTools.Method(typeof(ObjectDB), "UpdateRegisters", (Type[])null, (Type[])null).Invoke(db, null);
			}
		}

		internal static void Grant(Player p)
		{
			((Character)p).GetSEMan().RemoveStatusEffect(Hash, true);
			((Character)p).GetSEMan().AddStatusEffect((StatusEffect)(object)template, true, 0, 0f, (short)(-1));
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			Started = Time.time;
			ended = false;
		}

		public override void ModifyFallDamage(float baseDamage, ref float damage)
		{
			damage = 0f;
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			Character character = base.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (!Object.op_Implicit((Object)(object)val) || ((Character)val).IsDead() || ((Character)val).IsTeleporting() || ((Character)val).IsAttached() || ((Character)val).IsSwimming())
			{
				ended = true;
			}
		}

		public override bool IsDone()
		{
			if (!ended)
			{
				return ((StatusEffect)this).IsDone();
			}
			return true;
		}

		internal static void Release()
		{
			if (Object.op_Implicit((Object)(object)template))
			{
				Object.Destroy((Object)(object)template);
			}
			template = null;
		}
	}
	internal static class WindstoneModel
	{
		private sealed class Builder
		{
			private readonly List<Vector3> vertices = new List<Vector3>();

			private readonly List<Vector2> uv = new List<Vector2>();

			private readonly List<int> indices = new List<int>();

			internal void Tri(Vector3 a, Vector3 b, Vector3 c)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: 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_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: 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_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_0080: 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_00d5: 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_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: 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_00a4: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
				int count = vertices.Count;
				vertices.Add(a);
				vertices.Add(b);
				vertices.Add(c);
				Vector3 val = Vector3.Cross(b - a, c - a);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Vector3[] array = (Vector3[])(object)new Vector3[3] { a, b, c };
				foreach (Vector3 val2 in array)
				{
					uv.Add((Mathf.Abs(normalized.y) > 0.6f) ? new Vector2(val2.x, val2.z) : ((Mathf.Abs(normalized.x) > 0.6f) ? new Vector2(val2.z, val2.y) : new Vector2(val2.x, val2.y)));
				}
				indices.Add(count);
				indices.Add(count + 1);
				indices.Add(count + 2);
			}

			internal void Top(Vector3 a, Vector3 b, Vector3 c)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: 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_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				if (Vector3.Cross(b - a, c - a).y < 0f)
				{
					Tri(a, c, b);
				}
				else
				{
					Tri(a, b, c);
				}
			}

			internal Mesh Finish(string name)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Expected O, but got Unknown
				Mesh val = new Mesh
				{
					name = name
				};
				val.SetVertices(vertices);
				val.SetUVs(0, uv);
				val.SetTriangles(indices, 0);
				val.RecalculateNormals();
				val.RecalculateBounds();
				meshes.Add(val);
				return val;
			}
		}

		private static readonly List<Mesh> meshes = new List<Mesh>();

		private static readonly List<Material> materials = new List<Material>();

		private static readonly List<Texture2D> textures = new List<Texture2D>();

		private static float Height(float z)
		{
			return 0.16f + (z + 2f) * 0.25f;
		}

		private static Material MaterialFrom(GameObject source, Color tint, string name, bool plain = false)
		{
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			Material val = null;
			if (Object.op_Implicit((Object)(object)source))
			{
				MeshRenderer[] componentsInChildren = source.GetComponentsInChildren<MeshRenderer>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Material[] sharedMaterials = ((Renderer)componentsInChildren[i]).sharedMaterials;
					foreach (Material val2 in sharedMaterials)
					{
						if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.shader) && val2.renderQueue < 3000 && val2.HasProperty("_MainTex"))
						{
							val = val2;
							break;
						}
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)Plugin.Item))
			{
				MeshRenderer[] componentsInChildren = Plugin.Item.GetComponentsInChildren<MeshRenderer>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Material[] sharedMaterials = ((Renderer)componentsInChildren[i]).sharedMaterials;
					foreach (Material val3 in sharedMaterials)
					{
						if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val3.shader) && val3.renderQueue < 3000 && val3.HasProperty("_MainTex"))
						{
							val = val3;
							break;
						}
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("Windstone has no opaque game material template.");
			}
			Material val4 = new Material(val);
			((Object)val4).name = name;
			if (val4.HasProperty("_Color"))
			{
				val4.SetColor("_Color", tint);
			}
			if (plain)
			{
				if (val4.HasProperty("_MainTex"))
				{
					val4.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
				}
				string[] array = new string[3] { "_BumpMap", "_MetallicGlossMap", "_EmissionMap" };
				foreach (string text in array)
				{
					if (val4.HasProperty(text))
					{
						val4.SetTexture(text, (Texture)null);
					}
				}
				val4.DisableKeyword("_NORMALMAP");
				val4.DisableKeyword("_METALLICGLOSSMAP");
			}
			materials.Add(val4);
			return val4;
		}

		private static GameObject Part(Transform root, string name, Mesh mesh, Material material)
		{
			//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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(root, false);
			val.layer = ((Component)root).gameObject.layer;
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material;
			return val;
		}

		internal static void Populate(GameObject prefab, ObjectDB db, ZNetScene scene)
		{
			WindstoneVisualV026.Populate(prefab, db, scene);
		}

		private static void CombineBindings(Transform root)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			Dictionary<Material, List<MeshFilter>> dictionary = new Dictionary<Material, List<MeshFilter>>();
			MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				if (!(((Object)val).name != "WoodBinding"))
				{
					Material sharedMaterial = ((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterial;
					if (!dictionary.ContainsKey(sharedMaterial))
					{
						dictionary.Add(sharedMaterial, new List<MeshFilter>());
					}
					dictionary[sharedMaterial].Add(val);
				}
			}
			foreach (KeyValuePair<Material, List<MeshFilter>> item in dictionary)
			{
				CombineInstance[] array = (CombineInstance[])(object)new CombineInstance[item.Value.Count];
				for (int j = 0; j < array.Length; j++)
				{
					int num = j;
					CombineInstance val2 = default(CombineInstance);
					((CombineInstance)(ref val2)).mesh = item.Value[j].sharedMesh;
					((CombineInstance)(ref val2)).transform = root.worldToLocalMatrix * ((Component)item.Value[j]).transform.localToWorldMatrix;
					array[num] = val2;
				}
				Mesh val3 = new Mesh
				{
					name = "Windstone_CombinedBindings"
				};
				val3.CombineMeshes(array, true, true);
				meshes.Add(val3);
				Part(root, "CombinedBindings", val3, item.Key);
				foreach (MeshFilter item2 in item.Value)
				{
					((Component)item2).gameObject.SetActive(false);
					Object.Destroy((Object)(object)((Component)item2).gameObject);
				}
			}
		}

		internal static void SetAngle(Transform prefab, int degrees)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			Transform val = prefab.Find("Windstone_Model/AngleGlyphs");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			foreach (Transform item in val)
			{
				Transform val2 = item;
				((Component)val2).gameObject.SetActive(((Object)val2).name == "0" || ((Object)val2).name == degrees.ToString(CultureInfo.InvariantCulture));
			}
		}

		private static void Texture(Material material, string name)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0077: 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)
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true);
			textures.Add(val);
			if (!ImageConversion.LoadImage(val, memoryStream.ToArray()))
			{
				throw new InvalidDataException(name);
			}
			((Object)val).name = name;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			if (material.HasProperty("_MainTex"))
			{
				material.SetTexture("_MainTex", (Texture)(object)val);
				material.SetTextureScale("_MainTex", Vector2.one);
				material.SetTextureOffset("_MainTex", Vector2.zero);
			}
			if (material.HasProperty("_Glossiness"))
			{
				material.SetFloat("_Glossiness", 0.08f);
			}
		}

		private static void Lashing(Transform root, Vector3 center, float x, float z, Material material)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might b