Decompiled source of Sledding v1.0.0

plugins/Sledding.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Sledding.Audio;
using Sledding.Core;
using Sledding.Dev;
using Sledding.Gameplay;
using Sledding.Visual;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Sledding
{
	public static class Cfg
	{
		public static ConfigEntry<string>[] Recipe = new ConfigEntry<string>[SledSpec.All.Length];

		public static ConfigEntry<string>[] Station = new ConfigEntry<string>[SledSpec.All.Length];

		public static ConfigEntry<string>[] Cargo = new ConfigEntry<string>[SledSpec.All.Length];

		public static ConfigEntry<float> MaxSpeed;

		public static ConfigEntry<float> SafeDrop;

		public static ConfigEntry<float> BreakDrop;

		public static ConfigEntry<bool> RiderCanBeHurt;

		public static ConfigEntry<bool> CrashThrowsRider;

		public static ConfigEntry<float> PushStamina;

		public static ConfigEntry<bool> ShowControls;

		public static ConfigEntry<bool> ShowRunStats;

		public static ConfigEntry<float> Volume;

		private static readonly string[] DefaultRecipe = new string[4] { "Wood:10,LeatherScraps:4", "FineWood:10,Bronze:2,DeerHide:2", "FineWood:12,Silver:4,WolfPelt:3,LeatherScraps:4", "FineWood:20,BlackMetal:6,LoxPelt:4,LinenThread:8" };

		private static readonly string[] DefaultStation = new string[4] { "piece_workbench", "forge", "forge", "piece_artisanstation" };

		private static readonly string[] Names = new string[4] { "Wooden sled", "Bronze-shod sled", "Mountain sled", "Great sled" };

		public static void Bind(ConfigFile c)
		{
			//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
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Expected O, but got Unknown
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected O, but got Unknown
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Expected O, but got Unknown
			ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			};
			for (int i = 0; i < SledSpec.All.Length; i++)
			{
				SledSpec sledSpec = SledSpec.All[i];
				string text = char.ToUpperInvariant(sledSpec.Id[0]) + sledSpec.Id.Substring(1);
				Recipe[i] = c.Bind<string>("1 - Sleds", text + "Recipe", DefaultRecipe[i], new ConfigDescription("Build cost of the " + Names[i].ToLowerInvariant() + ", \"Item:amount,Item:amount\" (item prefab names).", (AcceptableValueBase)null, new object[1] { val }));
				Station[i] = c.Bind<string>("1 - Sleds", text + "Station", DefaultStation[i], new ConfigDescription("Crafting station that has to be near when building the " + Names[i].ToLowerInvariant() + " (prefab name, empty for none).", (AcceptableValueBase)null, new object[1] { val }));
				Cargo[i] = c.Bind<string>("1 - Sleds", text + "Cargo", sledSpec.CargoWidth + "x" + sledSpec.CargoHeight, new ConfigDescription("Cargo slots of the " + Names[i].ToLowerInvariant() + ", width x height (up to 8x4). Applies to sleds loaded after the change; shrink it only while they are empty.", (AcceptableValueBase)null, new object[1] { val }));
			}
			MaxSpeed = c.Bind<float>("1 - Sleds", "MaxSpeed", 28f, new ConfigDescription("Top speed in m/s (28 m/s is about 100 km/h). Air drag already slows sleds down long before on all but the steepest slopes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(8f, 60f), new object[1] { val }));
			SafeDrop = c.Bind<float>("1 - Sleds", "SafeDropHeight", 6f, new ConfigDescription("A sled lands unharmed from a free fall up to this height in metres. Only the speed straight into the ground counts: sliding down a steep mountainside is never a fall.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 40f), new object[1] { val }));
			BreakDrop = c.Bind<float>("1 - Sleds", "BreakDropHeight", 15f, new ConfigDescription("From a free fall of this height or more the sled breaks (between the two it takes damage). Its riders are hurt then, but a sled never kills.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(4f, 80f), new object[1] { val }));
			RiderCanBeHurt = c.Bind<bool>("1 - Sleds", "RiderCanBeHurt", true, new ConfigDescription("Riders take damage when their sled breaks or they are thrown off (always leaving them at least 1 health).", (AcceptableValueBase)null, new object[1] { val }));
			CrashThrowsRider = c.Bind<bool>("1 - Sleds", "CrashThrowsRider", true, new ConfigDescription("Hitting a tree, rock or wall at speed throws the riders off.", (AcceptableValueBase)null, new object[1] { val }));
			PushStamina = c.Bind<float>("1 - Sleds", "PushStamina", 6f, new ConfigDescription("Stamina per second for kicking off with the feet (forward key).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 40f), new object[1] { val }));
			ShowControls = c.Bind<bool>("2 - Client", "ShowControls", true, "Show the controls in the corner when you sit down on a sled.");
			ShowRunStats = c.Bind<bool>("2 - Client", "ShowRunStats", true, "After a long run, show its length, top speed and how far down it went.");
			Volume = c.Bind<float>("2 - Client", "Volume", 1f, new ConfigDescription("Volume of the runners' hiss and scrape (on top of the game's effects volume).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		}

		public static void CargoOf(SledSpec spec, out int w, out int h)
		{
			int num = Array.IndexOf(SledSpec.All, spec);
			SledSpec.ParseCargo((num >= 0) ? Cargo[num].Value : null, spec.CargoWidth, spec.CargoHeight, out w, out h);
		}
	}
	public static class Lang
	{
		private static readonly (string key, string en, string de)[] Texts = new(string, string, string)[28]
		{
			("sled_wood", "Wooden sled", "Holzschlitten"),
			("sled_wood_desc", "A small sled of bent wood, lashed with leather. Sit on it and ride down a snowy hill, or pull it along on its rope. Snow and ice are what it is made for; on grass it hardly slides. Room for a small bundle, no more.", "Ein kleiner Schlitten aus gebogenem Holz, mit Leder verschnürt. Setz dich drauf und fahr einen verschneiten Hang hinab, oder zieh ihn am Seil hinter dir her. Für Schnee und Eis ist er gemacht; auf Gras rutscht er kaum. Platz für ein kleines Bündel, mehr nicht."),
			("sled_bronze", "Bronze-shod sled", "Bronzebeschlagener Schlitten"),
			("sled_bronze_desc", "Bronze shoes under the runners: it glides better, steers more surely and takes a knock. A deer hide on the seat and room for three bundles.", "Bronzene Kufenbeschläge: Er gleitet besser, lenkt sicherer und steckt einen Stoß weg. Eine Hirschhaut auf dem Sitz und Platz für drei Bündel."),
			("sled_silver", "Mountain sled", "Bergschlitten"),
			("sled_silver_desc", "Long runners shod with silver, a wolf pelt to sit on: the fastest and nimblest of all sleds, made for the high slopes. It still carries only four bundles.", "Lange, silberbeschlagene Kufen und ein Wolfsfell zum Sitzen: der schnellste und wendigste aller Schlitten, gemacht für die hohen Hänge. Mehr als vier Bündel trägt er trotzdem nicht."),
			("sled_great", "Great sled", "Großschlitten"),
			("sled_great_desc", "A great sled after the old ship burials: long and broad, with carved posts and black metal fittings. Two can ride it – the one in front steers – and it carries a real load. Heavy to pull uphill.", "Ein Großschlitten nach den alten Schiffsgräbern: lang und breit, mit geschnitzten Pfosten und Schwarzmetallbeschlägen. Zwei können darauf fahren – wer vorne sitzt, lenkt –, und er trägt eine echte Ladung. Bergauf schwer zu ziehen."),
			("sled_ride", "Sit down and ride", "Aufsitzen und fahren"),
			("sled_ride_front", "Sit in front and steer", "Vorne sitzen und lenken"),
			("sled_ride_back", "Sit behind", "Hinten sitzen"),
			("sled_rope_take", "Take the tow rope", "Zugseil nehmen"),
			("sled_rope_drop", "Let go of the rope", "Seil loslassen"),
			("sled_taken", "Both seats are taken", "Beide Plätze sind besetzt"),
			("sled_taken_one", "Someone sits on it", "Jemand sitzt darauf"),
			("sled_pulled_by", "Pulled by {0}", "Gezogen von {0}"),
			("sled_cargo", "Cargo", "Ladung"),
			("sled_msg_controls", "$KEY_Left / $KEY_Right steer · $KEY_Forward kick off · $KEY_Backward brake · $KEY_Run duck · $KEY_Jump jump off", "$KEY_Left / $KEY_Right lenken · $KEY_Forward abstoßen · $KEY_Backward bremsen · $KEY_Run ducken · $KEY_Jump abspringen"),
			("sled_msg_passenger", "You sit behind – the one in front steers. $KEY_Jump jumps off.", "Du sitzt hinten – wer vorne sitzt, lenkt. $KEY_Jump springt ab."),
			("sled_msg_pulled", "The sled is on someone's rope – you ride along.", "Der Schlitten hängt an jemandes Seil – du fährst mit."),
			("sled_msg_seat_taken", "That place is taken.", "Der Platz ist besetzt."),
			("sled_msg_rope_taken", "Someone else has the rope.", "Jemand anderes hat das Seil."),
			("sled_msg_rope_slipped", "The rope slips from your hand.", "Das Seil rutscht dir aus der Hand."),
			("sled_msg_encumbered", "You carry too much to sit down.", "Du trägst zu viel, um dich zu setzen."),
			("sled_msg_cracked", "The sled creaks – that was a hard landing.", "Der Schlitten knarzt – das war eine harte Landung."),
			("sled_msg_broke", "The sled breaks apart!", "Der Schlitten bricht auseinander!"),
			("sled_msg_thrown", "You are thrown off the sled!", "Du fliegst vom Schlitten!"),
			("sled_msg_run", "Run: {0} m, top speed {1} km/h, {2} m down", "Fahrt: {0} m, Spitze {1} km/h, {2} m hinab")
		};

		public static void Register()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
			(string, string, string)[] texts = Texts;
			for (int i = 0; i < texts.Length; i++)
			{
				(string, string, string) tuple = texts[i];
				string item = tuple.Item1;
				string item2 = tuple.Item2;
				string item3 = tuple.Item3;
				dictionary[item] = item2;
				dictionary2[item] = item3;
			}
			string text = "English";
			localization.AddTranslation(ref text, dictionary);
			text = "German";
			localization.AddTranslation(ref text, dictionary2);
		}

		public static string T(string token, params object[] args)
		{
			string text = ((Localization.instance != null) ? Localization.instance.Localize("$" + token) : token);
			if (args == null || args.Length == 0)
			{
				return text;
			}
			try
			{
				return string.Format(text, args);
			}
			catch (FormatException)
			{
				return text;
			}
		}
	}
	public static class Pieces
	{
		[HarmonyPatch(typeof(Game), "Start")]
		private static class ApplyOnWorldStart
		{
			private static void Postfix()
			{
				ApplyConfig();
			}
		}

		private const string BasePrefab = "Cart";

		private static readonly Dictionary<SledSpec, GameObject> Prefabs = new Dictionary<SledSpec, GameObject>();

		private static PhysicsMaterial _slick;

		public static Sprite[] Icons { get; } = (Sprite[])(object)new Sprite[SledSpec.All.Length];

		private static PhysicsMaterial Slick
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Expected O, but got Unknown
				//IL_004d: Expected O, but got Unknown
				if (!((Object)(object)_slick != (Object)null))
				{
					PhysicsMaterial val = new PhysicsMaterial("sled_slick")
					{
						dynamicFriction = 0f,
						staticFriction = 0f,
						bounciness = 0f,
						frictionCombine = (PhysicsMaterialCombine)2,
						bounceCombine = (PhysicsMaterialCombine)2
					};
					_slick = val;
					return val;
				}
				return _slick;
			}
		}

		public static void Init()
		{
			PrefabManager.OnVanillaPrefabsAvailable += Add;
			SynchronizationManager.OnConfigurationSynchronized += delegate
			{
				ApplyConfig();
			};
			for (int num = 0; num < SledSpec.All.Length; num++)
			{
				ConfigEntry<string>[] array = new ConfigEntry<string>[3]
				{
					Cfg.Recipe[num],
					Cfg.Station[num],
					Cfg.Cargo[num]
				};
				for (int num2 = 0; num2 < array.Length; num2++)
				{
					array[num2].SettingChanged += delegate
					{
						ApplyConfig();
					};
				}
			}
		}

		public static void ApplyConfig()
		{
			for (int i = 0; i < SledSpec.All.Length; i++)
			{
				SledSpec sledSpec = SledSpec.All[i];
				if (Prefabs.TryGetValue(sledSpec, out var value) && !((Object)(object)value == (Object)null))
				{
					Apply(value, Cfg.Recipe[i].Value, Cfg.Station[i].Value);
					Container componentInChildren = value.GetComponentInChildren<Container>(true);
					if ((Object)(object)componentInChildren != (Object)null)
					{
						Cfg.CargoOf(sledSpec, out componentInChildren.m_width, out componentInChildren.m_height);
					}
				}
			}
		}

		internal static GameObject FindPrefab(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			GameObject val = null;
			if ((Object)(object)ObjectDB.instance != (Object)null)
			{
				val = ObjectDB.instance.GetItemPrefab(name);
			}
			if ((Object)(object)val == (Object)null && (Object)(object)ZNetScene.instance != (Object)null)
			{
				val = ZNetScene.instance.GetPrefab(name);
			}
			if ((Object)(object)val == (Object)null)
			{
				try
				{
					val = PrefabManager.Instance.GetPrefab(name);
				}
				catch (Exception)
				{
				}
			}
			return val;
		}

		internal static void Apply(GameObject prefab, string recipe, string station)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00ad: Expected O, but got Unknown
			try
			{
				Piece val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Piece>() : null);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				List<Requirement> list = new List<Requirement>();
				foreach (RequirementConfig item in ParseRecipe(recipe))
				{
					GameObject obj = FindPrefab(item.Item);
					ItemDrop val2 = ((obj != null) ? obj.GetComponent<ItemDrop>() : null);
					if ((Object)(object)val2 == (Object)null)
					{
						SleddingPlugin.Log.LogWarning((object)(((Object)prefab).name + " recipe: unknown item '" + item.Item + "'."));
						continue;
					}
					list.Add(new Requirement
					{
						m_resItem = val2,
						m_amount = item.Amount,
						m_recover = true
					});
				}
				if (list.Count > 0)
				{
					val.m_resources = list.ToArray();
				}
				if (string.IsNullOrWhiteSpace(station))
				{
					val.m_craftingStation = null;
					return;
				}
				GameObject obj2 = FindPrefab(station.Trim());
				CraftingStation val3 = ((obj2 != null) ? obj2.GetComponent<CraftingStation>() : null);
				if ((Object)(object)val3 != (Object)null)
				{
					val.m_craftingStation = val3;
				}
				else
				{
					SleddingPlugin.Log.LogWarning((object)(((Object)prefab).name + " station: unknown crafting station '" + station + "'."));
				}
			}
			catch (Exception ex)
			{
				SleddingPlugin.Log.LogWarning((object)("Could not apply the recipe of " + ((prefab != null) ? ((Object)prefab).name : null) + ": " + ex.Message));
			}
		}

		private static void Add()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Mats.Init();
				for (int i = 0; i < SledSpec.All.Length; i++)
				{
					SledSpec sledSpec = SledSpec.All[i];
					SledLayout sledLayout = SledModel.Create(sledSpec);
					Icons[i] = RenderIcon(sledLayout.Root, Quaternion.Euler(-24f, 128f, 0f));
					GameObject val = Register(sledSpec, Cfg.Recipe[i].Value, Cfg.Station[i].Value, Icons[i], sledLayout);
					if ((Object)(object)val != (Object)null)
					{
						Prefabs[sledSpec] = val;
					}
				}
			}
			catch (Exception ex)
			{
				SleddingPlugin.Log.LogError((object)("Could not register the sleds: " + ex));
			}
			finally
			{
				PrefabManager.OnVanillaPrefabsAvailable -= Add;
			}
		}

		private static GameObject Register(SledSpec spec, string recipe, string station, Sprite icon, SledLayout layout)
		{
			//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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			PieceConfig val = new PieceConfig
			{
				Name = "$" + spec.Prefab,
				Description = "$" + spec.Prefab + "_desc",
				PieceTable = "Hammer",
				Category = "Misc",
				CraftingStation = (station ?? ""),
				Icon = icon
			};
			foreach (RequirementConfig item in ParseRecipe(recipe))
			{
				val.AddRequirement(item);
			}
			CustomPiece val2 = new CustomPiece(spec.Prefab, "Cart", val);
			if ((Object)(object)val2.PiecePrefab == (Object)null)
			{
				SleddingPlugin.Log.LogError((object)("Cloning Cart failed; no " + spec.Prefab + "."));
				Object.Destroy((Object)(object)layout.Root);
				return null;
			}
			if (string.IsNullOrWhiteSpace(station))
			{
				Piece component = val2.PiecePrefab.GetComponent<Piece>();
				if ((Object)(object)component != (Object)null)
				{
					component.m_craftingStation = null;
				}
			}
			Rebuild(val2.PiecePrefab, spec, layout);
			PieceManager.Instance.AddPiece(val2);
			return val2.PiecePrefab;
		}

		private static void Rebuild(GameObject prefab, SledSpec spec, SledLayout layout)
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_01d9: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: 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_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = prefab.transform;
			int layer = LayerMask.NameToLayer("vehicle");
			Container componentInChildren = prefab.GetComponentInChildren<Container>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((Component)componentInChildren).transform.SetParent(transform, false);
			}
			for (int num = transform.childCount - 1; num >= 0; num--)
			{
				if ((Object)(object)componentInChildren == (Object)null || (Object)(object)transform.GetChild(num) != (Object)(object)((Component)componentInChildren).transform)
				{
					Object.DestroyImmediate((Object)(object)((Component)transform.GetChild(num)).gameObject);
				}
			}
			Type[] array = new Type[4]
			{
				typeof(Vagon),
				typeof(ImpactEffect),
				typeof(LODGroup),
				typeof(DisableInPlacementGhost)
			};
			foreach (Type type in array)
			{
				Component[] components = prefab.GetComponents(type);
				for (int j = 0; j < components.Length; j++)
				{
					Object.DestroyImmediate((Object)(object)components[j]);
				}
			}
			Collider[] components2 = prefab.GetComponents<Collider>();
			for (int i = 0; i < components2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components2[i]);
			}
			GameObject root = layout.Root;
			root.transform.SetParent(transform, false);
			root.transform.localPosition = Vector3.zero;
			root.transform.localRotation = Quaternion.identity;
			SetLayer(root, prefab.layer);
			GameObject val = new GameObject("colliders");
			val.transform.SetParent(transform, false);
			val.layer = layer;
			float num2 = layout.FlatFront - layout.FlatBack;
			for (int k = -1; k <= 1; k += 2)
			{
				CapsuleCollider obj = val.AddComponent<CapsuleCollider>();
				obj.direction = 2;
				obj.radius = 0.05f;
				obj.height = num2 + 0.1f;
				obj.center = new Vector3((float)k * layout.RunnerX, 0.13f, (layout.FlatBack + layout.FlatFront) * 0.5f);
				((Collider)obj).sharedMaterial = Slick;
			}
			BoxCollider obj2 = val.AddComponent<BoxCollider>();
			obj2.center = ((Bounds)(ref layout.Hull)).center;
			obj2.size = ((Bounds)(ref layout.Hull)).size;
			((Collider)obj2).sharedMaterial = Slick;
			CapsuleCollider obj3 = val.AddComponent<CapsuleCollider>();
			obj3.direction = 0;
			obj3.center = layout.BowCenter;
			obj3.radius = layout.BowRadius;
			obj3.height = spec.Width;
			((Collider)obj3).sharedMaterial = Slick;
			if ((Object)(object)componentInChildren != (Object)null)
			{
				Transform transform2 = ((Component)componentInChildren).transform;
				for (int num3 = transform2.childCount - 1; num3 >= 0; num3--)
				{
					Object.DestroyImmediate((Object)(object)((Component)transform2.GetChild(num3)).gameObject);
				}
				Component[] components = ((Component)transform2).GetComponents<Component>();
				foreach (Component val2 in components)
				{
					if (val2 is Collider || val2 is MeshRenderer || val2 is MeshFilter)
					{
						Object.DestroyImmediate((Object)(object)val2);
					}
				}
				((Object)transform2).name = "cargo";
				transform2.localPosition = Vector3.zero;
				transform2.localRotation = Quaternion.identity;
				BoxCollider obj4 = ((Component)transform2).gameObject.AddComponent<BoxCollider>();
				obj4.center = ((Bounds)(ref layout.Cargo)).center;
				obj4.size = ((Bounds)(ref layout.Cargo)).size;
				((Collider)obj4).sharedMaterial = Slick;
				componentInChildren.m_name = "$sled_cargo";
				componentInChildren.m_wagon = null;
				componentInChildren.m_rootObjectOverride = prefab.GetComponent<ZNetView>();
				Cfg.CargoOf(spec, out componentInChildren.m_width, out componentInChildren.m_height);
			}
			Rigidbody component = prefab.GetComponent<Rigidbody>();
			component.mass = spec.Mass;
			component.linearDamping = 0f;
			component.angularDamping = 0.8f;
			component.interpolation = (RigidbodyInterpolation)1;
			component.collisionDetectionMode = (CollisionDetectionMode)3;
			WearNTear component2 = prefab.GetComponent<WearNTear>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.m_new = root;
				component2.m_worn = root;
				component2.m_broken = root;
				component2.m_health = spec.Health;
				component2.m_fragmentRoots = null;
				GameObject obj5 = FindPrefab("wood_beam");
				WearNTear val3 = ((obj5 != null) ? obj5.GetComponent<WearNTear>() : null);
				if ((Object)(object)val3 != (Object)null)
				{
					component2.m_destroyedEffect = val3.m_destroyedEffect;
					component2.m_hitEffect = val3.m_hitEffect;
				}
			}
			Sled sled = prefab.AddComponent<Sled>();
			sled.m_specId = spec.Id;
			sled.m_runnerX = layout.RunnerX;
			sled.m_flatBack = layout.FlatBack;
			sled.m_flatFront = layout.FlatFront;
			sled.m_loadSmall = layout.LoadSmall;
			sled.m_loadBig = layout.LoadBig;
			sled.m_tow = MeshKit.Child(transform, "tow", layout.Tow, Quaternion.identity);
			sled.m_seats = (Transform[])(object)new Transform[layout.Seats.Length];
			for (int l = 0; l < layout.Seats.Length; l++)
			{
				Transform val4 = MeshKit.Child(transform, "seat" + l, layout.Seats[l] + new Vector3(0f, 0.08f, 0f) - Sled.PoseHips, Quaternion.identity);
				SledSeat sledSeat = ((Component)val4).gameObject.AddComponent<SledSeat>();
				sledSeat.m_sled = sled;
				sledSeat.m_index = l;
				sled.m_seats[l] = val4;
			}
		}

		private static void SetLayer(GameObject go, int layer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			go.layer = layer;
			foreach (Transform item in go.transform)
			{
				SetLayer(((Component)item).gameObject, layer);
			}
		}

		internal static Sprite RenderIcon(GameObject visual, Quaternion rotation)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			if (GUIManager.IsHeadless())
			{
				return null;
			}
			GameObject val = null;
			try
			{
				val = Object.Instantiate<GameObject>(visual);
				val.transform.position = Vector3.zero;
				val.transform.rotation = Quaternion.identity;
				foreach (Transform item in val.transform)
				{
					Transform val2 = item;
					if (((Object)val2).name.StartsWith("load_", StringComparison.Ordinal))
					{
						((Component)val2).gameObject.SetActive(true);
					}
				}
				return RenderManager.Instance.Render(new RenderRequest(val)
				{
					Rotation = rotation,
					Width = 128,
					Height = 128,
					ParticleSimulationTime = -1f,
					UseCache = false
				});
			}
			catch (Exception ex)
			{
				SleddingPlugin.Log.LogWarning((object)("Icon rendering failed: " + ex.Message));
				return null;
			}
			finally
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)val);
				}
			}
		}

		public static List<RequirementConfig> ParseRecipe(string recipe)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			List<RequirementConfig> list = new List<RequirementConfig>();
			if (string.IsNullOrWhiteSpace(recipe))
			{
				return list;
			}
			string[] array = recipe.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
			foreach (string text in array)
			{
				string[] array2 = text.Split(new char[1] { ':' });
				if (array2.Length == 2 && int.TryParse(array2[1].Trim(), out var result) && result > 0 && array2[0].Trim().Length > 0)
				{
					list.Add(new RequirementConfig(array2[0].Trim(), result, 0, true));
				}
				else
				{
					SleddingPlugin.Log.LogWarning((object)("Ignoring invalid recipe entry '" + text + "'."));
				}
			}
			return list;
		}
	}
	[BepInPlugin("zap.sledding", "Sledding", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class SleddingPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "zap.sledding";

		public const string PluginName = "Sledding";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		public static SleddingPlugin Instance { get; private set; }

		public static string PluginDir { get; private set; }

		public static ManualLogSource Log { get; private set; }

		public static string AssetPath(string fileName)
		{
			return Path.Combine(PluginDir ?? "", "Assets", fileName);
		}

		private void Awake()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			Cfg.Bind(((BaseUnityPlugin)this).Config);
			Lang.Register();
			Pieces.Init();
			_harmony = new Harmony("zap.sledding");
			_harmony.PatchAll(typeof(SleddingPlugin).Assembly);
			SelfTest.TryStart(((Component)this).gameObject);
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace Sledding.Visual
{
	internal static class Effects
	{
		public const string SoftLand = "sfx_snow_hit_transient";

		public const string HardHit = "sfx_cart_hit";

		public const string Splinters = "vfx_SawDust";

		public const string BreakSound = "sfx_wood_destroyed";

		private static Material _snow;

		private static bool _searched;

		public static Material SnowMaterial
		{
			get
			{
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_snow != (Object)null || _searched)
				{
					return _snow;
				}
				if ((Object)(object)ZNetScene.instance == (Object)null)
				{
					return null;
				}
				_searched = true;
				string[] array = new string[3] { "vfx_firetreecut_snow_small", "vfx_firetreecut_snow", "vfx_pinetreecut_snow" };
				foreach (string text in array)
				{
					GameObject prefab = ZNetScene.instance.GetPrefab(text);
					if ((Object)(object)prefab == (Object)null)
					{
						continue;
					}
					ParticleSystemRenderer[] componentsInChildren = prefab.GetComponentsInChildren<ParticleSystemRenderer>(true);
					foreach (ParticleSystemRenderer val in componentsInChildren)
					{
						if ((Object)(object)((Renderer)val).sharedMaterial != (Object)null && (int)val.renderMode == 0)
						{
							_snow = ((Renderer)val).sharedMaterial;
							ManualLogSource log = SleddingPlugin.Log;
							string[] obj = new string[7]
							{
								"Snow spray uses ",
								((Object)_snow).name,
								" (",
								null,
								null,
								null,
								null
							};
							Shader shader = _snow.shader;
							obj[3] = ((shader != null) ? ((Object)shader).name : null);
							obj[4] = ") from ";
							obj[5] = text;
							obj[6] = ".";
							log.LogInfo((object)string.Concat(obj));
							return _snow;
						}
					}
				}
				return null;
			}
		}

		public static void Play(string prefab, Vector3 at)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefab) : null);
				if ((Object)(object)val != (Object)null)
				{
					Object.Instantiate<GameObject>(val, at, Quaternion.identity);
				}
			}
			catch (Exception ex)
			{
				SleddingPlugin.Log.LogDebug((object)("effect " + prefab + ": " + ex.Message));
			}
		}

		public static ParticleSystem Spray(Transform parent, Vector3 local, Material mat)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("snow_spray");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = local;
			val.transform.localRotation = Quaternion.Euler(-28f, 180f, 0f);
			ParticleSystem obj = val.AddComponent<ParticleSystem>();
			obj.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = obj.main;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).playOnAwake = true;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.45f, 0.9f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.8f, 2f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.12f, 0.32f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.96f, 0.97f, 1f, 0.55f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.35f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).maxParticles = 120;
			EmissionModule emission = obj.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 22f;
			((ShapeModule)(ref shape)).radius = 0.04f;
			Fade(obj);
			Renderer(obj, mat);
			obj.Play();
			return obj;
		}

		public static ParticleSystem Puff(Transform parent, Material mat)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0047: 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_0073: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("snow_puff");
			val.transform.SetParent(parent, false);
			ParticleSystem obj = val.AddComponent<ParticleSystem>();
			obj.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = obj.main;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.6f, 1.4f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.8f, 3.2f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.2f, 0.55f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.96f, 0.97f, 1f, 0.6f));
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.25f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).maxParticles = 200;
			EmissionModule emission = obj.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			ShapeModule shape = obj.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)2;
			((ShapeModule)(ref shape)).radius = 0.6f;
			Fade(obj);
			Renderer(obj, mat);
			return obj;
		}

		private static void Fade(ParticleSystem ps)
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val = new Gradient();
			val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(1f, 0.12f),
				new GradientAlphaKey(0.6f, 0.5f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val);
			SizeOverLifetimeModule sizeOverLifetime = ps.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.6f, 1f, 1.6f));
			LimitVelocityOverLifetimeModule limitVelocityOverLifetime = ps.limitVelocityOverLifetime;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).enabled = true;
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).drag = MinMaxCurve.op_Implicit(1.8f);
			((LimitVelocityOverLifetimeModule)(ref limitVelocityOverLifetime)).limit = MinMaxCurve.op_Implicit(100f);
		}

		private static void Renderer(ParticleSystem ps, Material mat)
		{
			ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = mat;
			component.renderMode = (ParticleSystemRenderMode)0;
			component.sortMode = (ParticleSystemSortMode)1;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
		}
	}
	internal static class Mats
	{
		public static Material Wood;

		public static Material DarkWood;

		public static Material Bronze;

		public static Material Silver;

		public static Material Iron;

		public static Material BlackMetal;

		public static Material Leather;

		public static Material DeerHide;

		public static Material WolfPelt;

		public static Material LoxPelt;

		public static Material Rope;

		public static Material Sack;

		private static bool _vanilla;

		private static readonly int Metallic = Shader.PropertyToID("_Metallic");

		private static readonly int Glossiness = Shader.PropertyToID("_Glossiness");

		public static void Init()
		{
			//IL_00ce: 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_0144: 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_0217: 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_01fa: 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_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Expected O, but got Unknown
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			if (_vanilla)
			{
				return;
			}
			Material obj = FindMat("wood_beam", "woodwall");
			Material val = FindMat("darkwood_beam", "DarkWood_mat");
			Material val2 = FindMat("Bronze", "bronze");
			Material val3 = FindMat("Silver", "silverbar");
			Material val4 = FindMat("iron_grate", "metalwall");
			Material val5 = FindMat("LeatherScraps", "leatherscraps");
			Material val6 = FindMat("DeerHide", "deerhide");
			Material val7 = FindMat("WolfPelt", "wolfhide");
			Material val8 = FindMat("LoxPelt", "loxpelt");
			Material val9 = FindMat("Cart", "cart_rope");
			Wood = obj ?? Wood ?? Std("Wood", new Color(0.55f, 0.4f, 0.26f), 0f, 0.1f);
			DarkWood = val ?? DarkWood ?? Std("DarkWood", new Color(0.3f, 0.22f, 0.16f), 0f, 0.1f);
			Bronze = val2 ?? Bronze ?? Std("Bronze", new Color(0.78f, 0.52f, 0.28f), 0.85f, 0.55f);
			Silver = val3 ?? Silver ?? Std("Silver", new Color(0.82f, 0.84f, 0.88f), 0.9f, 0.6f);
			Iron = val4 ?? Iron ?? Std("Iron", new Color(0.32f, 0.32f, 0.33f), 0.8f, 0.4f);
			Leather = (((Object)(object)val5 != (Object)null) ? Opaque(val5, "Leather", Color.white, Leather) : (Leather ?? Std("Leather", new Color(0.36f, 0.22f, 0.12f), 0f, 0.2f)));
			DeerHide = val6 ?? DeerHide ?? Std("DeerHide", new Color(0.55f, 0.4f, 0.28f), 0f, 0.1f);
			WolfPelt = val7 ?? WolfPelt ?? Std("WolfPelt", new Color(0.75f, 0.75f, 0.78f), 0f, 0.05f);
			LoxPelt = val8 ?? LoxPelt ?? Std("LoxPelt", new Color(0.42f, 0.32f, 0.22f), 0f, 0.05f);
			Rope = val9 ?? Rope ?? Std("Rope", new Color(0.62f, 0.52f, 0.36f), 0f, 0.05f);
			if ((Object)(object)val4 != (Object)null)
			{
				if ((Object)(object)BlackMetal == (Object)null || ((Object)BlackMetal).name != "Sled_BlackMetal_v")
				{
					BlackMetal = new Material(val4)
					{
						name = "Sled_BlackMetal_v",
						hideFlags = (HideFlags)32
					};
				}
				BlackMetal.color = new Color(0.22f, 0.23f, 0.25f, 1f);
			}
			else if ((Object)(object)BlackMetal == (Object)null)
			{
				BlackMetal = Std("BlackMetal", new Color(0.16f, 0.17f, 0.18f), 0.7f, 0.35f);
			}
			if ((Object)(object)val5 != (Object)null)
			{
				Sack = Opaque(val5, "Sack", new Color(1.3f, 1.18f, 1f, 1f), Sack);
			}
			else if ((Object)(object)Sack == (Object)null)
			{
				Sack = Std("Sack", new Color(0.52f, 0.4f, 0.26f), 0f, 0.1f);
			}
			_vanilla = (Object)(object)obj != (Object)null && (Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null && (Object)(object)val5 != (Object)null && (Object)(object)val6 != (Object)null && (Object)(object)val7 != (Object)null && (Object)(object)val8 != (Object)null && (Object)(object)val9 != (Object)null;
		}

		private static Material FindMat(string prefabName, string matName)
		{
			GameObject val = null;
			try
			{
				val = PrefabManager.Instance.GetPrefab(prefabName);
			}
			catch (Exception)
			{
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				if ((Object)(object)val2 == (Object)null || val2 is ParticleSystemRenderer)
				{
					continue;
				}
				Material[] sharedMaterials = val2.sharedMaterials;
				foreach (Material val3 in sharedMaterials)
				{
					if (!((Object)(object)val3 == (Object)null) && (((Object)val3).name == matName || ((Object)val3).name.StartsWith(matName + " ", StringComparison.Ordinal)))
					{
						return val3;
					}
				}
			}
			return null;
		}

		private static Material Opaque(Material src, string name, Color tint, Material made)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)made != (Object)null && ((Object)made).name == "Sled_" + name + "_v")
			{
				return made;
			}
			Material obj = Std(name + "_v", Color.white, 0f, 0.12f);
			obj.mainTexture = src.mainTexture;
			obj.mainTextureScale = new Vector2(2f, 2f);
			obj.color = new Color(tint.r * src.color.r, tint.g * src.color.g, tint.b * src.color.b, 1f);
			return obj;
		}

		private static Material Std(string name, Color c, float metallic, float gloss)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			Material val = new Material(Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse"))
			{
				name = "Sled_" + name,
				hideFlags = (HideFlags)32,
				color = c
			};
			if (val.HasProperty(Metallic))
			{
				val.SetFloat(Metallic, metallic);
			}
			if (val.HasProperty(Glossiness))
			{
				val.SetFloat(Glossiness, gloss);
			}
			return val;
		}
	}
	internal sealed class MeshBuilder
	{
		public readonly List<Vector3> Vertices = new List<Vector3>(256);

		public readonly List<Vector3> Normals = new List<Vector3>(256);

		public readonly List<Vector2> UVs = new List<Vector2>(256);

		public readonly List<int> Triangles = new List<int>(512);

		private readonly Stack<Matrix4x4> _stack = new Stack<Matrix4x4>();

		private Matrix4x4 _base = Matrix4x4.identity;

		private Matrix4x4 _local = Matrix4x4.identity;

		private Matrix4x4 _m = Matrix4x4.identity;

		private Matrix4x4 _n = Matrix4x4.identity;

		private bool _flip;

		public bool IsEmpty => Triangles.Count == 0;

		public void SetBase(Matrix4x4 m)
		{
			//IL_0000: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (!(m == _base))
			{
				_base = m;
				Recalc();
			}
		}

		public void Push(Matrix4x4 m)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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)
			_stack.Push(_local);
			_local *= m;
			Recalc();
		}

		public void Push(Vector3 pos, Quaternion rot)
		{
			//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_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Push(Matrix4x4.TRS(pos, rot, Vector3.one));
		}

		public void Pop()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			_local = ((_stack.Count > 0) ? _stack.Pop() : Matrix4x4.identity);
			Recalc();
		}

		private void Recalc()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			_m = _base * _local;
			Matrix4x4 inverse = ((Matrix4x4)(ref _m)).inverse;
			_n = ((Matrix4x4)(ref inverse)).transpose;
			_flip = ((Matrix4x4)(ref _m)).determinant < 0f;
		}

		public int Add(Vector3 p, Vector3 n, Vector2 uv)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			Vertices.Add(((Matrix4x4)(ref _m)).MultiplyPoint3x4(p));
			Vector3 val = ((Matrix4x4)(ref _n)).MultiplyVector(n);
			float magnitude = ((Vector3)(ref val)).magnitude;
			Normals.Add((magnitude > 1E-08f) ? (val / magnitude) : Vector3.up);
			UVs.Add(uv);
			return Vertices.Count - 1;
		}

		public void Tri(int a, int b, int c)
		{
			Triangles.Add(a);
			if (_flip)
			{
				Triangles.Add(c);
				Triangles.Add(b);
			}
			else
			{
				Triangles.Add(b);
				Triangles.Add(c);
			}
		}

		public void Quad(int a, int b, int c, int d)
		{
			Tri(a, b, c);
			Tri(a, c, d);
		}

		public Mesh ToMesh(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
			};
			if (Vertices.Count > 65000)
			{
				val.indexFormat = (IndexFormat)1;
			}
			val.SetVertices(Vertices);
			val.SetNormals(Normals);
			val.SetUVs(0, UVs);
			val.SetTriangles(Triangles, 0, true);
			val.RecalculateTangents();
			return val;
		}

		public void Clear()
		{
			Vertices.Clear();
			Normals.Clear();
			UVs.Clear();
			Triangles.Clear();
		}
	}
	internal sealed class PartSet
	{
		private readonly List<Material> _mats = new List<Material>();

		private readonly List<MeshBuilder> _builders = new List<MeshBuilder>();

		private readonly Stack<Matrix4x4> _stack = new Stack<Matrix4x4>();

		private Matrix4x4 _current = Matrix4x4.identity;

		public MeshBuilder this[Material mat]
		{
			get
			{
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				MeshBuilder meshBuilder = null;
				for (int i = 0; i < _mats.Count; i++)
				{
					if (_mats[i] == mat)
					{
						meshBuilder = _builders[i];
						break;
					}
				}
				if (meshBuilder == null)
				{
					meshBuilder = new MeshBuilder();
					_mats.Add(mat);
					_builders.Add(meshBuilder);
				}
				meshBuilder.SetBase(_current);
				return meshBuilder;
			}
		}

		public void Push(Matrix4x4 m)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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)
			_stack.Push(_current);
			_current *= m;
		}

		public void Push(Vector3 pos, Quaternion rot)
		{
			//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_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Push(Matrix4x4.TRS(pos, rot, Vector3.one));
		}

		public void Push(Vector3 pos, Quaternion rot, Vector3 scale)
		{
			//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_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			Push(Matrix4x4.TRS(pos, rot, scale));
		}

		public void Pop()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			_current = ((_stack.Count > 0) ? _stack.Pop() : Matrix4x4.identity);
		}

		public void Emit(Transform parent, string name)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			for (int i = 0; i < _builders.Count; i++)
			{
				MeshBuilder meshBuilder = _builders[i];
				Material val = _mats[i];
				if (!meshBuilder.IsEmpty)
				{
					string text = (((Object)(object)val != (Object)null) ? ((Object)val).name.Replace("Sled_", "") : "Mat");
					GameObject val2 = new GameObject(name + "_" + text);
					val2.transform.SetParent(parent, false);
					val2.AddComponent<MeshFilter>().sharedMesh = meshBuilder.ToMesh(((Object)val2).name);
					MeshRenderer obj = val2.AddComponent<MeshRenderer>();
					((Renderer)obj).sharedMaterial = val;
					((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
					((Renderer)obj).receiveShadows = true;
				}
			}
			_mats.Clear();
			_builders.Clear();
			_stack.Clear();
			_current = Matrix4x4.identity;
		}
	}
	internal static class MeshKit
	{
		private const float Tau = (float)Math.PI * 2f;

		public static Quaternion AlongX => Quaternion.Euler(0f, 0f, -90f);

		public static Quaternion AlongZ => Quaternion.Euler(90f, 0f, 0f);

		public static void ProfileNormals(IList<Vector2> p, Vector2[] result)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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)
			int count = p.Count;
			for (int i = 0; i < count; i++)
			{
				Vector2 val = Vector2.zero;
				Vector2 val4;
				if (i > 0)
				{
					Vector2 val2 = p[i] - p[i - 1];
					if (((Vector2)(ref val2)).sqrMagnitude > 1E-12f)
					{
						Vector2 val3 = val;
						val4 = new Vector2(val2.y, 0f - val2.x);
						val = val3 + ((Vector2)(ref val4)).normalized;
					}
				}
				if (i < count - 1)
				{
					Vector2 val5 = p[i + 1] - p[i];
					if (((Vector2)(ref val5)).sqrMagnitude > 1E-12f)
					{
						Vector2 val6 = val;
						val4 = new Vector2(val5.y, 0f - val5.x);
						val = val6 + ((Vector2)(ref val4)).normalized;
					}
				}
				result[i] = (Vector2)((((Vector2)(ref val)).sqrMagnitude > 1E-12f) ? ((Vector2)(ref val)).normalized : new Vector2(1f, 0f));
			}
		}

		public static void Lathe(MeshBuilder mb, IList<Vector2> prof, int seg, float uTiles = 1f, float vPerMeter = 1f, IList<Vector2> normals = null, bool swapUV = false)
		{
			//IL_0027: 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_005d: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_0144: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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)
			int count = prof.Count;
			if (count < 2 || seg < 3)
			{
				return;
			}
			Vector2[] array = (Vector2[])(object)new Vector2[count];
			if (normals != null)
			{
				for (int i = 0; i < count; i++)
				{
					array[i] = normals[i];
				}
			}
			else
			{
				ProfileNormals(prof, array);
			}
			float[] array2 = new float[count];
			for (int j = 1; j < count; j++)
			{
				array2[j] = array2[j - 1] + Vector2.Distance(prof[j], prof[j - 1]);
			}
			int num = seg + 1;
			int num2 = -1;
			Vector2 val = default(Vector2);
			for (int k = 0; k < count; k++)
			{
				for (int l = 0; l <= seg; l++)
				{
					float num3 = (float)l * ((float)Math.PI * 2f / (float)seg);
					float num4 = Mathf.Cos(num3);
					float num5 = Mathf.Sin(num3);
					((Vector2)(ref val))..ctor((float)l / (float)seg * uTiles, array2[k] * vPerMeter);
					if (swapUV)
					{
						((Vector2)(ref val))..ctor(val.y, val.x);
					}
					int num6 = mb.Add(new Vector3(prof[k].x * num4, prof[k].y, prof[k].x * num5), new Vector3(array[k].x * num4, array[k].y, array[k].x * num5), val);
					if (num2 < 0)
					{
						num2 = num6;
					}
				}
			}
			for (int m = 0; m < count - 1; m++)
			{
				Vector2 val2 = prof[m + 1] - prof[m];
				if (!(((Vector2)(ref val2)).sqrMagnitude < 1E-12f) && (!(prof[m].x <= 0f) || !(prof[m + 1].x <= 0f)))
				{
					for (int n = 0; n < seg; n++)
					{
						int num7 = num2 + m * num + n;
						int d = num7 + 1;
						int num8 = num7 + num;
						int c = num8 + 1;
						mb.Quad(num7, num8, c, d);
					}
				}
			}
		}

		public static void LatheX(MeshBuilder mb, Vector3 origin, IList<Vector2> prof, int seg, float uTiles = 1f, float vPerMeter = 1f, bool swapUV = false)
		{
			//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)
			mb.Push(origin, AlongX);
			Lathe(mb, prof, seg, uTiles, vPerMeter, null, swapUV);
			mb.Pop();
		}

		public static void LatheZ(MeshBuilder mb, Vector3 origin, IList<Vector2> prof, int seg, float uTiles = 1f, float vPerMeter = 1f, bool swapUV = false)
		{
			//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)
			mb.Push(origin, AlongZ);
			Lathe(mb, prof, seg, uTiles, vPerMeter, null, swapUV);
			mb.Pop();
		}

		public static float Tiles(float radius, float perMeter)
		{
			return Mathf.Max(1f, Mathf.Round((float)Math.PI * 2f * radius * perMeter));
		}

		public static void Arc(List<Vector2> list, Vector2 center, float radius, float fromDeg, float toDeg, int steps)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i <= steps; i++)
			{
				float num = Mathf.Lerp(fromDeg, toDeg, (float)i / (float)steps) * ((float)Math.PI / 180f);
				list.Add(center + new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * radius);
			}
		}

		public static void Cylinder(MeshBuilder mb, Vector3 a, Vector3 b, float ra, float rb, int seg, bool capA = true, bool capB = true, float uTiles = 1f, float vPerMeter = 1f, bool swapUV = false)
		{
			//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_0051: 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_002f: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = b - a;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (!(magnitude < 1E-06f))
			{
				List<Vector2> list = new List<Vector2>(6);
				if (capA)
				{
					list.Add(new Vector2(0f, 0f));
					list.Add(new Vector2(ra, 0f));
				}
				list.Add(new Vector2(ra, 0f));
				list.Add(new Vector2(rb, magnitude));
				if (capB)
				{
					list.Add(new Vector2(rb, magnitude));
					list.Add(new Vector2(0f, magnitude));
				}
				mb.Push(a, Quaternion.FromToRotation(Vector3.up, val / magnitude));
				Lathe(mb, list, seg, uTiles, vPerMeter, null, swapUV);
				mb.Pop();
			}
		}

		public static void Cylinder(MeshBuilder mb, Vector3 a, Vector3 b, float r, int seg, bool caps = true, float uTiles = 1f, float vPerMeter = 1f)
		{
			//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)
			Cylinder(mb, a, b, r, r, seg, caps, caps, uTiles, vPerMeter);
		}

		public static void Sphere(MeshBuilder mb, Vector3 c, float r, int seg = 12, int rings = 8)
		{
			//IL_0001: 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_000a: Unknown result type (might be due to invalid IL or missing references)
			Ellipsoid(mb, c, new Vector3(r, r, r), Quaternion.identity, seg, rings);
		}

		public static void Ellipsoid(MeshBuilder mb, Vector3 c, Vector3 radii, Quaternion rot, int seg = 12, int rings = 8)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Vector2[] array = (Vector2[])(object)new Vector2[rings + 1];
			Vector2[] array2 = (Vector2[])(object)new Vector2[rings + 1];
			for (int i = 0; i <= rings; i++)
			{
				float num = (float)i / (float)rings * (float)Math.PI;
				array2[i] = new Vector2(Mathf.Sin(num), 0f - Mathf.Cos(num));
				array[i] = array2[i];
			}
			mb.Push(Matrix4x4.TRS(c, rot, radii));
			Lathe(mb, array, seg, 1f, 0.5f, array2);
			mb.Pop();
		}

		public static void Torus(MeshBuilder mb, Vector3 c, Quaternion rot, float majorR, float minorR, int seg, int tubeSeg, float uTiles = 1f, float vPerMeter = 1f)
		{
			//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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Vector2[] array = (Vector2[])(object)new Vector2[tubeSeg + 1];
			Vector2[] array2 = (Vector2[])(object)new Vector2[tubeSeg + 1];
			for (int i = 0; i <= tubeSeg; i++)
			{
				float num = -(float)Math.PI + (float)i * ((float)Math.PI * 2f) / (float)tubeSeg;
				array2[i] = new Vector2(Mathf.Cos(num), Mathf.Sin(num));
				array[i] = new Vector2(majorR, 0f) + array2[i] * minorR;
			}
			mb.Push(c, rot);
			Lathe(mb, array, seg, uTiles, vPerMeter, array2);
			mb.Pop();
		}

		public static void Box(MeshBuilder mb, Vector3 center, Vector3 size, Quaternion rot, float uvPerMeter = 2f)
		{
			//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_0008: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00b6: 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_00da: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_0115: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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)
			mb.Push(center, rot);
			Vector3 val = size * 0.5f;
			int num = ((!(size.x >= size.y) || !(size.x >= size.z)) ? ((size.y >= size.z) ? 1 : 2) : 0);
			for (int i = 0; i < 3; i++)
			{
				for (int j = -1; j <= 1; j += 2)
				{
					int num2 = (i + 1) % 3;
					int num3 = (i + 2) % 3;
					if (num3 == num)
					{
						int num4 = num2;
						num2 = num3;
						num3 = num4;
					}
					Vector3 val2 = Axis(i) * (float)j;
					Vector3 val3 = val2 * ((Vector3)(ref val))[i];
					Vector3 val4 = Axis(num2) * ((Vector3)(ref val))[num2];
					Vector3 val5 = Axis(num3) * ((Vector3)(ref val))[num3];
					float num5 = ((Vector3)(ref val))[num2] * uvPerMeter;
					float num6 = ((Vector3)(ref val))[num3] * uvPerMeter;
					FlatQuad(mb, val3 - val4 - val5, val3 - val4 + val5, val3 + val4 + val5, val3 + val4 - val5, val2, new Vector2(0f - num5, 0f - num6), new Vector2(0f - num5, num6), new Vector2(num5, num6), new Vector2(num5, 0f - num6));
				}
			}
			mb.Pop();
		}

		private static Vector3 Axis(int k)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return (Vector3)(k switch
			{
				1 => Vector3.up, 
				0 => Vector3.right, 
				_ => Vector3.forward, 
			});
		}

		public static void Disc(MeshBuilder mb, Vector3 c, float r, int seg, float uvRadius = 0.5f, float uvRotDeg = 0f)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			float num = Mathf.Cos(uvRotDeg * ((float)Math.PI / 180f));
			float num2 = Mathf.Sin(uvRotDeg * ((float)Math.PI / 180f));
			int a = mb.Add(c, Vector3.up, new Vector2(0.5f, 0.5f));
			int num3 = -1;
			Vector2 uv = default(Vector2);
			for (int i = 0; i <= seg; i++)
			{
				float num4 = (float)i * ((float)Math.PI * 2f) / (float)seg;
				float num5 = Mathf.Cos(num4);
				float num6 = Mathf.Sin(num4);
				((Vector2)(ref uv))..ctor(0.5f + uvRadius * (num5 * num - num6 * num2), 0.5f + uvRadius * (num5 * num2 + num6 * num));
				int num7 = mb.Add(c + new Vector3(num5 * r, 0f, num6 * r), Vector3.up, uv);
				if (num3 < 0)
				{
					num3 = num7;
				}
			}
			for (int j = 0; j < seg; j++)
			{
				mb.Tri(a, num3 + j + 1, num3 + j);
			}
		}

		public static void Sector(MeshBuilder mb, float rIn, float rOut, float phi0Deg, float phi1Deg, float thickness, int seg, float uvPerMeter)
		{
			//IL_0058: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00a0: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_0178: 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_017e: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_0129: 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_0132: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00c4: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: 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_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: 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_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: 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_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: 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_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			float num = thickness * 0.5f;
			float num2 = phi0Deg * ((float)Math.PI / 180f);
			float num3 = phi1Deg * ((float)Math.PI / 180f);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, 0f, num);
			Vector3 val4 = default(Vector3);
			for (int i = 0; i < seg; i++)
			{
				float num4 = Mathf.Lerp(num2, num3, (float)i / (float)seg);
				float num5 = Mathf.Lerp(num2, num3, (float)(i + 1) / (float)seg);
				Vector3 val2 = SectorDir(num4);
				Vector3 val3 = SectorDir(num5);
				for (int j = -1; j <= 1; j += 2)
				{
					((Vector3)(ref val4))..ctor(0f, 0f, (float)j);
					Vector3 val5 = val * (float)j;
					Vector3 val6 = val2 * rOut + val5;
					Vector3 val7 = val3 * rOut + val5;
					if (rIn <= 1E-05f)
					{
						TriN(mb, val5, val6, val7, val4, val4, val4, PlanarXY(val5, uvPerMeter), PlanarXY(val6, uvPerMeter), PlanarXY(val7, uvPerMeter), val4);
						continue;
					}
					Vector3 val8 = val2 * rIn + val5;
					Vector3 val9 = val3 * rIn + val5;
					FlatQuad(mb, val8, val6, val7, val9, val4, PlanarXY(val8, uvPerMeter), PlanarXY(val6, uvPerMeter), PlanarXY(val7, uvPerMeter), PlanarXY(val9, uvPerMeter));
				}
				float num6 = num * uvPerMeter;
				float num7 = num4 * rOut * uvPerMeter;
				float num8 = num5 * rOut * uvPerMeter;
				QuadN(mb, val2 * rOut - val, val2 * rOut + val, val3 * rOut + val, val3 * rOut - val, val2, val2, val3, val3, new Vector2(num7, 0f - num6), new Vector2(num7, num6), new Vector2(num8, num6), new Vector2(num8, 0f - num6), val2 + val3);
				if (rIn > 1E-05f)
				{
					float num9 = num4 * rIn * uvPerMeter;
					float num10 = num5 * rIn * uvPerMeter;
					QuadN(mb, val2 * rIn - val, val2 * rIn + val, val3 * rIn + val, val3 * rIn - val, -val2, -val2, -val3, -val3, new Vector2(num9, 0f - num6), new Vector2(num9, num6), new Vector2(num10, num6), new Vector2(num10, 0f - num6), -(val2 + val3));
				}
			}
			for (int k = 0; k < 2; k++)
			{
				float num11 = ((k == 0) ? num2 : num3);
				Vector3 val10 = SectorDir(num11);
				Vector3 n = new Vector3(Mathf.Cos(num11), Mathf.Sin(num11), 0f) * ((k == 0) ? (-1f) : 1f);
				float num12 = rIn * uvPerMeter;
				float num13 = rOut * uvPerMeter;
				float num14 = num * uvPerMeter;
				FlatQuad(mb, val10 * rIn - val, val10 * rOut - val, val10 * rOut + val, val10 * rIn + val, n, new Vector2(num12, 0f - num14), new Vector2(num13, 0f - num14), new Vector2(num13, num14), new Vector2(num12, num14));
			}
		}

		public static Vector3 SectorDir(float phiRad)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(Mathf.Sin(phiRad), 0f - Mathf.Cos(phiRad), 0f);
		}

		private static Vector2 PlanarXY(Vector3 p, float s)
		{
			//IL_0000: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(p.x * s, p.y * s);
		}

		public static void ExtrudeXZ(MeshBuilder mb, IList<Vector2> poly, float y0, float y1, float uvPerMeter = 20f)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_010e: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_017d: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: 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_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: 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_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)