Decompiled source of MoonforgedBuildPieces v2.0.4

MoonforgedBuildPieces.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoonforgedBuildPieces")]
[assembly: AssemblyDescription("Moonforged Build Pieces for Valheim Deep North.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Caenos")]
[assembly: AssemblyProduct("Moonforged Build Pieces")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("2.0.0.0")]
namespace Moonforged.BuildPieces;

public class BuildPieceVisualVariance : MonoBehaviour
{
	private const float MinPosOffset = 0.0005f;

	private const float MaxPosOffset = 0.001f;

	private const float MinYawOffset = 0.05f;

	private const float MaxYawOffset = 0.12f;

	private const float MinPitchRollOffset = 0.02f;

	private const float MaxPitchRollOffset = 0.06f;

	private bool _applied;

	private void Start()
	{
		TryApply();
	}

	private void OnEnable()
	{
		TryApply();
	}

	private void TryApply()
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		if (_applied)
		{
			return;
		}
		List<Transform> list = CollectVisualTargets();
		if (list.Count == 0)
		{
			return;
		}
		int baseSeed = GetBaseSeed();
		Vector3 val = default(Vector3);
		foreach (Transform item in list)
		{
			if (!((Object)(object)item == (Object)null))
			{
				Vector3 localPosition = item.localPosition;
				Quaternion localRotation = item.localRotation;
				int seed = CombineHash(baseSeed, GetTransformPath(item).GetHashCode());
				((Vector3)(ref val))..ctor(SignedRange(seed, 11, 0.0005f, 0.001f), SignedRange(seed, 23, 0.0005f, 0.001f), SignedRange(seed, 37, 0.0005f, 0.001f));
				float num = SignedRange(seed, 41, 0.02f, 0.06f);
				float num2 = SignedRange(seed, 53, 0.05f, 0.12f);
				float num3 = SignedRange(seed, 67, 0.02f, 0.06f);
				item.localPosition = localPosition + val;
				item.localRotation = localRotation * Quaternion.Euler(num, num2, num3);
			}
		}
		_applied = true;
	}

	private List<Transform> CollectVisualTargets()
	{
		List<Transform> list = new List<Transform>();
		HashSet<Transform> hashSet = new HashSet<Transform>();
		Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
		Renderer[] array = componentsInChildren;
		foreach (Renderer val in array)
		{
			if ((Object)(object)val == (Object)null || !val.enabled || val is ParticleSystemRenderer)
			{
				continue;
			}
			Transform transform = ((Component)val).transform;
			if ((Object)(object)transform == (Object)null || (Object)(object)transform == (Object)(object)((Component)this).transform)
			{
				continue;
			}
			string text = ((Object)transform).name.ToLowerInvariant();
			if (text.Contains("snap") || text.Contains("snapp") || text.Contains("collider") || text.Contains("trigger"))
			{
				continue;
			}
			Transform val2 = transform;
			while ((Object)(object)val2.parent != (Object)null && (Object)(object)val2.parent != (Object)(object)((Component)this).transform && HasRenderableAncestor(val2.parent))
			{
				string text2 = ((Object)val2.parent).name.ToLowerInvariant();
				if (text2.Contains("snap") || text2.Contains("snapp") || text2.Contains("collider") || text2.Contains("trigger"))
				{
					break;
				}
				val2 = val2.parent;
			}
			if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)((Component)this).transform && hashSet.Add(val2))
			{
				list.Add(val2);
			}
		}
		return list;
	}

	private bool HasRenderableAncestor(Transform t)
	{
		if ((Object)(object)t == (Object)null || (Object)(object)t == (Object)(object)((Component)this).transform)
		{
			return false;
		}
		return (Object)(object)((Component)t).GetComponent<Renderer>() != (Object)null;
	}

	private int GetBaseSeed()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: 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_0050: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)this).transform.position;
		Vector3 eulerAngles = ((Component)this).transform.eulerAngles;
		int b = Mathf.RoundToInt(position.x * 1000f);
		int b2 = Mathf.RoundToInt(position.y * 1000f);
		int b3 = Mathf.RoundToInt(position.z * 1000f);
		int b4 = Mathf.RoundToInt(eulerAngles.x * 100f);
		int b5 = Mathf.RoundToInt(eulerAngles.y * 100f);
		int b6 = Mathf.RoundToInt(eulerAngles.z * 100f);
		int hashCode = ((Object)((Component)this).gameObject).name.GetHashCode();
		hashCode = CombineHash(hashCode, b);
		hashCode = CombineHash(hashCode, b2);
		hashCode = CombineHash(hashCode, b3);
		hashCode = CombineHash(hashCode, b4);
		hashCode = CombineHash(hashCode, b5);
		return CombineHash(hashCode, b6);
	}

	private string GetTransformPath(Transform t)
	{
		if ((Object)(object)t == (Object)null)
		{
			return string.Empty;
		}
		List<string> list = new List<string>();
		Transform val = t;
		while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)((Component)this).transform)
		{
			list.Add(((Object)val).name);
			val = val.parent;
		}
		list.Reverse();
		return string.Join("/", list);
	}

	private static int CombineHash(int a, int b)
	{
		return (a * 397) ^ b;
	}

	private static float SignedRange(int seed, int salt, float minAbs, float maxAbs)
	{
		float num = Mathf.Lerp(minAbs, maxAbs, Hash01(seed, salt));
		float num2 = ((Hash01(seed, salt + 911) < 0.5f) ? (-1f) : 1f);
		return num * num2;
	}

	private static float Hash01(int seed, int salt)
	{
		int num = seed;
		num = (num * 397) ^ salt;
		num ^= num << 13;
		num ^= num >> 17;
		num ^= num << 5;
		uint num2 = (uint)num;
		return (float)(num2 & 0xFFFFFF) / 16777215f;
	}
}
[BepInPlugin("Moonforged.BuildPieces", "Moonforged Build Pieces", "2.0.4")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MoonforgedBuildPieces : BaseUnityPlugin
{
	public const string PluginGUID = "Moonforged.BuildPieces";

	public const string PluginName = "Moonforged Build Pieces";

	public const string PluginVersion = "2.0.4";

	private AssetBundle buildPiecesBundle;

	private void Awake()
	{
		RelicConfigManager.Init("Moonforged.BuildPieces", ((BaseUnityPlugin)this).Config);
		RelicRegistrar.InitConfig(((BaseUnityPlugin)this).Config);
		TallPillarSnapAssist.Install();
		MoonforgedPlacementPivot.Install();
		if (RelicRegistrar.AllRegistrations.Count == 0)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Moonforged Build Pieces template loaded. No build pieces are registered yet.");
			return;
		}
		string platformBundleResourcePath = GetPlatformBundleResourcePath();
		buildPiecesBundle = EmbeddedAssetBundleLoader.LoadBundle(platformBundleResourcePath);
		if ((Object)(object)buildPiecesBundle == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load embedded AssetBundle: " + platformBundleResourcePath));
		}
		else
		{
			PrefabManager.OnPrefabsRegistered += OnPrefabsRegistered;
		}
	}

	private static string GetPlatformBundleResourcePath()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Invalid comparison between Unknown and I4
		RuntimePlatform platform = Application.platform;
		RuntimePlatform val = platform;
		if ((int)val <= 1)
		{
			return "Moonforged.BuildPieces.mbp_mac";
		}
		return "Moonforged.BuildPieces.mbp_windows";
	}

	private void OnDestroy()
	{
		PrefabManager.OnPrefabsRegistered -= OnPrefabsRegistered;
		TallPillarSnapAssist.Uninstall();
		MoonforgedPlacementPivot.Uninstall();
	}

	private void OnPrefabsRegistered()
	{
		((MonoBehaviour)this).StartCoroutine(DelayedRegister(buildPiecesBundle));
	}

	private IEnumerator DelayedRegister(AssetBundle bundle)
	{
		while ((Object)(object)ZNetScene.instance == (Object)null)
		{
			yield return null;
		}
		RelicRegistrar.RegisterAllRelics(bundle);
	}
}
public static class EmbeddedAssetBundleLoader
{
	public static AssetBundle LoadBundle(string resourcePath)
	{
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		using Stream stream = executingAssembly.GetManifestResourceStream(resourcePath);
		if (stream == null)
		{
			Debug.LogError((object)("AssetBundle resource not found: " + resourcePath));
			return null;
		}
		using MemoryStream memoryStream = new MemoryStream();
		stream.CopyTo(memoryStream);
		return AssetBundle.LoadFromMemory(memoryStream.ToArray());
	}
}
internal static class MoonforgedPlacementPivot
{
	private sealed class SnapSearchState
	{
		internal Transform Ghost;

		internal Vector3 Position;

		internal bool Restored;
	}

	private static Harmony harmony;

	private static readonly FieldInfo GhostField = AccessTools.Field(typeof(Player), "m_placementGhost");

	private static readonly FieldInfo ManualSnapField = AccessTools.Field(typeof(Player), "m_manualSnapPoint");

	private static readonly HashSet<string> RegisteredNames = CreateRegisteredNames();

	private static Player offsetPlayer;

	private static GameObject offsetGhost;

	private static Vector3 snapSearchOffset;

	private static HashSet<string> CreateRegisteredNames()
	{
		HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal);
		foreach (RelicRegistration allRegistration in RelicRegistrar.AllRegistrations)
		{
			hashSet.Add(allRegistration.PrefabName);
		}
		return hashSet;
	}

	internal static void Install()
	{
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Expected O, but got Unknown
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Expected O, but got Unknown
		//IL_0154: 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_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Expected O, but got Unknown
		//IL_018a: Expected O, but got Unknown
		//IL_018a: Expected O, but got Unknown
		if (harmony != null)
		{
			return;
		}
		MethodInfo methodInfo = AccessTools.Method(typeof(Player), "UpdatePlacementGhost", new Type[1] { typeof(bool) }, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(Player), "FindClosestSnapPoints", new Type[5]
		{
			typeof(Transform),
			typeof(float),
			typeof(Transform).MakeByRefType(),
			typeof(Transform).MakeByRefType(),
			typeof(List<Piece>)
		}, (Type[])null);
		if (methodInfo == null || methodInfo2 == null || GhostField == null || ManualSnapField == null)
		{
			Debug.LogWarning((object)"[Moonforged Build Pieces] Root-pivot placement unavailable: Valheim placement API not found.");
			return;
		}
		harmony = new Harmony("Moonforged.BuildPieces.RootPlacementPivot");
		try
		{
			harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(MoonforgedPlacementPivot), "Transpile", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(MoonforgedPlacementPivot), "ResetSearchOffset", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(MoonforgedPlacementPivot), "BeforeSnapSearch", (Type[])null), new HarmonyMethod(typeof(MoonforgedPlacementPivot), "AfterSnapSearch", (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MoonforgedPlacementPivot), "FinishSnapSearch", (Type[])null), (HarmonyMethod)null);
		}
		catch (Exception ex)
		{
			Debug.LogWarning((object)("[Moonforged Build Pieces] Root-pivot placement patch failed: " + ex));
			harmony.UnpatchSelf();
			harmony = null;
		}
	}

	internal static void Uninstall()
	{
		if (harmony != null)
		{
			harmony.UnpatchSelf();
			harmony = null;
			ResetSearchOffset();
		}
	}

	private static void ResetSearchOffset()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		offsetPlayer = null;
		offsetGhost = null;
		snapSearchOffset = Vector3.zero;
	}

	private static Vector3 ChoosePlacementOffset(Vector3 original, Player player)
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: 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_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_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: 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)
		object? value = GhostField.GetValue(player);
		GameObject val = (GameObject)((value is GameObject) ? value : null);
		if ((Object)(object)val != (Object)null && RegisteredNames.Contains(((Object)val).name))
		{
			if ((int)ManualSnapField.GetValue(player) >= 0)
			{
				return original;
			}
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(0f, original.y, 0f);
			offsetPlayer = player;
			offsetGhost = val;
			snapSearchOffset = original - val2;
			return val2;
		}
		return original;
	}

	private static void BeforeSnapSearch(Player __instance, Transform __0, out SnapSearchState __state)
	{
		//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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		__state = null;
		if (!((Object)(object)__instance != (Object)(object)offsetPlayer) && Object.op_Implicit((Object)(object)offsetGhost) && Object.op_Implicit((Object)(object)__0) && !((Object)(object)((Component)__0).gameObject != (Object)(object)offsetGhost) && (int)ManualSnapField.GetValue(__instance) < 0)
		{
			__state = new SnapSearchState
			{
				Ghost = __0,
				Position = __0.position
			};
			__0.position += snapSearchOffset;
			ResetSearchOffset();
		}
	}

	private static void RestoreSnapSearch(SnapSearchState state)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		if (state != null && !state.Restored)
		{
			if (Object.op_Implicit((Object)(object)state.Ghost))
			{
				state.Ghost.position = state.Position;
			}
			state.Restored = true;
		}
	}

	private static void AfterSnapSearch(SnapSearchState __state)
	{
		RestoreSnapSearch(__state);
	}

	private static Exception FinishSnapSearch(Exception __exception, SnapSearchState __state)
	{
		RestoreSnapSearch(__state);
		return __exception;
	}

	private static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions)
	{
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Expected O, but got Unknown
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Expected O, but got Unknown
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		MethodInfo methodInfo = AccessTools.Method(typeof(Collider), "ClosestPoint", new Type[1] { typeof(Vector3) }, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(Vector3), "op_Subtraction", new Type[2]
		{
			typeof(Vector3),
			typeof(Vector3)
		}, (Type[])null);
		MethodInfo methodInfo3 = AccessTools.Method(typeof(MoonforgedPlacementPivot), "ChoosePlacementOffset", (Type[])null, (Type[])null);
		int num = -1;
		bool flag = false;
		for (int i = 0; i < list.Count; i++)
		{
			if (CodeInstructionExtensions.Calls(list[i], methodInfo))
			{
				flag = true;
			}
			if (flag && CodeInstructionExtensions.Calls(list[i], methodInfo2) && i + 1 < list.Count && list[i + 1].opcode.Name.StartsWith("stloc", StringComparison.Ordinal))
			{
				num = i;
				break;
			}
		}
		if (num < 0)
		{
			Debug.LogWarning((object)"[Moonforged Build Pieces] Root-pivot patch skipped: collider placement offset IL was not found.");
			return list;
		}
		list.Insert(num + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
		list.Insert(num + 2, new CodeInstruction(OpCodes.Call, (object)methodInfo3));
		Debug.Log((object)"[Moonforged Build Pieces] Root-pivot placement enabled for all registered prefabs.");
		return list;
	}
}
public static class RelicConfigManager
{
	public static void Init(string modName, ConfigFile config)
	{
	}

	public static ConfigEntry<T> AddEntry<T>(ConfigFile cfg, string section, string key, T defaultValue, string description)
	{
		return cfg.Bind<T>(section, key, defaultValue, description);
	}
}
public class RelicRegistration
{
	public string PrefabName;

	public string DisplayName;

	public RequirementConfig[] Requirements;

	public string Description;

	public string Category;

	public int Comfort;

	public RelicRegistration(string prefab, string display, RequirementConfig[] reqs, string desc, string cat, int comfort = 0)
	{
		PrefabName = prefab;
		DisplayName = display;
		Requirements = reqs;
		Description = desc;
		Category = cat;
		Comfort = comfort;
	}
}
public static class RelicRegistrar
{
	private static bool wasAlreadyRegistered = false;

	private static ConfigEntry<string> BuildingCategoryConfig;

	public static readonly List<RelicRegistration> AllRegistrations = new List<RelicRegistration>
	{
		new RelicRegistration("M_Wood_Beam_1m_H", "Carved Wood Beam 1m Horizontal", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_Beam_1m_V", "Carved Wood Beam 1m Vertical", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_Beam_2m_H", "Carved Wood Beam 2m Horizontal", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_Beam_2m_V", "Carved Wood Beam 2m Vertical", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_Beam_26", "Carved Wood Beam 26°", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_Beam_45", "Carved Wood Beam 45°", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_Pillar_Arched", "Carved Wood Beam Arched", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_Pillar_Arched_Flipped", "Carved Wood Beam Arched Flipped", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Connection_Box", "Carved Connection Box", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_RoundBeam_2m_H", "Carved Round Wood Beam 2m Horizontal", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_RoundBeam_2m_V", "Carved Round Wood Beam 2m Vertical", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_RoundBeam_4m_h", "Carved Round Wood Beam 4m Horizontal", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 4, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_RoundBeam_4m_V", "Carved Round Wood Beam 4m Vertical", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 4, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_RoundBeam_Arch", "Carved Round Wood Arch Beam", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 4, 0, true),
			new RequirementConfig("Coal", 2, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_RoundBeam_HalfArch", "Carved Round Wood Half-Arch Beam", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wood_RoundBeam_8m_V_Large", "Large Carved Round Wood Beam 8m Vertical", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 5, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Pillar_Corewood_Round_15M", "Core Wood Round Pillar 15m", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 15, 0, true),
			new RequirementConfig("Coal", 10, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall", "Carved Wall 2×2", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall_1m", "Carved Wall 1×2m", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall_26_In", "Carved Wall 26° In Right", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall_26_In2", "Carved Wall 26° In Left", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall_26_Out", "Carved Wall 26° Out Right", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall_26_Out2", "Carved Wall 26° Out Left", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall_45_In", "Carved Wall 45° In Right", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall_45_In2", "Carved Wall 45° In Left", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall_45_Out", "Carved Wall 45° Out Right", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Wall_45_Out2", "Carved Wall 45° Out Left", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall", "Runed Wall 2×2", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_1X1", "Runed Wall 1×1m", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_26_In", "Runed Wall 26° In Right", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_26_In2", "Runed Wall 26° In Left", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_26_Out", "Runed Wall 26° Out Right", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_26_Out2", "Runed Wall 26° Out Left", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_45_In", "Runed Wall 45° In Right", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_45_In2", "Runed Wall 45° In Left", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_45_Out", "Runed Wall 45° Out Right", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_45_Out2", "Runed Wall 45° Out Left", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_Corner", "Runed/Carved Corner Piece", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Wood", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Wall_Corner_Flipped", "Moonforged Runed Wall Corner Flipped", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Wood", 2, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Carved_Floor", "Carved Floor 2×2", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Floor", "Runed Floor 2×2", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RoundLog", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Carved_Stairs", "Carved Stairs", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runed_Stairs", "Runed Stairs", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runic_Railing_2m", "Runed Railing 2m", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Runic_Stairs_Railing_26", "Runed Railing 26°", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 2, 0, true),
			new RequirementConfig("Coal", 1, 0, true)
		}, "A carved wood building beam.", "building"),
		new RelicRegistration("M_Rune_Carved_Door", "Rune Carved Door", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("RoundLog", 10, 0, true),
			new RequirementConfig("Wood", 10, 0, true),
			new RequirementConfig("Coal", 5, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Rune_Carved_Double_Door", "Rune Carved Double Door", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("RoundLog", 20, 0, true),
			new RequirementConfig("Wood", 20, 0, true),
			new RequirementConfig("Coal", 10, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Arched_Runed_Door", "Runed Arched Door", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("RoundLog", 5, 0, true),
			new RequirementConfig("Wood", 5, 0, true),
			new RequirementConfig("Coal", 2, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Arched_Runed_Door_Huge", "Huge Runed Arched Door", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("RoundLog", 20, 0, true),
			new RequirementConfig("Wood", 20, 0, true),
			new RequirementConfig("Coal", 15, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Ship_Mozaic_Window_4m", "Moonforged Window Frame 4m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Wood", 1, 0, true),
			new RequirementConfig("Stone", 10, 0, true),
			new RequirementConfig("Crystal", 3, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Ship_Mozaic_Window_2m", "Moonforged Window Frame 2m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Wood", 1, 0, true),
			new RequirementConfig("Stone", 10, 0, true),
			new RequirementConfig("Crystal", 3, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Window_Frame_2x2", "Window Frame 2x2", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Wood", 1, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_Frame_4x4", "Window Frame 4x4", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Wood", 1, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_Frame_4x4_Flipped", "Window Frame 4x4 Flipped", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Wood", 1, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Corner_Window_Frame", "Corner Window Frame", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Wood", 1, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_Frame_2x2_grausten", "2x2 Grausten Window Frame", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Grausten", 5, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_Frame_4x4_grausten", "4x4 Grausten Window Frame", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Grausten", 10, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Corner_Window_Frame_grausten", "Corner Grausten Window Frame", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Grausten", 2, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Corner_Window_Frame_grausten_inv", "Inverted Corner Grausten Window Frame", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Grausten", 2, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_1", "H-Pattern Window I", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_2", "H-Pattern Window II", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_3", "H-Pattern Window III", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_2x1", "2×1 Window", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Stone", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_2x2", "2×2 Window", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Stone", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window2x2", "Sunflower 2×2 Window", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_26", "Moonforged Window 26", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Window_45", "Moonforged Window 45", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Rounded_Wood_Window", "Rounded Wood Window", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 10, 0, true),
			new RequirementConfig("Stone", 10, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Ship_Round_Window_Mozaic_2m", "Moonforged Round Window+Ship 2m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Wood", 1, 0, true),
			new RequirementConfig("Stone", 10, 0, true),
			new RequirementConfig("Crystal", 3, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Ship_Round_Window_Mozaic_4m", "Moonforged Round Window+Ship 4m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Wood", 1, 0, true),
			new RequirementConfig("Stone", 10, 0, true),
			new RequirementConfig("Crystal", 3, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Round_Moonforged_Window_1", "Moonforged Round Window I", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Round_Window_Kitchen", "Rounded Kitchen Window", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Wood", 10, 0, true),
			new RequirementConfig("Stone", 5, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Round_Church_Window", "Round Church Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_WoodFrame_Rose_Window", "Wood-Framed Rose Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_RoundMozaic", "Round Mosaic Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ChurchMozaic", "Church Rose Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Mage_Round_Window_Mozaic", "Mage Round Stained Glass Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ArchedWindowGreen", "Green Arched Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ArchedWindowPurple", "Purple Arched Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ArchedWindowRed", "Red Arched Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ArchedWindowBat", "Bat Arched Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Arched_Window_Church", "Arched Church Window Big", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 5, 0, true),
			new RequirementConfig("Wood", 10, 0, true),
			new RequirementConfig("Crystal", 10, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Arched_Window_Church_small", "Arched Church Window Small", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 5, 0, true),
			new RequirementConfig("Crystal", 5, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ArchedWindow_SwampWraith_2x3", "Swamp Wraith Arched Window 2×3", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 1, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Stone", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Arched_Window_Church_2", "Moonforged Church Windows", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Wood", 1, 0, true),
			new RequirementConfig("Stone", 10, 0, true),
			new RequirementConfig("Crystal", 3, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_ArchedWindowMozaic", "Valkyrie Mosaic Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ArchedWindowPurpleM", "Purple Mosaic Arched Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ArchedWindowRedM", "Red Mosaic Arched Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ArchedWindowC", "Arched Stained Glass Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Church-of-Odin-Window-10m", "Moonforged Odin`s Church Window 10m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Church-of-Odin-Window-6m", "Moonforged Odin`s Church Window 6m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 3, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Church-of-Odin-Window-3x2m", "Moonforged Odin`s Church Window 3x2m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 2, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Church-of-Thor-Window-10m", "Moonforged Thor`s Church Window 10m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Church-of-Thor-Window-6m", "Moonforged Thor`s Church Window 6m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 3, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Church-of-Thor-Window-3x2m", "Moonforged Thor`s Church Window 3x2m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 2, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Church-of-Freya-Window-10m", "Moonforged Freya`s Church Window 10m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Church-of-Freya-Window-6m", "Moonforged Freya`s Church Window 6m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 3, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_Church-of-Freya-Window-3x2m", "Moonforged Freya`s Church Window 3m", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 2, 0, true)
		}, "Stained glass window.", "building"),
		new RelicRegistration("M_BrownBearMozaic", "Bear Mosaic Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_GreenCloverMozaic", "Clover Mosaic Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_CrowMozaic", "Crow Mosaic Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_WorldTreeMozaic", "World Tree Mosaic Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_OdinMozaic", "Odin Mosaic Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_ElfMozaic", "Elf Stained Glass Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_WolfMozaic", "Wolf Stained Glass Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_MageMozaic", "Mage Stained Glass Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Dome_Frame", "Moonforged Dome Frame", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("Iron", 2, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Dome_Silent_Night", "Silent Night Dome Window", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Dome_Moonforged_Window_1", "Moonforged Dome Window I", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Dome2x2", "Quarter Dome Glass Piece 2×2", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Dome2x2x2", "Quarter Dome Glass Piece 2×2×2", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Iron", 2, 0, true),
			new RequirementConfig("Wood", 4, 0, true),
			new RequirementConfig("Crystal", 4, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Roof_45", "45 Degree Grass Roof", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("Dandelion", 2, 0, true),
			new RequirementConfig("Wood", 5, 0, true)
		}, "", "building"),
		new RelicRegistration("M_Trellis", "Moonforged Trellis", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("Wood", 1, 0, true),
			new RequirementConfig("Blueberries", 10, 0, true),
			new RequirementConfig("Dandelion", 3, 0, true)
		}, "A Garden Trellis.", "building")
	};

	public static void InitConfig(ConfigFile cfg)
	{
		BuildingCategoryConfig = RelicConfigManager.AddEntry(cfg, "Categories", "BuildingCategory", "Moonforged Build Pieces", "Hammer tab name for Moonforged build pieces.");
	}

	private static string CategoryToTab(string category)
	{
		return (BuildingCategoryConfig != null) ? BuildingCategoryConfig.Value : "Moonforged Build Pieces";
	}

	public static void RegisterAllRelics(AssetBundle bundle)
	{
		if (wasAlreadyRegistered)
		{
			return;
		}
		foreach (RelicRegistration allRegistration in AllRegistrations)
		{
			RegisterRelic(bundle, allRegistration);
		}
		wasAlreadyRegistered = true;
	}

	private static void RegisterRelic(AssetBundle bundle, RelicRegistration reg)
	{
		//IL_04af: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Expected O, but got Unknown
		//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04df: Expected O, but got Unknown
		//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0502: Expected O, but got Unknown
		//IL_053f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0546: Expected O, but got Unknown
		//IL_055d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0562: Unknown result type (might be due to invalid IL or missing references)
		//IL_056f: Expected O, but got Unknown
		//IL_0580: Unknown result type (might be due to invalid IL or missing references)
		//IL_0585: Unknown result type (might be due to invalid IL or missing references)
		//IL_0592: Expected O, but got Unknown
		//IL_0632: Unknown result type (might be due to invalid IL or missing references)
		//IL_0639: Expected O, but got Unknown
		//IL_069e: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a8: Expected O, but got Unknown
		if ((Object)(object)bundle == (Object)null)
		{
			return;
		}
		GameObject val = bundle.LoadAsset<GameObject>(reg.PrefabName);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)("[Moonforged Build Pieces] Missing prefab in AssetBundle: " + reg.PrefabName));
			return;
		}
		((Object)val).name = reg.PrefabName;
		ConfigureDoorSounds(val, reg.PrefabName);
		ZNetView val2 = val.GetComponent<ZNetView>() ?? val.AddComponent<ZNetView>();
		val2.m_persistent = true;
		val2.m_syncInitialScale = true;
		ZSyncTransform val3 = val.GetComponent<ZSyncTransform>() ?? val.AddComponent<ZSyncTransform>();
		val3.m_syncPosition = false;
		val3.m_syncRotation = false;
		val3.m_syncScale = true;
		val3.m_syncBodyVelocity = false;
		val3.m_characterParentSync = false;
		if ((Object)(object)val.GetComponent<BuildPieceVisualVariance>() == (Object)null)
		{
			val.AddComponent<BuildPieceVisualVariance>();
		}
		Piece val4 = val.GetComponent<Piece>() ?? val.AddComponent<Piece>();
		val4.m_name = reg.DisplayName;
		val4.m_description = reg.Description;
		val4.m_enabled = true;
		val4.m_canBeRemoved = true;
		val4.m_canRotate = true;
		val4.m_groundOnly = false;
		ZNetScene instance = ZNetScene.instance;
		GameObject val5 = ((instance != null) ? instance.GetPrefab("vfx_Place_wood") : null);
		ZNetScene instance2 = ZNetScene.instance;
		GameObject val6 = ((instance2 != null) ? instance2.GetPrefab("sfx_build_hammer_wood") : null);
		ZNetScene instance3 = ZNetScene.instance;
		GameObject val7 = ((instance3 != null) ? instance3.GetPrefab("vfx_destroyed") : null);
		ZNetScene instance4 = ZNetScene.instance;
		GameObject val8 = ((instance4 != null) ? instance4.GetPrefab("sfx_wood_break") : null);
		string text = reg.PrefabName.ToLowerInvariant();
		string text2 = (reg.DisplayName ?? "").ToLowerInvariant();
		bool flag = text.Contains("grausten") || text2.Contains("grausten");
		bool flag2 = text.Contains("window") || text.Contains("mozaic") || text.Contains("dome");
		bool flag3 = flag2 && (text.Contains("dome") || text.Contains("arch") || text.Contains("round") || text2.Contains("arched") || text2.Contains("round"));
		if (flag)
		{
			ZNetScene instance5 = ZNetScene.instance;
			val6 = ((instance5 != null) ? instance5.GetPrefab("sfx_build_hammer_stone") : null);
			ZNetScene instance6 = ZNetScene.instance;
			val8 = ((instance6 != null) ? instance6.GetPrefab("sfx_rock_destroyed") : null);
		}
		else if (flag2)
		{
			if (flag3)
			{
				ZNetScene instance7 = ZNetScene.instance;
				val6 = ((instance7 != null) ? instance7.GetPrefab("sfx_build_hammer_metal") : null);
			}
			ZNetScene instance8 = ZNetScene.instance;
			object obj = ((instance8 != null) ? instance8.GetPrefab("sfx_crystal_break") : null);
			if (obj == null)
			{
				ZNetScene instance9 = ZNetScene.instance;
				obj = ((instance9 != null) ? instance9.GetPrefab("sfx_clay_pot_break") : null);
			}
			val8 = (GameObject)obj;
		}
		switch (reg.PrefabName)
		{
		case "M_Ship_Mozaic_Window_4m":
		case "M_Ship_Mozaic_Window_2m":
		case "M_Window_Frame_2x2":
		case "M_Window_Frame_4x4":
		case "M_Window_Frame_4x4_Flipped":
		case "M_Corner_Window_Frame":
		case "M_Rounded_Wood_Window":
		case "M_Ship_Round_Window_Mozaic_2m":
		case "M_Ship_Round_Window_Mozaic_4m":
		case "M_Round_Moonforged_Window_1":
		case "M_Round_Window_Kitchen":
		{
			ZNetScene instance10 = ZNetScene.instance;
			val6 = ((instance10 != null) ? instance10.GetPrefab("sfx_build_hammer_wood") : null);
			ZNetScene instance11 = ZNetScene.instance;
			object obj2 = ((instance11 != null) ? instance11.GetPrefab("sfx_crystal_break") : null);
			if (obj2 == null)
			{
				ZNetScene instance12 = ZNetScene.instance;
				obj2 = ((instance12 != null) ? instance12.GetPrefab("sfx_clay_pot_break") : null);
			}
			val8 = (GameObject)obj2;
			break;
		}
		}
		EffectList val9 = new EffectList();
		List<EffectData> list = new List<EffectData>();
		if ((Object)(object)val5 != (Object)null)
		{
			list.Add(new EffectData
			{
				m_prefab = val5
			});
		}
		if ((Object)(object)val6 != (Object)null)
		{
			list.Add(new EffectData
			{
				m_prefab = val6
			});
		}
		val9.m_effectPrefabs = list.ToArray();
		val4.m_placeEffect = val9;
		WearNTear val10 = val.GetComponent<WearNTear>() ?? val.AddComponent<WearNTear>();
		val10.m_health = 2000f;
		val10.m_noRoofWear = true;
		EffectList val11 = new EffectList();
		List<EffectData> list2 = new List<EffectData>();
		if ((Object)(object)val7 != (Object)null)
		{
			list2.Add(new EffectData
			{
				m_prefab = val7
			});
		}
		if ((Object)(object)val8 != (Object)null)
		{
			list2.Add(new EffectData
			{
				m_prefab = val8
			});
		}
		val11.m_effectPrefabs = list2.ToArray();
		val10.m_destroyedEffect = val11;
		if (reg.Comfort > 0)
		{
			val4.m_comfort = reg.Comfort;
		}
		Sprite val12 = bundle.LoadAsset<Sprite>(reg.PrefabName);
		if ((Object)(object)val12 != (Object)null)
		{
			val4.m_icon = val12;
		}
		string craftingStation = ((reg.Requirements != null && reg.Requirements.Any((RequirementConfig r) => r.Item.ToLower() == "iron")) ? "forge" : "piece_workbench");
		PieceConfig val13 = new PieceConfig();
		val13.PieceTable = PieceTables.Hammer;
		val13.Category = CategoryToTab(reg.Category);
		val13.Usage = new string[1] { PieceUsages.Building };
		val13.CraftingStation = craftingStation;
		val13.Requirements = (RequirementConfig[])(((object)reg.Requirements) ?? ((object)new RequirementConfig[0]));
		PieceConfig val14 = val13;
		PieceManager.Instance.AddPiece(new CustomPiece(val, true, val14));
	}

	private static void ConfigureDoorSounds(GameObject prefab, string prefabName)
	{
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Expected O, but got Unknown
		//IL_0173: 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_0198: Expected O, but got Unknown
		string text;
		switch (prefabName)
		{
		default:
			return;
		case "M_Rune_Carved_Double_Door":
		case "M_Arched_Runed_Door_Huge":
			text = "darkwood_gate";
			break;
		case "M_Rune_Carved_Door":
		case "M_Arched_Runed_Door":
			text = "wood_door";
			break;
		}
		Door[] componentsInChildren = prefab.GetComponentsInChildren<Door>(true);
		if (componentsInChildren.Length == 0)
		{
			Debug.LogWarning((object)("[Moonforged Build Pieces] Cannot configure door sounds: " + prefabName + " has no Door component."));
			return;
		}
		ZNetScene instance = ZNetScene.instance;
		GameObject val = ((instance != null) ? instance.GetPrefab(text) : null);
		Door val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Door>() : null);
		if ((Object)(object)val2 == (Object)null || val2.m_openEffects == null || val2.m_closeEffects == null || val2.m_openEffects.m_effectPrefabs == null || val2.m_openEffects.m_effectPrefabs.Length == 0 || val2.m_closeEffects.m_effectPrefabs == null || val2.m_closeEffects.m_effectPrefabs.Length == 0)
		{
			Debug.LogWarning((object)("[Moonforged Build Pieces] Cannot configure door sounds for " + prefabName + ": vanilla door effects unavailable on " + text + "."));
			return;
		}
		Door[] array = componentsInChildren;
		foreach (Door val3 in array)
		{
			val3.m_openEffects = new EffectList
			{
				m_effectPrefabs = (EffectData[])val2.m_openEffects.m_effectPrefabs.Clone()
			};
			val3.m_closeEffects = new EffectList
			{
				m_effectPrefabs = (EffectData[])val2.m_closeEffects.m_effectPrefabs.Clone()
			};
		}
	}
}
internal static class TallPillarSnapAssist
{
	private const float TallPillarPlacementDistance = 22f;

	private const float TallPillarSnapDistance = 1.25f;

	private const string EightMeterPillar = "M_Wood_RoundBeam_8m_V_Large";

	private const string FifteenMeterPillar = "M_Pillar_Corewood_Round_15M";

	private static readonly RaycastHit[] AimHits = (RaycastHit[])(object)new RaycastHit[128];

	private static Harmony harmony;

	private static bool isAimingAtTallPillar;

	internal static void Install()
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Expected O, but got Unknown
		//IL_00a1: Expected O, but got Unknown
		//IL_00a1: Expected O, but got Unknown
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Expected O, but got Unknown
		if (harmony != null)
		{
			return;
		}
		MethodInfo methodInfo = AccessTools.Method(typeof(Player), "UpdatePlacementGhost", (Type[])null, (Type[])null);
		if (methodInfo == null)
		{
			Debug.LogWarning((object)"[Moonforged Build Pieces] Tall pillar snap assist unavailable: UpdatePlacementGhost was not found.");
			return;
		}
		harmony = new Harmony("Moonforged.BuildPieces.TallPillarSnapAssist");
		try
		{
			harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(TallPillarSnapAssist), "BeforePlacementGhost", (Type[])null), new HarmonyMethod(typeof(TallPillarSnapAssist), "AfterPlacementGhost", (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(TallPillarSnapAssist), "FinishPlacementGhost", (Type[])null), (HarmonyMethod)null);
			MethodInfo methodInfo2 = FindSnapMethod();
			if (methodInfo2 != null)
			{
				harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(TallPillarSnapAssist), "BeforeFindSnapPoints", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else
			{
				Debug.LogWarning((object)"[Moonforged Build Pieces] Tall pillar reach enabled, but the optional snap radius patch could not find FindClosestSnapPoints.");
			}
		}
		catch (Exception ex)
		{
			Debug.LogWarning((object)("[Moonforged Build Pieces] Could not install tall pillar snap assist: " + ex));
			harmony.UnpatchSelf();
			harmony = null;
		}
	}

	internal static void Uninstall()
	{
		if (harmony != null)
		{
			harmony.UnpatchSelf();
			harmony = null;
			isAimingAtTallPillar = false;
		}
	}

	private static MethodInfo FindSnapMethod()
	{
		MethodInfo[] methods = typeof(Player).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
		foreach (MethodInfo methodInfo in methods)
		{
			if (!(methodInfo.Name != "FindClosestSnapPoints"))
			{
				ParameterInfo[] parameters = methodInfo.GetParameters();
				if (parameters.Length > 1 && parameters[1].ParameterType == typeof(float))
				{
					return methodInfo;
				}
			}
		}
		return null;
	}

	private static void BeforePlacementGhost(Player __instance, GameObject ___m_placementGhost, ref float ___m_maxPlaceDistance, out float __state)
	{
		__state = ___m_maxPlaceDistance;
		isAimingAtTallPillar = false;
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !((Object)(object)___m_placementGhost == (Object)null) && IsAimingAtTallPillar(__instance, ___m_placementGhost))
		{
			isAimingAtTallPillar = true;
			___m_maxPlaceDistance = Mathf.Max(___m_maxPlaceDistance, 22f);
		}
	}

	private static void AfterPlacementGhost(ref float ___m_maxPlaceDistance, float __state)
	{
		___m_maxPlaceDistance = __state;
		isAimingAtTallPillar = false;
	}

	private static Exception FinishPlacementGhost(Exception __exception, ref float ___m_maxPlaceDistance, float __state)
	{
		___m_maxPlaceDistance = __state;
		isAimingAtTallPillar = false;
		return __exception;
	}

	private static void BeforeFindSnapPoints(ref float __1)
	{
		if (isAimingAtTallPillar)
		{
			__1 = Mathf.Max(__1, 1.25f);
		}
	}

	private static bool IsAimingAtTallPillar(Player player, GameObject placementGhost)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null)
		{
			return false;
		}
		Ray val = main.ScreenPointToRay(new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f, 0f));
		int num = Physics.RaycastNonAlloc(val, AimHits, 22f, -5, (QueryTriggerInteraction)1);
		float num2 = float.MaxValue;
		Piece val2 = null;
		bool flag = false;
		for (int i = 0; i < num; i++)
		{
			RaycastHit val3 = AimHits[i];
			if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !((Component)((RaycastHit)(ref val3)).collider).transform.IsChildOf(((Component)player).transform) && (!((Object)(object)placementGhost != (Object)null) || !((Component)((RaycastHit)(ref val3)).collider).transform.IsChildOf(placementGhost.transform)) && !(((RaycastHit)(ref val3)).distance >= num2))
			{
				num2 = ((RaycastHit)(ref val3)).distance;
				val2 = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<Piece>();
				flag = true;
			}
		}
		if (!flag || (Object)(object)val2 == (Object)null)
		{
			return false;
		}
		string text = ((Object)((Component)val2).gameObject).name;
		if (text.EndsWith("(Clone)", StringComparison.Ordinal))
		{
			text = text.Substring(0, text.Length - "(Clone)".Length);
		}
		return string.Equals(text, "M_Wood_RoundBeam_8m_V_Large", StringComparison.Ordinal) || string.Equals(text, "M_Pillar_Corewood_Round_15M", StringComparison.Ordinal);
	}
}