Decompiled source of MissingMarble v0.6.0

plugins/MissingMarble.dll

Decompiled 16 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MissingMarble
{
	internal static class CreepingRotationCorrection
	{
		internal static void Apply(GameObject prefab, string id, ManualLogSource logger)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (!(id != "MM_BlackMarble_creep_4x1x1") || !(id != "MM_BlackMarble_creep_4x2x1"))
			{
				RandomPieceRotation[] componentsInChildren = prefab.GetComponentsInChildren<RandomPieceRotation>(true);
				Transform val = prefab.transform.Find("new");
				if (prefab.activeInHierarchy || !Object.op_Implicit((Object)(object)val) || componentsInChildren.Length != 1 || (Object)(object)((Component)componentsInChildren[0]).transform != (Object)(object)val)
				{
					throw new InvalidOperationException("Unexpected creeping rotation hierarchy or active prefab: " + id);
				}
				Object.DestroyImmediate((Object)(object)componentsInChildren[0]);
				val.localRotation = Quaternion.identity;
				if (prefab.GetComponentsInChildren<RandomPieceRotation>(true).Length != 0)
				{
					throw new InvalidOperationException("Creeping rotation component removal failed: " + id);
				}
				logger.LogInfo((object)("Missing Marble Alpha.4-C: " + id + " RandomPieceRotation 1 -> 0; new local rotation identity."));
			}
		}
	}
	internal static class DemisterConverter
	{
		internal static void RegisterAll(ManualLogSource logger)
		{
			TryRegister(logger, "dverger_demister", "MM_Dvergr_WispLight", "Dvergr Wisp Light", 1, 2, 1);
			TryRegister(logger, "dverger_demister_large", "MM_Dvergr_WispLight_Large", "Dvergr Large Wisp Light", 2, 4, 2);
		}

		internal static void AddSnap(Transform parent, Vector3 position)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_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)
			GameObject val = new GameObject("$hud_snappoint_bottom");
			val.SetActive(false);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = position;
			val.layer = ((Component)parent).gameObject.layer;
			val.tag = "snappoint";
		}

		private static void TryRegister(ManualLogSource logger, string sourceName, string id, string displayName, int marble, int copper, int wisp)
		{
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: 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_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: 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_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: 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_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Expected O, but got Unknown
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Expected O, but got Unknown
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = null;
			try
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab(sourceName);
				GameObject prefab2 = PrefabManager.Instance.GetPrefab("blackmarble_2x2x1");
				GameObject prefab3 = PrefabManager.Instance.GetPrefab("piece_wisplure");
				if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)prefab2) || Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab(id)))
				{
					throw new InvalidOperationException("Source/reference missing or duplicate ID.");
				}
				Piece component = prefab2.GetComponent<Piece>();
				if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.m_icon) || !Object.op_Implicit((Object)(object)prefab.GetComponent<WearNTear>()) || !Object.op_Implicit((Object)(object)prefab.GetComponent<ZNetView>()) || Object.op_Implicit((Object)(object)prefab.GetComponent<Piece>()))
				{
					throw new InvalidOperationException("Unexpected source/reference components.");
				}
				string[] array = new string[3] { "BlackMarble", "Copper", "Wisp" };
				foreach (string text in array)
				{
					if (!Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab(text)))
					{
						throw new InvalidOperationException("Missing recipe item: " + text);
					}
				}
				val = new GameObject("MissingMarble_Staging_" + id);
				val.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)val);
				GameObject val2 = Object.Instantiate<GameObject>(prefab, val.transform, false);
				((Object)val2).name = id;
				val2.transform.localPosition = Vector3.zero;
				Transform obj = val2.transform.Find("New");
				if (!Object.op_Implicit((Object)(object)obj))
				{
					throw new InvalidOperationException("Missing pedestal.");
				}
				BoxCollider component2 = ((Component)obj).GetComponent<BoxCollider>();
				if (!Object.op_Implicit((Object)(object)component2) || !((Collider)component2).enabled)
				{
					throw new InvalidOperationException("Missing pedestal collider.");
				}
				float num = float.PositiveInfinity;
				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 val3 = component2.center + Vector3.Scale(component2.size * 0.5f, new Vector3((float)j, (float)k, (float)l));
							num = Mathf.Min(num, val2.transform.InverseTransformPoint(((Component)component2).transform.TransformPoint(val3)).y);
						}
					}
				}
				foreach (Transform item in val2.transform)
				{
					item.localPosition -= Vector3.up * num;
				}
				val2.layer = prefab2.layer;
				Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Component)componentsInChildren[i]).gameObject.layer = prefab2.layer;
				}
				DropOnDestroyed[] componentsInChildren2 = val2.GetComponentsInChildren<DropOnDestroyed>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
				}
				Destructible[] componentsInChildren3 = val2.GetComponentsInChildren<Destructible>(true);
				for (int i = 0; i < componentsInChildren3.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
				}
				Piece val5 = val2.AddComponent<Piece>();
				Piece val6 = (Object.op_Implicit((Object)(object)prefab3) ? prefab3.GetComponent<Piece>() : null);
				val5.m_icon = ((Object.op_Implicit((Object)(object)val6) && Object.op_Implicit((Object)(object)val6.m_icon)) ? val6.m_icon : component.m_icon);
				val5.m_canRotate = true;
				val5.m_canBeRemoved = true;
				val5.m_placeEffect = component.m_placeEffect;
				if (sourceName == "dverger_demister")
				{
					Transform val7 = val2.transform.Find("_enabled");
					Transform val8 = (Object.op_Implicit((Object)(object)val7) ? val7.Find("demister_ball (1)") : null);
					if (Object.op_Implicit((Object)(object)val7) && Object.op_Implicit((Object)(object)val8))
					{
						val7.localPosition -= Vector3.up * 0.09f;
						val8.localScale *= 0.8f;
						logger.LogInfo((object)"Missing Marble: standard wisp effect group lowered 0.09 m; orb scale factor 0.8.");
					}
					else
					{
						logger.LogWarning((object)"Missing Marble: standard wisp visual hierarchy changed; retaining native effects.");
					}
					AddSnap(val2.transform, Vector3.zero);
				}
				PieceConfig val9 = new PieceConfig
				{
					Name = displayName,
					Description = "A Dvergr light that dispels mist.",
					PieceTable = "_HammerPieceTable",
					Category = HammerCategories.For(id),
					CraftingStation = "piece_stonecutter",
					Enabled = true,
					Icon = val5.m_icon
				};
				val9.AddRequirement("BlackMarble", marble, true);
				val9.AddRequirement("Copper", copper, true);
				val9.AddRequirement("Wisp", wisp, true);
				CustomPiece val10 = new CustomPiece(val2, false, val9);
				if (!val10.IsValid())
				{
					throw new InvalidOperationException("Custom piece validation failed.");
				}
				HammerCategories.ApplyUsage(val10.PiecePrefab.GetComponent<Piece>(), id, logger);
				if (!PieceManager.Instance.AddPiece(val10))
				{
					throw new InvalidOperationException("Jotunn rejected custom piece.");
				}
				logger.LogInfo((object)$"Missing Marble category: {id}; requested={val9.Category}; prefab={val10.PiecePrefab.GetComponent<Piece>().m_category}");
				logger.LogInfo((object)$"Missing Marble: submitted {id} to Jotunn; pedestal offset={0f - num:F3} m.");
			}
			catch (Exception arg)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					Object.DestroyImmediate((Object)(object)val);
				}
				logger.LogError((object)$"Missing Marble demister conversion failed ({sourceName}): {arg}");
			}
		}
	}
	public enum HammerCategoryMode
	{
		Vanilla,
		Dedicated
	}
	internal static class HammerCategories
	{
		private static bool vanilla;

		private static readonly Dictionary<string, PieceCategory> Categories = new Dictionary<string, PieceCategory>();

		private static readonly Dictionary<string, UsageTagFlags> Usage = new Dictionary<string, UsageTagFlags>
		{
			{
				"MM_BlackMarble_2x2x1",
				(UsageTagFlags)92
			},
			{
				"MM_BlackMarble_2x2_enforced",
				(UsageTagFlags)92
			},
			{
				"MM_BlackMarble_base_2",
				(UsageTagFlags)68
			},
			{
				"MM_BlackMarble_column_3",
				(UsageTagFlags)68
			},
			{
				"MM_BlackMarble_out_2",
				(UsageTagFlags)68
			},
			{
				"MM_BlackMarble_post01",
				(UsageTagFlags)68
			},
			{
				"MM_BlackMarble_floor_large",
				(UsageTagFlags)76
			},
			{
				"MM_BlackMarble_tile_floor_1x1",
				(UsageTagFlags)76
			},
			{
				"MM_BlackMarble_tile_floor_2x2",
				(UsageTagFlags)76
			},
			{
				"MM_BlackMarble_slope_1x2",
				(UsageTagFlags)84
			},
			{
				"MM_BlackMarble_slope_inverted_1x2",
				(UsageTagFlags)84
			},
			{
				"MM_BlackMarble_tile_wall_1x1",
				(UsageTagFlags)84
			},
			{
				"MM_BlackMarble_tile_wall_2x2",
				(UsageTagFlags)84
			},
			{
				"MM_BlackMarble_tile_wall_2x4",
				(UsageTagFlags)84
			},
			{
				"MM_BlackMarble_creep_4x1x1",
				(UsageTagFlags)84
			},
			{
				"MM_BlackMarble_creep_4x2x1",
				(UsageTagFlags)84
			},
			{
				"MM_BlackMarble_creep_slope_inverted_1x1x2",
				(UsageTagFlags)84
			},
			{
				"MM_BlackMarble_creep_slope_inverted_2x2x1",
				(UsageTagFlags)84
			},
			{
				"MM_BlackMarble_stair_corner",
				(UsageTagFlags)131076
			},
			{
				"MM_BlackMarble_stair_corner_left",
				(UsageTagFlags)131076
			},
			{
				"MM_BlackMarble_creep_stair",
				(UsageTagFlags)131076
			},
			{
				"MM_BlackMarble_head01",
				(UsageTagFlags)512
			},
			{
				"MM_BlackMarble_head02",
				(UsageTagFlags)512
			},
			{
				"MM_BlackMarble_head_big01",
				(UsageTagFlags)512
			},
			{
				"MM_BlackMarble_head_big02",
				(UsageTagFlags)512
			},
			{
				"MM_Dvergr_WispLight",
				(UsageTagFlags)33024
			},
			{
				"MM_Dvergr_WispLight_Large",
				(UsageTagFlags)33024
			}
		};

		internal static void Initialize(HammerCategoryMode selected, bool forceFallback, ManualLogSource logger)
		{
			vanilla = false;
			Categories.Clear();
			if (selected == HammerCategoryMode.Dedicated)
			{
				logger.LogInfo((object)"Missing Marble Hammer mode=Dedicated");
				return;
			}
			try
			{
				if (forceFallback || selected != HammerCategoryMode.Vanilla)
				{
					throw new InvalidOperationException("Forced fallback or invalid mode.");
				}
				Resolve("Architecture", "blackmarble_1x1", (PieceCategory)3, logger);
				Resolve("Stairs", "blackmarble_stair", (PieceCategory)3, logger);
				Resolve("Decor", "piece_banner01", (PieceCategory)4, logger);
				Resolve("Lighting", "piece_groundtorch_mist", (PieceCategory)4, logger);
				ValidateMatrix();
				vanilla = true;
				logger.LogInfo((object)"Missing Marble Hammer mode=Vanilla; Building=21; Floor=5; Wall=11; Architecture=18; Stairs=3; Decor=4; Lighting=2; Defense=2 (planned)");
			}
			catch (Exception ex)
			{
				Categories.Clear();
				logger.LogWarning((object)("Missing Marble category fallback=Dedicated; registration continues: " + ex.Message));
			}
		}

		private static void Resolve(string group, string name, PieceCategory expected, ManualLogSource logger)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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)
			GameObject prefab = PrefabManager.Instance.GetPrefab(name);
			Piece val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Piece>() : null);
			if (!Object.op_Implicit((Object)(object)val) || val.m_category != expected)
			{
				throw new InvalidOperationException("Unexpected native reference: " + name);
			}
			Categories.Add(group, expected);
			logger.LogInfo((object)$"Missing Marble reference: {name}; category={val.m_category}; usage={val.m_usage}");
		}

		private static string Group(string id)
		{
			if (!id.StartsWith("MM_Dvergr_WispLight", StringComparison.Ordinal))
			{
				if (!id.StartsWith("MM_BlackMarble_head", StringComparison.Ordinal))
				{
					if (!id.Contains("_stair"))
					{
						return "Architecture";
					}
					return "Stairs";
				}
				return "Decor";
			}
			return "Lighting";
		}

		internal unsafe static string For(string id)
		{
			if (!vanilla || !Categories.TryGetValue(Group(id), out var value))
			{
				return "Missing Marble";
			}
			return ((object)(*(PieceCategory*)(&value))/*cast due to .constrained prefix*/).ToString();
		}

		internal static void ApplyUsage(Piece piece, string id, ManualLogSource logger)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (vanilla)
			{
				piece.m_usage = Usage[id];
				logger.LogInfo((object)$"Missing Marble usage: {id}; category={piece.m_category}; usage={piece.m_usage}");
			}
		}

		private static void ValidateMatrix()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal);
			string[][] array = new string[3][]
			{
				ProductionIcons.Accepted,
				ProductionIcons.Remaining,
				ProductionIcons.Retained
			};
			foreach (string[] array2 in array)
			{
				foreach (string text in array2)
				{
					if (!hashSet.Add(text) || !Usage.ContainsKey(text) || (int)Usage[text] == 0)
					{
						throw new InvalidOperationException("Invalid usage matrix entry: " + text);
					}
				}
			}
			if (hashSet.Count != 27 || Usage.Count != 27)
			{
				throw new InvalidOperationException("Invalid usage matrix size.");
			}
		}

		internal static void Report(ManualLogSource logger)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = 0;
			string[][] array = new string[3][]
			{
				ProductionIcons.Accepted,
				ProductionIcons.Remaining,
				ProductionIcons.Retained
			};
			foreach (string[] array2 in array)
			{
				foreach (string text in array2)
				{
					if (PieceManager.Instance.GetPiece(text) != null && Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab(text)))
					{
						num++;
						Piece component = PrefabManager.Instance.GetPrefab(text).GetComponent<Piece>();
						if (vanilla && Object.op_Implicit((Object)(object)component) && component.m_usage == Usage[text])
						{
							num2++;
						}
					}
				}
			}
			if (vanilla)
			{
				if (num2 == 27)
				{
					logger.LogInfo((object)"Missing Marble combined usage validation: 27/27 PASS");
				}
				else
				{
					logger.LogError((object)$"Missing Marble combined usage validation: {num2}/27; DO NOT LOAD EXISTING WORLDS.");
				}
			}
			if (num == 27)
			{
				logger.LogInfo((object)"Missing Marble registration readiness: 27/27 submitted prefabs available; verify world registration in disposable world.");
			}
			else
			{
				logger.LogError((object)$"Missing Marble registration readiness: {num}/27; DO NOT LOAD EXISTING WORLDS.");
			}
		}
	}
	internal static class IconAudit
	{
		private static Sprite Icon(string id)
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab(id);
			Piece val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Piece>() : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return val.m_icon;
		}

		private static string Describe(Sprite sprite)
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)sprite))
			{
				return "NONE";
			}
			Texture2D texture = sprite.texture;
			Rect rect = sprite.rect;
			return $"sprite={((Object)sprite).name}; spriteId={((Object)sprite).GetInstanceID()}; rect={rect}; " + "texture=" + (Object.op_Implicit((Object)(object)texture) ? ((Object)texture).name : "NONE") + "; " + $"textureId={(Object.op_Implicit((Object)(object)texture) ? ((Object)texture).GetInstanceID() : 0)}; " + $"textureSize={(Object.op_Implicit((Object)(object)texture) ? ((Texture)texture).width : 0)}x{(Object.op_Implicit((Object)(object)texture) ? ((Texture)texture).height : 0)}";
		}

		internal static void Run(string path)
		{
			StringBuilder stringBuilder = new StringBuilder("Missing Marble 0.6.0 icon audit\n");
			Dictionary<int, List<string>> dictionary = new Dictionary<int, List<string>>();
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			Sprite val = Icon("blackmarble_2x2x1");
			Sprite val2 = Icon("piece_wisplure");
			stringBuilder.AppendLine("Block reference: " + Describe(val));
			stringBuilder.AppendLine("Wisp lure reference: " + Describe(val2));
			(string, string)[] targets = SnapDiagnostics.Targets;
			for (int i = 0; i < targets.Length; i++)
			{
				(string, string) tuple = targets[i];
				stringBuilder.AppendLine("\n-- " + tuple.Item2 + " --");
				try
				{
					GameObject prefab = PrefabManager.Instance.GetPrefab(tuple.Item2);
					Piece val3 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Piece>() : null);
					if (Object.op_Implicit((Object)(object)val3))
					{
						num++;
					}
					Sprite val4 = (Object.op_Implicit((Object)(object)val3) ? val3.m_icon : null);
					Sprite val5 = Icon(tuple.Item1);
					stringBuilder.AppendLine("Source: " + tuple.Item1 + "; display=" + (Object.op_Implicit((Object)(object)val3) ? val3.m_name : "MISSING"));
					stringBuilder.AppendLine("Native: " + Describe(val5));
					stringBuilder.AppendLine("Custom: " + Describe(val4));
					if (Object.op_Implicit((Object)(object)val4))
					{
						num2++;
						stringBuilder.AppendLine("Same native sprite: " + (Object.op_Implicit((Object)(object)val5) && (Object)(object)val4 == (Object)(object)val5));
						stringBuilder.AppendLine("Same block sprite: " + (Object.op_Implicit((Object)(object)val) && (Object)(object)val4 == (Object)(object)val));
						stringBuilder.AppendLine("Same wisp lure sprite: " + (Object.op_Implicit((Object)(object)val2) && (Object)(object)val4 == (Object)(object)val2));
						int instanceID = ((Object)val4).GetInstanceID();
						if (!dictionary.TryGetValue(instanceID, out var value))
						{
							value = (dictionary[instanceID] = new List<string>());
						}
						value.Add(tuple.Item2);
					}
				}
				catch (Exception ex)
				{
					num3++;
					stringBuilder.AppendLine("AUDIT ERROR: " + ex);
				}
			}
			stringBuilder.AppendLine("\nShared sprite objects:");
			foreach (KeyValuePair<int, List<string>> item in dictionary)
			{
				if (item.Value.Count > 1)
				{
					stringBuilder.AppendLine(item.Key + ": " + string.Join(", ", item.Value));
				}
			}
			stringBuilder.AppendLine($"Summary: targets={SnapDiagnostics.Targets.Length}; pieces={num}; icons={num2}; distinctSprites={dictionary.Count}; errors={num3}");
			File.WriteAllText(path, stringBuilder.ToString());
		}
	}
	internal static class LocalizationDiagnostics
	{
		internal static void Run(string path)
		{
			StringBuilder s = new StringBuilder("Missing Marble localization diagnostics - 0.6.0\n");
			Localization loc = Localization.instance;
			s.AppendLine("Selected language: " + loc.GetSelectedLanguage());
			int evaluations = 0;
			int unresolved = 0;
			int num = 0;
			int num2 = 0;
			string[] array = new string[6] { "top", "bottom", "edge", "inner", "center", "corner" };
			foreach (string text in array)
			{
				Evaluate("TOKEN", "$hud_snappoint_" + text);
			}
			array = new string[8] { "top $hud_snappoint_corner 1", "bottom $hud_snappoint_corner 2", "top $hud_snappoint_edge 3", "bottom $hud_snappoint_edge 4", "top $hud_snappoint_center", "bottom $hud_snappoint_center", "top $hud_snappoint_inner 1", "bottom $hud_snappoint_inner 2" };
			foreach (string text2 in array)
			{
				Evaluate("COMPOUND", "$hud_snappoint_" + text2);
			}
			int[] array2 = new int[3] { 1, 10, 12 };
			foreach (int num3 in array2)
			{
				Evaluate("NUMBER", "$hud_snappoint_top " + num3);
			}
			Evaluate("MISSING CONTROL", "$hud_snappoint_missingmarble_test_invalid", control: true);
			(string, string)[] targets = SnapDiagnostics.Targets;
			for (int i = 0; i < targets.Length; i++)
			{
				(string, string) tuple = targets[i];
				GameObject prefab = PrefabManager.Instance.GetPrefab(tuple.Item2);
				if (!Object.op_Implicit((Object)(object)prefab))
				{
					s.AppendLine("UNAVAILABLE " + tuple.Item2);
					continue;
				}
				num++;
				Transform[] array3 = (from t in prefab.GetComponentsInChildren<Transform>(true)
					where ((Component)t).CompareTag("snappoint")
					select t).ToArray();
				s.AppendLine("ASSET " + tuple.Item2 + " count=" + array3.Length);
				for (int num4 = 0; num4 < array3.Length; num4++)
				{
					Evaluate("SNAP " + num4, "$msg_snapping " + ((Object)array3[num4]).name);
					num2++;
				}
			}
			s.AppendLine("Assets found: " + num + "/27");
			s.AppendLine("Snap points evaluated: " + num2 + "/208");
			s.AppendLine("Total evaluations: " + evaluations + "/226");
			s.AppendLine("Unexpected unresolved evaluations: " + unresolved);
			File.WriteAllText(path, s.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: true));
			void Evaluate(string label, string input, bool control = false)
			{
				string text3 = loc.Localize(input);
				bool flag = text3.Contains("[hud_snappoint_") || text3.Contains("[msg_snapping") || text3.Contains("$hud_snappoint_") || text3.Contains("$msg_snapping");
				evaluations++;
				if (flag && !control)
				{
					unresolved++;
				}
				s.AppendLine(label + " | input=" + input + " | output=" + text3 + " | " + ((!control) ? (flag ? "UNRESOLVED" : (input.Contains("$") ? "TRANSLATED (review)" : "LITERAL")) : (flag ? "EXPECTED MISSING" : "CONTROL UNEXPECTED")));
			}
		}
	}
	internal static class PieceRegistrar
	{
		private static readonly (string Source, string Id, string Display, int Marble, int Copper)[] Definitions = new(string, string, string, int, int)[24]
		{
			("blackmarble_2x2x1", "MM_BlackMarble_2x2x1", "Black Marble Block 2x2x1", 6, 0),
			("blackmarble_2x2_enforced", "MM_BlackMarble_2x2_enforced", "Black Marble Reinforced Block 2x2", 8, 2),
			("blackmarble_base_2", "MM_BlackMarble_base_2", "Black Marble Base II", 5, 0),
			("blackmarble_column_3", "MM_BlackMarble_column_3", "Black Marble Column III", 6, 0),
			("blackmarble_floor_large", "MM_BlackMarble_floor_large", "Black Marble Large Floor", 8, 0),
			("blackmarble_out_2", "MM_BlackMarble_out_2", "Black Marble Cornice II", 5, 0),
			("blackmarble_slope_1x2", "MM_BlackMarble_slope_1x2", "Black Marble Slope 1x2", 3, 0),
			("blackmarble_slope_inverted_1x2", "MM_BlackMarble_slope_inverted_1x2", "Black Marble Inverted Slope 1x2", 3, 0),
			("blackmarble_stair_corner", "MM_BlackMarble_stair_corner", "Black Marble Corner Stair Right", 4, 0),
			("blackmarble_stair_corner_left", "MM_BlackMarble_stair_corner_left", "Black Marble Corner Stair Left", 4, 0),
			("blackmarble_tile_floor_1x1", "MM_BlackMarble_tile_floor_1x1", "Black Marble Floor Tile 1x1", 1, 0),
			("blackmarble_tile_floor_2x2", "MM_BlackMarble_tile_floor_2x2", "Black Marble Floor Tile 2x2", 2, 0),
			("blackmarble_tile_wall_1x1", "MM_BlackMarble_tile_wall_1x1", "Black Marble Wall Tile 1x1", 1, 0),
			("blackmarble_tile_wall_2x2", "MM_BlackMarble_tile_wall_2x2", "Black Marble Wall Tile 2x2", 2, 0),
			("blackmarble_tile_wall_2x4", "MM_BlackMarble_tile_wall_2x4", "Black Marble Wall Tile 2x4", 4, 0),
			("blackmarble_creep_4x1x1", "MM_BlackMarble_creep_4x1x1", "Black Marble Creeping Block 4x1x1", 4, 0),
			("blackmarble_creep_4x2x1", "MM_BlackMarble_creep_4x2x1", "Black Marble Creeping Block 4x2x1", 8, 0),
			("blackmarble_creep_slope_inverted_1x1x2", "MM_BlackMarble_creep_slope_inverted_1x1x2", "Black Marble Creeping Inverted Slope 1x1x2", 3, 0),
			("blackmarble_creep_slope_inverted_2x2x1", "MM_BlackMarble_creep_slope_inverted_2x2x1", "Black Marble Creeping Inverted Slope 2x2x1", 4, 0),
			("blackmarble_creep_stair", "MM_BlackMarble_creep_stair", "Black Marble Creeping Stair", 4, 0),
			("blackmarble_head01", "MM_BlackMarble_head01", "Black Marble Head I", 4, 0),
			("blackmarble_head02", "MM_BlackMarble_head02", "Black Marble Head II", 4, 0),
			("blackmarble_head_big01", "MM_BlackMarble_head_big01", "Black Marble Large Head I", 8, 0),
			("blackmarble_head_big02", "MM_BlackMarble_head_big02", "Black Marble Large Head II", 8, 0)
		};

		private static bool submitted;

		internal static void Register(ManualLogSource logger)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: 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_021b: 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_0242: Unknown result type (might be due to invalid IL or missing references)
			if (submitted)
			{
				return;
			}
			submitted = true;
			int num = 0;
			(string, string, string, int, int)[] definitions = Definitions;
			for (int i = 0; i < definitions.Length; i++)
			{
				(string, string, string, int, int) tuple = definitions[i];
				try
				{
					GameObject prefab = PrefabManager.Instance.GetPrefab(tuple.Item1);
					if (!Object.op_Implicit((Object)(object)prefab))
					{
						throw new InvalidOperationException("Missing source prefab.");
					}
					Piece component = prefab.GetComponent<Piece>();
					if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.m_icon) || !Object.op_Implicit((Object)(object)prefab.GetComponent<WearNTear>()) || !Object.op_Implicit((Object)(object)prefab.GetComponent<ZNetView>()))
					{
						throw new InvalidOperationException("Source lacks required construction components or icon.");
					}
					if (Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab(tuple.Item2)))
					{
						throw new InvalidOperationException("Custom prefab ID already exists.");
					}
					PieceConfig val = new PieceConfig
					{
						Name = tuple.Item3,
						Description = ((tuple.Item1 == "blackmarble_2x2x1") ? "A solid black marble building block." : "A black marble construction piece."),
						PieceTable = "_HammerPieceTable",
						Category = HammerCategories.For(tuple.Item2),
						CraftingStation = "piece_stonecutter",
						Enabled = true,
						Icon = component.m_icon
					};
					val.AddRequirement("BlackMarble", tuple.Item4, true);
					if (tuple.Item5 > 0)
					{
						val.AddRequirement("Copper", tuple.Item5, true);
					}
					CustomPiece val2 = new CustomPiece(tuple.Item2, tuple.Item1, val);
					if (!val2.IsValid())
					{
						throw new InvalidOperationException("Custom piece validation failed.");
					}
					SnapPointEngineering.Apply(val2.PiecePrefab, tuple.Item2, logger);
					if (tuple.Item2 == "MM_BlackMarble_stair_corner" || tuple.Item2 == "MM_BlackMarble_stair_corner_left")
					{
						GameObject prefab2 = PrefabManager.Instance.GetPrefab("blackmarble_stair");
						Piece val3 = (Object.op_Implicit((Object)(object)prefab2) ? prefab2.GetComponent<Piece>() : null);
						Piece component2 = val2.PiecePrefab.GetComponent<Piece>();
						if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)component2))
						{
							throw new InvalidOperationException("Stair usage reference or target missing.");
						}
						UsageTagFlags usage = component2.m_usage;
						component2.m_usage = val3.m_usage;
						StairPlacementCollider.Apply(val2.PiecePrefab, logger);
						logger.LogInfo((object)$"Missing Marble Rev4: {tuple.Item2} usage {usage} -> {component2.m_usage}");
					}
					CreepingRotationCorrection.Apply(val2.PiecePrefab, tuple.Item2, logger);
					HammerCategories.ApplyUsage(val2.PiecePrefab.GetComponent<Piece>(), tuple.Item2, logger);
					if (!PieceManager.Instance.AddPiece(val2))
					{
						throw new InvalidOperationException("Jotunn rejected custom piece.");
					}
					logger.LogInfo((object)$"Missing Marble category: {tuple.Item2}; requested={val.Category}; prefab={val2.PiecePrefab.GetComponent<Piece>().m_category}");
					num++;
					logger.LogInfo((object)("Missing Marble: submitted " + tuple.Item2 + " to Jotunn."));
				}
				catch (Exception ex)
				{
					logger.LogError((object)("Missing Marble: failed " + tuple.Item1 + ": " + ex));
				}
			}
			logger.LogInfo((object)$"Missing Marble: submitted {num}/{Definitions.Length} pieces to Jotunn.");
		}
	}
	[BepInPlugin("com.missingmarble.discovery", "Missing Marble", "0.6.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		private ConfigEntry<bool> exportDiagnostics;

		private ConfigEntry<HammerCategoryMode> hammerMode;

		private ConfigEntry<bool> forceFallback;

		private void Awake()
		{
			hammerMode = ((BaseUnityPlugin)this).Config.Bind<HammerCategoryMode>("Building", "HammerCategoryMode", HammerCategoryMode.Vanilla, "Vanilla integrates pieces into native categories; Dedicated keeps Missing Marble separate. Restart required.");
			forceFallback = ((BaseUnityPlugin)this).Config.Bind<bool>("Diagnostics", "ForceCategoryFallback", false, "Test dedicated fallback in Vanilla mode. Restart required.");
			exportDiagnostics = ((BaseUnityPlugin)this).Config.Bind<bool>("Diagnostics", "ExportStartupReports", false, "Export read-only icon, snap and localization reports at startup for verification.");
			PrefabManager.OnVanillaPrefabsAvailable += Initialize;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Missing Marble 0.6.0 ready.");
		}

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

		private void Initialize()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Initialize;
			HammerCategories.Initialize(hammerMode.Value, forceFallback.Value, ((BaseUnityPlugin)this).Logger);
			try
			{
				PieceRegistrar.Register(((BaseUnityPlugin)this).Logger);
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Missing Marble piece registration failed: {arg}");
			}
			try
			{
				PostConverter.Register(((BaseUnityPlugin)this).Logger);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Missing Marble: submitted converted post to Jotunn.");
			}
			catch (Exception arg2)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Missing Marble post conversion failed: {arg2}");
			}
			DemisterConverter.RegisterAll(((BaseUnityPlugin)this).Logger);
			HammerCategories.Report(((BaseUnityPlugin)this).Logger);
			try
			{
				SnapPointNaming.Apply(((BaseUnityPlugin)this).Logger);
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Missing Marble naming standardization aborted: " + ex));
			}
			try
			{
				ProductionIcons.Apply();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Missing Marble production icons: assigned=22; retained=5");
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Missing Marble production icon assignment failed: " + ex2));
			}
			if (!exportDiagnostics.Value)
			{
				return;
			}
			try
			{
				string text = Path.Combine(Paths.ConfigPath, "MissingMarble_IconAudit.txt");
				IconAudit.Run(text);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Missing Marble: post-assignment icon audit exported to " + text));
			}
			catch (Exception ex3)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Missing Marble icon audit failed: " + ex3));
			}
			try
			{
				string text2 = Path.Combine(Paths.ConfigPath, "MissingMarble_LocalizationDiagnostics.txt");
				LocalizationDiagnostics.Run(text2);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Missing Marble: localization diagnostics exported to " + text2));
			}
			catch (Exception ex4)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Missing Marble localization diagnostics failed: " + ex4));
			}
			try
			{
				string text3 = Path.Combine(Paths.ConfigPath, "MissingMarble_SnapDiagnostics.txt");
				SnapDiagnostics.Run(text3);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Missing Marble: snap diagnostics exported to " + text3));
			}
			catch (Exception ex5)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Missing Marble snap diagnostics failed: " + ex5));
			}
		}
	}
	internal static class PostConverter
	{
		internal const string Id = "MM_BlackMarble_post01";

		internal static void Register(ManualLogSource logger)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: 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_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: 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_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Expected O, but got Unknown
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Expected O, but got Unknown
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = PrefabManager.Instance.GetPrefab("blackmarble_post01");
			GameObject prefab2 = PrefabManager.Instance.GetPrefab("blackmarble_2x2x1");
			if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)prefab2) || Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("MM_BlackMarble_post01")))
			{
				throw new InvalidOperationException("Post source/reference missing or ID already exists.");
			}
			Piece component = prefab2.GetComponent<Piece>();
			WearNTear component2 = prefab2.GetComponent<WearNTear>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.m_icon) || !Object.op_Implicit((Object)(object)component2) || !Object.op_Implicit((Object)(object)prefab.GetComponent<ZNetView>()))
			{
				throw new InvalidOperationException("Required reference components missing.");
			}
			GameObject val = new GameObject("MissingMarble_PostStaging");
			val.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)val);
			GameObject val2 = null;
			try
			{
				val2 = Object.Instantiate<GameObject>(prefab, val.transform, false);
				((Object)val2).name = "MM_BlackMarble_post01";
				Destructible[] componentsInChildren = val2.GetComponentsInChildren<Destructible>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
				}
				StaticPhysics[] componentsInChildren2 = val2.GetComponentsInChildren<StaticPhysics>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
				}
				DropOnDestroyed[] componentsInChildren3 = val2.GetComponentsInChildren<DropOnDestroyed>(true);
				for (int i = 0; i < componentsInChildren3.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
				}
				Component[] componentsInChildren4 = val2.GetComponentsInChildren<Component>(true);
				foreach (Component val3 in componentsInChildren4)
				{
					if ((Object)(object)val3 != (Object)null && ((object)val3).GetType().Name == "SimpleMeshCombine")
					{
						Object.DestroyImmediate((Object)(object)val3);
					}
				}
				val2.transform.localPosition = Vector3.zero;
				Collider[] componentsInChildren5 = val2.GetComponentsInChildren<Collider>(true);
				for (int i = 0; i < componentsInChildren5.Length; i++)
				{
					((Component)componentsInChildren5[i]).gameObject.layer = prefab2.layer;
				}
				val2.layer = prefab2.layer;
				DemisterConverter.AddSnap(val2.transform, new Vector3(0f, 3.25f, 0f));
				int num = SnapPointEngineering.AddPostFoundation(val2);
				Piece obj = val2.AddComponent<Piece>();
				obj.m_icon = component.m_icon;
				obj.m_canRotate = true;
				obj.m_canBeRemoved = true;
				obj.m_placeEffect = component.m_placeEffect;
				WearNTear obj2 = val2.AddComponent<WearNTear>();
				obj2.m_materialType = component2.m_materialType;
				obj2.m_health = 2000f;
				obj2.m_damages = component2.m_damages;
				obj2.m_supports = component2.m_supports;
				obj2.m_noSupportWear = component2.m_noSupportWear;
				obj2.m_noRoofWear = component2.m_noRoofWear;
				obj2.m_staticPosition = component2.m_staticPosition;
				obj2.m_burnable = component2.m_burnable;
				obj2.m_ashDamageResist = component2.m_ashDamageResist;
				obj2.m_destroyedEffect = component2.m_destroyedEffect;
				obj2.m_hitEffect = component2.m_hitEffect;
				obj2.m_autoCreateFragments = false;
				PieceConfig val4 = new PieceConfig
				{
					Name = "Black Marble Post",
					Description = "A decorative black marble post.",
					PieceTable = "_HammerPieceTable",
					Category = HammerCategories.For("MM_BlackMarble_post01"),
					CraftingStation = "piece_stonecutter",
					Enabled = true,
					Icon = component.m_icon
				};
				val4.AddRequirement("BlackMarble", 4, true);
				CustomPiece val5 = new CustomPiece(val2, false, val4);
				if (!val5.IsValid())
				{
					throw new InvalidOperationException("Converted post validation failed.");
				}
				HammerCategories.ApplyUsage(val5.PiecePrefab.GetComponent<Piece>(), "MM_BlackMarble_post01", logger);
				if (!PieceManager.Instance.AddPiece(val5))
				{
					throw new InvalidOperationException("Jotunn rejected custom piece.");
				}
				logger.LogInfo((object)string.Format("Missing Marble category: {0}; requested={1}; prefab={2}", "MM_BlackMarble_post01", val4.Category, val5.PiecePrefab.GetComponent<Piece>().m_category));
				logger.LogInfo((object)string.Format("Missing Marble: snap engineering {0}: added {1} foundation points.", "MM_BlackMarble_post01", num));
			}
			catch
			{
				Object.DestroyImmediate((Object)(object)val);
				throw;
			}
		}
	}
	internal static class ProductionIcons
	{
		internal static readonly string[] Remaining = new string[15]
		{
			"MM_BlackMarble_2x2_enforced", "MM_BlackMarble_base_2", "MM_BlackMarble_floor_large", "MM_BlackMarble_out_2", "MM_BlackMarble_slope_1x2", "MM_BlackMarble_slope_inverted_1x2", "MM_BlackMarble_stair_corner_left", "MM_BlackMarble_creep_4x1x1", "MM_BlackMarble_creep_4x2x1", "MM_BlackMarble_creep_slope_inverted_1x1x2",
			"MM_BlackMarble_creep_slope_inverted_2x2x1", "MM_BlackMarble_creep_stair", "MM_BlackMarble_head01", "MM_BlackMarble_head02", "MM_BlackMarble_head_big02"
		};

		internal static readonly string[] Accepted = new string[7] { "MM_BlackMarble_2x2x1", "MM_BlackMarble_column_3", "MM_BlackMarble_stair_corner", "MM_BlackMarble_head_big01", "MM_BlackMarble_post01", "MM_Dvergr_WispLight", "MM_Dvergr_WispLight_Large" };

		internal static readonly string[] Retained = new string[5] { "MM_BlackMarble_tile_floor_1x1", "MM_BlackMarble_tile_floor_2x2", "MM_BlackMarble_tile_wall_1x1", "MM_BlackMarble_tile_wall_2x2", "MM_BlackMarble_tile_wall_2x4" };

		internal static void Apply()
		{
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Expected O, but got Unknown
			//IL_022e: 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)
			string[] array = Accepted.Concat(Remaining).ToArray();
			Assembly assembly = typeof(ProductionIcons).Assembly;
			string[] manifestResourceNames = assembly.GetManifestResourceNames();
			string[] source = array.Select((string id) => "MissingMarble.Icons." + id + ".png").ToArray();
			if (!(from n in manifestResourceNames
				where n.StartsWith("MissingMarble.Icons.", StringComparison.Ordinal)
				orderby n
				select n).SequenceEqual(source.OrderBy((string n) => n)))
			{
				throw new InvalidOperationException("Production requires exactly 22 approved resources");
			}
			Dictionary<Piece, Sprite> dictionary = new Dictionary<Piece, Sprite>();
			Dictionary<Piece, Sprite> dictionary2 = new Dictionary<Piece, Sprite>();
			List<Texture2D> list = new List<Texture2D>();
			List<Sprite> list2 = new List<Sprite>();
			try
			{
				foreach (string item in array.Concat(Retained))
				{
					GameObject prefab = PrefabManager.Instance.GetPrefab(item);
					Piece val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Piece>() : null);
					if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.m_icon))
					{
						throw new InvalidOperationException("Missing piece/icon: " + item);
					}
					dictionary.Add(val, val.m_icon);
					if (Retained.Contains(item))
					{
						continue;
					}
					using Stream stream = assembly.GetManifestResourceStream("MissingMarble.Icons." + item + ".png");
					using MemoryStream memoryStream = new MemoryStream();
					stream.CopyTo(memoryStream);
					Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false);
					list.Add(val2);
					if (!ImageConversion.LoadImage(val2, memoryStream.ToArray()) || ((Texture)val2).width != 64 || ((Texture)val2).height != 64)
					{
						throw new InvalidOperationException("Invalid PNG: " + item);
					}
					((Object)val2).name = item + "_IconTexture";
					((Texture)val2).wrapMode = (TextureWrapMode)1;
					((Texture)val2).filterMode = (FilterMode)1;
					Sprite val3 = Sprite.Create(val2, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f));
					if (!Object.op_Implicit((Object)(object)val3))
					{
						throw new InvalidOperationException("Sprite creation failed: " + item);
					}
					list2.Add(val3);
					((Object)val3).name = item + "_Icon";
					dictionary2.Add(val, val3);
				}
				foreach (KeyValuePair<Piece, Sprite> item2 in dictionary2)
				{
					item2.Key.m_icon = item2.Value;
				}
				foreach (KeyValuePair<Piece, Sprite> item3 in dictionary)
				{
					if ((Object)(object)item3.Key.m_icon != (Object)(object)(dictionary2.TryGetValue(item3.Key, out var value) ? value : item3.Value))
					{
						throw new InvalidOperationException("Assignment verification failed");
					}
				}
			}
			catch
			{
				foreach (KeyValuePair<Piece, Sprite> item4 in dictionary)
				{
					if (Object.op_Implicit((Object)(object)item4.Key))
					{
						item4.Key.m_icon = item4.Value;
					}
				}
				foreach (Sprite item5 in list2)
				{
					if (Object.op_Implicit((Object)(object)item5))
					{
						Object.DestroyImmediate((Object)(object)item5);
					}
				}
				foreach (Texture2D item6 in list)
				{
					if (Object.op_Implicit((Object)(object)item6))
					{
						Object.DestroyImmediate((Object)(object)item6);
					}
				}
				throw;
			}
		}
	}
	internal static class SnapDiagnostics
	{
		internal static readonly (string Source, string Id)[] Targets = new(string, string)[27]
		{
			("blackmarble_2x2x1", "MM_BlackMarble_2x2x1"),
			("blackmarble_2x2_enforced", "MM_BlackMarble_2x2_enforced"),
			("blackmarble_base_2", "MM_BlackMarble_base_2"),
			("blackmarble_column_3", "MM_BlackMarble_column_3"),
			("blackmarble_floor_large", "MM_BlackMarble_floor_large"),
			("blackmarble_out_2", "MM_BlackMarble_out_2"),
			("blackmarble_slope_1x2", "MM_BlackMarble_slope_1x2"),
			("blackmarble_slope_inverted_1x2", "MM_BlackMarble_slope_inverted_1x2"),
			("blackmarble_stair_corner", "MM_BlackMarble_stair_corner"),
			("blackmarble_stair_corner_left", "MM_BlackMarble_stair_corner_left"),
			("blackmarble_tile_floor_1x1", "MM_BlackMarble_tile_floor_1x1"),
			("blackmarble_tile_floor_2x2", "MM_BlackMarble_tile_floor_2x2"),
			("blackmarble_tile_wall_1x1", "MM_BlackMarble_tile_wall_1x1"),
			("blackmarble_tile_wall_2x2", "MM_BlackMarble_tile_wall_2x2"),
			("blackmarble_tile_wall_2x4", "MM_BlackMarble_tile_wall_2x4"),
			("blackmarble_creep_4x1x1", "MM_BlackMarble_creep_4x1x1"),
			("blackmarble_creep_4x2x1", "MM_BlackMarble_creep_4x2x1"),
			("blackmarble_creep_slope_inverted_1x1x2", "MM_BlackMarble_creep_slope_inverted_1x1x2"),
			("blackmarble_creep_slope_inverted_2x2x1", "MM_BlackMarble_creep_slope_inverted_2x2x1"),
			("blackmarble_creep_stair", "MM_BlackMarble_creep_stair"),
			("blackmarble_head01", "MM_BlackMarble_head01"),
			("blackmarble_head02", "MM_BlackMarble_head02"),
			("blackmarble_head_big01", "MM_BlackMarble_head_big01"),
			("blackmarble_head_big02", "MM_BlackMarble_head_big02"),
			("blackmarble_post01", "MM_BlackMarble_post01"),
			("dverger_demister", "MM_Dvergr_WispLight"),
			("dverger_demister_large", "MM_Dvergr_WispLight_Large")
		};

		private static string F(float n)
		{
			return n.ToString("F5", CultureInfo.InvariantCulture);
		}

		private static string V(Vector3 v)
		{
			//IL_0010: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			return "(" + F(v.x) + ", " + F(v.y) + ", " + F(v.z) + ")";
		}

		private static string Q(Quaternion q)
		{
			//IL_0011: 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_003d: 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)
			return "(" + F(q.x) + ", " + F(q.y) + ", " + F(q.z) + ", " + F(q.w) + ")";
		}

		private static string PathOf(Transform t, Transform root)
		{
			if (!((Object)(object)t == (Object)(object)root))
			{
				return PathOf(t.parent, root) + "/" + ((Object)t).name;
			}
			return ((Object)root).name;
		}

		private static string BoundsInRoot(Bounds b, Transform from, Transform root)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_00a9: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_0063: 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_006a: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0078: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
			Vector3 val2 = -val;
			for (int i = -1; i <= 1; i += 2)
			{
				for (int j = -1; j <= 1; j += 2)
				{
					for (int k = -1; k <= 1; k += 2)
					{
						Vector3 val3 = ((Bounds)(ref b)).center + Vector3.Scale(((Bounds)(ref b)).extents, new Vector3((float)i, (float)j, (float)k));
						if (Object.op_Implicit((Object)(object)from))
						{
							val3 = from.TransformPoint(val3);
						}
						val3 = root.InverseTransformPoint(val3);
						val = Vector3.Min(val, val3);
						val2 = Vector3.Max(val2, val3);
					}
				}
			}
			return "min=" + V(val) + " max=" + V(val2);
		}

		internal static void Run(string path)
		{
			StringBuilder stringBuilder = new StringBuilder("Missing Marble snap diagnostics - 0.6.0\nRead-only prefab inspection after submission; not live placement validation.\nCoordinates in prefab root space; world AABB projections may overestimate geometry.\nInactive objects included; collider bounds may be empty when inactive.\nDuplicate tolerance: 0.001 m. Zero snaps are observations, not automatic defects.\n");
			int num = 0;
			(string, string)[] targets = Targets;
			for (int i = 0; i < targets.Length; i++)
			{
				(string, string) tuple = targets[i];
				stringBuilder.AppendLine("\n=== TARGET " + tuple.Item2 + " ===");
				InspectName(stringBuilder, tuple.Item1, "native source");
				if (InspectName(stringBuilder, tuple.Item2, "submitted custom prefab"))
				{
					num++;
				}
			}
			stringBuilder.AppendLine("\nCustom prefab lookups found: " + num + "/" + Targets.Length);
			stringBuilder.AppendLine("\n=== VANILLA HAMMER REFERENCES ===");
			GameObject prefab = PrefabManager.Instance.GetPrefab("Hammer");
			PieceTable val = ((!Object.op_Implicit((Object)(object)prefab)) ? null : prefab.GetComponent<ItemDrop>()?.m_itemData?.m_shared?.m_buildPieces);
			if (Object.op_Implicit((Object)(object)val) && val.m_pieces != null)
			{
				foreach (GameObject item in from p in val.m_pieces
					where Object.op_Implicit((Object)(object)p) && !((Object)p).name.StartsWith("MM_", StringComparison.Ordinal) && (((Object)p).name.IndexOf("blackmarble", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)p).name.StartsWith("stone_", StringComparison.OrdinalIgnoreCase) || ((Object)p).name.StartsWith("piece_stone", StringComparison.OrdinalIgnoreCase))
					group p by ((Object)p).name into g
					select g.First() into p
					orderby ((Object)p).name
					select p)
				{
					InspectSafe(stringBuilder, item, "vanilla hammer reference");
				}
			}
			else
			{
				stringBuilder.AppendLine("Hammer table unavailable.");
			}
			File.WriteAllText(path, stringBuilder.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: true));
		}

		private static bool InspectName(StringBuilder s, string name, string role)
		{
			try
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab(name);
				if (!Object.op_Implicit((Object)(object)prefab))
				{
					s.AppendLine(role + ": " + name + " unavailable at this lifecycle stage");
					return false;
				}
				InspectSafe(s, prefab, role);
				return true;
			}
			catch (Exception ex)
			{
				s.AppendLine(role + ": " + name + " lookup error: " + ex);
				return false;
			}
		}

		private static void InspectSafe(StringBuilder s, GameObject p, string role)
		{
			//IL_0060: 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_0096: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_02a3: 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_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Transform r = p.transform;
				s.AppendLine("\n-- " + role + ": " + ((Object)p).name + " --");
				s.AppendLine("Root world=" + V(r.position) + " rotation=" + Q(r.rotation) + " scale=" + V(r.lossyScale));
				Transform[] array = (from t in p.GetComponentsInChildren<Transform>(true)
					where ((Component)t).CompareTag("snappoint")
					select t).ToArray();
				s.AppendLine("Tagged snap count=" + array.Length);
				Vector3[] array2 = array.Select((Transform t) => r.InverseTransformPoint(t.position)).ToArray();
				for (int num = 0; num < array.Length; num++)
				{
					Transform val = array[num];
					s.AppendLine($"  SNAP {num}: {PathOf(val, r)} rootPos={V(array2[num])} rootRot={Q(Quaternion.Inverse(r.rotation) * val.rotation)} localPos={V(val.localPosition)} activeSelf={((Component)val).gameObject.activeSelf} activeInHierarchy={((Component)val).gameObject.activeInHierarchy} directChild={(Object)(object)val.parent == (Object)(object)r}");
					for (int num2 = 0; num2 < num; num2++)
					{
						Vector3 val2 = array2[num] - array2[num2];
						if (((Vector3)(ref val2)).sqrMagnitude <= 1E-06f)
						{
							s.AppendLine($"    Coincident position with SNAP {num2}");
						}
					}
				}
				MeshFilter[] componentsInChildren = p.GetComponentsInChildren<MeshFilter>(true);
				foreach (MeshFilter val3 in componentsInChildren)
				{
					if (Object.op_Implicit((Object)(object)val3.sharedMesh))
					{
						s.AppendLine("  MESH " + PathOf(((Component)val3).transform, r) + " " + ((Object)val3.sharedMesh).name + " " + BoundsInRoot(val3.sharedMesh.bounds, ((Component)val3).transform, r));
					}
				}
				Collider[] componentsInChildren2 = p.GetComponentsInChildren<Collider>(true);
				foreach (Collider val4 in componentsInChildren2)
				{
					BoxCollider val5 = (BoxCollider)(object)((val4 is BoxCollider) ? val4 : null);
					object obj;
					if (val5 == null)
					{
						MeshCollider val6 = (MeshCollider)(object)((val4 is MeshCollider) ? val4 : null);
						obj = ((val6 != null && Object.op_Implicit((Object)(object)val6.sharedMesh)) ? BoundsInRoot(val6.sharedMesh.bounds, ((Component)val6).transform, r) : ("world AABB projection: " + BoundsInRoot(val4.bounds, null, r)));
					}
					else
					{
						obj = BoundsInRoot(new Bounds(val5.center, val5.size), ((Component)val5).transform, r);
					}
					string text = (string)obj;
					s.AppendLine("  COLLIDER " + PathOf(((Component)val4).transform, r) + " " + ((object)val4).GetType().Name + " enabled=" + val4.enabled + " trigger=" + val4.isTrigger + " active=" + ((Component)val4).gameObject.activeInHierarchy + " " + text);
				}
				Renderer[] componentsInChildren3 = p.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val7 in componentsInChildren3)
				{
					s.AppendLine("  RENDERER " + PathOf(((Component)val7).transform, r) + " enabled=" + val7.enabled + " active=" + ((Component)val7).gameObject.activeInHierarchy + " world AABB projection: " + BoundsInRoot(val7.bounds, null, r));
				}
			}
			catch (Exception ex)
			{
				s.AppendLine("Inspection error for " + ((Object)p).name + ": " + ex);
			}
		}
	}
	internal static class SnapPointEngineering
	{
		internal static void Apply(GameObject prefab, string id, ManualLogSource logger)
		{
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			if (id == "MM_BlackMarble_head_big01" || id == "MM_BlackMarble_head_big02")
			{
				if (!Object.op_Implicit((Object)(object)prefab) || ((Object)prefab).name != id)
				{
					throw new InvalidOperationException("Unexpected large head prefab identity.");
				}
				int num = 0;
				int[] array = new int[2] { 1, -1 };
				foreach (int num2 in array)
				{
					int num3 = 0;
					string text = ((num2 > 0) ? "$hud_snappoint_top " : "$hud_snappoint_bottom ");
					int[] array2 = new int[2] { 1, -1 };
					foreach (int num4 in array2)
					{
						int[] array3 = new int[2] { 1, -1 };
						foreach (int num5 in array3)
						{
							int num6 = num;
							Vector3 p = new Vector3((float)num4, (float)num2, (float)num5);
							int num7 = ++num3;
							num = num6 + Add(prefab, p, text + num7);
						}
					}
				}
				logger.LogInfo((object)$"Missing Marble: snap engineering {id}: added {num} points.");
			}
			else if (id.StartsWith("MM_BlackMarble_creep_", StringComparison.Ordinal))
			{
				if (!Object.op_Implicit((Object)(object)prefab) || ((Object)prefab).name != id)
				{
					throw new InvalidOperationException("Unexpected creeping prefab identity.");
				}
				int num8 = ApplyCreeping(prefab, id);
				logger.LogInfo((object)$"Missing Marble: snap engineering {id}: added {num8} points.");
			}
			else
			{
				if (id != "MM_BlackMarble_base_2" && id != "MM_BlackMarble_column_3" && id != "MM_BlackMarble_stair_corner" && id != "MM_BlackMarble_stair_corner_left")
				{
					return;
				}
				if (!Object.op_Implicit((Object)(object)prefab) || ((Object)prefab).name != id)
				{
					throw new InvalidOperationException("Unexpected custom prefab identity.");
				}
				int num9 = 0;
				if (id == "MM_BlackMarble_base_2")
				{
					num9 += Add(prefab, new Vector3(0f, 1f, 0f), "$hud_snappoint_top $hud_snappoint_edge");
					num9 += Add(prefab, new Vector3(-1f, 1f, 0f), "$hud_snappoint_top $hud_snappoint_inner");
					num9 += Add(prefab, new Vector3(1f, -1f, 0f), "$hud_snappoint_bottom $hud_snappoint_edge");
					num9 += Add(prefab, new Vector3(-1f, -1f, 0f), "$hud_snappoint_bottom $hud_snappoint_inner");
				}
				else if (id == "MM_BlackMarble_column_3")
				{
					int[] array = new int[2] { -4, 4 };
					foreach (int num10 in array)
					{
						for (int l = -1; l <= 1; l++)
						{
							for (int m = -1; m <= 1; m++)
							{
								string text2 = ((num10 > 0) ? "$hud_snappoint_top" : "$hud_snappoint_bottom");
								num9 += Add(prefab, new Vector3((float)l, (float)num10, (float)m), text2 + $" {l + 1}-{m + 1}");
							}
						}
					}
				}
				else
				{
					num9 += Add(prefab, new Vector3(0f, 1f, -1f), "$hud_snappoint_top 3");
					num9 += Add(prefab, new Vector3(0f, 0f, -1f), "$hud_snappoint_bottom 5");
					num9 += Add(prefab, new Vector3(0f, 0f, 1f), "$hud_snappoint_bottom 6");
					num9 += Add(prefab, new Vector3(-1f, 0f, 0f), "$hud_snappoint_bottom 7");
					num9 += Add(prefab, new Vector3(1f, 0f, 0f), "$hud_snappoint_bottom 8");
				}
				logger.LogInfo((object)$"Missing Marble: snap engineering {id}: added {num9} points.");
			}
		}

		private static int ApplyCreeping(GameObject prefab, string id)
		{
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			switch (id)
			{
			case "MM_BlackMarble_creep_4x1x1":
			case "MM_BlackMarble_creep_4x2x1":
			{
				float num6 = (id.EndsWith("4x1x1", StringComparison.Ordinal) ? 0.5f : 1f);
				int[] array = new int[3] { 2, -2, 0 };
				foreach (int num7 in array)
				{
					int num8 = 0;
					string text = ((num7 > 0) ? "$hud_snappoint_top " : ((num7 < 0) ? "$hud_snappoint_bottom " : "$hud_snappoint_edge "));
					float[] array2 = new float[2]
					{
						0f - num6,
						num6
					};
					foreach (float num9 in array2)
					{
						float[] array3 = new float[2] { -0.5f, 0.5f };
						foreach (float num10 in array3)
						{
							int num11 = num;
							Vector3 p = new Vector3(num9, (float)num7, num10);
							int num12 = ++num8;
							num = num11 + Add(prefab, p, text + num12);
						}
					}
				}
				break;
			}
			case "MM_BlackMarble_creep_slope_inverted_1x1x2":
			case "MM_BlackMarble_creep_slope_inverted_2x2x1":
			{
				bool num2 = id.EndsWith("2x2x1", StringComparison.Ordinal);
				float num3 = (num2 ? 1f : 0.5f);
				float num4 = (num2 ? 0.5f : 1f);
				float num5 = (num2 ? 1f : 0.5f);
				num += Add(prefab, new Vector3(num3, 0f - num4, 0f - num5), "$hud_snappoint_bottom 1");
				num += Add(prefab, new Vector3(0f - num3, 0f - num4, 0f - num5), "$hud_snappoint_bottom 2");
				num += Add(prefab, new Vector3(num3, num4, 0f - num5), "$hud_snappoint_top 1");
				num += Add(prefab, new Vector3(0f - num3, num4, 0f - num5), "$hud_snappoint_top 2");
				num += Add(prefab, new Vector3(num3, num4, num5), "$hud_snappoint_top 3");
				num += Add(prefab, new Vector3(0f - num3, num4, num5), "$hud_snappoint_top 4");
				break;
			}
			case "MM_BlackMarble_creep_stair":
				num += Add(prefab, new Vector3(-1f, 1f, -1f), "$hud_snappoint_top 1");
				num += Add(prefab, new Vector3(1f, 1f, -1f), "$hud_snappoint_top 2");
				num += Add(prefab, new Vector3(-1f, 0f, 1f), "$hud_snappoint_bottom 1");
				num += Add(prefab, new Vector3(1f, 0f, 1f), "$hud_snappoint_bottom 2");
				num += Add(prefab, new Vector3(-1f, 0f, -1f), "$hud_snappoint_bottom $hud_snappoint_inner 1");
				num += Add(prefab, new Vector3(1f, 0f, -1f), "$hud_snappoint_bottom $hud_snappoint_inner 2");
				break;
			}
			return num;
		}

		internal static int AddPostFoundation(GameObject prefab)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)prefab) || ((Object)prefab).name != "MM_BlackMarble_post01")
			{
				throw new InvalidOperationException("Unexpected post prefab identity.");
			}
			int num = 0;
			int num2 = 0;
			int[] array = new int[2] { 1, -1 };
			foreach (int num3 in array)
			{
				int[] array2 = new int[2] { 1, -1 };
				foreach (int num4 in array2)
				{
					int num5 = num;
					Vector3 p = new Vector3((float)num3, -1f, (float)num4);
					int num6 = ++num2;
					num = num5 + Add(prefab, p, "$hud_snappoint_bottom " + num6);
				}
			}
			if (num != 4)
			{
				throw new InvalidOperationException("Expected four new post foundation snaps.");
			}
			return num;
		}

		private static int Add(GameObject prefab, Vector3 p, string name)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_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_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_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)
			Transform[] componentsInChildren = prefab.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)(object)prefab.transform && ((Component)val).CompareTag("snappoint"))
				{
					Vector3 val2 = prefab.transform.InverseTransformPoint(val.position) - p;
					if (((Vector3)(ref val2)).sqrMagnitude <= 1E-06f)
					{
						return 0;
					}
				}
			}
			GameObject val3 = new GameObject(name);
			val3.SetActive(false);
			val3.transform.SetParent(prefab.transform, false);
			val3.transform.localPosition = p;
			val3.layer = prefab.layer;
			val3.tag = "snappoint";
			return 1;
		}
	}
	internal static class SnapPointNaming
	{
		private sealed class Entry
		{
			internal readonly int Index;

			internal readonly Vector3 Position;

			internal readonly string Before;

			internal readonly string After;

			internal Entry(int index, Vector3 position, string before, string after)
			{
				//IL_000e: 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)
				Index = index;
				Position = position;
				Before = before;
				After = after;
			}
		}

		private static readonly Dictionary<string, Entry[]> Profiles = new Dictionary<string, Entry[]>(StringComparer.Ordinal)
		{
			{
				"MM_BlackMarble_2x2x1",
				new Entry[8]
				{
					new Entry(0, new Vector3(1f, 1f, 0.5f), "$hud_snappoint_top 1", "$hud_snappoint_top 1"),
					new Entry(1, new Vector3(1f, 1f, -0.5f), "$hud_snappoint_top 2", "$hud_snappoint_top 2"),
					new Entry(2, new Vector3(1f, -1f, 0.5f), "$hud_snappoint_bottom 1", "$hud_snappoint_bottom 1"),
					new Entry(3, new Vector3(1f, -1f, -0.5f), "$hud_snappoint_bottom 2", "$hud_snappoint_bottom 2"),
					new Entry(4, new Vector3(-1f, 1f, 0.5f), "$hud_snappoint_top 3", "$hud_snappoint_top 3"),
					new Entry(5, new Vector3(-1f, 1f, -0.5f), "$hud_snappoint_top 4", "$hud_snappoint_top 4"),
					new Entry(6, new Vector3(-1f, -1f, 0.5f), "$hud_snappoint_bottom 3", "$hud_snappoint_bottom 3"),
					new Entry(7, new Vector3(-1f, -1f, -0.5f), "$hud_snappoint_bottom 4", "$hud_snappoint_bottom 4")
				}
			},
			{
				"MM_BlackMarble_2x2_enforced",
				new Entry[8]
				{
					new Entry(0, new Vector3(1f, 1f, 1f), "_snappoint", "$hud_snappoint_top 1"),
					new Entry(1, new Vector3(1f, 1f, -1f), "_snappoint (1)", "$hud_snappoint_top 2"),
					new Entry(2, new Vector3(1f, -1f, 1f), "_snappoint (2)", "$hud_snappoint_bottom 1"),
					new Entry(3, new Vector3(1f, -1f, -1f), "_snappoint (3)", "$hud_snappoint_bottom 2"),
					new Entry(4, new Vector3(-1f, 1f, 1f), "_snappoint (4)", "$hud_snappoint_top 3"),
					new Entry(5, new Vector3(-1f, 1f, -1f), "_snappoint (5)", "$hud_snappoint_top 4"),
					new Entry(6, new Vector3(-1f, -1f, 1f), "_snappoint (6)", "$hud_snappoint_bottom 3"),
					new Entry(7, new Vector3(-1f, -1f, -1f), "_snappoint (7)", "$hud_snappoint_bottom 4")
				}
			},
			{
				"MM_BlackMarble_base_2",
				new Entry[12]
				{
					new Entry(0, new Vector3(0f, 1f, 1f), "$hud_snappoint_top $hud_snappoint_edge 1", "$hud_snappoint_top $hud_snappoint_edge 1"),
					new Entry(1, new Vector3(0f, 1f, -1f), "$hud_snappoint_top $hud_snappoint_edge 2", "$hud_snappoint_top $hud_snappoint_edge 2"),
					new Entry(2, new Vector3(1f, -1f, 1f), "$hud_snappoint_bottom $hud_snappoint_edge 1", "$hud_snappoint_bottom $hud_snappoint_edge 1"),
					new Entry(3, new Vector3(1f, -1f, -1f), "$hud_snappoint_bottom $hud_snappoint_edge 2", "$hud_snappoint_bottom $hud_snappoint_edge 2"),
					new Entry(4, new Vector3(-1f, 1f, 1f), "$hud_snappoint_top $hud_snappoint_inner 1", "$hud_snappoint_top $hud_snappoint_inner 1"),
					new Entry(5, new Vector3(-1f, 1f, -1f), "$hud_snappoint_top $hud_snappoint_inner 2", "$hud_snappoint_top $hud_snappoint_inner 2"),
					new Entry(6, new Vector3(-1f, -1f, 1f), "$hud_snappoint_bottom $hud_snappoint_inner 1", "$hud_snappoint_bottom $hud_snappoint_inner 1"),
					new Entry(7, new Vector3(-1f, -1f, -1f), "$hud_snappoint_bottom $hud_snappoint_inner 2", "$hud_snappoint_bottom $hud_snappoint_inner 2"),
					new Entry(8, new Vector3(0f, 1f, 0f), "$hud_snappoint_top $hud_snappoint_edge", "$hud_snappoint_top $hud_snappoint_edge 3"),
					new Entry(9, new Vector3(-1f, 1f, 0f), "$hud_snappoint_top $hud_snappoint_inner", "$hud_snappoint_top $hud_snappoint_inner 3"),
					new Entry(10, new Vector3(1f, -1f, 0f), "$hud_snappoint_bottom $hud_snappoint_edge", "$hud_snappoint_bottom $hud_snappoint_edge 3"),
					new Entry(11, new Vector3(-1f, -1f, 0f), "$hud_snappoint_bottom $hud_snappoint_inner", "$hud_snappoint_bottom $hud_snappoint_inner 3")
				}
			},
			{
				"MM_BlackMarble_column_3",
				new Entry[18]
				{
					new Entry(0, new Vector3(-1f, -4f, -1f), "$hud_snappoint_bottom 0-0", "$hud_snappoint_bottom $hud_snappoint_corner 4"),
					new Entry(1, new Vector3(-1f, -4f, 0f), "$hud_snappoint_bottom 0-1", "$hud_snappoint_bottom $hud_snappoint_edge 3"),
					new Entry(2, new Vector3(-1f, -4f, 1f), "$hud_snappoint_bottom 0-2", "$hud_snappoint_bottom $hud_snappoint_corner 3"),
					new Entry(3, new Vector3(0f, -4f, -1f), "$hud_snappoint_bottom 1-0", "$hud_snappoint_bottom $hud_snappoint_edge 2"),
					new Entry(4, new Vector3(0f, -4f, 0f), "$hud_snappoint_bottom 1-1", "$hud_snappoint_bottom $hud_snappoint_center"),
					new Entry(5, new Vector3(0f, -4f, 1f), "$hud_snappoint_bottom 1-2", "$hud_snappoint_bottom $hud_snappoint_edge 4"),
					new Entry(6, new Vector3(1f, -4f, -1f), "$hud_snappoint_bottom 2-0", "$hud_snappoint_bottom $hud_snappoint_corner 2"),
					new Entry(7, new Vector3(1f, -4f, 0f), "$hud_snappoint_bottom 2-1", "$hud_snappoint_bottom $hud_snappoint_edge 1"),
					new Entry(8, new Vector3(1f, -4f, 1f), "$hud_snappoint_bottom 2-2", "$hud_snappoint_bottom $hud_snappoint_corner 1"),
					new Entry(9, new Vector3(-1f, 4f, -1f), "$hud_snappoint_top 0-0", "$hud_snappoint_top $hud_snappoint_corner 4"),
					new Entry(10, new Vector3(-1f, 4f, 0f), "$hud_snappoint_top 0-1", "$hud_snappoint_top $hud_snappoint_edge 3"),
					new Entry(11, new Vector3(-1f, 4f, 1f), "$hud_snappoint_top 0-2", "$hud_snappoint_top $hud_snappoint_corner 3"),
					new Entry(12, new Vector3(0f, 4f, -1f), "$hud_snappoint_top 1-0", "$hud_snappoint_top $hud_snappoint_edge 2"),
					new Entry(13, new Vector3(0f, 4f, 0f), "$hud_snappoint_top 1-1", "$hud_snappoint_top $hud_snappoint_center"),
					new Entry(14, new Vector3(0f, 4f, 1f), "$hud_snappoint_top 1-2", "$hud_snappoint_top $hud_snappoint_edge 4"),
					new Entry(15, new Vector3(1f, 4f, -1f), "$hud_snappoint_top 2-0", "$hud_snappoint_top $hud_snappoint_corner 2"),
					new Entry(16, new Vector3(1f, 4f, 0f), "$hud_snappoint_top 2-1", "$hud_snappoint_top $hud_snappoint_edge 1"),
					new Entry(17, new Vector3(1f, 4f, 1f), "$hud_snappoint_top 2-2", "$hud_snappoint_top $hud_snappoint_corner 1")
				}
			},
			{
				"MM_BlackMarble_floor_large",
				new Entry[8]
				{
					new Entry(0, new Vector3(4f, 1f, 4f), "_snappoint (3)", "$hud_snappoint_top 1"),
					new Entry(1, new Vector3(4f, -1f, 4f), "_snappoint (4)", "$hud_snappoint_bottom 1"),
					new Entry(2, new Vector3(4f, 1f, -4f), "_snappoint (5)", "$hud_snappoint_top 2"),
					new Entry(3, new Vector3(4f, -1f, -4f), "_snappoint (6)", "$hud_snappoint_bottom 2"),
					new Entry(4, new Vector3(-4f, 1f, 4f), "_snappoint (7)", "$hud_snappoint_top 3"),
					new Entry(5, new Vector3(-4f, -1f, 4f), "_snappoint (8)", "$hud_snappoint_bottom 3"),
					new Entry(6, new Vector3(-4f, 1f, -4f), "_snappoint (9)", "$hud_snappoint_top 4"),
					new Entry(7, new Vector3(-4f, -1f, -4f), "_snappoint (10)", "$hud_snappoint_bottom 4")
				}
			},
			{
				"MM_BlackMarble_out_2",
				new Entry[8]
				{
					new Entry(0, new Vector3(1f, 1f, 1f), "$hud_snappoint_top $hud_snappoint_edge 1", "$hud_snappoint_top $hud_snappoint_edge 1"),
					new Entry(1, new Vector3(1f, 1f, -1f), "$hud_snappoint_top $hud_snappoint_edge 2", "$hud_snappoint_top $hud_snappoint_edge 2"),
					new Entry(2, new Vector3(0f, -1f, 1f), "$hud_snappoint_bottom $hud_snappoint_edge 1", "$hud_snappoint_bottom $hud_snappoint_edge 1"),
					new Entry(3, new Vector3(0f, -1f, -1f), "$hud_snappoint_bottom $hud_snappoint_edge 1", "$hud_snappoint_bottom $hud_snappoint_edge 2"),
					new Entry(4, new Vector3(-1f, 1f, 1f), "$hud_snappoint_top $hud_snappoint_inner 1", "$hud_snappoint_top $hud_snappoint_inner 1"),
					new Entry(5, new Vector3(-1f, 1f, -1f), "$hud_snappoint_top $hud_snappoint_inner 2", "$hud_snappoint_top $hud_snappoint_inner 2"),
					new Entry(6, new Vector3(-1f, -1f, 1f), "$hud_snappoint_bottom $hud_snappoint_inner 1", "$hud_snappoint_bottom $hud_snappoint_inner 1"),
					new Entry(7, new Vector3(-1f, -1f, -1f), "$hud_snappoint_bottom $hud_snappoint_inner 2", "$hud_snappoint_bottom $hud_snappoint_inner 2")
				}
			},
			{
				"MM_BlackMarble_slope_1x2",
				new Entry[6]
				{
					new Entry(0, new Vector3(0.5f, -1f, -0.5f), "_snappoint (1)", "$hud_snappoint_bottom 1"),
					new Entry(1, new Vector3(-0.5f, -1f, -0.5f), "_snappoint (2)", "$hud_snappoint_bottom 2"),
					new Entry(2, new Vector3(0.5f, -1f, 0.5f), "_snappoint (3)", "$hud_snappoint_bottom 3"),
					new Entry(3, new Vector3(-0.5f, -1f, 0.5f), "_snappoint (4)", "$hud_snappoint_bottom 4"),
					new Entry(4, new Vector3(0.5f, 1f, 0.5f), "_snappoint (5)", "$hud_snappoint_top 1"),
					new Entry(5, new Vector3(-0.5f, 1f, 0.5f), "_snappoint (6)", "$hud_snappoint_top 2")
				}
			},
			{
				"MM_BlackMarble_slope_inverted_1x2",
				new Entry[6]
				{
					new Entry(0, new Vector3(0.5f, -1f, -0.5f), "_snappoint (1)", "$hud_snappoint_bottom 1"),
					new Entry(1, new Vector3(-0.5f, -1f, -0.5f), "_snappoint (2)", "$hud_snappoint_bottom 2"),
					new Entry(2, new Vector3(0.5f, 1f, -0.5f), "_snappoint (3)", "$hud_snappoint_top 1"),
					new Entry(3, new Vector3(-0.5f, 1f, -0.5f), "_snappoint (4)", "$hud_snappoint_top 2"),
					new Entry(4, new Vector3(0.5f, 1f, 0.5f), "_snappoint (5)", "$hud_snappoint_top 3"),
					new Entry(5, new Vector3(-0.5f, 1f, 0.5f), "_snappoint (6)", "$hud_snappoint_top 4")
				}
			},
			{
				"MM_BlackMarble_stair_corner",
				new Entry[11]
				{
					new Entry(0, new Vector3(-1f, 1f, -1f), "_snappoint (4)", "$hud_snappoint_top 1"),
					new Entry(1, new Vector3(1f, 1f, -1f), "_snappoint (5)", "$hud_snappoint_top 2"),
					new Entry(2, new Vector3(-1f, 0f, 1f), "_snappoint (3)", "$hud_snappoint_bottom 1"),
					new Entry(3, new Vector3(1f, 0f, 1f), "_snappoint (6)", "$hud_snappoint_bottom 2"),
					new Entry(4, new Vector3(-1f, 0f, -1f), "_snappoint (7)", "$hud_snappoint_bottom $hud_snappoint_inner 1"),
					new Entry(5, new Vector3(1f, 0f, -1f), "_snappoint (8)", "$hud_snappoint_bottom $hud_snappoint_inner 2"),
					new Entry(6, new Vector3(0f, 1f, -1f), "$hud_snappoint_top 3", "$hud_snappoint_top 3"),
					new Entry(7, new Vector3(0f, 0f, -1f), "$hud_snappoint_bottom 5", "$hud_snappoint_bottom $hud_snappoint_inner 3"),
					new Entry(8, new Vector3(0f, 0f, 1f), "$hud_snappoint_bottom 6", "$hud_snappoint_bottom 3"),
					new Entry(9, new Vector3(-1f, 0f, 0f), "$hud_snappoint_bottom 7", "$hud_snappoint_bottom 4"),
					new Entry(10, new Vector3(1f, 0f, 0f), "$hud_snappoint_bottom 8", "$hud_snappoint_bottom 5")
				}
			},
			{
				"MM_BlackMarble_stair_corner_left",
				new Entry[11]
				{
					new Entry(0, new Vector3(-1f, 1f, -1f), "_snappoint (4)", "$hud_snappoint_top 1"),
					new Entry(1, new Vector3(1f, 1f, -1f), "_snappoint (5)", "$hud_snappoint_top 2"),
					new Entry(2, new Vector3(-1f, 0f, 1f), "_snappoint (3)", "$hud_snappoint_bottom 1"),
					new Entry(3, new Vector3(1f, 0f, 1f), "_snappoint (6)", "$hud_snappoint_bottom 2"),
					new Entry(4, new Vector3(-1f, 0f, -1f), "_snappoint (7)", "$hud_snappoint_bottom $hud_snappoint_inner 1"),
					new Entry(5, new Vector3(1f, 0f, -1f), "_snappoint (8)", "$hud_snappoint_bottom $hud_snappoint_inner 2"),
					new Entry(6, new Vector3(0f, 1f, -1f), "$hud_snappoint_top 3", "$hud_snappoint_top 3"),
					new Entry(7, new Vector3(0f, 0f, -1f), "$hud_snappoint_bottom 5", "$hud_snappoint_bottom $hud_snappoint_inner 3"),
					new Entry(8, new Vector3(0f, 0f, 1f), "$hud_snappoint_bottom 6", "$hud_snappoint_bottom 3"),
					new Entry(9, new Vector3(-1f, 0f, 0f), "$hud_snappoint_bottom 7", "$hud_snappoint_bottom 4"),
					new Entry(10, new Vector3(1f, 0f, 0f), "$hud_snappoint_bottom 8", "$hud_snappoint_bottom 5")
				}
			},
			{
				"MM_BlackMarble_tile_floor_1x1",
				new Entry[4]
				{
					new Entry(0, new Vector3(0.5f, 0f, 0.5f), "_snappoint", "$hud_snappoint_corner 1"),
					new Entry(1, new Vector3(0.5f, 0f, -0.5f), "_snappoint (1)", "$hud_snappoint_corner 2"),
					new Entry(2, new Vector3(-0.5f, 0f, 0.5f), "_snappoint (2)", "$hud_snappoint_corner 3"),
					new Entry(3, new Vector3(-0.5f, 0f, -0.5f), "_snappoint (3)", "$hud_snappoint_corner 4")
				}
			},
			{
				"MM_BlackMarble_tile_floor_2x2",
				new Entry[4]
				{
					new Entry(0, new Vector3(1f, 0f, 1f), "_snappoint", "$hud_snappoint_corner 1"),
					new Entry(1, new Vector3(1f, 0f, -1f), "_snappoint (1)", "$hud_snappoint_corner 2"),
					new Entry(2, new Vector3(-1f, 0f, 1f), "_snappoint (2)", "$hud_snappoint_corner 3"),
					new Entry(3, new Vector3(-1f, 0f, -1f), "_snappoint (3)", "$hud_snappoint_corner 4")
				}
			},
			{
				"MM_BlackMarble_tile_wall_1x1",
				new Entry[8]
				{
					new Entry(0, new Vector3(0.5f, 0f, 0f), "_snappoint", "$hud_snappoint_bottom 1"),
					new Entry(1, new Vector3(0.5f, 1f, 0f), "_snappoint (1)", "$hud_snappoint_top 1"),
					new Entry(2, new Vector3(-0.5f, 0f, 0f), "_snappoint (2)", "$hud_snappoint_bottom 3"),
					new Entry(3, new Vector3(-0.5f, 1f, 0f), "_snappoint (3)", "$hud_snappoint_top 3"),
					new Entry(4, new Vector3(0.5f, 0f, -0.2f), "_snappoint (4)", "$hud_snappoint_bottom 2"),
					new Entry(5, new Vector3(0.5f, 1f, -0.2f), "_snappoint (5)", "$hud_snappoint_top 2"),
					new Entry(6, new Vector3(-0.5f, 0f, -0.2f), "_snappoint (6)", "$hud_snappoint_bottom 4"),
					new Entry(7, new Vector3(-0.5f, 1f, -0.2f), "_snappoint (7)", "$hud_snappoint_top 4")
				}
			},
			{
				"MM_BlackMarble_tile_wall_2x2",
				new Entry[8]
				{
					new Entry(0, new Vector3(1f, 0f, 0f), "_snappoint", "$hud_snappoint_bottom 1"),
					new Entry(1, new Vector3(1f, 2f, 0f), "_snappoint (1)", "$hud_snappoint_top 1"),
					new Entry(2, new Vector3(-1f, 0f, 0f), "_snappoint (2)", "$hud_snappoint_bottom 3"),
					new Entry(3, new Vector3(-1f, 2f, 0f), "_snappoint (3)", "$hud_snappoint_top 3"),
					new Entry(4, new Vector3(1f, 0f, -0.2f), "_snappoint (4)", "$hud_snappoint_bottom 2"),
					new Entry(5, new Vector3(1f, 2f, -0.2f), "_snappoint (5)", "$hud_snappoint_top 2"),
					new Entry(6, new Vector3(-1f, 0f, -0.2f), "_snappoint (6)", "$hud_snappoint_bottom 4"),
					new Entry(7, new Vector3(-1f, 2f, -0.2f), "_snappoint (7)", "$hud_snappoint_top 4")
				}
			},
			{
				"MM_BlackMarble_tile_wall_2x4",
				new Entry[8]
				{
					new Entry(0, new Vector3(1f, 0f, 0f), "_snappoint", "$hud_snappoint_bottom 1"),
					new Entry(1, new Vector3(1f, 4f, 0f), "_snappoint (1)", "$hud_snappoint_top 1"),
					new Entry(2, new Vector3(-1f, 0f, 0f), "_snappoint (2)", "$hud_snappoint_bottom 3"),
					new Entry(3, new Vector3(-1f, 4f, 0f), "_snappoint (3)", "$hud_snappoint_top 3"),
					new Entry(4, new Vector3(1f, 0f, -0.2f), "_snappoint (4)", "$hud_snappoint_bottom 2"),
					new Entry(5, new Vector3(1f, 4f, -0.2f), "_snappoint (5)", "$hud_snappoint_top 2"),
					new Entry(6, new Vector3(-1f, 0f, -0.2f), "_snappoint (6)", "$hud_snappoint_bottom 4"),
					new Entry(7, new Vector3(-1f, 4f, -0.2f), "_snappoint (7)", "$hud_snappoint_top 4")
				}
			},
			{
				"MM_BlackMarble_creep_4x1x1",
				new Entry[12]
				{
					new Entry(0, new Vector3(-0.5f, 2f, -0.5f), "$hud_snappoint_top 1", "$hud_snappoint_top 4"),
					new Entry(1, new Vector3(-0.5f, 2f, 0.5f), "$hud_snappoint_top 2", "$hud_snappoint_top 3"),
					new Entry(2, new Vector3(0.5f, 2f, -0.5f), "$hud_snappoint_top 3", "$hud_snappoint_top 2"),
					new Entry(3, new Vector3(0.5f, 2f, 0.5f), "$hud_snappoint_top 4", "$hud_snappoint_top 1"),
					new Entry(4, new Vector3(-0.5f, -2f, -0.5f), "$hud_snappoint_bottom 1", "$hud_snappoint_bottom 4"),
					new Entry(5, new Vector3(-0.5f, -2f, 0.5f), "$hud_snappoint_bottom 2", "$hud_snappoint_bottom 3"),
					new Entry(6, new Vector3(0.5f, -2f, -0.5f), "$hud_snappoint_bottom 3", "$hud_snappoint_bottom 2"),
					new Entry(7, new Vector3(0.5f, -2f, 0.5f), "$hud_snappoint_bottom 4", "$hud_snappoint_bottom 1"),
					new Entry(8, new Vector3(-0.5f, 0f, -0.5f), "$hud_snappoint_edge 1", "$hud_snappoint_edge 4"),
					new Entry(9, new Vector3(-0.5f, 0f, 0.5f), "$hud_snappoint_edge 2", "$hud_snappoint_edge 3"),
					new Entry(10, new Vector3(0.5f, 0f, -0.5f), "$hud_snappoint_edge 3", "$hud_snappoint_edge 2"),
					new Entry(11, new Vector3(0.5f, 0f, 0.5f), "$hud_snappoint_edge 4", "$hud_snappoint_edge 1")
				}
			},
			{
				"MM_BlackMarble_creep_4x2x1",
				new Entry[12]
				{
					new Entry(0, new Vector3(-1f, 2f, -0.5f), "$hud_snappoint_top 1", "$hud_snappoint_top 4"),
					new Entry(1, new Vector3(-1f, 2f, 0.5f), "$hud_snappoint_top 2", "$hud_snappoint_top 3"),
					new Entry(2, new Vector3(1f, 2f, -0.5f), "$hud_snappoint_top 3", "$hud_snappoint_top 2"),
					new Entry(3, new Vector3(1f, 2f, 0.5f), "$hud_snappoint_top 4", "$hud_snappoint_top 1"),
					new Entry(4, new Vector3(-1f, -2f, -0.5f), "$hud_snappoint_bottom 1", "$hud_snappoint_bottom 4"),
					new Entry(5, new Vector3(-1f, -2f, 0.5f), "$hud_snappoint_bottom 2", "$hud_snappoint_bottom 3"),
					new Entry(6, new Vector3(1f, -2f, -0.5f), "$hud_snappoint_bottom 3", "$hud_snappoint_bottom 2"),
					new Entry(7, new Vector3(1f, -2f, 0.5f), "$hud_snappoint_bottom 4", "$hud_snappoint_bottom 1"),
					new Entry(8, new Vector3(-1f, 0f, -0.5f), "$hud_snappoint_edge 1", "$hud_snappoint_edge 4"),
					new Entry(9, new Vector3(-1f, 0f, 0.5f), "$hud_snappoint_edge 2", "$hud_snappoint_edge 3"),
					new Entry(10, new Vector3(1f, 0f, -0.5f), "$hud_snappoint_edge 3", "$hud_snappoint_edge 2"),
					new Entry(11, new Vector3(1f, 0f, 0.5f), "$hud_snappoint_edge 4", "$hud_snappoint_edge 1")
				}
			},
			{
				"MM_BlackMarble_creep_slope_inverted_1x1x2",
				new Entry[6]
				{
					new Entry(0, new Vector3(0.5f, -1f, -0.5f), "$hud_snappoint_bottom 1", "$hud_snappoint_bottom 1"),
					new Entry(1, new Vector3(-0.5f, -1f, -0.5f), "$hud_snappoint_bottom 2", "$hud_snappoint_bottom 2"),
					new Entry(2, new Vector3(0.5f, 1f, -0.5f), "$hud_snappoint_top 1", "$hud_snappoint_top 1"),
					new Entry(3, new Vector3(-0.5f, 1f, -0.5f), "$hud_snappoint_top 2", "$hud_snappoint_top 2"),
					new Entry(4, new Vector3(0.5f, 1f, 0.5f), "$hud_snappoint_top 3", "$hud_snappoint_top 3"),
					new Entry(5, new Vector3(-0.5f, 1f, 0.5f), "$hud_snappoint_top 4", "$hud_snappoint_top 4")
				}
			},
			{
				"MM_BlackMarble_creep_slope_inverted_2x2x1",
				new Entry[6]
				{
					new Entry(0, new Vector3(1f, -0.5f, -1f), "$hud_snappoint_bottom 1", "$hud_snappoint_bottom 1"),
					new Entry(1, new Vector3(-1f, -0.5f, -1f), "$hud_snappoint_bottom 2", "$hud_snappoint_bottom 2"),
					new Entry(2, new Vector3(1f, 0.5f, -1f), "$hud_snappoint_top 1", "$hud_snappoint_top 1"),
					new Entry(3, new Vector3(-1f, 0.5f, -1f), "$hud_snappoint_top 2", "$hud_snappoint_top 2"),
					new Entry(4, new Vector3(1f, 0.5f, 1f), "$hud_snappoint_top 3", "$hud_snappoint_top 3"),
					new Entry(5, new Vector3(-1f, 0.5f, 1f), "$hud_snappoint_top 4", "$hud_snappoint_top 4")
				}
			},
			{
				"MM_BlackMarble_creep_stair",
				new Entry[6]
				{
					new Entry(0, new Vector3(-1f, 1f, -1f), "$hud_snappoint_top 1", "$hud_snappoint_top 1"),
					new Entry(1, new Vector3(1f, 1f, -1f), "$hud_snappoint_top 2", "$hud_snappoint_top 2"),
					new Entry(2, new Vector3(-1f, 0f, 1f), "$hud_snappoint_bottom 1", "$hud_snappoint_bottom 1"),
					new Entry(3, new Vector3(1f, 0f, 1f), "$hud_snappoint_bottom 2", "$hud_snappoint_bottom 2"),
					new Entry(4, new Vector3(-1f, 0f, -1f), "$hud_snappoint_bottom $hud_snappoint_inner 1", "$hud_snappoint_bottom $hud_snappoint_inner 1"),
					new Entry(5, new Vector3(1f, 0f, -1f), "$hud_snappoint_bottom $hud_snappoint_inner 2", "$hud_snappoint_bottom $hud_snappoint_inner 2")
				}
			},
			{
				"MM_BlackMarble_head01",
				new Entry[8]
				{
					new Entry(0, new Vector3(0.5f, 0.5f, 0.5f), "_snappoint", "$hud_snappoint_top 1"),
					new Entry(1, new Vector3(0.5f, 0.5f, -0.5f), "_snappoint (1)", "$hud_snappoint_top 2"),
					new Entry(2, new Vector3(0.5f, -0.5f, 0.5f), "_snappoint (2)", "$hud_snappoint_bottom 1"),
					new Entry(3, new Vector3(0.5f, -0.5f, -0.5f), "_snappoint (3)", "$hud_snappoint_bottom 2"),
					new Entry(4, new Vector3(-0.5f, 0.5f, 0.5f), "_snappoint (4)", "$hud_snappoint_top 3"),
					new Entry(5, new Vector3(-0.5f, 0.5f, -0.5f), "_snappoint (5)", "$hud_snappoint_top 4"),
					new Entry(6, new Vector3(-0.5f, -0.5f, 0.5f), "_snappoint (6)", "$hud_snappoint_bottom 3"),
					new Entry(7, new Vector3(-0.5f, -0.5f, -0.5f), "_snappoint (7)", "$hud_snappoint_bottom 4")
				}
			},
			{
				"MM_BlackMarble_head02",
				new Entry[8]
				{
					new Entry(0, new Vector3(-0.5f, -0.5f, -0.5f), "_snappoint (7)", "$hud_snappoint_bottom 4"),
					new Entry(1, new Vector3(-0.5f, -0.5f, 0.5f), "_snappoint (6)", "$hud_snappoint_bottom 3"),
					new Entry(2, new Vector3(-0.5f, 0.5f, -0.5f), "_snappoint (5)", "$hud_snappoint_top 4"),
					new Entry(3, new Vector3(-0.5f, 0.5f, 0.5f), "_snappoint (4)", "$hud_snappoint_top 3"),
					new Entry(4, new Vector3(0.5f, -0.5f, -0.5f), "_snappoint (3)", "$hud_snappoint_bottom 2"),
					new Entry(5, new Vector3(0.5f, -0.5f, 0.5f), "_snappoint (2)", "$hud_snappoint_bottom 1"),
					new Entry(6, new Vector3(0.5f, 0.5f, -0.5f), "_snappoint (1)", "$hud_snappoint_top 2"),
					new Entry(7, new Vector3(0.5f, 0.5f, 0.5f), "_snappoint", "$hud_snappoint_top 1")
				}
			},
			{
				"MM_BlackMarble_head_big01",
				new Entry[8]
				{
					new Entry(0, new Vector3(1f, 1f, 1f), "$hud_snappoint_top 1", "$hud_snappoint_top 1"),
					new Entry(1, new Vector3(1f, 1f, -1f), "$hud_snappoint_top 2", "$hud_snappoint_top 2"),
					new Entry(2, new Vector3(-1f, 1f, 1f), "$hud_snappoint_top 3", "$hud_snappoint_top 3"),
					new Entry(3, new Vector3(-1f, 1f, -1f), "$hud_snappoint_top 4", "$hud_snappoint_top 4"),
					new Entry(4, new Vector3(1f, -1f, 1f), "$hud_snappoint_bottom 1", "$hud_snappoint_bottom 1"),
					new Entry(5, new Vector3(1f, -1f, -1f), "$hud_snappoint_bottom 2", "$hud_snappoint_bottom 2"),
					new Entry(6, new Vector3(-1f, -1f, 1f), "$hud_snappoint_bottom 3", "$hud_snappoint_bottom 3"),
					new Entry(7, new Vector3(-1f, -1f, -1f), "$hud_snappoint_bottom 4", "$hud_snappoint_bottom 4")
				}
			},
			{
				"MM_BlackMarble_head_big02",
				new Entry[8]
				{
					new Entry(0, new Vector3(1f, 1f, 1f), "$hud_snappoint_top 1", "$hud_snappoint_top 1"),
					new Entry(1, new Vector3(1f, 1f, -1f), "$hud_snappoint_top 2", "$hud_snappoint_top 2"),
					new Entry(2, new Vector3(-1f, 1f, 1f), "$hud_snappoint_top 3", "$hud_snappoint_top 3"),
					new Entry(3, new Vector3(-1f, 1f, -1f), "$hud_snappoint_top 4", "$hud_snappoint_top 4"),
					new Entry(4, new Vector3(1f, -1f, 1f), "$hud_snappoint_bottom 1", "$hud_snappoint_bottom 1"),
					new Entry(5, new Vector3(1f, -1f, -1f), "$hud_snappoint_bottom 2", "$hud_snappoint_bottom 2"),
					new Entry(6, new Vector3(-1f, -1f, 1f), "$hud_snappoint_bottom 3", "$hud_snappoint_bottom 3"),
					new Entry(7, new Vector3(-1f, -1f, -1f), "$hud_snappoint_bottom 4", "$hud_snappoint_bottom 4")
				}
			},
			{
				"MM_BlackMarble_post01",
				new Entry[5]
				{
					new Entry(0, new Vector3(0f, 3.25f, 0f), "$hud_snappoint_bottom", "$hud_snappoint_top $hud_snappoint_center"),
					new Entry(1, new Vector3(1f, -1f, 1f), "$hud_snappoint_bottom 1", "$hud_snappoint_bottom 1"),
					new Entry(2, new Vector3(1f, -1f, -1f), "$hud_snappoint_bottom 2", "$hud_snappoint_bottom 2"),
					new Entry(3, new Vector3(-1f, -1f, 1f), "$hud_snappoint_bottom 3", "$hud_snappoint_bottom 3"),
					new Entry(4, new Vector3(-1f, -1f, -1f), "$hud_snappoint_bottom 4", "$hud_snappoint_bottom 4")
				}
			},
			{
				"MM_Dvergr_WispLight",
				new Entry[1]
				{
					new Entry(0, new Vector3(0f, 0f, 0f), "$hud_snappoint_bottom", "$hud_snappoint_bottom")
				}
			},
			{
				"MM_Dvergr_WispLight_Large",
				new Entry[0]
			}
		};

		internal unsafe static void Apply(ManualLogSource logger)
		{
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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)
			List<(Transform, Entry)> list = new List<(Transform, Entry)>();
			HashSet<Transform> hashSet = new HashSet<Transform>();
			int num = 0;
			(string, string)[] targets = SnapDiagnostics.Targets;
			for (int i = 0; i < targets.Length; i++)
			{
				(string, string) tuple = targets[i];
				if (!Profiles.TryGetValue(tuple.Item2, out var value))
				{
					throw new InvalidOperationException("Missing naming profile: " + tuple.Item2);
				}
				GameObject prefab = PrefabManager.Instance.GetPrefab(tuple.Item2);
				if (!Object.op_Implicit((Object)(object)prefab) || ((Object)prefab).name != tuple.Item2 || !tuple.Item2.StartsWith("MM_", StringComparison.Ordinal))
				{
					throw new InvalidOperationException("Custom prefab unavailable or mismatched: " + tuple.Item2);
				}
				Transform[] array = (from t in prefab.GetComponentsInChildren<Transform>(true)
					where ((Component)t).CompareTag("snappoint")
					select t).ToArray();
				if (array.Length != value.Length)
				{
					throw new InvalidOperationException("Snap count mismatch: " + tuple.Item2);
				}
				int num2 = 0;
				while (num2 < array.Length)
				{
					Transform val = array[num2];
					Entry entry = value[num2];
					Vector3 val2 = prefab.transform.InverseTransformPoint(val.position);
					Vector3 val3;
					if (entry.Index == num2 && !(((Object)val).name != entry.Before))
					{
						val3 = val2 - entry.Position;
						if (!(((Vector3)(ref val3)).sqrMagnitude > 1E-06f) && hashSet.Add(val))
						{
							list.Add((val, entry));
							num2++;
							continue;
						}
					}
					string[] obj = new string[8]
					{
						"Naming baseline mismatch: ",
						tuple.Item2,
						" index ",
						num2.ToString(),
						" name=",
						((Object)val).name,
						" position=",
						null
					};
					val3 = val2;
					obj[7] = ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString();
					throw new InvalidOperationException(string.Concat(obj));
				}
				num++;
			}
			int num3 = list.Count<(Transform, Entry)>(((Transform Point, Entry Spec) p) => p.Spec.Before != p.Spec.After);
			if (num != 27 || Profiles.Count != 27 || list.Count != 208 || num3 != 144)
			{
				throw new InvalidOperationException("Naming specification totals mismatch.");
			}
			foreach (var item in list)
			{
				if (item.Item2.Before != item.Item2.After)
				{
					((Object)item.Item1).name = item.Item2.After;
				}
			}
			logger.LogInfo((object)"Missing Marble Alpha.6-B: naming standardized; assets=27, snaps=208, renamed=144, retained=64.");
		}
	}
	internal static class StairPlacementCollider
	{
		internal static void Apply(GameObject prefab, ManualLogSource logger)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			int num = LayerMask.NameToLayer("ghost");
			if (num < 0 || Object.op_Implicit((Object)(object)prefab.transform.Find("_GhostOnly")))
			{
				throw new InvalidOperationException("Unexpected ghost layer or existing GhostOnly hierarchy.");
			}
			MeshCollider[] componentsInChildren