Decompiled source of HalfBeam v0.1.0

HalfBeam.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("HalfBeam")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Half-sized beams so you can build with more precision.")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+77ff354b16cb42fed4cfd5bba437178babc89bc2")]
[assembly: AssemblyProduct("HalfBeam")]
[assembly: AssemblyTitle("HalfBeam")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HalfBeams
{
	internal static class IconLoader
	{
		private static readonly MethodInfo LoadImageMethod = typeof(ImageConversion).GetMethod("LoadImage", new Type[2]
		{
			typeof(Texture2D),
			typeof(byte[])
		});

		public static Sprite Load(string prefabName, ManualLogSource log)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_00c7: 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)
			string text = "Icons." + prefabName + ".png";
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text);
			if (stream == null)
			{
				return null;
			}
			byte[] array;
			using (MemoryStream memoryStream = new MemoryStream())
			{
				stream.CopyTo(memoryStream);
				array = memoryStream.ToArray();
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				name = prefabName + "_icon"
			};
			if (!(LoadImageMethod != null) || !(bool)LoadImageMethod.Invoke(null, new object[2] { val, array }))
			{
				log.LogWarning((object)("Could not decode icon " + text));
				return null;
			}
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
	internal enum SnowMode
	{
		ScaleLength,
		Remove
	}
	internal sealed class PieceVariantDefinition
	{
		public string SourcePrefabName { get; }

		public string NewPrefabName { get; }

		public string DisplayName { get; }

		public string Description { get; }

		public float LengthScale { get; }

		public float CostRatio { get; }

		public SnowMode Snow { get; }

		public PieceVariantDefinition(string sourcePrefabName, string newPrefabName, string displayName, string description, float lengthScale, SnowMode snow, float? costRatio = null)
		{
			SourcePrefabName = sourcePrefabName;
			NewPrefabName = newPrefabName;
			DisplayName = displayName;
			Description = description;
			LengthScale = lengthScale;
			Snow = snow;
			CostRatio = costRatio ?? lengthScale;
		}
	}
	internal static class PieceVariantFactory
	{
		private struct BeamFrame
		{
			public readonly Vector3 Center;

			public readonly Vector3 Axis;

			public readonly float Scale;

			public BeamFrame(Vector3 center, Vector3 axis, float scale)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				Center = center;
				Axis = axis;
				Scale = scale;
			}

			public Vector3 Directional(Vector3 v)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: 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_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				return v - (1f - Scale) * Vector3.Dot(v, Axis) * Axis;
			}

			public Vector3 MapPoint(Vector3 p)
			{
				//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_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				return Scale * Center + Directional(p - Center);
			}
		}

		private const float AxisAlignmentThreshold = 0.998f;

		public static void Build(PieceVariantDefinition def, ManualLogSource log)
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0181: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			GameObject prefab = PrefabManager.Instance.GetPrefab(def.SourcePrefabName);
			if ((Object)(object)prefab == (Object)null)
			{
				log.LogError((object)("Source prefab not found: " + def.SourcePrefabName));
				return;
			}
			Piece component = prefab.GetComponent<Piece>();
			List<Transform> list = new List<Transform>();
			component.GetSnapPoints(list);
			if (list.Count != 2)
			{
				log.LogError((object)(def.SourcePrefabName + ": expected exactly 2 snap points (beam or pole), found " + list.Count + ". Skipped."));
				return;
			}
			GameObject val = PrefabManager.Instance.CreateClonedPrefab(def.NewPrefabName, prefab);
			Resize(val, def, log);
			Sprite val2 = IconLoader.Load(def.NewPrefabName, log);
			if ((Object)(object)val2 != (Object)null)
			{
				val.GetComponent<Piece>().m_icon = val2;
			}
			PieceConfig val3 = new PieceConfig
			{
				Name = def.DisplayName,
				Description = def.Description,
				Icon = val2,
				PieceTable = "Hammer",
				Category = ((object)Unsafe.As<PieceCategory, PieceCategory>(ref component.m_category)/*cast due to .constrained prefix*/).ToString(),
				CraftingStation = (((Object)(object)component.m_craftingStation != (Object)null) ? ((Object)component.m_craftingStation).name : ""),
				Requirements = ((IEnumerable<Requirement>)component.m_resources).Select((Func<Requirement, RequirementConfig>)((Requirement r) => new RequirementConfig
				{
					Item = ((Object)r.m_resItem).name,
					Amount = Math.Max(1, (int)Math.Ceiling((float)r.m_amount * def.CostRatio)),
					Recover = r.m_recover
				})).ToArray()
			};
			PieceManager.Instance.AddPiece(new CustomPiece(val, false, val3));
			log.LogInfo((object)("Registered " + def.NewPrefabName + " (from " + def.SourcePrefabName + ")"));
		}

		private static void Resize(GameObject clone, PieceVariantDefinition def, ManualLogSource log)
		{
			//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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			float lengthScale = def.LengthScale;
			Transform transform = clone.transform;
			Piece component = clone.GetComponent<Piece>();
			List<Transform> list = new List<Transform>();
			component.GetSnapPoints(list);
			Vector3 localPosition = list[0].localPosition;
			Vector3 localPosition2 = list[1].localPosition;
			Vector3 center = (localPosition + localPosition2) * 0.5f;
			Vector3 val = localPosition2 - localPosition;
			BeamFrame frame = new BeamFrame(center, ((Vector3)(ref val)).normalized, lengthScale);
			val = localPosition2 - localPosition;
			float magnitude = ((Vector3)(ref val)).magnitude;
			foreach (Transform item in list)
			{
				item.localPosition = frame.MapPoint(item.localPosition);
			}
			Transform val2 = null;
			int num = 0;
			foreach (Transform item2 in ((IEnumerable)transform).Cast<Transform>().ToList())
			{
				if (list.Contains(item2))
				{
					continue;
				}
				if (((Object)item2).name.IndexOf("snow", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					HandleSnow(item2, def);
					continue;
				}
				bool flag = (Object)(object)((Component)item2).GetComponent<Collider>() != (Object)null;
				bool flag2 = (Object)(object)((Component)item2).GetComponent<MeshFilter>() != (Object)null;
				if (flag || flag2)
				{
					if (TryFindAlignedAxis(item2, frame.Axis, out var axisIndex))
					{
						item2.localPosition = frame.MapPoint(item2.localPosition);
						item2.localScale = ScaleAxis(item2.localScale, axisIndex, lengthScale);
						continue;
					}
					if (flag)
					{
						log.LogWarning((object)(def.NewPrefabName + ": collider '" + ((Object)item2).name + "' has no axis along the beam; left unchanged."));
						continue;
					}
				}
				if (!((Object)(object)((Component)item2).GetComponentInChildren<Renderer>(true) == (Object)null) || !((Object)(object)((Component)item2).GetComponentInChildren<Collider>(true) == (Object)null))
				{
					if ((Object)(object)val2 == (Object)null)
					{
						val2 = CreatePivot(transform, frame);
					}
					Wrap(item2, val2, frame);
					num++;
				}
			}
			LODGroup[] componentsInChildren = clone.GetComponentsInChildren<LODGroup>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].RecalculateBounds();
			}
			string[] obj = new string[9]
			{
				def.NewPrefabName,
				": snap distance ",
				magnitude.ToString("F3"),
				" -> ",
				null,
				null,
				null,
				null,
				null
			};
			val = list[0].localPosition - list[1].localPosition;
			obj[4] = ((Vector3)(ref val)).magnitude.ToString("F3");
			obj[5] = " (expected ";
			obj[6] = (magnitude * lengthScale).ToString("F3");
			obj[7] = ")";
			obj[8] = ((num > 0) ? (", " + num + " baked node(s) scaled via pivot") : "");
			log.LogInfo((object)string.Concat(obj));
		}

		private static bool TryFindAlignedAxis(Transform node, Vector3 beamAxis, out int axisIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Quaternion localRotation = node.localRotation;
			Vector3[] array = (Vector3[])(object)new Vector3[3]
			{
				localRotation * Vector3.right,
				localRotation * Vector3.up,
				localRotation * Vector3.forward
			};
			axisIndex = 0;
			float num = 0f;
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = Mathf.Abs(Vector3.Dot(array[i], beamAxis));
				if (num2 > num)
				{
					num = num2;
					axisIndex = i;
				}
			}
			return num >= 0.998f;
		}

		private static Vector3 ScaleAxis(Vector3 scale, int axis, float f)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			((Vector3)(ref scale))[axis] = ((Vector3)(ref scale))[axis] * f;
			return scale;
		}

		private static Transform CreatePivot(Transform root, BeamFrame frame)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("HalfBeams_pivot");
			val.transform.SetParent(root, false);
			val.transform.localRotation = Quaternion.FromToRotation(Vector3.forward, frame.Axis);
			val.transform.localPosition = frame.Scale * frame.Center;
			val.transform.localScale = new Vector3(1f, 1f, frame.Scale);
			return val.transform;
		}

		private static void Wrap(Transform node, Transform pivot, BeamFrame frame)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0038: 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)
			Quaternion val = Quaternion.Inverse(pivot.localRotation);
			Quaternion localRotation = node.localRotation;
			Vector3 localPosition = node.localPosition;
			node.SetParent(pivot, false);
			node.localRotation = val * localRotation;
			node.localPosition = val * (localPosition - frame.Center);
		}

		private static void HandleSnow(Transform node, PieceVariantDefinition def)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (def.Snow == SnowMode.ScaleLength)
			{
				Vector3 localPosition = node.localPosition;
				localPosition.x *= def.LengthScale;
				node.localPosition = localPosition;
				Vector3 localScale = node.localScale;
				localScale.x *= def.LengthScale;
				node.localScale = localScale;
			}
			else
			{
				Object.DestroyImmediate((Object)(object)((Component)node).gameObject);
			}
		}
	}
	internal static class PieceVariantRegistry
	{
		private const float Half = 0.5f;

		private const float Quarter = 0.25f;

		public static readonly IReadOnlyList<PieceVariantDefinition> All = new List<PieceVariantDefinition>
		{
			new PieceVariantDefinition("wood_pole", "half_wood_pole", "Wood Pole 0.5 m", "A half-length sturdy wooden support.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("wood_beam_1", "half_wood_beam", "Wood Beam 0.5 m", "A half-length sturdy wooden support.", 0.5f, SnowMode.ScaleLength),
			new PieceVariantDefinition("wood_beam_26", "half_wood_beam_26", "Wood Beam 26° (Half)", "A half-length sturdy wooden support.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("wood_beam_45", "half_wood_beam_45", "Wood Beam 45° (Half)", "A half-length sturdy wooden support.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("wood_beam_67", "half_wood_beam_67", "Wood Beam 67° (Half)", "A half-length sturdy wooden support.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("darkwood_pole", "quarter_darkwood_pole", "Darkwood Pole 0.5 m", "Intricate designs run along this half-length support structure.", 0.25f, SnowMode.Remove),
			new PieceVariantDefinition("darkwood_pole", "half_darkwood_pole", "Darkwood Pole 1 m", "Intricate designs run along this half-length support structure.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("darkwood_beam", "quarter_darkwood_beam", "Darkwood Beam 0.5 m", "Intricate designs run along this half-length support structure.", 0.25f, SnowMode.Remove),
			new PieceVariantDefinition("darkwood_beam", "half_darkwood_beam", "Darkwood Beam 1 m", "Intricate designs run along this half-length support structure.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("darkwood_beam_26", "half_darkwood_beam_26", "Darkwood Beam 26° (Half)", "Intricate designs run along this half-length support structure.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("darkwood_beam_45", "half_darkwood_beam_45", "Darkwood Beam 45° (Half)", "Intricate designs run along this half-length support structure.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("darkwood_beam_67", "half_darkwood_beam_67", "Darkwood Beam 67° (Half)", "Intricate designs run along this half-length support structure.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("ashwood_pole_1m", "half_ashwood_pole", "Ashwood Pole 0.5 m", "These half-length supports are always warm to the touch.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("ashwood_beam_1m", "half_ashwood_beam", "Ashwood Beam 0.5 m", "These half-length supports are always warm to the touch.", 0.5f, SnowMode.ScaleLength),
			new PieceVariantDefinition("ashwood_wall_beam_26", "half_ashwood_beam_26", "Ashwood Beam 26° (Half)", "These half-length supports are always warm to the touch.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("ashwood_wall_beam_45", "half_ashwood_beam_45", "Ashwood Beam 45° (Half)", "These half-length supports are always warm to the touch.", 0.5f, SnowMode.Remove),
			new PieceVariantDefinition("ashwood_wall_beam_67", "half_ashwood_beam_67", "Ashwood Beam 67° (Half)", "These half-length supports are always warm to the touch.", 0.5f, SnowMode.Remove)
		};
	}
	[BepInPlugin("javidahmed64592.halfbeam", "HalfBeam", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class HalfBeamPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "javidahmed64592.halfbeam";

		public const string PluginName = "HalfBeam";

		public const string PluginVersion = "0.1.0";

		private bool _knownRecipesRefreshed;

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

		private void Update()
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)ObjectDB.instance == (Object)null)
			{
				_knownRecipesRefreshed = false;
			}
			else if (!_knownRecipesRefreshed)
			{
				_knownRecipesRefreshed = true;
				Player.m_localPlayer.UpdateKnownRecipesList();
			}
		}

		private void RegisterPieces()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= RegisterPieces;
			foreach (PieceVariantDefinition item in PieceVariantRegistry.All)
			{
				try
				{
					PieceVariantFactory.Build(item, ((BaseUnityPlugin)this).Logger);
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("Failed to build " + item.NewPrefabName + ": " + ex));
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}