Decompiled source of EscalierColimacon v0.11.0

BepInEx/plugins/EscalierColimacon/EscalierColimacon.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EscalierColimacon")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EscalierColimacon")]
[assembly: AssemblyTitle("EscalierColimacon")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 EscalierColimacon
{
	[BepInPlugin("fr.dessouille.valheim.escaliercolimacon", "Escalier en colimacon", "0.11.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "fr.dessouille.valheim.escaliercolimacon";

		public const string PluginName = "Escalier en colimacon";

		public const string PluginVersion = "0.11.0";

		private const int StepCount = 8;

		private const float QuarterTurn = 90f;

		private const float Rise = 2f;

		private const float InnerRadius = 0.115f;

		private const float OuterRadius = 2f;

		private const float CentralPoleDiameter = 0.25f;

		private const float RailingRadius = 2f;

		private const float FloorGridRadius = 2f;

		private const float StepThickness = 0.18f;

		private const int CentralAssistStepCount = 16;

		private const float CentralAssistOuterRadius = 1.42f;

		private const float CentralAssistStepThickness = 0.14f;

		private const float WalkingRampInnerRadius = 1.35f;

		private const float WalkingRampOuterRadius = 2.06f;

		private const float WalkingRampThickness = 0.1f;

		private const float WalkingRampSurfaceOffset = 0.015f;

		private const float RailingHeight = 1f;

		private const float RailingThickness = 0.11f;

		private const float CurvedRailingCollisionOffset = 0.1f;

		private const float CurvedRailingCollisionThickness = 0.06f;

		private const float CurvedRailingPostCollisionThickness = 0.1f;

		private const float StraightRailingLength = 2f;

		private void Awake()
		{
			PrefabManager.OnVanillaPrefabsAvailable += RegisterSpiralStair;
		}

		private void OnDestroy()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterSpiralStair;
		}

		private void RegisterSpiralStair()
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: 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_022b: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterSpiralStair;
			if ((Object)(object)PrefabManager.Instance.GetPrefab("wood_stair") == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Prefab wood_stair introuvable; l'escalier en colimacon n'a pas ete ajoute.");
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_spiral_stair_wood", "wood_stair");
			GameObject prefab = PrefabManager.Instance.GetPrefab("wood_floor");
			GameObject prefab2 = PrefabManager.Instance.GetPrefab("wood_beam");
			GameObject prefab3 = PrefabManager.Instance.GetPrefab("wood_pole2");
			if ((Object)(object)prefab3 == (Object)null)
			{
				prefab3 = PrefabManager.Instance.GetPrefab("wood_pole");
			}
			if (!TryGetNativeWoodRendering(prefab, out var material, out var properties, out var uvBounds))
			{
				material = CreateWoodMaterial();
				properties = null;
				((Vector4)(ref uvBounds))..ctor(0f, 0f, 1f, 1f);
			}
			if ((Object)(object)material == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Impossible de creer le materiau bois; la piece n'a pas ete enregistree.");
				return;
			}
			DisableVanillaGeometry(val);
			RemoveVanillaSnapPoints(val);
			BuildGeometry(val.transform, material, properties, uvBounds, prefab2, prefab3, 1f);
			AddSnapPoint(val.transform, "_snappoint_bottom", PointOnCircle(0f, 2f, 0f), 0f);
			AddSnapPoint(val.transform, "_snappoint_top", PointOnCircle(90f, 2f, 2f), 90f);
			AddSnapPoint(val.transform, "_snappoint_center_bottom", new Vector3(0f, 0f, 0f), 0f);
			AddSnapPoint(val.transform, "_snappoint_center_top", new Vector3(0f, 2f, 0f), 90f);
			AddSnapPoint(val.transform, "_snappoint_railing_module", PointOnCircle(5.625f, 2f, 0.25f), 5.625f);
			PieceConfig val2 = new PieceConfig
			{
				Name = "Escalier en colimaçon",
				Description = "Quart de tour de 2 m en bois autour d'un poteau central. Empilez quatre modules pour un tour complet.",
				Icon = CreateRenderedIcon(val, "escalier", -30f),
				PieceTable = PieceTables.Hammer,
				Category = PieceCategories.Building,
				CraftingStation = CraftingStations.Workbench
			};
			val2.AddRequirement("Wood", 4, true);
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Escalier en colimacon enregistre dans le marteau.");
			RegisterRailing(prefab2, prefab3);
			RegisterStraightRailing(prefab2, prefab3);
			RegisterShortStraightRailing(prefab2, prefab3);
			RegisterCornerRailing(prefab2, prefab3);
			RegisterMirroredStair(material, properties, uvBounds, prefab2, prefab3);
			RegisterMirroredRailing(prefab2, prefab3);
			RegisterLanding(prefab);
		}

		private void RegisterRailing(GameObject woodBeam, GameObject woodPole)
		{
			//IL_0070: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0103: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			if ((Object)(object)woodBeam == (Object)null || (Object)(object)woodPole == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Poutre ou poteau Valheim introuvable; la rambarde n'a pas ete ajoutee.");
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_spiral_stair_railing_wood", "wood_beam");
			DisableVanillaGeometry(val);
			RemoveVanillaSnapPoints(val);
			BuildRailing(val.transform, woodBeam, woodPole, 1f);
			AddSnapPoint(val.transform, "_snappoint_railing_anchor", PointOnCircle(5.625f, 2f, 0.25f), 5.625f);
			AddSnapPoint(val.transform, "_snappoint_railing_start", PointOnCircle(0f, 2f, 1f), 0f);
			AddSnapPoint(val.transform, "_snappoint_railing_end", PointOnCircle(90f, 2f, 3f), 90f);
			PieceConfig val2 = new PieceConfig
			{
				Name = "Rambarde d'escalier en colimaçon",
				Description = "Rambarde extérieure complète adaptée à l'escalier en colimaçon.",
				Icon = CreateRenderedIcon(val, "rambarde", 35f),
				PieceTable = PieceTables.Hammer,
				Category = PieceCategories.Building,
				CraftingStation = CraftingStations.Workbench
			};
			val2.AddRequirement("Wood", 2, true);
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Rambarde d'escalier en colimacon enregistree dans le marteau.");
		}

		private void RegisterMirroredStair(Material woodMaterial, MaterialPropertyBlock woodProperties, Vector4 woodUvBounds, GameObject woodBeam, GameObject woodPole)
		{
			//IL_0029: 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_007b: 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_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_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)
			//IL_0106: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_spiral_stair_wood_mirrored", "wood_stair");
			DisableVanillaGeometry(val);
			RemoveVanillaSnapPoints(val);
			BuildGeometry(val.transform, woodMaterial, woodProperties, woodUvBounds, woodBeam, woodPole, -1f);
			AddSnapPoint(val.transform, "_snappoint_bottom", PointOnCircle(0f, 2f, 0f), 0f);
			AddSnapPoint(val.transform, "_snappoint_top", PointOnCircle(-90f, 2f, 2f), -90f);
			AddSnapPoint(val.transform, "_snappoint_center_bottom", Vector3.zero, 0f);
			AddSnapPoint(val.transform, "_snappoint_center_top", new Vector3(0f, 2f, 0f), -90f);
			AddSnapPoint(val.transform, "_snappoint_railing_module", PointOnCircle(-5.625f, 2f, 0.25f), -5.625f);
			PieceConfig val2 = new PieceConfig
			{
				Name = "Escalier en colimaçon inversé",
				Description = "Version tournant dans le sens opposé du quart de tour en bois de 2 m.",
				Icon = CreateRenderedIcon(val, "escalier inverse", 30f),
				PieceTable = PieceTables.Hammer,
				Category = PieceCategories.Building,
				CraftingStation = CraftingStations.Workbench
			};
			val2.AddRequirement("Wood", 4, true);
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2));
		}

		private void RegisterMirroredRailing(GameObject woodBeam, GameObject woodPole)
		{
			//IL_0070: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0103: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			if ((Object)(object)woodBeam == (Object)null || (Object)(object)woodPole == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Poutre ou poteau Valheim introuvable; la rambarde inversee n'a pas ete ajoutee.");
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_spiral_stair_railing_wood_mirrored", "wood_beam");
			DisableVanillaGeometry(val);
			RemoveVanillaSnapPoints(val);
			BuildRailing(val.transform, woodBeam, woodPole, -1f);
			AddSnapPoint(val.transform, "_snappoint_railing_anchor", PointOnCircle(-5.625f, 2f, 0.25f), -5.625f);
			AddSnapPoint(val.transform, "_snappoint_railing_start", PointOnCircle(0f, 2f, 1f), 0f);
			AddSnapPoint(val.transform, "_snappoint_railing_end", PointOnCircle(-90f, 2f, 3f), -90f);
			PieceConfig val2 = new PieceConfig
			{
				Name = "Rambarde d'escalier inversée",
				Description = "Rambarde courbe adaptée à l'escalier en colimaçon inversé.",
				Icon = CreateRenderedIcon(val, "rambarde inversee", -35f),
				PieceTable = PieceTables.Hammer,
				Category = PieceCategories.Building,
				CraftingStation = CraftingStations.Workbench
			};
			val2.AddRequirement("Wood", 2, true);
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2));
		}

		private Sprite CreateRenderedIcon(GameObject prefab, string pieceName, float yawOffset)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_001d: 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_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_002f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = prefab.transform.position;
			try
			{
				if (TryGetVisualBounds(prefab, out var bounds))
				{
					Transform transform = prefab.transform;
					transform.position += position - ((Bounds)(ref bounds)).center;
				}
				Quaternion val = RenderManager.IsometricRotation * Quaternion.Euler(0f, yawOffset, 0f);
				Sprite obj = RenderManager.Instance.Render(prefab, val);
				if ((Object)(object)obj == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("L'icone rendue de la piece " + pieceName + " est vide; l'icone heritee sera utilisee."));
				}
				return obj;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Impossible de generer l'icone de la piece " + pieceName + ": " + ex.Message));
				return null;
			}
			finally
			{
				prefab.transform.position = position;
			}
		}

		private void RegisterStraightRailing(GameObject woodBeam, GameObject woodPole)
		{
			//IL_0074: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			if ((Object)(object)woodBeam == (Object)null || (Object)(object)woodPole == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Poutre ou poteau Valheim introuvable; la rambarde droite n'a pas ete ajoutee.");
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_straight_floor_railing_wood", "wood_beam");
			DisableVanillaGeometry(val);
			RemoveVanillaSnapPoints(val);
			BuildStraightRailing(val.transform, woodBeam, woodPole, 2f, addMiddlePost: true);
			float num = 1f;
			AddSnapPoint(val.transform, "_snappoint_floor_left", new Vector3(0f - num, 0f, 0f), 0f);
			AddSnapPoint(val.transform, "_snappoint_floor_right", new Vector3(num, 0f, 0f), 180f);
			AddSnapPoint(val.transform, "_snappoint_floor_middle", Vector3.zero, 0f);
			AddSnapPoint(val.transform, "_snappoint_straight_railing_left", new Vector3(0f - num, 1f, 0f), 0f);
			AddSnapPoint(val.transform, "_snappoint_straight_railing_right", new Vector3(num, 1f, 0f), 180f);
			PieceConfig val2 = new PieceConfig
			{
				Name = "Rambarde droite en bois",
				Description = "Rambarde droite de 2 m adaptée au bord d'un plancher en bois.",
				Icon = CreateRenderedIcon(val, "rambarde droite", 25f),
				PieceTable = PieceTables.Hammer,
				Category = PieceCategories.Building,
				CraftingStation = CraftingStations.Workbench
			};
			val2.AddRequirement("Wood", 2, true);
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Rambarde droite en bois enregistree dans le marteau.");
		}

		private void RegisterShortStraightRailing(GameObject woodBeam, GameObject woodPole)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0082: 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_00a4: 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_00bb: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			if ((Object)(object)woodBeam == (Object)null || (Object)(object)woodPole == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Poutre ou poteau Valheim introuvable; la rambarde de 1 m n'a pas ete ajoutee.");
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_straight_floor_railing_wood_1m", "wood_beam");
			DisableVanillaGeometry(val);
			RemoveVanillaSnapPoints(val);
			BuildStraightRailing(val.transform, woodBeam, woodPole, 1f, addMiddlePost: false);
			AddStraightRailingSnapPoints(val.transform, 1f);
			PieceConfig val2 = new PieceConfig
			{
				Name = "Rambarde droite en bois 1 m",
				Description = "Petite rambarde droite pour fermer un espace d'un metre.",
				Icon = CreateRenderedIcon(val, "rambarde droite 1 m", 25f),
				PieceTable = PieceTables.Hammer,
				Category = PieceCategories.Building,
				CraftingStation = CraftingStations.Workbench
			};
			val2.AddRequirement("Wood", 1, true);
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2));
		}

		private void RegisterCornerRailing(GameObject woodBeam, GameObject woodPole)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_0114: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			if ((Object)(object)woodBeam == (Object)null || (Object)(object)woodPole == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Poutre ou poteau Valheim introuvable; l'angle de rambarde n'a pas ete ajoute.");
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_corner_floor_railing_wood", "wood_beam");
			DisableVanillaGeometry(val);
			RemoveVanillaSnapPoints(val);
			BuildCornerRailing(val.transform, woodBeam, woodPole);
			AddSnapPoint(val.transform, "_snappoint_corner_base", Vector3.zero, 0f);
			AddSnapPoint(val.transform, "_snappoint_corner_x_base", new Vector3(1f, 0f, 0f), 180f);
			AddSnapPoint(val.transform, "_snappoint_corner_z_base", new Vector3(0f, 0f, 1f), 90f);
			AddSnapPoint(val.transform, "_snappoint_corner_x_top", new Vector3(1f, 1f, 0f), 180f);
			AddSnapPoint(val.transform, "_snappoint_corner_z_top", new Vector3(0f, 1f, 1f), 90f);
			PieceConfig val2 = new PieceConfig
			{
				Name = "Angle de rambarde en bois 90°",
				Description = "Angle de rambarde de 1 m par 1 m pour les coins de plancher.",
				Icon = CreateRenderedIcon(val, "angle de rambarde", -20f),
				PieceTable = PieceTables.Hammer,
				Category = PieceCategories.Building,
				CraftingStation = CraftingStations.Workbench
			};
			val2.AddRequirement("Wood", 2, true);
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2));
		}

		private void RegisterLanding(GameObject woodFloor)
		{
			//IL_0049: 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_009b: 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_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_00e3: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			if ((Object)(object)woodFloor == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Prefab wood_floor introuvable; le palier n'a pas ete ajoute.");
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_spiral_stair_landing_wood", "wood_floor");
			AddSnapPoint(val.transform, "_snappoint_landing_north", new Vector3(0f, 0f, 1f), 0f);
			AddSnapPoint(val.transform, "_snappoint_landing_south", new Vector3(0f, 0f, -1f), 180f);
			AddSnapPoint(val.transform, "_snappoint_landing_east", new Vector3(1f, 0f, 0f), 90f);
			AddSnapPoint(val.transform, "_snappoint_landing_west", new Vector3(-1f, 0f, 0f), -90f);
			PieceConfig val2 = new PieceConfig
			{
				Name = "Palier pour escalier en colimaçon",
				Description = "Plancher en bois de 2 m avec accroches centrales adaptées au sommet de l'escalier.",
				Icon = CreateRenderedIcon(val, "palier", -15f),
				PieceTable = PieceTables.Hammer,
				Category = PieceCategories.Building,
				CraftingStation = CraftingStations.Workbench
			};
			val2.AddRequirement("Wood", 2, true);
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val2));
		}

		private static void AddStraightRailingSnapPoints(Transform root, float length)
		{
			//IL_001a: 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_004f: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			float num = length * 0.5f;
			AddSnapPoint(root, "_snappoint_floor_left", new Vector3(0f - num, 0f, 0f), 0f);
			AddSnapPoint(root, "_snappoint_floor_right", new Vector3(num, 0f, 0f), 180f);
			AddSnapPoint(root, "_snappoint_floor_middle", Vector3.zero, 0f);
			AddSnapPoint(root, "_snappoint_railing_left", new Vector3(0f - num, 1f, 0f), 0f);
			AddSnapPoint(root, "_snappoint_railing_right", new Vector3(num, 1f, 0f), 180f);
		}

		private static void BuildStraightRailing(Transform root, GameObject woodBeam, GameObject woodPole, float length, bool addMiddlePost)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0083: 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)
			GameObject val = new GameObject("StraightRailingGeometry");
			val.transform.SetParent(root, false);
			val.layer = ((Component)root).gameObject.layer;
			float num = length * 0.5f;
			CreateStraightRailingPost(val.transform, woodPole, 1, 0f - num);
			if (addMiddlePost)
			{
				CreateStraightRailingPost(val.transform, woodPole, 2, 0f);
			}
			CreateStraightRailingPost(val.transform, woodPole, addMiddlePost ? 3 : 2, num);
			CreateRailingSegment(val.transform, woodBeam, "MainCouranteDroite", new Vector3(0f - num, 1f, 0f), new Vector3(num, 1f, 0f));
		}

		private static void BuildCornerRailing(Transform root, GameObject woodBeam, GameObject woodPole)
		{
			//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_0028: 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_003a: 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_005b: 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_007c: 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_00ab: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CornerRailingGeometry");
			val.transform.SetParent(root, false);
			val.layer = ((Component)root).gameObject.layer;
			CreateStraightRailingPostAt(val.transform, woodPole, 1, Vector3.zero);
			CreateStraightRailingPostAt(val.transform, woodPole, 2, new Vector3(1f, 0f, 0f));
			CreateStraightRailingPostAt(val.transform, woodPole, 3, new Vector3(0f, 0f, 1f));
			CreateRailingSegment(val.transform, woodBeam, "MainCouranteAngleX", new Vector3(0f, 1f, 0f), new Vector3(1f, 1f, 0f));
			CreateRailingSegment(val.transform, woodBeam, "MainCouranteAngleZ", new Vector3(0f, 1f, 0f), new Vector3(0f, 1f, 1f));
		}

		private static void CreateStraightRailingPost(Transform parent, GameObject woodPole, int number, float xPosition)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			CreateStraightRailingPostAt(parent, woodPole, number, new Vector3(xPosition, 0f, 0f));
		}

		private static void CreateStraightRailingPostAt(Transform parent, GameObject woodPole, int number, Vector3 basePosition)
		{
			//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_000b: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0070: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = basePosition + Vector3.up * 0.5f;
			GameObject obj = CloneVanillaVisual(woodPole, parent, $"PoteauDroit_{number:00}");
			obj.transform.localPosition = val;
			obj.transform.localRotation = Quaternion.identity;
			obj.transform.localScale = new Vector3(0.52f, 0.5f, 0.52f);
			obj.SetActive(true);
			CenterVisualOn(obj, parent.TransformPoint(val));
			GameObject val2 = new GameObject($"CollisionPoteauDroit_{number:00}");
			val2.transform.SetParent(parent, false);
			val2.layer = ((Component)parent).gameObject.layer;
			val2.transform.localPosition = val;
			val2.AddComponent<BoxCollider>().size = new Vector3(0.15f, 1f, 0.15f);
		}

		private static bool TryGetVisualBounds(GameObject target, out Bounds bounds)
		{
			//IL_0001: 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_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)
			bounds = default(Bounds);
			bool flag = false;
			Renderer[] componentsInChildren = target.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (val.enabled)
				{
					if (!flag)
					{
						bounds = val.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val.bounds);
					}
				}
			}
			return flag;
		}

		private static void BuildRailing(Transform root, GameObject woodBeam, GameObject woodPole, float turnDirection)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_013a: 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_0150: 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_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_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("RailingGeometry");
			val.transform.SetParent(root, false);
			val.layer = ((Component)root).gameObject.layer;
			float num = 0.25f;
			float num2 = 0f;
			float num3 = 90f * turnDirection;
			int[] array = new int[3] { 0, 4, 8 };
			foreach (int num4 in array)
			{
				float angle = Mathf.Lerp(num2, num3, (float)num4 / 8f);
				float baseHeight = Mathf.Min((float)(num4 + 1) * num, 2f);
				float num5 = Mathf.Lerp(0f, 2f, (float)num4 / 8f);
				CreateRailingPost(val.transform, woodPole, num4 + 1, angle, 2f, baseHeight, num5 + 1f);
			}
			for (int j = 0; j < 8; j++)
			{
				float degrees = Mathf.Lerp(num2, num3, (float)j / 8f);
				float degrees2 = Mathf.Lerp(num2, num3, (float)(j + 1) / 8f);
				float num6 = Mathf.Lerp(0f, 2f, (float)j / 8f);
				float num7 = Mathf.Lerp(0f, 2f, (float)(j + 1) / 8f);
				Vector3 visualStart = PointOnCircle(degrees, 2f, num6 + 1f);
				Vector3 visualEnd = PointOnCircle(degrees2, 2f, num7 + 1f);
				float radius = 2.1f;
				Vector3 collisionStart = PointOnCircle(degrees, radius, num6 + 1f);
				Vector3 collisionEnd = PointOnCircle(degrees2, radius, num7 + 1f);
				CreateRailingSegment(val.transform, woodBeam, $"MainCourante_{j + 1:00}", visualStart, visualEnd, collisionStart, collisionEnd, 0.06f);
			}
		}

		private static void CreateRailingPost(Transform parent, GameObject woodPole, int number, float angle, float radius, float baseHeight, float topHeight)
		{
			//IL_001d: 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_0040: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(topHeight - baseHeight, 0.28f);
			Vector3 val = PointOnCircle(angle, radius, baseHeight + num * 0.5f);
			GameObject obj = CloneVanillaVisual(woodPole, parent, $"PoteauRambarde_{number:00}");
			obj.transform.localPosition = val;
			obj.transform.localRotation = Quaternion.identity;
			obj.transform.localScale = new Vector3(0.52f, num / 2f, 0.52f);
			obj.SetActive(true);
			CenterVisualOn(obj, parent.TransformPoint(val));
			GameObject val2 = new GameObject($"CollisionPoteau_{number:00}");
			val2.transform.SetParent(parent, false);
			val2.layer = ((Component)parent).gameObject.layer;
			val2.transform.localPosition = PointOnCircle(angle, radius + 0.1f, baseHeight + num * 0.5f);
			val2.AddComponent<BoxCollider>().size = new Vector3(0.1f, num, 0.1f);
		}

		private static void CreateRailingSegment(Transform parent, GameObject woodBeam, string name, Vector3 start, Vector3 end)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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)
			CreateRailingSegment(parent, woodBeam, name, start, end, start, end, 0.11f);
		}

		private static void CreateRailingSegment(Transform parent, GameObject woodBeam, string name, Vector3 visualStart, Vector3 visualEnd, Vector3 collisionStart, Vector3 collisionEnd, float collisionThickness)
		{
			//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_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0014: 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)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0075: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0111: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = visualEnd - visualStart;
			float magnitude = ((Vector3)(ref val)).magnitude;
			Vector3 val2 = (visualStart + visualEnd) * 0.5f;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val3 = Vector3.Cross(normalized, Vector3.up);
			Vector3 normalized2 = ((Vector3)(ref val3)).normalized;
			val3 = Vector3.Cross(normalized2, normalized);
			Vector3 normalized3 = ((Vector3)(ref val3)).normalized;
			Quaternion localRotation = Quaternion.LookRotation(normalized2, normalized3);
			GameObject obj = CloneVanillaVisual(woodBeam, parent, name);
			obj.transform.localPosition = val2;
			obj.transform.localRotation = localRotation;
			obj.transform.localScale = new Vector3(magnitude / 2f, 0.44f, 0.44f);
			obj.SetActive(true);
			CenterVisualOn(obj, parent.TransformPoint(val2));
			Vector3 val4 = collisionEnd - collisionStart;
			float magnitude2 = ((Vector3)(ref val4)).magnitude;
			Vector3 localPosition = (collisionStart + collisionEnd) * 0.5f;
			Vector3 normalized4 = ((Vector3)(ref val4)).normalized;
			val3 = Vector3.Cross(normalized4, Vector3.up);
			Vector3 normalized5 = ((Vector3)(ref val3)).normalized;
			val3 = Vector3.Cross(normalized5, normalized4);
			Vector3 normalized6 = ((Vector3)(ref val3)).normalized;
			Quaternion localRotation2 = Quaternion.LookRotation(normalized5, normalized6);
			GameObject val5 = new GameObject("Collision_" + name);
			val5.transform.SetParent(parent, false);
			val5.layer = ((Component)parent).gameObject.layer;
			val5.transform.localPosition = localPosition;
			val5.transform.localRotation = localRotation2;
			val5.AddComponent<BoxCollider>().size = new Vector3(magnitude2, collisionThickness, collisionThickness);
		}

		private static Material CreateWoodMaterial()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Standard");
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Legacy Shaders/Diffuse");
			}
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Unlit/Texture");
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Texture2D val2 = new Texture2D(128, 128, (TextureFormat)4, true);
			((Object)val2).name = "EscalierColimacon_WoodTexture";
			((Texture)val2).wrapMode = (TextureWrapMode)0;
			((Texture)val2).filterMode = (FilterMode)1;
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.105f, 0.07f, 0.032f, 1f);
			Color val4 = default(Color);
			((Color)(ref val4))..ctor(0.39f, 0.265f, 0.125f, 1f);
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num = Mathf.PerlinNoise((float)j * 0.07f, (float)i * 0.015f);
					float num2 = Mathf.PerlinNoise((float)j * 0.23f, (float)i * 0.045f);
					float num3 = 0.5f + 0.5f * Mathf.Sin((float)i * 0.23f + num * 4f);
					float num4 = 0.26f + num * 0.4f + num2 * 0.1f + num3 * 0.07f;
					float num5 = (float)j / 128f;
					float num6 = (float)i / 128f;
					float num7 = Mathf.Sqrt(Mathf.Pow((num5 - 0.28f) * 2.8f, 2f) + Mathf.Pow((num6 - 0.34f) * 6f, 2f));
					float num8 = Mathf.Sqrt(Mathf.Pow((num5 - 0.76f) * 3.2f, 2f) + Mathf.Pow((num6 - 0.73f) * 7f, 2f));
					if (num7 < 0.22f)
					{
						num4 -= (0.22f - num7) * 0.55f;
					}
					if (num8 < 0.18f)
					{
						num4 -= (0.18f - num8) * 0.5f;
					}
					num4 = Mathf.Clamp01(num4);
					val2.SetPixel(j, i, Color.Lerp(val3, val4, num4));
				}
			}
			val2.Apply(true, false);
			Object.DontDestroyOnLoad((Object)(object)val2);
			Material val5 = new Material(val)
			{
				name = "EscalierColimacon_WoodMaterial",
				mainTexture = (Texture)(object)val2,
				color = new Color(0.9f, 0.88f, 0.82f, 1f)
			};
			if (val5.HasProperty("_Glossiness"))
			{
				val5.SetFloat("_Glossiness", 0.12f);
			}
			if (val5.HasProperty("_Metallic"))
			{
				val5.SetFloat("_Metallic", 0f);
			}
			Object.DontDestroyOnLoad((Object)(object)val5);
			return val5;
		}

		private static bool TryGetNativeWoodRendering(GameObject source, out Material material, out MaterialPropertyBlock properties, out Vector4 uvBounds)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			material = null;
			properties = null;
			uvBounds = new Vector4(0f, 0f, 1f, 1f);
			if ((Object)(object)source == (Object)null)
			{
				return false;
			}
			MeshRenderer val = null;
			Mesh mesh = null;
			float num = 0f;
			MeshFilter[] componentsInChildren = source.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val2 in componentsInChildren)
			{
				MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>();
				if (!((Object)(object)component == (Object)null) && !((Object)(object)val2.sharedMesh == (Object)null) && !((Object)(object)((Renderer)component).sharedMaterial == (Object)null) && ((Object)((Renderer)component).sharedMaterial).name.IndexOf("ghost", StringComparison.OrdinalIgnoreCase) < 0)
				{
					Bounds bounds = val2.sharedMesh.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					float num2 = size.x * Mathf.Max(size.y, 0.01f) * size.z;
					if (num2 > num)
					{
						num = num2;
						val = component;
						mesh = val2.sharedMesh;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			material = ((Renderer)val).sharedMaterial;
			properties = new MaterialPropertyBlock();
			((Renderer)val).GetPropertyBlock(properties);
			uvBounds = GetUvBounds(mesh);
			return true;
		}

		private static Vector4 GetUvBounds(Mesh mesh)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			Vector2[] array = (((Object)(object)mesh != (Object)null) ? mesh.uv : null);
			if (array == null || array.Length == 0)
			{
				return new Vector4(0f, 0f, 1f, 1f);
			}
			float num = array[0].x;
			float num2 = array[0].y;
			float num3 = num;
			float num4 = num2;
			Vector2[] array2 = array;
			foreach (Vector2 val in array2)
			{
				num = Mathf.Min(num, val.x);
				num2 = Mathf.Min(num2, val.y);
				num3 = Mathf.Max(num3, val.x);
				num4 = Mathf.Max(num4, val.y);
			}
			return new Vector4(num, num2, num3, num4);
		}

		private static void DisableVanillaGeometry(GameObject prefab)
		{
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			Collider[] componentsInChildren2 = prefab.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				componentsInChildren2[i].enabled = false;
			}
			LODGroup[] componentsInChildren3 = prefab.GetComponentsInChildren<LODGroup>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				componentsInChildren3[i].enabled = false;
			}
		}

		private static void RemoveVanillaSnapPoints(GameObject prefab)
		{
			Transform[] componentsInChildren = prefab.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)(object)prefab.transform && ((Object)val).name.StartsWith("_snappoint", StringComparison.OrdinalIgnoreCase))
				{
					Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
				}
			}
		}

		private static void BuildGeometry(Transform root, Material woodMaterial, MaterialPropertyBlock woodProperties, Vector4 woodUvBounds, GameObject woodBeam, GameObject woodPole, float turnDirection)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0038: 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)
			GameObject val = new GameObject("SpiralGeometry");
			val.transform.SetParent(root, false);
			val.layer = ((Component)root).gameObject.layer;
			val.SetActive(true);
			CreatePole(val.transform, woodMaterial, woodProperties, woodUvBounds, woodPole);
			float num = 11.25f;
			float num2 = 0.25f;
			for (int i = 0; i < 8; i++)
			{
				float startAngle = ((turnDirection > 0f) ? ((float)i * num) : ((float)(-(i + 1)) * num));
				float endAngle = ((turnDirection > 0f) ? ((float)(i + 1) * num) : ((float)(-i) * num));
				float top = (float)(i + 1) * num2;
				CreateStep(val.transform, i + 1, startAngle, endAngle, top, woodMaterial, woodProperties, woodUvBounds, woodBeam);
			}
			CreateCentralWalkingSteps(val.transform, turnDirection);
			CreateWalkingRamp(val.transform, turnDirection);
		}

		private static void CreatePole(Transform parent, Material material, MaterialPropertyBlock properties, Vector4 uvBounds, GameObject woodPole)
		{
			//IL_0044: 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_00ea: 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_011a: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj).name = "PoteauCentral";
			obj.transform.SetParent(parent, false);
			obj.layer = ((Component)parent).gameObject.layer;
			obj.transform.localPosition = new Vector3(0f, 1f, 0f);
			float num = 0.25f;
			obj.transform.localScale = new Vector3(num, 1f, num);
			obj.SetActive(true);
			MeshFilter component = obj.GetComponent<MeshFilter>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null)
			{
				Mesh val = Object.Instantiate<Mesh>(component.sharedMesh);
				RemapMeshUv(val, uvBounds);
				component.sharedMesh = val;
			}
			Renderer component2 = obj.GetComponent<Renderer>();
			if ((Object)(object)woodPole != (Object)null)
			{
				component2.enabled = false;
				GameObject obj2 = CloneVanillaVisual(woodPole, parent, "PoteauValheimVisuel");
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(0f, 1f, 0f);
				obj2.transform.localPosition = val2;
				obj2.transform.localRotation = Quaternion.identity;
				obj2.transform.localScale = new Vector3(num / 0.25f, 1f, num / 0.25f);
				obj2.SetActive(true);
				CenterVisualOn(obj2, parent.TransformPoint(val2));
			}
			else
			{
				component2.sharedMaterial = material;
				if (properties != null)
				{
					component2.SetPropertyBlock(properties);
				}
			}
		}

		private static void CreateStep(Transform parent, int number, float startAngle, float endAngle, float top, Material material, MaterialPropertyBlock properties, Vector4 uvBounds, GameObject woodBeam)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject($"Marche_{number:00}");
			val.transform.SetParent(parent, false);
			val.layer = ((Component)parent).gameObject.layer;
			val.SetActive(true);
			Mesh sharedMesh = CreateWedgeMesh(startAngle, endAngle, top - 0.18f, top, uvBounds);
			val.AddComponent<MeshFilter>().sharedMesh = sharedMesh;
			if ((Object)(object)woodBeam != (Object)null)
			{
				CreateBeamStepVisual(val.transform, woodBeam, startAngle, endAngle, top);
				return;
			}
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			((Renderer)val2).sharedMaterial = material;
			if (properties != null)
			{
				((Renderer)val2).SetPropertyBlock(properties);
			}
		}

		private static void CreateCentralWalkingSteps(Transform parent, float turnDirection)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			float num = 5.625f;
			float num2 = 0.125f;
			for (int i = 0; i < 16; i++)
			{
				float startDegrees = ((turnDirection > 0f) ? ((float)i * num) : ((float)(-(i + 1)) * num));
				float endDegrees = ((turnDirection > 0f) ? ((float)(i + 1) * num) : ((float)(-i) * num));
				float num3 = (float)(i + 1) * num2 + 0.015f;
				GameObject val = new GameObject($"MarcheAssistanceInvisible_{i + 1:00}");
				val.transform.SetParent(parent, false);
				val.layer = ((Component)parent).gameObject.layer;
				MeshCollider obj = val.AddComponent<MeshCollider>();
				obj.sharedMesh = CreateWedgeMeshRadii(startDegrees, endDegrees, num3 - 0.14f, num3, 0.115f, 1.42f, new Vector4(0f, 0f, 1f, 1f));
				obj.convex = true;
			}
		}

		private static void CreateWalkingRamp(Transform parent, float turnDirection)
		{
			//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)
			GameObject val = new GameObject("RampeHelicoidaleInvisible");
			val.transform.SetParent(parent, false);
			val.layer = ((Component)parent).gameObject.layer;
			bool num = turnDirection < 0f;
			float startDegrees = (num ? (-90f) : 0f);
			float endDegrees = (num ? 0f : 90f);
			float startHeight = (num ? 2.015f : 0.015f);
			float endHeight = (num ? 0.015f : 2.015f);
			MeshCollider obj = val.AddComponent<MeshCollider>();
			obj.sharedMesh = CreateSlopedWedgeMesh(startDegrees, endDegrees, startHeight, endHeight, 1.35f, 2.06f, 0.1f);
			obj.convex = false;
		}

		private static void CreateBeamStepVisual(Transform parent, GameObject woodBeam, float startAngle, float endAngle, float top)
		{
			//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_004b: 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_008c: 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)
			GameObject obj = CloneVanillaVisual(woodBeam, parent, "PoutreMarcheValheim");
			float num = (startAngle + endAngle) * 0.5f;
			float num2 = 1.0575f;
			float num3 = 1.885f;
			float num4 = num2 * (endAngle - startAngle) * (MathF.PI / 180f) * 0.9f;
			Vector3 val = PointOnCircle(num, num2, top - 0.09f);
			obj.transform.localPosition = val;
			obj.transform.localRotation = Quaternion.Euler(0f, num - 90f, 0f);
			obj.transform.localScale = new Vector3(num3 / 2f, 0.72f, num4 / 0.25f);
			obj.SetActive(true);
			CenterVisualOn(obj, parent.TransformPoint(val));
		}

		private static void CenterVisualOn(GameObject visual, Vector3 targetWorldPosition)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004c: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = visual.GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren.Length != 0)
			{
				Bounds bounds = componentsInChildren[0].bounds;
				for (int i = 1; i < componentsInChildren.Length; i++)
				{
					((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds);
				}
				Transform transform = visual.transform;
				transform.position += targetWorldPosition - ((Bounds)(ref bounds)).center;
			}
		}

		private static GameObject CloneVanillaVisual(GameObject source, Transform parent, string name)
		{
			GameObject val = Object.Instantiate<GameObject>(source);
			((Object)val).name = name;
			val.SetActive(false);
			Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			Rigidbody[] componentsInChildren2 = val.GetComponentsInChildren<Rigidbody>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			ZNetView[] componentsInChildren3 = val.GetComponentsInChildren<ZNetView>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
			}
			WearNTear[] componentsInChildren4 = val.GetComponentsInChildren<WearNTear>(true);
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren4[i]);
			}
			Piece[] componentsInChildren5 = val.GetComponentsInChildren<Piece>(true);
			for (int i = 0; i < componentsInChildren5.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren5[i]);
			}
			RemoveVanillaSnapPoints(val);
			Renderer[] componentsInChildren6 = val.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren6.Length; i++)
			{
				componentsInChildren6[i].enabled = true;
			}
			LODGroup[] componentsInChildren7 = val.GetComponentsInChildren<LODGroup>(true);
			for (int i = 0; i < componentsInChildren7.Length; i++)
			{
				componentsInChildren7[i].enabled = true;
			}
			val.transform.SetParent(parent, false);
			SetLayerRecursively(val.transform, ((Component)parent).gameObject.layer);
			return val;
		}

		private static void SetLayerRecursively(Transform root, int layer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			((Component)root).gameObject.layer = layer;
			foreach (Transform item in root)
			{
				SetLayerRecursively(item, layer);
			}
		}

		private static Mesh CreateWedgeMesh(float startDegrees, float endDegrees, float bottom, float top, Vector4 uvBounds)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return CreateWedgeMeshRadii(startDegrees, endDegrees, bottom, top, 0.115f, 2f, uvBounds);
		}

		private static Mesh CreateWedgeMeshRadii(float startDegrees, float endDegrees, float bottom, float top, float innerRadius, float outerRadius, Vector4 uvBounds)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00a2: 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_00b1: 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_00c2: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00f1: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: 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_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			int num = 4;
			Vector3[] array = (Vector3[])(object)new Vector3[num * 4];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			Color[] array3 = (Color[])(object)new Color[array.Length];
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / 3f;
				float num3 = Mathf.Lerp(startDegrees, endDegrees, num2) * (MathF.PI / 180f);
				((Vector3)(ref val))..ctor(Mathf.Sin(num3) * innerRadius, 0f, Mathf.Cos(num3) * innerRadius);
				((Vector3)(ref val2))..ctor(Mathf.Sin(num3) * outerRadius, 0f, Mathf.Cos(num3) * outerRadius);
				array[i] = new Vector3(val.x, bottom, val.z);
				array[num + i] = new Vector3(val2.x, bottom, val2.z);
				array[num * 2 + i] = new Vector3(val.x, top, val.z);
				array[num * 3 + i] = new Vector3(val2.x, top, val2.z);
				array2[i] = WoodUv(array[i], uvBounds);
				array2[num + i] = WoodUv(array[num + i], uvBounds);
				array2[num * 2 + i] = WoodUv(array[num * 2 + i], uvBounds);
				array2[num * 3 + i] = WoodUv(array[num * 3 + i], uvBounds);
				array3[i] = Color.white;
				array3[num + i] = Color.white;
				array3[num * 2 + i] = Color.white;
				array3[num * 3 + i] = Color.white;
			}
			List<int> list = new List<int>();
			for (int j = 0; j < 3; j++)
			{
				AddQuad(list, num * 2 + j, num * 3 + j, num * 3 + j + 1, num * 2 + j + 1);
				AddQuad(list, j + 1, num + j + 1, num + j, j);
				AddQuad(list, num + j, num + j + 1, num * 3 + j + 1, num * 3 + j);
				AddQuad(list, j + 1, j, num * 2 + j, num * 2 + j + 1);
			}
			AddQuad(list, 0, num, num * 3, num * 2);
			int num4 = num - 1;
			AddQuad(list, num4, num * 2 + num4, num * 3 + num4, num + num4);
			Mesh val3 = new Mesh
			{
				name = "SpiralStep",
				vertices = array,
				uv = array2,
				uv2 = array2,
				colors = array3,
				triangles = list.ToArray()
			};
			val3.RecalculateNormals();
			val3.RecalculateTangents();
			val3.RecalculateBounds();
			return val3;
		}

		private static Mesh CreateSlopedWedgeMesh(float startDegrees, float endDegrees, float startHeight, float endHeight, float innerRadius, float outerRadius, float thickness)
		{
			//IL_0097: 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_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_00b6: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_0137: 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_013a: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: 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_0176: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: 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_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Expected O, but got Unknown
			int num = 25;
			Vector3[] array = (Vector3[])(object)new Vector3[num * 4];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			Color[] array3 = (Color[])(object)new Color[array.Length];
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / 24f;
				float num3 = Mathf.Lerp(startDegrees, endDegrees, num2) * (MathF.PI / 180f);
				float num4 = Mathf.Lerp(startHeight, endHeight, num2);
				float num5 = num4 - thickness;
				((Vector3)(ref val))..ctor(Mathf.Sin(num3) * innerRadius, 0f, Mathf.Cos(num3) * innerRadius);
				((Vector3)(ref val2))..ctor(Mathf.Sin(num3) * outerRadius, 0f, Mathf.Cos(num3) * outerRadius);
				array[i] = new Vector3(val.x, num5, val.z);
				array[num + i] = new Vector3(val2.x, num5, val2.z);
				array[num * 2 + i] = new Vector3(val.x, num4, val.z);
				array[num * 3 + i] = new Vector3(val2.x, num4, val2.z);
				array2[i] = (array2[num + i] = (array2[num * 2 + i] = (array2[num * 3 + i] = Vector2.zero)));
				array3[i] = (array3[num + i] = (array3[num * 2 + i] = (array3[num * 3 + i] = Color.white)));
			}
			List<int> list = new List<int>();
			for (int j = 0; j < 24; j++)
			{
				AddQuad(list, num * 2 + j, num * 3 + j, num * 3 + j + 1, num * 2 + j + 1);
				AddQuad(list, j + 1, num + j + 1, num + j, j);
				AddQuad(list, num + j, num + j + 1, num * 3 + j + 1, num * 3 + j);
				AddQuad(list, j + 1, j, num * 2 + j, num * 2 + j + 1);
			}
			AddQuad(list, 0, num, num * 3, num * 2);
			int num6 = num - 1;
			AddQuad(list, num6, num * 2 + num6, num * 3 + num6, num + num6);
			Mesh val3 = new Mesh
			{
				name = "SpiralWalkingRampSegment",
				vertices = array,
				uv = array2,
				uv2 = array2,
				colors = array3,
				triangles = list.ToArray()
			};
			val3.RecalculateNormals();
			val3.RecalculateBounds();
			return val3;
		}

		private static Vector2 WoodUv(Vector3 vertex, Vector4 bounds)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			float num = Mathf.InverseLerp(-2f, 2f, vertex.x);
			float num2 = Mathf.InverseLerp(-2f, 2f, vertex.z);
			return new Vector2(Mathf.Lerp(bounds.x, bounds.z, num), Mathf.Lerp(bounds.y, bounds.w, num2));
		}

		private static void RemapMeshUv(Mesh mesh, Vector4 bounds)
		{
			//IL_0015: 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_0032: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Vector2[] uv = mesh.uv;
			if (uv != null && uv.Length != 0)
			{
				for (int i = 0; i < uv.Length; i++)
				{
					uv[i] = new Vector2(Mathf.Lerp(bounds.x, bounds.z, uv[i].x), Mathf.Lerp(bounds.y, bounds.w, uv[i].y));
				}
				mesh.uv = uv;
			}
		}

		private static void AddQuad(List<int> triangles, int a, int b, int c, int d)
		{
			triangles.Add(a);
			triangles.Add(b);
			triangles.Add(c);
			triangles.Add(a);
			triangles.Add(c);
			triangles.Add(d);
		}

		private static Vector3 PointOnCircle(float degrees, float radius, float y)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			float num = degrees * (MathF.PI / 180f);
			return new Vector3(Mathf.Sin(num) * radius, y, Mathf.Cos(num) * radius);
		}

		private static void AddSnapPoint(Transform parent, string name, Vector3 localPosition, float rotation)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.layer = ((Component)parent).gameObject.layer;
			val.transform.localPosition = localPosition;
			val.transform.localRotation = Quaternion.Euler(0f, rotation, 0f);
			val.tag = "snappoint";
		}

		private static void AddOuterRailingSnapPoints(Transform parent)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			float num = 11.25f;
			float num2 = 0.25f;
			for (int i = 0; i < 8; i++)
			{
				float num3 = ((float)i + 0.5f) * num;
				float y = (float)(i + 1) * num2;
				AddSnapPoint(parent, $"_snappoint_railing_outer_{i + 1:00}", PointOnCircle(num3, 2f, y), num3);
			}
		}
	}
}