Decompiled source of Exteriors v1.0.0

plugins/RavenwoodRelicsExteriors/RavenwoodRelicsExteriors.dll

Decompiled a day ago
using System;
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 BepInEx;
using BepInEx.Configuration;
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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace RavenwoodRelicsExteriors;

public class JapaneseStoneLampColorCycler : MonoBehaviour, Hoverable, Interactable
{
	private readonly List<Light> lights = new List<Light>();

	private readonly List<Material> materials = new List<Material>();

	private readonly List<Color> colors = new List<Color>
	{
		new Color(0.78f, 0.68f, 0.88f),
		new Color(0.737f, 0.043f, 0.043f),
		new Color(0.55f, 0.9f, 1f),
		new Color(0.3f, 1f, 0.55f),
		new Color(1f, 1f, 1f),
		new Color(1f, 0.165f, 0f),
		new Color(0.18f, 0.85f, 0.3f),
		new Color(1f, 0.62f, 0.1f),
		new Color(0.2f, 0.9f, 0.55f),
		new Color(1f, 0.6f, 0.1f),
		new Color(1f, 0.45f, 0.65f),
		new Color(0.75f, 0.9f, 0.7f),
		new Color(0.74f, 0.68f, 0.88f),
		new Color(0.9f, 0.3f, 0.78f),
		new Color(0.65f, 0.85f, 1f),
		new Color(0.333f, 0.839f, 0.745f)
	};

	private int currentIndex = -1;

	private Piece m_piece;

	private void Awake()
	{
		m_piece = ((Component)this).GetComponentInParent<Piece>();
		GameObject val = (((Object)(object)m_piece != (Object)null) ? ((Component)m_piece).gameObject : ((Component)((Component)this).transform.root).gameObject);
		Light[] componentsInChildren = val.GetComponentsInChildren<Light>(true);
		foreach (Light val2 in componentsInChildren)
		{
			if ((Object)(object)val2 != (Object)null)
			{
				lights.Add(val2);
			}
		}
		Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val3 in componentsInChildren2)
		{
			if ((Object)(object)val3 == (Object)null)
			{
				continue;
			}
			Material[] sharedMaterials = val3.sharedMaterials;
			Material[] array = val3.materials;
			for (int k = 0; k < sharedMaterials.Length && k < array.Length; k++)
			{
				Material val4 = sharedMaterials[k];
				if (!((Object)(object)val4 == (Object)null) && ((Object)val4).name.IndexOf("Bolb", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					Material val5 = array[k];
					if ((Object)(object)val5 != (Object)null)
					{
						materials.Add(val5);
					}
				}
			}
		}
	}

	public string GetHoverText()
	{
		string text = (((Object)(object)m_piece != (Object)null) ? m_piece.m_name : "Japanese Stone Lantern");
		return text + "\n[<color=yellow><b>E</b></color>] Change Light Color";
	}

	public string GetHoverName()
	{
		return ((Object)(object)m_piece != (Object)null) ? m_piece.m_name : "Japanese Stone Lantern";
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		if (hold)
		{
			return false;
		}
		currentIndex++;
		if (currentIndex < colors.Count)
		{
			ApplyColor(colors[currentIndex]);
		}
		else
		{
			TurnOff();
			currentIndex = -1;
		}
		return true;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		return false;
	}

	private void ApplyColor(Color color)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		foreach (Light light in lights)
		{
			if (!((Object)(object)light == (Object)null))
			{
				light.color = color;
				light.intensity = 2.5f;
				((Behaviour)light).enabled = true;
			}
		}
		foreach (Material material in materials)
		{
			if (!((Object)(object)material == (Object)null))
			{
				material.EnableKeyword("_EMISSION");
				material.SetColor("_EmissionColor", color * 3f);
			}
		}
	}

	private void TurnOff()
	{
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		foreach (Light light in lights)
		{
			if (!((Object)(object)light == (Object)null))
			{
				light.intensity = 0f;
				((Behaviour)light).enabled = false;
			}
		}
		foreach (Material material in materials)
		{
			if (!((Object)(object)material == (Object)null))
			{
				material.EnableKeyword("_EMISSION");
				material.SetColor("_EmissionColor", Color.black);
			}
		}
	}

	public static void AttachTo(GameObject prefab)
	{
		if ((Object)(object)prefab == (Object)null || (((Object)prefab).name != "RWE_Japanese_Stone_Lantern_Small" && ((Object)prefab).name != "RWE_Japanese_Stone_Lantern_Large"))
		{
			return;
		}
		Transform val = null;
		Transform[] componentsInChildren = prefab.GetComponentsInChildren<Transform>(true);
		foreach (Transform val2 in componentsInChildren)
		{
			Renderer component = ((Component)val2).GetComponent<Renderer>();
			Collider component2 = ((Component)val2).GetComponent<Collider>();
			if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
			{
				continue;
			}
			Material[] sharedMaterials = component.sharedMaterials;
			foreach (Material val3 in sharedMaterials)
			{
				if ((Object)(object)val3 != (Object)null && ((Object)val3).name.IndexOf("Bolb", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					val = val2;
					break;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				break;
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			Transform[] componentsInChildren2 = prefab.GetComponentsInChildren<Transform>(true);
			foreach (Transform val4 in componentsInChildren2)
			{
				if (((Object)val4).name == "Sphere" && (Object)(object)((Component)val4).GetComponent<Collider>() != (Object)null)
				{
					val = val4;
					break;
				}
			}
		}
		if (!((Object)(object)val == (Object)null) && (Object)(object)((Component)val).GetComponent<JapaneseStoneLampColorCycler>() == (Object)null)
		{
			((Component)val).gameObject.AddComponent<JapaneseStoneLampColorCycler>();
		}
	}
}
[BepInPlugin("Ravenwood.RelicsExteriors", "Ravenwood Relics Exteriors", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RavenwoodRelicsExteriors : BaseUnityPlugin
{
	public const string PluginGUID = "Ravenwood.RelicsExteriors";

	public const string PluginName = "Ravenwood Relics Exteriors";

	public const string PluginVersion = "1.0.0";

	private AssetBundle exteriorsBundle;

	private void Awake()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		RelicRegistrar.InitConfig(((BaseUnityPlugin)this).Config);
		foreach (string allCategory in RelicRegistrar.GetAllCategories())
		{
			PieceManager.Instance.AddPieceCategory(allCategory);
		}
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string r) => r.ToLowerInvariant().Contains("ravenwoodexteriors"));
		if (string.IsNullOrEmpty(text))
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not find embedded asset bundle resource containing 'ravenwoodexteriors'.");
			return;
		}
		using (Stream stream = executingAssembly.GetManifestResourceStream(text))
		{
			if (stream == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Embedded asset bundle stream was null for '" + text + "'."));
				return;
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			exteriorsBundle = AssetBundle.LoadFromMemory(memoryStream.ToArray());
		}
		if ((Object)(object)exteriorsBundle == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load Ravenwood Exteriors AssetBundle from embedded resource.");
		}
		else
		{
			PrefabManager.OnPrefabsRegistered += RegisterNow;
		}
	}

	private void RegisterNow()
	{
		if (!((Object)(object)exteriorsBundle == (Object)null))
		{
			RelicRegistrar.RegisterAllRelics(exteriorsBundle);
			PrefabManager.OnPrefabsRegistered -= RegisterNow;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Ravenwood Relics Exteriors 1.0.0 loaded. Exterior prefabs registered.");
		}
	}
}
public class RelicRegistration
{
	public string PrefabName;

	public string DisplayName;

	public RequirementConfig[] Requirements;

	public string Description;

	public int Comfort;

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

	private static ConfigEntry<string> customHammerTabConfig;

	private static readonly Dictionary<string, ConfigEntry<string>> recipeConfigs = new Dictionary<string, ConfigEntry<string>>(StringComparer.OrdinalIgnoreCase);

	public static readonly List<RelicRegistration> AllRegistrations = new List<RelicRegistration>
	{
		new RelicRegistration("RWE_Japanese_Hanging_Lamp", "Japanese Hanging Lamp", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Bear", 5, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_Japanese_Stone_Lantern_Small", "Japanese Stone Lantern Small", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Snake", 3, 0, true)
		}, "A Ravenwood exterior relic.", 1),
		new RelicRegistration("RWE_Japanese_Stone_Lantern_Large", "Japanese Stone Lantern Large", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Snake", 5, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_Japanese_Tori_Gate_Large", "Japanese Torii Gate Large", (RequirementConfig[])(object)new RequirementConfig[4]
		{
			new RequirementConfig("RWc_Deer", 100, 0, true),
			new RequirementConfig("RWc_Bear", 5, 0, true),
			new RequirementConfig("RWc_Snake", 5, 0, true),
			new RequirementConfig("RWc_Wolf", 1, 0, true)
		}, "A Ravenwood exterior relic.", 1),
		new RelicRegistration("RWE_Japanese_Tori_Gate_Tall", "Japanese Torii Gate Tall", (RequirementConfig[])(object)new RequirementConfig[4]
		{
			new RequirementConfig("RWc_Deer", 100, 0, true),
			new RequirementConfig("RWc_Bear", 5, 0, true),
			new RequirementConfig("RWc_Snake", 5, 0, true),
			new RequirementConfig("RWc_Wolf", 1, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_PedestalPlanter", "Pedestal Planter", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 12, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress0", "Italian Cypress 0", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 100, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress1", "Italian Cypress 1", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 100, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress2", "Italian Cypress 2", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 50, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress3", "Italian Cypress 3", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 25, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress4", "Italian Cypress 4", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 25, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress5", "Italian Cypress 5", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 25, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress6", "Italian Cypress 6", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 100, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress7", "Italian Cypress 7", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 100, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress5", "Italian Cypress 5", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 25, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_ItalianCypress6", "Italian Cypress 6", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 100, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_SM_ItalianCypress_Growing_A", "Italian Cypress Growing A", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 10, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_SM_ItalianCypress_Growing_C", "Italian Cypress Growing C", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 15, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_SM_ItalianCypress_Growing_E", "Italian Cypress Growing E", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 10, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_SM_ItalianCypress_Large_A", "Italian Cypress Large A", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 40, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_SM_ItalianCypress_Large_B", "Italian Cypress Large B", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 30, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_SM_ItalianCypress_Large_B1", "Italian Cypress Large B1", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 80, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_SM_ItalianCypress_Massive", "Italian Cypress Massive", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 70, 0, true)
		}, "A Ravenwood exterior relic."),
		new RelicRegistration("RWE_SM_ItalianCypress_Medium_B", "Italian Cypress Medium B", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 20, 0, true)
		}, "A Ravenwood exterior relic.")
	};

	public static void InitConfig(ConfigFile config)
	{
		if (config == null)
		{
			return;
		}
		if (customHammerTabConfig == null)
		{
			customHammerTabConfig = config.Bind<string>("General", "CustomHammerTab", "Ravenwood", "Hammer tab/category used by Ravenwood Relics Exteriors pieces. Restart Valheim after changing this setting.");
		}
		if (recipeConfigs.Count > 0)
		{
			return;
		}
		foreach (RelicRegistration allRegistration in AllRegistrations)
		{
			recipeConfigs[allRegistration.PrefabName] = config.Bind<string>("Recipes", allRegistration.PrefabName, string.Join(",", Array.ConvertAll(allRegistration.Requirements, (RequirementConfig requirement) => $"{requirement.Item}:{requirement.Amount}")), "Build recipe for this prefab. Format: ItemPrefab:Amount. Separate multiple requirements with commas, for example: Coins:1,Wood:5. Restart Valheim after changing this setting.");
		}
	}

	public static void RegisterAllRelics(AssetBundle bundle)
	{
		if (wasAlreadyRegistered)
		{
			return;
		}
		if ((Object)(object)bundle == (Object)null)
		{
			Debug.LogError((object)"[RavenwoodRelicsExteriors] AssetBundle is null. Registration stopped.");
			return;
		}
		int num = 0;
		int num2 = 0;
		foreach (RelicRegistration allRegistration in AllRegistrations)
		{
			if (RegisterRelic(bundle, allRegistration))
			{
				num++;
			}
			else
			{
				num2++;
			}
		}
		wasAlreadyRegistered = true;
		Debug.Log((object)$"[RavenwoodRelicsExteriors] Registered {num}/{AllRegistrations.Count} relics. Failed: {num2}.");
	}

	private static bool RegisterRelic(AssetBundle bundle, RelicRegistration reg)
	{
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Expected O, but got Unknown
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Expected O, but got Unknown
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Expected O, but got Unknown
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Expected O, but got Unknown
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Expected O, but got Unknown
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Expected O, but got Unknown
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Expected O, but got Unknown
		//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Expected O, but got Unknown
		if ((Object)(object)bundle == (Object)null)
		{
			return false;
		}
		if (reg == null || string.IsNullOrWhiteSpace(reg.PrefabName))
		{
			Debug.LogWarning((object)"[RavenwoodRelicsExteriors] Skipped a null or empty relic registration.");
			return false;
		}
		GameObject val = bundle.LoadAsset<GameObject>(reg.PrefabName);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)("[RavenwoodRelicsExteriors] Missing prefab in AssetBundle: " + reg.PrefabName));
			return false;
		}
		((Object)val).name = reg.PrefabName;
		ZNetView val2 = val.GetComponent<ZNetView>();
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = val.AddComponent<ZNetView>();
		}
		val2.m_persistent = true;
		val2.m_syncInitialScale = true;
		if (!Object.op_Implicit((Object)(object)val.GetComponent<ZSyncTransform>()))
		{
			val.AddComponent<ZSyncTransform>();
		}
		Piece val3 = val.GetComponent<Piece>() ?? val.AddComponent<Piece>();
		val3.m_name = reg.DisplayName;
		val3.m_description = reg.Description;
		val3.m_comfort = reg.Comfort;
		val3.m_groundOnly = false;
		JapaneseStoneLampColorCycler.AttachTo(val);
		ZNetScene instance = ZNetScene.instance;
		GameObject val4 = ((instance != null) ? instance.GetPrefab("vfx_Place_wood") : null);
		ZNetScene instance2 = ZNetScene.instance;
		GameObject val5 = ((instance2 != null) ? instance2.GetPrefab("sfx_build_hammer_wood") : null);
		ZNetScene instance3 = ZNetScene.instance;
		GameObject val6 = ((instance3 != null) ? instance3.GetPrefab("vfx_destroyed") : null);
		ZNetScene instance4 = ZNetScene.instance;
		GameObject val7 = ((instance4 != null) ? instance4.GetPrefab("sfx_wood_break") : null);
		EffectList val8 = new EffectList();
		List<EffectData> list = new List<EffectData>();
		if ((Object)(object)val4 != (Object)null)
		{
			list.Add(new EffectData
			{
				m_prefab = val4,
				m_enabled = true
			});
		}
		if ((Object)(object)val5 != (Object)null)
		{
			list.Add(new EffectData
			{
				m_prefab = val5,
				m_enabled = true
			});
		}
		val8.m_effectPrefabs = list.ToArray();
		val3.m_placeEffect = val8;
		WearNTear val9 = val.GetComponent<WearNTear>() ?? val.AddComponent<WearNTear>();
		val9.m_health = 1000000f;
		val9.m_noRoofWear = true;
		EffectList val10 = new EffectList();
		List<EffectData> list2 = new List<EffectData>();
		if ((Object)(object)val6 != (Object)null)
		{
			list2.Add(new EffectData
			{
				m_prefab = val6,
				m_enabled = true
			});
		}
		if ((Object)(object)val7 != (Object)null)
		{
			list2.Add(new EffectData
			{
				m_prefab = val7,
				m_enabled = true
			});
		}
		val10.m_effectPrefabs = list2.ToArray();
		val9.m_destroyedEffect = val10;
		Sprite val11 = bundle.LoadAsset<Sprite>(reg.PrefabName);
		if ((Object)(object)val11 != (Object)null)
		{
			val3.m_icon = val11;
		}
		PieceConfig val12 = new PieceConfig
		{
			PieceTable = "Hammer",
			Category = GetConfiguredCategory(),
			CraftingStation = "piece_workbench",
			Requirements = GetConfiguredRequirements(reg)
		};
		PieceManager.Instance.AddPiece(new CustomPiece(val, true, val12));
		return true;
	}

	private static RequirementConfig[] GetConfiguredRequirements(RelicRegistration reg)
	{
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Expected O, but got Unknown
		if (reg == null || string.IsNullOrWhiteSpace(reg.PrefabName))
		{
			return reg?.Requirements;
		}
		if (!recipeConfigs.TryGetValue(reg.PrefabName, out var value) || value == null)
		{
			return reg.Requirements;
		}
		string value2 = value.Value;
		if (string.IsNullOrWhiteSpace(value2))
		{
			Debug.LogWarning((object)("[RavenwoodRelicsExteriors] Empty recipe config for " + reg.PrefabName + ". Using the default recipe."));
			return reg.Requirements;
		}
		List<RequirementConfig> list = new List<RequirementConfig>();
		string[] array = value2.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
		string[] array2 = array;
		foreach (string text in array2)
		{
			string text2 = text.Trim();
			int num = text2.IndexOf(':');
			if (num <= 0 || num >= text2.Length - 1)
			{
				Debug.LogWarning((object)("[RavenwoodRelicsExteriors] Invalid recipe entry '" + text2 + "' for " + reg.PrefabName + ". Expected ItemPrefab:Amount."));
				continue;
			}
			string text3 = text2.Substring(0, num).Trim();
			string s = text2.Substring(num + 1).Trim();
			if (string.IsNullOrWhiteSpace(text3) || !int.TryParse(s, out var result) || result <= 0)
			{
				Debug.LogWarning((object)("[RavenwoodRelicsExteriors] Invalid recipe entry '" + text2 + "' for " + reg.PrefabName + ". Expected ItemPrefab:Amount with an amount greater than zero."));
			}
			else
			{
				list.Add(new RequirementConfig(text3, result, 0, true));
			}
		}
		if (list.Count == 0)
		{
			Debug.LogWarning((object)("[RavenwoodRelicsExteriors] No valid configured requirements for " + reg.PrefabName + ". Using the default recipe."));
			return reg.Requirements;
		}
		return list.ToArray();
	}

	private static string GetConfiguredCategory()
	{
		string text = customHammerTabConfig?.Value;
		return string.IsNullOrWhiteSpace(text) ? "Ravenwood" : text.Trim();
	}

	public static IEnumerable<string> GetAllCategories()
	{
		return new string[1] { GetConfiguredCategory() };
	}
}