Decompiled source of How to Fish Shattered Horizons v1.0.2

BepInEx/patchers/FST.Compatibility.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx.Logging;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("1.1.3.0")]
namespace FST.Compatibility;

public static class Patcher
{
	public static IEnumerable<string> TargetDLLs => new string[1] { "Assembly-CSharp.dll" };

	private static void Require(bool ok, string api)
	{
		if (!ok)
		{
			throw new InvalidOperationException("FST requires How to Fish 1.1.3 API: " + api + ". Compatibility was not applied; update FST before loading custom islands.");
		}
	}

	private static TypeDefinition Type(ModuleDefinition m, string name)
	{
		TypeDefinition? obj = ((IEnumerable<TypeDefinition>)m.Types).SingleOrDefault((Func<TypeDefinition, bool>)((TypeDefinition x) => ((MemberReference)x).FullName == name));
		Require(obj != null, name);
		return obj;
	}

	private static MethodDefinition Method(TypeDefinition t, string name, bool isStatic, string result, params string[] args)
	{
		MethodDefinition[] array = ((IEnumerable<MethodDefinition>)t.Methods).Where((MethodDefinition x) => ((MemberReference)x).Name == name && x.IsStatic == isStatic && ((MemberReference)((MethodReference)x).ReturnType).FullName == result && ((IEnumerable<ParameterDefinition>)((MethodReference)x).Parameters).Select((ParameterDefinition p) => ((MemberReference)((ParameterReference)p).ParameterType).FullName).SequenceEqual(args)).ToArray();
		Require(array.Length == 1, ((MemberReference)t).Name + "." + name + "(" + string.Join(",", args) + ")");
		return array[0];
	}

	public static void Patch(AssemblyDefinition assembly)
	{
		ManualLogSource val = Logger.CreateLogSource("FST 1.1.3 compatibility");
		try
		{
			Apply(assembly);
			val.LogInfo((object)"How to Fish 1.1.3 API verified. Legacy island ABI restored in memory; original HTFMapLoader is unchanged.");
		}
		catch (Exception ex)
		{
			val.LogFatal((object)ex.Message);
			throw;
		}
	}

	public static void Apply(AssemblyDefinition assembly)
	{
		//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0502: Unknown result type (might be due to invalid IL or missing references)
		//IL_0504: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ac: Expected O, but got Unknown
		//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_05da: Expected O, but got Unknown
		//IL_0492: Unknown result type (might be due to invalid IL or missing references)
		//IL_0497: Unknown result type (might be due to invalid IL or missing references)
		ModuleDefinition mainModule = assembly.MainModule;
		if (((IEnumerable<TypeDefinition>)mainModule.Types).Any((TypeDefinition val9) => ((MemberReference)val9).FullName == "FstCompatibility.Runtime"))
		{
			return;
		}
		TypeDefinition t = Type(mainModule, "BaitInfo");
		Method(t, "get_NameLocalized", false, "UnityEngine.Localization.LocalizedString");
		Method(t, "get_Description", false, "System.String");
		TypeDefinition val = Type(mainModule, "SpawnManager");
		TypeDefinition val2 = Type(mainModule, "IslandManager");
		TypeDefinition val3 = Type(mainModule, "OnlineIslandManager");
		MethodDefinition val4 = Method(val2, "get_TotalIslands", true, "System.Int32");
		Method(val2, "set_TotalIslands", true, "System.Void", "System.Int32");
		Method(val2, "IsMainIsland", true, "System.Boolean", "System.Byte");
		Method(val, "SetSpawnPoints", false, "System.Void");
		Method(val, "TryGetInitialPlayerSpawn", true, "System.Boolean", "UnityEngine.Vector3&", "System.Single&");
		string[] array = new string[2] { "_mainPlayerSpawnPoint", "_mainBoatSpawnPoint" };
		foreach (string name in array)
		{
			Require(((IEnumerable<FieldDefinition>)val.Fields).Any((FieldDefinition f) => ((MemberReference)f).Name == name && f.IsStatic && ((MemberReference)((FieldReference)f).FieldType).FullName == "UnityEngine.Transform"), "SpawnManager." + name);
		}
		TypeReference returnType = ((MethodReference)Method(val, "get_MainSpawnPos", true, "UnityEngine.Vector3")).ReturnType;
		TypeReference returnType2 = ((MethodReference)Method(val, "get__boatSpawnRot", true, "UnityEngine.Quaternion")).ReturnType;
		MethodDefinition native = Method(val3, "ToggleTeleportPlayers", true, "System.Void", "System.Boolean", "System.Boolean");
		MethodDefinition native2 = Method(val3, "SpawnIsland", false, "System.Void", "System.Byte", "System.Boolean", "Player", "System.Nullable`1<UnityEngine.Vector2>");
		FieldDefinition val5 = ((IEnumerable<Instruction>)val4.Body.Instructions).Where((Instruction i) => i.OpCode == OpCodes.Ldsfld).Select(delegate(Instruction i)
		{
			object operand = i.Operand;
			return (FieldDefinition)((operand is FieldDefinition) ? operand : null);
		}).SingleOrDefault();
		Require(val5 != null && val5.IsStatic && ((MemberReference)((FieldReference)val5).FieldType).FullName == "System.Int32", "TotalIslands storage");
		array = new string[2] { "PlayerSpawnPos", "BoatSpawnPos" };
		foreach (string name2 in array)
		{
			ValidateField(val, name2, returnType);
		}
		ValidateField(val, "PlayerSpawnRot", mainModule.TypeSystem.Single);
		ValidateField(val, "BoatSpawnRot", returnType2);
		ValidateField(val2, "TotalIslands", mainModule.TypeSystem.Int32);
		ValidateWrapper(val3, native);
		ValidateWrapper(val3, native2);
		TypeDefinition val6 = Type(mainModule, "ProjectileManager");
		MethodDefinition native3 = Method(val6, "AddProjectile", false, "System.Void", "Player", "WeaponInfo", "System.Boolean", "UnityEngine.Vector3", "UnityEngine.Vector3", "System.UInt32", "System.UInt32", "System.Boolean", "System.Boolean");
		MethodDefinition native4 = Method(val6, "AddProjectiles", false, "System.Void", "Player", "WeaponInfo", "System.Boolean", "UnityEngine.Vector3", "UnityEngine.Vector3[]", "System.UInt32", "System.UInt32", "System.Boolean", "System.Boolean");
		FieldDefinition val7 = ((IEnumerable<FieldDefinition>)val2.Fields).FirstOrDefault((Func<FieldDefinition, bool>)((FieldDefinition f) => ((MemberReference)f).Name == "TotalIslands"));
		if (val7 != null && val7 != val5)
		{
			foreach (MethodDefinition item in ((IEnumerable<MethodDefinition>)val2.Methods).Where((MethodDefinition x) => x.HasBody))
			{
				Enumerator<Instruction> enumerator2 = item.Body.Instructions.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						Instruction current = enumerator2.Current;
						if (current.Operand == val5)
						{
							current.Operand = val7;
						}
					}
				}
				finally
				{
					((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
				}
			}
		}
		else
		{
			((MemberReference)val5).Name = "TotalIslands";
			val5.Attributes = (FieldAttributes)((val5.Attributes & 0xFFF8) | 6);
		}
		array = new string[2] { "PlayerSpawnPos", "BoatSpawnPos" };
		foreach (string name3 in array)
		{
			EnsureField(val, name3, returnType);
		}
		EnsureField(val, "PlayerSpawnRot", mainModule.TypeSystem.Single);
		EnsureField(val, "BoatSpawnRot", returnType2);
		Wrapper(val3, native);
		Wrapper(val3, native2);
		ProjectileWrapper(val6, native3);
		ProjectileWrapper(val6, native4);
		TypeDefinition val8 = new TypeDefinition("FstCompatibility", "Runtime", (TypeAttributes)385, mainModule.TypeSystem.Object);
		val8.Fields.Add(new FieldDefinition("Version", (FieldAttributes)86, mainModule.TypeSystem.String)
		{
			Constant = "1.1.3/v2"
		});
		mainModule.Types.Add(val8);
	}

	private static void ProjectileWrapper(TypeDefinition owner, MethodDefinition native)
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: 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_00d8: 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_0109: 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)
		if (((IEnumerable<MethodDefinition>)owner.Methods).Any((MethodDefinition method) => ((MemberReference)method).Name == ((MemberReference)native).Name && ((MethodReference)method).Parameters.Count == 8))
		{
			return;
		}
		MethodDefinition val = new MethodDefinition(((MemberReference)native).Name, (MethodAttributes)134, ((MethodReference)native).ReturnType);
		foreach (ParameterDefinition item in ((IEnumerable<ParameterDefinition>)((MethodReference)native).Parameters).Take(8))
		{
			((MethodReference)val).Parameters.Add(new ParameterDefinition(((ParameterReference)item).Name, (ParameterAttributes)0, ((ParameterReference)item).ParameterType));
		}
		owner.Methods.Add(val);
		ILProcessor iLProcessor = val.Body.GetILProcessor();
		iLProcessor.Emit(OpCodes.Ldarg_0);
		Enumerator<ParameterDefinition> enumerator2 = ((MethodReference)val).Parameters.GetEnumerator();
		try
		{
			while (enumerator2.MoveNext())
			{
				ParameterDefinition current2 = enumerator2.Current;
				iLProcessor.Emit(OpCodes.Ldarg, current2);
			}
		}
		finally
		{
			((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
		}
		iLProcessor.Emit(OpCodes.Ldc_I4_0);
		iLProcessor.Emit(OpCodes.Call, (MethodReference)(object)native);
		iLProcessor.Emit(OpCodes.Ret);
	}

	private static void ValidateField(TypeDefinition type, string name, TypeReference fieldType)
	{
		FieldDefinition[] array = ((IEnumerable<FieldDefinition>)type.Fields).Where((FieldDefinition f) => ((MemberReference)f).Name == name).ToArray();
		Require(array.Length <= 1 && (array.Length == 0 || (array[0].IsStatic && array[0].IsPublic && ((MemberReference)((FieldReference)array[0]).FieldType).FullName == ((MemberReference)fieldType).FullName)), ((MemberReference)type).Name + "." + name + " legacy field type");
	}

	private static void EnsureField(TypeDefinition type, string name, TypeReference fieldType)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		if (!((IEnumerable<FieldDefinition>)type.Fields).Any((FieldDefinition f) => ((MemberReference)f).Name == name))
		{
			type.Fields.Add(new FieldDefinition(name, (FieldAttributes)22, fieldType));
		}
	}

	private static void ValidateWrapper(TypeDefinition type, MethodDefinition native)
	{
		MethodDefinition[] array = ((IEnumerable<MethodDefinition>)type.Methods).Where((MethodDefinition m) => ((MemberReference)m).Name == ((MemberReference)native).Name && ((MethodReference)m).Parameters.Count == 1).ToArray();
		Require(array.Length <= 1 && (array.Length == 0 || (array[0].IsStatic == native.IsStatic && ((MemberReference)((MethodReference)array[0]).ReturnType).FullName == ((MemberReference)((MethodReference)native).ReturnType).FullName && ((MemberReference)((ParameterReference)((MethodReference)array[0]).Parameters[0]).ParameterType).FullName == ((MemberReference)((ParameterReference)((MethodReference)native).Parameters[0]).ParameterType).FullName)), ((MemberReference)native).Name + " legacy overload");
	}

	private static void Wrapper(TypeDefinition owner, MethodDefinition native)
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: 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_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Expected O, but got Unknown
		//IL_0129: 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_0146: Unknown result type (might be due to invalid IL or missing references)
		if (!((IEnumerable<MethodDefinition>)owner.Methods).Any((MethodDefinition m) => ((MemberReference)m).Name == ((MemberReference)native).Name && ((MethodReference)m).Parameters.Count == 1))
		{
			MethodDefinition val = new MethodDefinition(((MemberReference)native).Name, (MethodAttributes)(0x86 | (native.IsStatic ? 16 : 0)), ((MethodReference)native).ReturnType);
			((MethodReference)val).Parameters.Add(new ParameterDefinition("value", (ParameterAttributes)0, ((ParameterReference)((MethodReference)native).Parameters[0]).ParameterType));
			owner.Methods.Add(val);
			ILProcessor iLProcessor = val.Body.GetILProcessor();
			iLProcessor.Emit(OpCodes.Ldarg_0);
			if (!native.IsStatic)
			{
				iLProcessor.Emit(OpCodes.Ldarg_1);
			}
			iLProcessor.Emit(OpCodes.Ldc_I4_0);
			if (((MemberReference)native).Name == "SpawnIsland")
			{
				iLProcessor.Emit(OpCodes.Ldnull);
				VariableDefinition val2 = new VariableDefinition(((ParameterReference)((MethodReference)native).Parameters[3]).ParameterType);
				val.Body.Variables.Add(val2);
				val.Body.InitLocals = true;
				iLProcessor.Emit(OpCodes.Ldloca, val2);
				iLProcessor.Emit(OpCodes.Initobj, ((VariableReference)val2).VariableType);
				iLProcessor.Emit(OpCodes.Ldloc, val2);
			}
			iLProcessor.Emit(OpCodes.Call, (MethodReference)(object)native);
			iLProcessor.Emit(OpCodes.Ret);
		}
	}
}

BepInEx/plugins/ShatteredHorizons/HTF.DLC.FST.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FishNet;
using FishNet.Broadcast;
using FishNet.Connection;
using FishNet.Managing;
using FishNet.Managing.Object;
using FishNet.Managing.Timing;
using FishNet.Object;
using FishNet.Object.Synchronizing;
using FishNet.Serializing;
using FishNet.Transporting;
using HTF.DLC.FST.Content;
using HTF.DLC.FST.Content.Fauna;
using HTF.DLC.FST.Content.Island7;
using HTF.DLC.FST.Content.Island8;
using HTF.DLC.FST.Content.Island9;
using HTF.DLC.FST.Content.Weapons;
using HTF.DLC.FST.Core;
using HTF.DLC.FST.Progression;
using HarmonyLib;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Samples.RebindUI;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HTF DLC FST")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2")]
[assembly: AssemblyVersion("1.0.2.0")]
public static class FstMarineMotorMount
{
	public static Transform Prepare(Transform model)
	{
		//IL_0024: 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_0053: Unknown result type (might be due to invalid IL or missing references)
		Transform val = model.Find("Propeller");
		if (!Object.op_Implicit((Object)(object)val))
		{
			throw new InvalidOperationException("Missing motor visual propeller");
		}
		Transform transform = new GameObject("Visual-only native X-axis spin").transform;
		transform.SetParent(model, false);
		transform.localPosition = val.localPosition;
		transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
		val.SetParent(transform, true);
		return transform;
	}

	public static void Align(Transform model, Transform spin, Transform nativeThrust, Transform boatFrame)
	{
		//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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)model) && Object.op_Implicit((Object)(object)spin) && Object.op_Implicit((Object)(object)nativeThrust) && Object.op_Implicit((Object)(object)boatFrame))
		{
			model.rotation = Quaternion.LookRotation(-nativeThrust.right, boatFrame.up);
			Transform parent = model.parent;
			Vector3 val = (Object.op_Implicit((Object)(object)parent) ? parent.lossyScale : Vector3.one);
			model.localScale = new Vector3(1f / Mathf.Max(0.0001f, Mathf.Abs(val.x)), 1f / Mathf.Max(0.0001f, Mathf.Abs(val.y)), 1f / Mathf.Max(0.0001f, Mathf.Abs(val.z)));
			model.position += nativeThrust.position - spin.position;
		}
	}
}
public static class FstTempestPointGeometry
{
	public static Vector3 Offset(string marker)
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		bool flag = marker == "AmmoShop" || marker == "SupplyShop" || marker == "ArmorShop";
		float num = ((marker == "Workbench") ? 0.85f : ((flag || marker == "DragonSocket") ? 1.45f : 1f));
		return new Vector3(0f, num, (marker == "Workbench") ? (-1.1f) : (flag ? (-0.95f) : 0f));
	}

	public static void Configure(BoxCollider box, string marker)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: 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)
		box.size = new Vector3(1.4f, (marker == "DragonSocket") ? 1.4f : 1.6f, 1.2f);
		box.center = Vector3.up * ((marker == "DragonSocket") ? 0.55f : (0.8f - Offset(marker).y));
		((Collider)box).isTrigger = true;
	}
}
public static class FstTempestObjectiveVisual
{
	public static readonly string[] Markers = new string[9] { "SurveyCourt", "SurveyWall", "SurveyChannel", "RestorePump", "HarborAnchor", "ChannelAnchor", "KeepAnchor", "DeepAnchor", "DragonSocket" };

	public static GameObject Create(Transform parent, string marker, GameObject sensor, GameObject relay)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//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_0100: 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_0118: 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_0140: 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_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: 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_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_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: 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)
		GameObject obj = (marker.StartsWith("Survey", StringComparison.Ordinal) ? sensor : relay);
		if (!Object.op_Implicit((Object)(object)obj))
		{
			throw new InvalidOperationException("Missing visible Island9 objective model: " + marker);
		}
		GameObject val = new GameObject("Visible objective fixture " + marker);
		val.transform.SetParent(parent, false);
		GameObject val2 = Object.Instantiate<GameObject>(obj, val.transform, false);
		((Object)val2).name = (marker.StartsWith("Survey", StringComparison.Ordinal) ? "Storm survey instrument" : "Storm control relay");
		val2.SetActive(true);
		Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Remove(componentsInChildren[i]);
		}
		MeshRenderer[] array = (from r in val2.GetComponentsInChildren<MeshRenderer>(true)
			where ((Renderer)r).enabled && Object.op_Implicit((Object)(object)((Component)r).GetComponent<MeshFilter>()) && Object.op_Implicit((Object)(object)((Component)r).GetComponent<MeshFilter>().sharedMesh)
			select r).ToArray();
		if (array.Length == 0)
		{
			throw new InvalidOperationException("Empty Island9 objective visual: " + marker);
		}
		Bounds val3 = Bounds(val2.transform);
		float num = 1f / Mathf.Max(0.01f, Mathf.Max(((Bounds)(ref val3)).size.x, Mathf.Max(((Bounds)(ref val3)).size.y, ((Bounds)(ref val3)).size.z)));
		Transform transform = val2.transform;
		transform.localScale *= num;
		val3 = Bounds(val2.transform);
		Vector3 val4 = val.transform.InverseTransformPoint(((Bounds)(ref val3)).center);
		Transform transform2 = val2.transform;
		transform2.localPosition -= val4;
		float num2 = ((marker == "DragonSocket") ? (-0.16f) : (-0.94f));
		if (marker == "DragonSocket")
		{
			Transform transform3 = val2.transform;
			transform3.localPosition += Vector3.up * 0.55f;
		}
		Material sharedMaterial = ((Renderer)array[0]).sharedMaterial;
		Piece(val.transform, "Visible instrument base", new Vector3(0f, num2, 0f), new Vector3(0.68f, 0.1f, 0.5f), sharedMaterial, (PrimitiveType)3);
		float num3 = ((marker == "DragonSocket") ? 0.3f : (-0.3f));
		Piece(val.transform, "Instrument support", new Vector3(0f, (num2 + num3) / 2f, 0f), new Vector3(0.1f, (num3 - num2) / 2f, 0.1f), sharedMaterial, (PrimitiveType)2);
		return val;
	}

	private static void Piece(Transform parent, string name, Vector3 position, Vector3 scale, Material material, PrimitiveType type)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = GameObject.CreatePrimitive(type);
		((Object)obj).name = name;
		obj.transform.SetParent(parent, false);
		obj.transform.localPosition = position;
		obj.transform.localScale = scale;
		obj.GetComponent<Renderer>().sharedMaterial = material;
		Remove(obj.GetComponent<Collider>());
	}

	private static void Remove(Collider collider)
	{
		collider.enabled = false;
		Object.Destroy((Object)(object)collider);
	}

	public static Bounds Bounds(Transform root)
	{
		//IL_0004: 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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_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)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
		bool flag = true;
		Bounds result = default(Bounds);
		MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>(true);
		foreach (MeshFilter val in componentsInChildren)
		{
			Renderer component = ((Component)val).GetComponent<Renderer>();
			if (!Object.op_Implicit((Object)(object)component) || !component.enabled || !Object.op_Implicit((Object)(object)val.sharedMesh))
			{
				continue;
			}
			Bounds bounds = val.sharedMesh.bounds;
			for (int j = 0; j < 8; j++)
			{
				Vector3 val2 = ((Component)val).transform.TransformPoint(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)))));
				if (flag)
				{
					((Bounds)(ref result))..ctor(val2, Vector3.zero);
					flag = false;
				}
				else
				{
					((Bounds)(ref result)).Encapsulate(val2);
				}
			}
		}
		if (flag)
		{
			throw new InvalidOperationException("Objective fixture has no visible mesh");
		}
		return result;
	}
}
public static class FstMarineMotorGeometry
{
	private static GameObject root;

	private static Material[] materials;

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

	public static GameObject Create(int tier, Shader shader)
	{
		return Create(tier, shader, null);
	}

	public static GameObject Create(int tier, Material material)
	{
		if (!Object.op_Implicit((Object)(object)material))
		{
			throw new ArgumentNullException("material");
		}
		return Create(tier, material.shader, material);
	}

	private static GameObject Create(int tier, Shader shader, Material source)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected O, but got Unknown
		//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_00bf: 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_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0444: Unknown result type (might be due to invalid IL or missing references)
		//IL_0449: Unknown result type (might be due to invalid IL or missing references)
		//IL_045f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0464: Unknown result type (might be due to invalid IL or missing references)
		//IL_047a: Unknown result type (might be due to invalid IL or missing references)
		//IL_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0517: Unknown result type (might be due to invalid IL or missing references)
		//IL_051d: Expected O, but got Unknown
		//IL_0548: Unknown result type (might be due to invalid IL or missing references)
		//IL_0566: Unknown result type (might be due to invalid IL or missing references)
		//IL_057a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04de: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0610: Unknown result type (might be due to invalid IL or missing references)
		//IL_063e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0643: Unknown result type (might be due to invalid IL or missing references)
		//IL_0644: Unknown result type (might be due to invalid IL or missing references)
		//IL_064f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0654: Unknown result type (might be due to invalid IL or missing references)
		root = new GameObject((new string[4] { "Rustjaw V8", "Frostbite Turbo", "Leviathan Drive", "Tempest Heart" })[tier]);
		Color val = (Color)(tier switch
		{
			2 => new Color(0.025f, 0.24f, 0.22f), 
			1 => new Color(0.12f, 0.47f, 0.61f), 
			0 => new Color(0.48f, 0.14f, 0.055f), 
			_ => new Color(0.28f, 0.18f, 0.43f), 
		});
		materials = ((IEnumerable<Color>)(object)new Color[7]
		{
			new Color(0.075f, 0.085f, 0.095f),
			new Color(0.34f, 0.37f, 0.39f),
			val,
			new Color(0.55f, 0.3f, 0.12f),
			new Color(0.015f, 0.02f, 0.025f),
			new Color(0.64f, 0.67f, 0.64f),
			(tier == 3) ? new Color(0.43f, 0.66f, 0.95f) : new Color(0.42f, 0.68f, 0.63f)
		}).Select(delegate(Color c, int i)
		{
			//IL_0020: 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_0026: Expected O, but got Unknown
			//IL_0093: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			Material val4 = (Object.op_Implicit((Object)(object)source) ? new Material(source) : new Material(shader));
			((Object)val4).name = ((Object)root).name + " / " + (new string[7] { "cast iron", "machined steel", "enamel", "copper", "rubber", "fasteners", "instrument glass" })[i];
			if (val4.HasProperty("_Tint"))
			{
				val4.SetColor("_Tint", c);
			}
			if (val4.HasProperty("_BaseColor"))
			{
				val4.SetColor("_BaseColor", c);
			}
			if (val4.HasProperty("_Color"))
			{
				val4.SetColor("_Color", c);
			}
			if (val4.HasProperty("_Metallic"))
			{
				val4.SetFloat("_Metallic", (i == 4 || i == 6) ? 0f : 0.72f);
			}
			if (val4.HasProperty("_Smoothness"))
			{
				val4.SetFloat("_Smoothness", i switch
				{
					2 => 0.34f, 
					4 => 0.2f, 
					_ => 0.48f, 
				});
			}
			return val4;
		}).ToArray();
		float[] array = new float[2] { -0.22f, 0.22f };
		foreach (float num2 in array)
		{
			Block("Transom jaw", new Vector3(num2, -0.1f, 0.2f), new Vector3(0.065f, 0.38f, 0.14f), 1);
			Block("Clamp pad", new Vector3(num2, -0.04f, 0.29f), new Vector3(0.095f, 0.12f, 0.035f), 4);
			Pipe("Clamp screw", new Vector3(num2, -0.06f, 0.11f), new Vector3(num2, -0.06f, 0.34f), 0.022f, 5);
			Pipe("Clamp handle", new Vector3(num2 - 0.06f, -0.06f, 0.34f), new Vector3(num2 + 0.06f, -0.06f, 0.34f), 0.013f, 1);
		}
		Pipe("Tilt hinge", new Vector3(-0.29f, -0.14f, 0.08f), new Vector3(0.29f, -0.14f, 0.08f), 0.052f, 1);
		Block("Drive leg", new Vector3(0f, -0.49f, -0.035f), new Vector3(0.15f, 0.69f, 0.18f), 0);
		Block("Anti ventilation plate", new Vector3(0f, -0.69f, -0.06f), new Vector3(0.43f, 0.035f, 0.39f), 1);
		Pipe("Gearcase", new Vector3(0f, -0.83f, -0.29f), new Vector3(0f, -0.83f, 0.15f), 0.09f, 1);
		Block("Skeg", new Vector3(0f, -0.98f, -0.02f), new Vector3(0.035f, 0.26f, 0.19f), 0).transform.localRotation = Quaternion.Euler(12f, 0f, 0f);
		Block("Engine bed", new Vector3(0f, 0.02f, 0f), new Vector3(0.58f, 0.12f, 0.47f), 1);
		switch (tier)
		{
		case 0:
			V8();
			break;
		case 1:
			Turbo();
			break;
		case 2:
			Leviathan();
			break;
		default:
			Tempest();
			break;
		}
		Hose("Fuel line", (Vector3[])(object)new Vector3[3]
		{
			new Vector3(0.24f, 0.02f, 0.08f),
			new Vector3(0.3f, 0.18f, 0.16f),
			new Vector3(0.31f, 0.32f, 0.15f)
		}, 0.016f, 4);
		array = new float[2] { -0.24f, 0.24f };
		foreach (float num3 in array)
		{
			float[] array2 = new float[2] { -0.18f, 0.18f };
			foreach (float num5 in array2)
			{
				Bolt(new Vector3(num3, 0.085f, num5));
			}
		}
		Batch(root.transform);
		GameObject val2 = new GameObject("Propeller");
		val2.transform.SetParent(root.transform, false);
		val2.transform.localPosition = new Vector3(0f, -0.83f, -0.32f);
		Pipe("Propeller hub", new Vector3(0f, -0.83f, -0.37f), new Vector3(0f, -0.83f, -0.27f), 0.052f, 5, val2.transform);
		for (int num6 = 0; num6 < 3; num6++)
		{
			float num7 = (float)(num6 * 120) * ((float)Math.PI / 180f);
			Block("Swept propeller blade", new Vector3(Mathf.Sin(num7) * 0.115f, -0.83f + Mathf.Cos(num7) * 0.115f, -0.32f), new Vector3(0.1f, 0.2f, 0.026f), 5, val2.transform).transform.rotation = Quaternion.Euler(0f, 23f, (float)(-num6 * 120 + 24));
		}
		foreach (Transform item in val2.transform)
		{
			item.localPosition -= val2.transform.localPosition;
		}
		owned.Clear();
		return root;
	}

	private static void V8()
	{
		//IL_0014: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: 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_00ea: 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_0125: 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_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: 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)
		Block("Crankcase", new Vector3(0f, 0.24f, -0.02f), new Vector3(0.36f, 0.29f, 0.43f), 0);
		int[] array = new int[2] { -1, 1 };
		foreach (int num in array)
		{
			Block("V8 rocker cover", new Vector3((float)num * 0.18f, 0.39f, -0.03f), new Vector3(0.16f, 0.15f, 0.48f), 2).transform.localRotation = Quaternion.Euler(0f, 0f, (float)(-num * 24));
			for (int j = 0; j < 4; j++)
			{
				float num2 = -0.2f + (float)j * 0.115f;
				Pipe("Exhaust header", new Vector3((float)num * 0.2f, 0.29f, num2), new Vector3((float)num * 0.31f, 0.15f, num2 + 0.04f), 0.027f, 3);
				Pipe("Spark plug lead", new Vector3((float)num * 0.12f, 0.47f, num2), new Vector3((float)num * 0.055f, 0.3f, num2), 0.008f, 4);
				Bolt(new Vector3((float)num * 0.18f, 0.48f, num2));
			}
			Pipe("Water cooled exhaust", new Vector3((float)num * 0.3f, 0.13f, -0.23f), new Vector3((float)num * 0.3f, 0.13f, 0.24f), 0.045f, 0);
		}
		Block("Intake plenum", new Vector3(0f, 0.48f, -0.01f), new Vector3(0.13f, 0.13f, 0.3f), 1);
		Pipe("Air intake", new Vector3(0f, 0.55f, -0.03f), new Vector3(0f, 0.64f, -0.03f), 0.09f, 0);
		Block("Timing belt guard", new Vector3(0f, 0.23f, -0.28f), new Vector3(0.27f, 0.3f, 0.055f), 2);
		for (int k = 0; k < 5; k++)
		{
			Block("Guard cooling slot", new Vector3(0f, 0.12f + (float)k * 0.045f, -0.313f), new Vector3(0.17f, 0.016f, 0.012f), 4);
		}
	}

	private static void Turbo()
	{
		//IL_0014: 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_0049: 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_008b: 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_00c8: 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_0105: 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_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: 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_01ff: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		Block("Inline block", new Vector3(0f, 0.25f, 0f), new Vector3(0.31f, 0.33f, 0.42f), 0);
		Block("Ceramic cold cowl", new Vector3(0f, 0.47f, 0f), new Vector3(0.44f, 0.17f, 0.49f), 2);
		for (int i = 0; i < 8; i++)
		{
			Block("Intercooler fin", new Vector3(0f, 0.13f + (float)i * 0.033f, -0.27f), new Vector3(0.37f, 0.012f, 0.055f), 1);
		}
		Torus("Turbo compressor", new Vector3(-0.24f, 0.33f, 0f), 0.105f, 0.034f, 1, Quaternion.Euler(0f, 90f, 0f));
		Pipe("Compressor intake", new Vector3(-0.34f, 0.33f, 0f), new Vector3(-0.24f, 0.33f, 0f), 0.055f, 0);
		Hose("Charge pipe", (Vector3[])(object)new Vector3[3]
		{
			new Vector3(-0.24f, 0.43f, 0f),
			new Vector3(-0.24f, 0.57f, 0.1f),
			new Vector3(0f, 0.57f, 0.1f)
		}, 0.037f, 1);
		float[] array = new float[2] { -0.14f, 0.14f };
		foreach (float num in array)
		{
			for (int k = 0; k < 4; k++)
			{
				Bolt(new Vector3(num, 0.56f, -0.17f + (float)k * 0.11f));
			}
		}
		Block("Heat shield", new Vector3(0.23f, 0.26f, 0.03f), new Vector3(0.045f, 0.25f, 0.35f), 5);
		for (int l = 0; l < 5; l++)
		{
			Block("Shield perforation", new Vector3(0.255f, 0.18f + (float)l * 0.04f, 0.03f), new Vector3(0.009f, 0.014f, 0.24f), 4);
		}
	}

	private static void Leviathan()
	{
		//IL_0014: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: 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_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_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)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: 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_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		Block("Marine reduction housing", new Vector3(0f, 0.24f, 0f), new Vector3(0.49f, 0.35f, 0.49f), 2);
		int[] array = new int[2] { -1, 1 };
		foreach (int num in array)
		{
			Pipe("Pressure cylinder", new Vector3((float)num * 0.29f, 0.16f, -0.19f), new Vector3((float)num * 0.29f, 0.16f, 0.22f), 0.074f, 1);
			float[] array2 = new float[2] { -0.15f, 0.17f };
			foreach (float num2 in array2)
			{
				Torus("Cylinder collar", new Vector3((float)num * 0.29f, 0.16f, num2), 0.078f, 0.013f, 5, Quaternion.identity);
			}
			Hose("Braided cooling hose", (Vector3[])(object)new Vector3[3]
			{
				new Vector3((float)num * 0.29f, 0.22f, -0.1f),
				new Vector3((float)num * 0.3f, 0.53f, -0.1f),
				new Vector3((float)num * 0.15f, 0.58f, -0.05f)
			}, 0.023f, 4);
		}
		Block("Sealed upper manifold", new Vector3(0f, 0.48f, 0f), new Vector3(0.39f, 0.17f, 0.4f), 0);
		for (int k = 0; k < 6; k++)
		{
			Block("Cast cooling rib", new Vector3(0f, 0.17f + (float)k * 0.045f, -0.28f), new Vector3(0.42f, 0.017f, 0.055f), 1);
		}
		Pipe("Gauge bezel", new Vector3(0f, 0.46f, -0.23f), new Vector3(0f, 0.46f, -0.27f), 0.065f, 5);
		Pipe("Gauge glass", new Vector3(0f, 0.46f, -0.273f), new Vector3(0f, 0.46f, -0.279f), 0.052f, 6);
		for (int l = 0; l < 4; l++)
		{
			Bolt(new Vector3((float)((l % 2 != 0) ? 1 : (-1)) * 0.18f, 0.58f, (float)((l >= 2) ? 1 : (-1)) * 0.17f));
		}
	}

	private static void Tempest()
	{
		//IL_0014: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: 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_00c4: 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_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: 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_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: 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)
		Block("Storm shield casting", new Vector3(0f, 0.28f, 0f), new Vector3(0.49f, 0.4f, 0.47f), 0);
		int[] array = new int[2] { -1, 1 };
		foreach (int num in array)
		{
			Pipe("Induction core", new Vector3((float)num * 0.24f, 0.23f, -0.2f), new Vector3((float)num * 0.24f, 0.23f, 0.2f), 0.085f, 1);
			for (int j = 0; j < 12; j++)
			{
				Torus("Copper induction winding", new Vector3((float)num * 0.24f, 0.23f, -0.18f + (float)j * 0.032f), 0.09f, 0.009f, 3, Quaternion.identity);
			}
			Block("Insulated coil shield", new Vector3((float)num * 0.34f, 0.25f, 0f), new Vector3(0.045f, 0.28f, 0.47f), 2);
			for (int k = 0; k < 4; k++)
			{
				Pipe("Shield fastener", new Vector3((float)num * 0.34f, 0.14f + (float)k * 0.075f, -0.18f), new Vector3((float)num * 0.36f, 0.14f + (float)k * 0.075f, -0.18f), 0.012f, 5);
			}
		}
		Block("Armored crown", new Vector3(0f, 0.54f, 0f), new Vector3(0.4f, 0.12f, 0.44f), 2);
		Pipe("Ceramic terminal", new Vector3(0f, 0.6f, 0f), new Vector3(0f, 0.75f, 0f), 0.045f, 5);
		for (int l = 0; l < 4; l++)
		{
			Torus("Terminal insulator", new Vector3(0f, 0.61f + (float)l * 0.03f, 0f), 0.055f, 0.012f, 6, Quaternion.Euler(90f, 0f, 0f));
		}
		for (int m = 0; m < 5; m++)
		{
			Block("Front intake louvre", new Vector3(0f, 0.19f + (float)m * 0.058f, -0.26f), new Vector3(0.31f, 0.026f, 0.04f), 1);
		}
	}

	private static void Bolt(Vector3 p)
	{
		//IL_0005: 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)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		Pipe("Hex captive bolt", p, p + Vector3.up * 0.018f, 0.015f, 5, null, 6);
	}

	private static GameObject Block(string name, Vector3 p, Vector3 size, int mat, Transform parent = null)
	{
		//IL_0000: 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_000c: 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_007f: 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_004f: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: 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_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Min(size.x, Mathf.Min(size.y, size.z)) * 0.16f;
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		for (int i = 0; i < 4; i++)
		{
			float num2 = i switch
			{
				2 => size.z / 2f - num, 
				1 => (0f - size.z) / 2f + num, 
				0 => (0f - size.z) / 2f, 
				_ => size.z / 2f, 
			};
			float num3 = size.x / 2f - ((i == 0 || i == 3) ? (num * 0.5f) : 0f);
			float num4 = size.y / 2f - ((i == 0 || i == 3) ? (num * 0.5f) : 0f);
			Vector2[] array = (Vector2[])(object)new Vector2[8]
			{
				new Vector2(0f - num3 + num, 0f - num4),
				new Vector2(num3 - num, 0f - num4),
				new Vector2(num3, 0f - num4 + num),
				new Vector2(num3, num4 - num),
				new Vector2(num3 - num, num4),
				new Vector2(0f - num3 + num, num4),
				new Vector2(0f - num3, num4 - num),
				new Vector2(0f - num3, 0f - num4 + num)
			};
			foreach (Vector2 val in array)
			{
				list.Add(new Vector3(val.x, val.y, num2));
			}
		}
		for (int k = 0; k < 3; k++)
		{
			for (int l = 0; l < 8; l++)
			{
				int num5 = k * 8 + l;
				int num6 = k * 8 + (l + 1) % 8;
				list2.AddRange(new int[6]
				{
					num5,
					num6,
					num5 + 8,
					num6,
					num6 + 8,
					num5 + 8
				});
			}
		}
		for (int m = 1; m < 7; m++)
		{
			list2.AddRange(new int[6]
			{
				0,
				m + 1,
				m,
				24,
				24 + m,
				24 + m + 1
			});
		}
		return MeshObject(name, list, list2, p, Quaternion.identity, mat, parent);
	}

	private static void Pipe(string name, Vector3 a, Vector3 b, float radius, int mat, Transform parent = null, int sides = 16)
	{
		//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_004f: 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_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: 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_0111: 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_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)
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		float num = Vector3.Distance(a, b);
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < sides; j++)
			{
				float num2 = (float)j * (float)Math.PI * 2f / (float)sides;
				list.Add(new Vector3(Mathf.Cos(num2) * radius, Mathf.Sin(num2) * radius, ((float)i - 0.5f) * num));
			}
		}
		for (int k = 0; k < sides; k++)
		{
			int num3 = (k + 1) % sides;
			list2.AddRange(new int[6]
			{
				k,
				num3,
				k + sides,
				num3,
				num3 + sides,
				k + sides
			});
		}
		for (int l = 1; l < sides - 1; l++)
		{
			list2.AddRange(new int[6]
			{
				0,
				l + 1,
				l,
				sides,
				sides + l,
				sides + l + 1
			});
		}
		Vector3 position = (a + b) / 2f;
		Vector3 val = b - a;
		MeshObject(name, list, list2, position, Quaternion.LookRotation(((Vector3)(ref val)).normalized), mat, parent);
	}

	private static void Hose(string name, Vector3[] p, float radius, int material)
	{
		//IL_0009: 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)
		for (int i = 1; i < p.Length; i++)
		{
			Pipe(name, p[i - 1], p[i], radius, material);
		}
	}

	private static void Torus(string name, Vector3 p, float radius, float tube, int mat, Quaternion rotation)
	{
		//IL_0070: 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_0110: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		for (int i = 0; i < 24; i++)
		{
			for (int j = 0; j < 8; j++)
			{
				float num = (float)i * (float)Math.PI * 2f / 24f;
				float num2 = (float)j * (float)Math.PI * 2f / 8f;
				list.Add(new Vector3(Mathf.Cos(num) * (radius + Mathf.Cos(num2) * tube), Mathf.Sin(num) * (radius + Mathf.Cos(num2) * tube), Mathf.Sin(num2) * tube));
			}
		}
		for (int k = 0; k < 24; k++)
		{
			for (int l = 0; l < 8; l++)
			{
				int num3 = k * 8 + l;
				int num4 = (k + 1) % 24 * 8 + l;
				int num5 = k * 8 + (l + 1) % 8;
				int num6 = (k + 1) % 24 * 8 + (l + 1) % 8;
				list2.AddRange(new int[6] { num3, num4, num5, num5, num4, num6 });
			}
		}
		MeshObject(name, list, list2, p, rotation, mat, null);
	}

	private static GameObject MeshObject(string name, List<Vector3> vertices, List<int> triangles, Vector3 position, Quaternion rotation, int material, Transform parent)
	{
		//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_0054: 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_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_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Expected O, but got Unknown
		Mesh val = new Mesh
		{
			name = name
		};
		val.SetVertices(vertices);
		val.SetTriangles(triangles, 0);
		val.RecalculateNormals();
		val.SetUVs(0, vertices.Select((Vector3 v) => new Vector2(v.x + v.z, v.y + v.z) * 2f).ToList());
		val.colors = Enumerable.Repeat<Color>(Color.white, vertices.Count).ToArray();
		val.RecalculateTangents();
		val.RecalculateBounds();
		owned.Add(val);
		GameObject val2 = new GameObject(name);
		val2.transform.SetParent(Object.op_Implicit((Object)(object)parent) ? parent : root.transform, false);
		val2.transform.localPosition = position;
		val2.transform.localRotation = rotation;
		val2.AddComponent<MeshFilter>().sharedMesh = val;
		((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = materials[material];
		return val2;
	}

	private static void Batch(Transform holder)
	{
		//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_0087: Expected O, but got Unknown
		//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_00e8: Unknown result type (might be due to invalid IL or missing references)
		MeshFilter[] componentsInChildren = ((Component)holder).GetComponentsInChildren<MeshFilter>();
		Material[] array = materials;
		foreach (Material material in array)
		{
			MeshFilter[] array2 = componentsInChildren.Where((MeshFilter f) => (Object)(object)((Component)f).GetComponent<Renderer>().sharedMaterial == (Object)(object)material).ToArray();
			if (array2.Length != 0)
			{
				Mesh val = new Mesh
				{
					name = ((Object)holder).name + " " + ((Object)material).name
				};
				val.indexFormat = (IndexFormat)1;
				val.CombineMeshes(array2.Select(delegate(MeshFilter f)
				{
					//IL_0002: 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_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_0037: Unknown result type (might be due to invalid IL or missing references)
					CombineInstance result = default(CombineInstance);
					((CombineInstance)(ref result)).mesh = f.sharedMesh;
					((CombineInstance)(ref result)).transform = holder.worldToLocalMatrix * ((Component)f).transform.localToWorldMatrix;
					return result;
				}).ToArray(), true, true);
				GameObject val2 = new GameObject(((Object)material).name);
				val2.transform.SetParent(holder, false);
				val2.AddComponent<MeshFilter>().sharedMesh = val;
				((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = material;
			}
		}
		MeshFilter[] array3 = componentsInChildren;
		for (int i = 0; i < array3.Length; i++)
		{
			Object.DestroyImmediate((Object)(object)((Component)array3[i]).gameObject);
		}
		foreach (Mesh item in owned)
		{
			Object.DestroyImmediate((Object)(object)item);
		}
		owned.Clear();
	}
}
public sealed class FstSemiAuto : MonoBehaviour
{
	private Weapon _weapon;

	private InputAction _action;

	private bool _armed;

	private bool _permit;

	public void Equip()
	{
		Detach();
		_weapon = ((Component)this).GetComponent<Weapon>();
		if (Object.op_Implicit((Object)(object)((Item)_weapon).Holder) && ((NetworkBehaviour)((Item)_weapon).Holder).Owner.IsLocalClient && !((Object)(object)GameInfo.Input == (Object)null))
		{
			_action = GameInfo.Input.actions["PlayerLeftClick"];
			_armed = !PhysicalHeld();
			_action.canceled += Release;
			ClearVanillaRequest();
		}
	}

	private bool PhysicalHeld()
	{
		//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_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)
		if (_action == null)
		{
			return true;
		}
		Enumerator<InputControl> enumerator = _action.controls.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				InputControl current = enumerator.Current;
				ButtonControl val = (ButtonControl)(object)((current is ButtonControl) ? current : null);
				if (val != null && val.isPressed)
				{
					return true;
				}
			}
		}
		finally
		{
			((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		return false;
	}

	private void Release(CallbackContext context)
	{
		_armed = !PhysicalHeld();
		ClearVanillaRequest();
	}

	public void Press(CallbackContext context)
	{
		if (_action == null)
		{
			Equip();
		}
		else if (((CallbackContext)(ref context)).performed && ((CallbackContext)(ref context)).action == _action && _armed && PhysicalHeld())
		{
			_armed = false;
			ClearVanillaRequest();
			_permit = true;
			try
			{
				AccessTools.Method(typeof(Weapon), "Shoot", (Type[])null, (Type[])null).Invoke(_weapon, null);
			}
			finally
			{
				_permit = false;
			}
		}
	}

	public bool ConsumePermit()
	{
		bool permit = _permit;
		_permit = false;
		return permit;
	}

	private void ClearVanillaRequest()
	{
		if (!((Object)(object)_weapon == (Object)null))
		{
			WeaponPack.Write(_weapon, "_holdingFireInput", false);
			WeaponPack.Write(_weapon, "_queuedShoot", false);
		}
	}

	public void Detach()
	{
		if (_action != null)
		{
			_action.canceled -= Release;
		}
		_action = null;
		_armed = false;
		_permit = false;
		ClearVanillaRequest();
	}

	private void OnDisable()
	{
		Detach();
	}

	private void OnEnable()
	{
		Equip();
	}

	private void OnApplicationFocus(bool focused)
	{
		_armed = focused && !PhysicalHeld();
		_permit = false;
	}
}
public static class FrostboundDisplayGeometry
{
	public static Color BaitTint(string name)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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_0089: Unknown result type (might be due to invalid IL or missing references)
		string text = name.ToLowerInvariant();
		if (text.Contains("hotdog"))
		{
			return new Color(0.65f, 0.27f, 0.15f);
		}
		if (text.Contains("carrot"))
		{
			return new Color(0.95f, 0.48f, 0.12f);
		}
		if (text.Contains("coconut"))
		{
			return new Color(0.4f, 0.26f, 0.15f);
		}
		if (text.Contains("leech"))
		{
			return new Color(0.28f, 0.34f, 0.22f);
		}
		return new Color(0.82f, 0.88f, 0.9f);
	}

	public static void FitBait(Transform model, Mesh mesh)
	{
		//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_0013: 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_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: 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_007f: 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_0077: 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_009c: 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_00a9: 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_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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		Bounds bounds = mesh.bounds;
		float x = ((Bounds)(ref bounds)).size.x;
		bounds = mesh.bounds;
		float y = ((Bounds)(ref bounds)).size.y;
		bounds = mesh.bounds;
		float num = 0.52f / Mathf.Max(0.01f, Mathf.Max(x, Mathf.Max(y, ((Bounds)(ref bounds)).size.z)));
		bounds = mesh.bounds;
		Vector3 size = ((Bounds)(ref bounds)).size;
		Quaternion val = (model.localRotation = ((size.y > size.x && size.y > size.z) ? Quaternion.Euler(0f, 0f, 90f) : Quaternion.identity));
		model.localScale = Vector3.one * num;
		bounds = mesh.bounds;
		model.localPosition = -(val * ((Bounds)(ref bounds)).center) * num + Vector3.up * (RotatedSize(val, size).y * num * 0.5f - 0.3f);
	}

	public static float KeepAboveFloor(Transform body, MeshFilter[] meshes)
	{
		//IL_0001: 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_00ca: 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_0045: 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_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_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		body.localPosition = Vector3.zero;
		float num = float.PositiveInfinity;
		foreach (MeshFilter val in meshes)
		{
			Bounds bounds = val.sharedMesh.bounds;
			for (int j = -1; j <= 1; j += 2)
			{
				for (int k = -1; k <= 1; k += 2)
				{
					for (int l = -1; l <= 1; l += 2)
					{
						Vector3 val2 = ((Component)val).transform.TransformPoint(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)j, (float)k, (float)l)));
						num = Mathf.Min(num, body.parent.InverseTransformPoint(val2).y);
					}
				}
			}
		}
		float num2 = Mathf.Max(0f, 0.025f - num);
		body.localPosition = Vector3.up * num2;
		return num2;
	}

	public static void CopyVisual(Transform source, Transform target, float width, bool alongWall, Transform frame = null, Renderer exclude = null)
	{
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_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_0102: 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_010a: 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_0119: 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_0128: 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_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Expected O, but got Unknown
		//IL_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_0490: Unknown result type (might be due to invalid IL or missing references)
		//IL_049c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04da: Unknown result type (might be due to invalid IL or missing references)
		//IL_04df: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0511: Unknown result type (might be due to invalid IL or missing references)
		//IL_0516: Unknown result type (might be due to invalid IL or missing references)
		//IL_0466: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0471: Unknown result type (might be due to invalid IL or missing references)
		//IL_0476: Unknown result type (might be due to invalid IL or missing references)
		//IL_047b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: 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_0302: 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_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0408: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (Object.op_Implicit((Object)(object)frame) ? frame : source);
		MeshFilter[] componentsInChildren = ((Component)source).GetComponentsInChildren<MeshFilter>(true);
		foreach (MeshFilter val2 in componentsInChildren)
		{
			MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>();
			if (!Object.op_Implicit((Object)(object)val2.sharedMesh) || !Object.op_Implicit((Object)(object)component) || !((Renderer)component).enabled || (Object)(object)component == (Object)(object)exclude)
			{
				continue;
			}
			bool flag = true;
			Transform val3 = ((Component)val2).transform;
			while ((Object)(object)val3 != (Object)(object)source)
			{
				if (!((Component)val3).gameObject.activeSelf)
				{
					flag = false;
				}
				val3 = val3.parent;
			}
			if (flag)
			{
				Transform transform = new GameObject(((Object)val2).name).transform;
				transform.SetParent(target, false);
				transform.localPosition = val.InverseTransformPoint(((Component)val2).transform.position);
				transform.localRotation = Quaternion.Inverse(val.rotation) * ((Component)val2).transform.rotation;
				Vector3 lossyScale = ((Component)val2).transform.lossyScale;
				Vector3 lossyScale2 = val.lossyScale;
				transform.localScale = new Vector3(lossyScale.x / lossyScale2.x, lossyScale.y / lossyScale2.y, lossyScale.z / lossyScale2.z);
				((Component)transform).gameObject.AddComponent<MeshFilter>().sharedMesh = val2.sharedMesh;
				((Renderer)((Component)transform).gameObject.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)component).sharedMaterials;
			}
		}
		SkinnedMeshRenderer[] componentsInChildren2 = ((Component)source).GetComponentsInChildren<SkinnedMeshRenderer>(true);
		foreach (SkinnedMeshRenderer val4 in componentsInChildren2)
		{
			if (!((Renderer)val4).enabled || !Object.op_Implicit((Object)(object)val4.sharedMesh) || (Object)(object)val4 == (Object)(object)exclude)
			{
				continue;
			}
			bool flag2 = true;
			Transform val5 = ((Component)val4).transform;
			while ((Object)(object)val5 != (Object)(object)source)
			{
				if (!((Component)val5).gameObject.activeSelf)
				{
					flag2 = false;
				}
				val5 = val5.parent;
			}
			if (!flag2)
			{
				continue;
			}
			Mesh val6 = new Mesh();
			val4.BakeMesh(val6, false);
			((Object)val6).name = ((Object)val4.sharedMesh).name + " presentation pose";
			if (val6.vertexCount != 0)
			{
				Bounds bounds = val6.bounds;
				Vector3 size = ((Bounds)(ref bounds)).size;
				if (!float.IsNaN(((Vector3)(ref size)).sqrMagnitude))
				{
					bounds = val6.bounds;
					size = ((Bounds)(ref bounds)).size;
					if (!float.IsInfinity(((Vector3)(ref size)).sqrMagnitude))
					{
						Transform transform2 = new GameObject(((Object)val4).name).transform;
						transform2.SetParent(target, false);
						transform2.localPosition = val.InverseTransformPoint(((Component)val4).transform.position);
						transform2.localRotation = Quaternion.Inverse(val.rotation) * ((Component)val4).transform.rotation;
						Vector3 lossyScale3 = ((Component)val4).transform.lossyScale;
						Vector3 lossyScale4 = val.lossyScale;
						transform2.localScale = new Vector3(lossyScale3.x / lossyScale4.x, lossyScale3.y / lossyScale4.y, lossyScale3.z / lossyScale4.z);
						((Component)transform2).gameObject.AddComponent<MeshFilter>().sharedMesh = val6;
						((Renderer)((Component)transform2).gameObject.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)val4).sharedMaterials;
						continue;
					}
				}
			}
			throw new InvalidOperationException("Invalid native skinned bake: " + ((Object)val4).name);
		}
		if (((Component)target).GetComponentsInChildren<Renderer>(true).Length == 0)
		{
			throw new InvalidOperationException("FST shop visual has no renderers");
		}
		Bounds val7 = default(Bounds);
		bool flag3 = true;
		componentsInChildren = ((Component)target).GetComponentsInChildren<MeshFilter>(true);
		foreach (MeshFilter val8 in componentsInChildren)
		{
			Bounds bounds2 = val8.sharedMesh.bounds;
			for (int j = -1; j <= 1; j += 2)
			{
				for (int k = -1; k <= 1; k += 2)
				{
					for (int l = -1; l <= 1; l += 2)
					{
						Vector3 val9 = target.InverseTransformPoint(((Component)val8).transform.TransformPoint(((Bounds)(ref bounds2)).center + Vector3.Scale(((Bounds)(ref bounds2)).extents, new Vector3((float)j, (float)k, (float)l))));
						if (flag3)
						{
							((Bounds)(ref val7))..ctor(val9, Vector3.zero);
							flag3 = false;
						}
						else
						{
							((Bounds)(ref val7)).Encapsulate(val9);
						}
					}
				}
			}
		}
		Quaternion val10 = Quaternion.Euler(0f, (float)((!alongWall) ? 90 : 0), 0f);
		if (Object.op_Implicit((Object)(object)frame))
		{
			val10 *= Quaternion.AngleAxis(90f, Vector3.forward);
		}
		float num = width / Mathf.Max(0.01f, Mathf.Max(((Bounds)(ref val7)).size.x, Mathf.Max(((Bounds)(ref val7)).size.y, ((Bounds)(ref val7)).size.z)));
		target.localRotation = val10;
		target.localScale = Vector3.one * num;
		target.localPosition = -(val10 * ((Bounds)(ref val7)).center) * num + Vector3.up * (RotatedSize(val10, ((Bounds)(ref val7)).size).y * num * 0.5f - 0.3f);
	}

	public static void Fit(Transform model, Mesh mesh, float width, bool alongWall)
	{
		//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_000a: 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_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_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: 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_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_007a: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: 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_0057: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_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_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: 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_00fa: 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_010b: 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_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: 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_014f: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: 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)
		Bounds bounds = mesh.bounds;
		Vector3 size = ((Bounds)(ref bounds)).size;
		Quaternion val = Quaternion.identity;
		if (size.z > size.x && size.z > size.y)
		{
			val = Quaternion.Euler(0f, 90f, 0f);
		}
		else if (size.y > size.x && size.y > size.z)
		{
			val = Quaternion.Euler(0f, 0f, 90f);
		}
		Vector3 val2 = RotatedSize(val, size);
		if (val2.y < val2.z)
		{
			val = Quaternion.Euler(-90f, 0f, 0f) * val;
		}
		if (alongWall)
		{
			val = Quaternion.Euler(0f, 90f, 0f) * val;
		}
		float num = width / Mathf.Max(0.01f, Mathf.Max(size.x, Mathf.Max(size.y, size.z)));
		model.localRotation = val;
		model.localScale = Vector3.one * num;
		Quaternion val3 = val;
		bounds = mesh.bounds;
		model.localPosition = -(val3 * ((Bounds)(ref bounds)).center) * num + Vector3.up * (RotatedSize(val, size).y * num * 0.5f - 0.3f);
	}

	private static Vector3 RotatedSize(Quaternion q, Vector3 size)
	{
		//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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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_0054: 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_006b: 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_008e: 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_00a5: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = q * new Vector3(size.x, 0f, 0f);
		Vector3 val2 = q * new Vector3(0f, size.y, 0f);
		Vector3 val3 = q * new Vector3(0f, 0f, size.z);
		return new Vector3(Mathf.Abs(val.x) + Mathf.Abs(val2.x) + Mathf.Abs(val3.x), Mathf.Abs(val.y) + Mathf.Abs(val2.y) + Mathf.Abs(val3.y), Mathf.Abs(val.z) + Mathf.Abs(val2.z) + Mathf.Abs(val3.z));
	}

	public static void Workshop(Transform merchandise, Material material, string name)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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_005e: 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_0095: 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_00c3: 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_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: 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)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: 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_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		Renderer component = ((Component)merchandise).GetComponent<Renderer>();
		if (Object.op_Implicit((Object)(object)component))
		{
			component.enabled = false;
		}
		merchandise.localPosition = Vector3.down * 0.14f;
		merchandise.localRotation = Quaternion.identity;
		merchandise.localScale = Vector3.one;
		string text = name.ToLowerInvariant();
		Part(merchandise, material, "Foam holder", new Vector3(0f, -0.16f, 0f), new Vector3(0.72f, 0.1f, 0.55f), cylinder: false);
		if (text.Contains("mag"))
		{
			Part(merchandise, material, "Magazine", Vector3.zero, new Vector3(0.28f, 0.12f, 0.48f), cylinder: false).localRotation = Quaternion.Euler(0f, -12f, 0f);
			for (int i = 0; i < 3; i++)
			{
				Part(merchandise, material, "Magazine rib", new Vector3(0f, 0.07f, -0.16f + (float)i * 0.15f), new Vector3(0.3f, 0.025f, 0.03f), cylinder: false);
			}
		}
		else if (text.Contains("ammo"))
		{
			for (int j = 0; j < 4; j++)
			{
				Part(merchandise, material, "Cartridge", new Vector3(((float)j - 1.5f) * 0.14f, 0.02f, 0f), new Vector3(0.09f, 0.16f, 0.09f), cylinder: true);
			}
		}
		else if (text.Contains("sharp"))
		{
			Part(merchandise, material, "Whetstone", Vector3.zero, new Vector3(0.5f, 0.13f, 0.26f), cylinder: false);
			Part(merchandise, material, "Honing handle", new Vector3(0.1f, 0.11f, 0f), new Vector3(0.6f, 0.05f, 0.06f), cylinder: false);
		}
		else if (text.Contains("scope") || text.Contains("sight") || text.Contains("laser") || text.Contains("dot"))
		{
			Part(merchandise, material, "Optic body", new Vector3(0f, 0.05f, 0f), new Vector3(0.16f, 0.26f, 0.16f), cylinder: true).localRotation = Quaternion.Euler(90f, 0f, 0f);
			int[] array = new int[2] { -1, 1 };
			foreach (int num in array)
			{
				Part(merchandise, material, "Optic mount", new Vector3(0f, -0.02f, (float)num * 0.14f), new Vector3(0.26f, 0.18f, 0.09f), cylinder: false);
			}
		}
		else
		{
			Part(merchandise, material, text.Contains("suppress") ? "Suppressor" : "Muzzle brake", Vector3.zero, new Vector3(0.17f, text.Contains("suppress") ? 0.28f : 0.16f, 0.17f), cylinder: true).localRotation = Quaternion.Euler(90f, 0f, 0f);
			for (int l = 0; l < 3; l++)
			{
				Part(merchandise, material, "Machined ring", new Vector3(0f, 0f, -0.17f + (float)l * 0.17f), new Vector3(0.19f, 0.025f, 0.19f), cylinder: true).localRotation = Quaternion.Euler(90f, 0f, 0f);
			}
		}
	}

	private static Transform Part(Transform parent, Material mat, string name, Vector3 p, Vector3 size, bool cylinder)
	{
		//IL_0027: 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)
		GameObject obj = GameObject.CreatePrimitive((PrimitiveType)(cylinder ? 2 : 3));
		((Object)obj).name = name;
		obj.transform.SetParent(parent, false);
		obj.transform.localPosition = p;
		obj.transform.localScale = size;
		obj.GetComponent<Renderer>().sharedMaterial = mat;
		Collider component = obj.GetComponent<Collider>();
		component.enabled = false;
		Object.Destroy((Object)(object)component);
		return obj.transform;
	}
}
public static class BuildNewFstWeapons
{
	internal sealed class Shape
	{
		private readonly List<Vector3> v = new List<Vector3>();

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

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

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

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

		internal float PixelDensity = 112f;

		internal int VertexCount => v.Count;

		internal void Face(int color, params Vector3[] p)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004e: 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_007a: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_0090: 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_0096: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00cb: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00e2: 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_00f3: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			int count = v.Count;
			Vector3 val = Vector3.Cross(p[1] - p[0], p[2] - p[0]);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			int num = ((normalized.y > 0.45f) ? 3 : ((!(normalized.y < -0.35f)) ? ((normalized.x < -0.4f) ? 1 : 2) : 0));
			Vector2 val2 = NewWeaponSurfaces.Project(p[0], normalized);
			Vector2 val3 = val2;
			Vector3[] array = p;
			for (int i = 0; i < array.Length; i++)
			{
				Vector2 val4 = NewWeaponSurfaces.Project(array[i], normalized);
				val2 = Vector2.Min(val2, val4);
				val3 = Vector2.Max(val3, val4);
			}
			array = p;
			foreach (Vector3 val5 in array)
			{
				Vector2 val6 = NewWeaponSurfaces.Project(val5, normalized);
				v.Add(val5);
				uv.Add(NewWeaponSurfaces.PixelUV(color, num, val6, val2, val3 - val2, PixelDensity));
				surface.Add(val6 * 3f);
				semantics.Add(new Vector2((float)color, (float)num));
			}
			for (int j = 1; j < p.Length - 1; j++)
			{
				tri.AddRange(new int[3]
				{
					count,
					count + j,
					count + j + 1
				});
			}
		}

		internal void Loft(int color, params Vector4[] stations)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_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_006d: 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_0081: 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_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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_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_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3[]> list = new List<Vector3[]>();
			foreach (Vector4 val in stations)
			{
				float num = val.z * 0.5f;
				float num2 = val.w * 0.5f;
				float num3 = Mathf.Min(num, num2) * 0.38f;
				Vector2[] array = (Vector2[])(object)new Vector2[8]
				{
					new Vector2(0f - num, 0f - num2 + num3),
					new Vector2(0f - num + num3, 0f - num2),
					new Vector2(num - num3, 0f - num2),
					new Vector2(num, 0f - num2 + num3),
					new Vector2(num, num2 - num3),
					new Vector2(num - num3, num2),
					new Vector2(0f - num + num3, num2),
					new Vector2(0f - num, num2 - num3)
				};
				Vector3[] array2 = (Vector3[])(object)new Vector3[8];
				for (int j = 0; j < 8; j++)
				{
					array2[j] = new Vector3(array[j].x, array[j].y + val.y, val.x);
				}
				list.Add(array2);
			}
			for (int k = 0; k < list.Count - 1; k++)
			{
				for (int l = 0; l < 8; l++)
				{
					int num4 = (l + 1) % 8;
					Face(color, list[k][l], list[k][num4], list[k + 1][num4], list[k + 1][l]);
				}
			}
			Vector3[] array3 = (Vector3[])list[0].Clone();
			Array.Reverse((Array)array3);
			Face(color, array3);
			Face(color, list[list.Count - 1]);
		}

		internal void Profile(int color, float width, float bevel, float offsetX, params Vector2[] p)
		{
			//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_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0031: 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_003c: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0125: 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_0134: 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_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)
			Vector2 val = Vector2.zero;
			foreach (Vector2 val2 in p)
			{
				val += val2;
			}
			val /= (float)p.Length;
			float num = 0f;
			for (int j = 0; j < p.Length; j++)
			{
				num += p[j].x * p[(j + 1) % p.Length].y - p[(j + 1) % p.Length].x * p[j].y;
			}
			if (num < 0f)
			{
				Array.Reverse((Array)p);
			}
			Vector3[][] array = new Vector3[4][];
			for (int k = 0; k < 4; k++)
			{
				float num2 = k switch
				{
					2 => width * 0.5f - bevel, 
					1 => (0f - width) * 0.5f + bevel, 
					0 => (0f - width) * 0.5f, 
					_ => width * 0.5f, 
				} + offsetX;
				array[k] = (Vector3[])(object)new Vector3[p.Length];
				for (int l = 0; l < p.Length; l++)
				{
					Vector2 val3 = p[l];
					if (k == 0 || k == 3)
					{
						val3 = Vector2.MoveTowards(val3, val, bevel);
					}
					array[k][l] = new Vector3(num2, val3.y, val3.x);
				}
			}
			for (int m = 0; m < 3; m++)
			{
				for (int n = 0; n < p.Length; n++)
				{
					int num3 = (n + 1) % p.Length;
					Face(color, array[m][num3], array[m][n], array[m + 1][n], array[m + 1][num3]);
				}
			}
			Face(color, array[0]);
			Vector3[] array2 = (Vector3[])array[3].Clone();
			Array.Reverse((Array)array2);
			Face(color, array2);
		}

		internal void Tube(int color, Vector3 a, Vector3 b, float radius, float inner = 0f, int count = 12, float tipRadius = -1f)
		{
			//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_000a: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00a0: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00dc: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00f9: 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_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_0108: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: 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_027b: 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_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: 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: Unkno