Decompiled source of Interiors v1.0.0

plugins/RavenwoodRelicsInteriors/RavenwoodRelicsInteriors.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 RavenwoodRelicsInteriors;

public class ClockInteract : MonoBehaviour, Hoverable, Interactable
{
	private Piece m_piece;

	private readonly List<GameObject> m_activeSounds = new List<GameObject>();

	private int m_lastHour = -1;

	private float m_nextHourCheck;

	private float m_hourTrackingReadyAt;

	private bool m_hourTrackingReady;

	public GameObject HourSoundPrefab;

	public bool PlaySoundEveryHour;

	private void Awake()
	{
		m_piece = ((Component)this).GetComponent<Piece>();
		m_lastHour = -1;
		m_hourTrackingReady = false;
		m_hourTrackingReadyAt = 0f;
	}

	private void Update()
	{
		if (PlaySoundEveryHour && !((Object)(object)HourSoundPrefab == (Object)null) && !((Object)(object)EnvMan.instance == (Object)null) && !(Time.time < m_nextHourCheck))
		{
			m_nextHourCheck = Time.time + 0.5f;
			int currentHour = GetCurrentHour();
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				m_lastHour = currentHour;
				m_hourTrackingReady = false;
				m_hourTrackingReadyAt = 0f;
			}
			else if (!m_hourTrackingReady)
			{
				m_lastHour = currentHour;
				m_hourTrackingReady = true;
				m_hourTrackingReadyAt = Time.time + 3f;
			}
			else if (Time.time < m_hourTrackingReadyAt)
			{
				m_lastHour = currentHour;
			}
			else if (m_lastHour < 0)
			{
				m_lastHour = currentHour;
			}
			else if (currentHour != m_lastHour)
			{
				m_lastHour = currentHour;
				PlayClockSound();
			}
		}
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		if (hold)
		{
			return false;
		}
		if ((Object)(object)EnvMan.instance == (Object)null)
		{
			((Character)user).Message((MessageType)2, "The clock cannot read the time right now.", 0, (Sprite)null);
			return true;
		}
		float num = Mathf.Repeat(EnvMan.instance.GetDayFraction(), 1f);
		float num2 = num * 24f;
		int num3 = Mathf.FloorToInt(num2);
		int num4 = Mathf.FloorToInt((num2 - (float)num3) * 60f);
		((Character)user).Message((MessageType)2, $"Current in-game time: {num3:00}:{num4:00}", 0, (Sprite)null);
		PlayClockSound();
		return true;
	}

	private int GetCurrentHour()
	{
		if ((Object)(object)EnvMan.instance == (Object)null)
		{
			return -1;
		}
		float num = Mathf.Repeat(EnvMan.instance.GetDayFraction(), 1f);
		return Mathf.FloorToInt(num * 24f);
	}

	private void PlayClockSound()
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)HourSoundPrefab == (Object)null)
		{
			return;
		}
		for (int num = m_activeSounds.Count - 1; num >= 0; num--)
		{
			if ((Object)(object)m_activeSounds[num] == (Object)null)
			{
				m_activeSounds.RemoveAt(num);
			}
		}
		GameObject val = Object.Instantiate<GameObject>(HourSoundPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation);
		if (!((Object)(object)val == (Object)null))
		{
			val.transform.SetParent(((Component)this).transform, true);
			if (!val.activeSelf)
			{
				val.SetActive(true);
			}
			AudioSource component = val.GetComponent<AudioSource>();
			if ((Object)(object)component != (Object)null)
			{
				component.Stop();
				component.playOnAwake = false;
				component.loop = false;
				component.Play();
				m_activeSounds.Add(val);
				Object.Destroy((Object)(object)val, ((Object)(object)component.clip != (Object)null) ? (component.clip.length + 0.1f) : 8f);
			}
			else
			{
				Debug.LogWarning((object)("[RavenwoodRelicsInteriors] Clock sound prefab has no AudioSource: " + ((Object)HourSoundPrefab).name));
				Object.Destroy((Object)(object)val, 8f);
			}
		}
	}

	private void OnDestroy()
	{
		for (int i = 0; i < m_activeSounds.Count; i++)
		{
			if ((Object)(object)m_activeSounds[i] != (Object)null)
			{
				AudioSource component = m_activeSounds[i].GetComponent<AudioSource>();
				if ((Object)(object)component != (Object)null)
				{
					component.Stop();
				}
				m_activeSounds[i].SetActive(false);
				Object.Destroy((Object)(object)m_activeSounds[i]);
			}
		}
		m_activeSounds.Clear();
	}

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

	public string GetHoverText()
	{
		string text = (((Object)(object)m_piece != (Object)null) ? m_piece.m_name : "Clock");
		return text + "\n[<color=yellow><b>E</b></color>] Check Time";
	}

	public string GetHoverName()
	{
		return ((Object)(object)m_piece != (Object)null) ? m_piece.m_name : "Clock";
	}
}
public class HornOfThor : MonoBehaviour, Hoverable, Interactable
{
	private Piece m_piece;

	private void Awake()
	{
		m_piece = ((Component)this).GetComponent<Piece>();
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		if (hold)
		{
			return false;
		}
		ZNetScene instance = ZNetScene.instance;
		GameObject val = ((instance != null) ? instance.GetPrefab("sfx_gjall_alerted") : null);
		if ((Object)(object)val != (Object)null)
		{
			Object.Instantiate<GameObject>(val, ((Component)this).transform.position + Vector3.up * 1f, Quaternion.identity);
		}
		return true;
	}

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

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

	public string GetHoverName()
	{
		return ((Object)(object)m_piece != (Object)null) ? m_piece.m_name : "Horn";
	}
}
[BepInPlugin("Ravenwood.RelicsInteriors", "Ravenwood Relics Interiors", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RavenwoodRelicsInteriors : BaseUnityPlugin
{
	public const string PluginGUID = "Ravenwood.RelicsInteriors";

	public const string PluginName = "Ravenwood Relics Interiors";

	public const string PluginVersion = "1.0.0";

	private AssetBundle interiorsBundle;

	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("ravenwoodinteriors"));
		if (string.IsNullOrEmpty(text))
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Could not find embedded asset bundle resource containing 'ravenwoodinteriors'.");
			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);
			interiorsBundle = AssetBundle.LoadFromMemory(memoryStream.ToArray());
		}
		if ((Object)(object)interiorsBundle == (Object)null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load Ravenwood Interiors AssetBundle from embedded resource.");
		}
		else
		{
			PrefabManager.OnPrefabsRegistered += RegisterNow;
		}
	}

	private void RegisterNow()
	{
		if (!((Object)(object)interiorsBundle == (Object)null))
		{
			RelicRegistrar.RegisterAllRelics(interiorsBundle);
			PrefabManager.OnPrefabsRegistered -= RegisterNow;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Ravenwood Relics Interiors 1.0.0 loaded. Interior 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 readonly Dictionary<string, ConfigEntry<string>> recipeConfigs = new Dictionary<string, ConfigEntry<string>>(StringComparer.OrdinalIgnoreCase);

	private static ConfigEntry<string> hammerTabConfig;

	private static ConfigEntry<bool> cuckooHourlySoundConfig;

	private static ConfigEntry<bool> swissHourlySoundConfig;

	public static readonly List<RelicRegistration> AllRegistrations = new List<RelicRegistration>
	{
		new RelicRegistration("RWI_AsianTeaSet", "Asian Tea Set", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 10, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_AsianTeaSetPlate", "Asian Tea Set Plate", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 5, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_ChairoftheWindweaver", "Chair of the Windweaver", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Bear", 5, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_Cuckoo_Clock", "Cuckoo Clock", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RWc_Deer", 40, 0, true),
			new RequirementConfig("RWc_Bear", 10, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_FlowerBouquet", "Flower Bouquet", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 25, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_Horn", "Horn", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Wolf", 1, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_PorcelainTeaSet", "Porcelain Tea Set", (RequirementConfig[])(object)new RequirementConfig[2]
		{
			new RequirementConfig("RWc_Bear", 5, 0, true),
			new RequirementConfig("RWc_Wolf", 1, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_RoseinaGlobe", "Rose in a Globe", (RequirementConfig[])(object)new RequirementConfig[4]
		{
			new RequirementConfig("RWc_Deer", 2, 0, true),
			new RequirementConfig("RWc_Bear", 2, 0, true),
			new RequirementConfig("RWc_Snake", 2, 0, true),
			new RequirementConfig("RWc_Wolf", 2, 0, true)
		}, "A Ravenwood interior relic.", 1),
		new RelicRegistration("RWI_SkullGoblet", "Skull Goblet", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Snake", 2, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_SwissBigBangClock", "Swiss Big Bang Clock", (RequirementConfig[])(object)new RequirementConfig[3]
		{
			new RequirementConfig("RWc_Deer", 10, 0, true),
			new RequirementConfig("RWc_Bear", 10, 0, true),
			new RequirementConfig("RWc_Lion", 1, 0, true)
		}, "A Ravenwood interior relic.", 1),
		new RelicRegistration("RWI_TheBlackPearl", "The Black Pearl", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Snake", 8, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_ToiletPaper", "Toilet Paper", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 2, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_WorldTreeRug", "World Tree Rug", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Bear", 10, 0, true)
		}, "A Ravenwood interior relic."),
		new RelicRegistration("RWI_WorldTreeRug_1", "Warn World Tree Rug", (RequirementConfig[])(object)new RequirementConfig[1]
		{
			new RequirementConfig("RWc_Deer", 10, 0, true)
		}, "A Ravenwood interior relic.")
	};

	public static void InitConfig(ConfigFile config)
	{
		if (config == null || recipeConfigs.Count > 0)
		{
			return;
		}
		hammerTabConfig = config.Bind<string>("General", "CustomHammerTab", "Ravenwood", "Hammer build-menu tab used for every Ravenwood Relics Interiors prefab. Restart Valheim after changing this setting.");
		foreach (RelicRegistration allRegistration in AllRegistrations)
		{
			string text = FormatRequirements(allRegistration.Requirements);
			ConfigEntry<string> val = config.Bind<string>("Recipes", allRegistration.PrefabName, text, "Build recipe for this prefab. Format: ItemPrefab:Amount. Separate multiple requirements with commas, for example: RWc_Deer:10,RWc_Bear:5. Restart Valheim after changing this setting.");
			if (string.Equals(val.Value?.Trim(), "Coins:1", StringComparison.OrdinalIgnoreCase))
			{
				val.Value = text;
			}
			recipeConfigs[allRegistration.PrefabName] = val;
		}
		cuckooHourlySoundConfig = config.Bind<bool>("Clock Sounds", "RWI_Cuckoo_Clock_HourlyChime", true, "Play the cuckoo clock sound automatically every in-game hour. Setting this to false does not disable the sound when pressing E to check the time.");
		swissHourlySoundConfig = config.Bind<bool>("Clock Sounds", "RWI_SwissBigBangClock_HourlyChime", true, "Play the Swiss Big Bang clock sound automatically every in-game hour. Setting this to false does not disable the sound when pressing E to check the time.");
	}

	public static void RegisterAllRelics(AssetBundle bundle)
	{
		if (wasAlreadyRegistered)
		{
			return;
		}
		if ((Object)(object)bundle == (Object)null)
		{
			Debug.LogError((object)"[RavenwoodRelicsInteriors] 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)$"[RavenwoodRelicsInteriors] Registered {num}/{AllRegistrations.Count} relics. Failed: {num2}.");
	}

	private static bool RegisterRelic(AssetBundle bundle, RelicRegistration reg)
	{
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Expected O, but got Unknown
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Expected O, but got Unknown
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Expected O, but got Unknown
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Expected O, but got Unknown
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Expected O, but got Unknown
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Expected O, but got Unknown
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Expected O, but got Unknown
		//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d0: Expected O, but got Unknown
		if ((Object)(object)bundle == (Object)null)
		{
			return false;
		}
		if (reg == null || string.IsNullOrWhiteSpace(reg.PrefabName))
		{
			Debug.LogWarning((object)"[RavenwoodRelicsInteriors] 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)("[RavenwoodRelicsInteriors] 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;
		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 = GetConfiguredHammerTab(),
			CraftingStation = "piece_workbench",
			Requirements = GetConfiguredRequirements(reg)
		};
		if (reg.PrefabName == "RWI_Horn" && (Object)(object)val.GetComponent<HornOfThor>() == (Object)null)
		{
			val.AddComponent<HornOfThor>();
		}
		if ((reg.PrefabName == "RWI_Cuckoo_Clock" || reg.PrefabName == "RWI_SwissBigBangClock") && (Object)(object)val.GetComponent<ClockInteract>() == (Object)null)
		{
			val.AddComponent<ClockInteract>();
		}
		if (reg.PrefabName == "RWI_Cuckoo_Clock")
		{
			ClockInteract component = val.GetComponent<ClockInteract>();
			if ((Object)(object)component != (Object)null)
			{
				component.HourSoundPrefab = bundle.LoadAsset<GameObject>("sfx_RWI_Cuckoo_Clock");
				component.PlaySoundEveryHour = GetHourlyClockSoundEnabled(reg.PrefabName);
				AudioSource val13 = (((Object)(object)component.HourSoundPrefab != (Object)null) ? component.HourSoundPrefab.GetComponent<AudioSource>() : null);
				if ((Object)(object)val13 != (Object)null)
				{
					val13.playOnAwake = false;
					val13.loop = false;
				}
				if ((Object)(object)component.HourSoundPrefab == (Object)null)
				{
					Debug.LogWarning((object)"[RavenwoodRelicsInteriors] Missing sound prefab in AssetBundle: sfx_RWI_Cuckoo_Clock");
				}
			}
		}
		if (reg.PrefabName == "RWI_SwissBigBangClock")
		{
			ClockInteract component2 = val.GetComponent<ClockInteract>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.HourSoundPrefab = bundle.LoadAsset<GameObject>("sfx_RWI_SwissBigBangClock");
				component2.PlaySoundEveryHour = GetHourlyClockSoundEnabled(reg.PrefabName);
				AudioSource val14 = (((Object)(object)component2.HourSoundPrefab != (Object)null) ? component2.HourSoundPrefab.GetComponent<AudioSource>() : null);
				if ((Object)(object)val14 != (Object)null)
				{
					val14.playOnAwake = false;
					val14.loop = false;
				}
				if ((Object)(object)component2.HourSoundPrefab == (Object)null)
				{
					Debug.LogWarning((object)"[RavenwoodRelicsInteriors] Missing sound prefab in AssetBundle: sfx_RWI_SwissBigBangClock");
				}
			}
		}
		PieceManager.Instance.AddPiece(new CustomPiece(val, true, val12));
		return true;
	}

	private static string FormatRequirements(RequirementConfig[] requirements)
	{
		if (requirements == null || requirements.Length == 0)
		{
			return string.Empty;
		}
		List<string> list = new List<string>();
		foreach (RequirementConfig val in requirements)
		{
			if (val != null && !string.IsNullOrWhiteSpace(val.Item))
			{
				list.Add($"{val.Item}:{val.Amount}");
			}
		}
		return string.Join(",", list);
	}

	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)("[RavenwoodRelicsInteriors] 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)("[RavenwoodRelicsInteriors] 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)("[RavenwoodRelicsInteriors] 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)("[RavenwoodRelicsInteriors] No valid configured requirements for " + reg.PrefabName + ". Using the default recipe."));
			return reg.Requirements;
		}
		return list.ToArray();
	}

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

	private static string GetConfiguredHammerTab()
	{
		string text = ((hammerTabConfig != null) ? hammerTabConfig.Value : null);
		return string.IsNullOrWhiteSpace(text) ? "Ravenwood" : text.Trim();
	}

	private static bool GetHourlyClockSoundEnabled(string prefabName)
	{
		if (string.Equals(prefabName, "RWI_Cuckoo_Clock", StringComparison.OrdinalIgnoreCase))
		{
			return cuckooHourlySoundConfig == null || cuckooHourlySoundConfig.Value;
		}
		if (string.Equals(prefabName, "RWI_SwissBigBangClock", StringComparison.OrdinalIgnoreCase))
		{
			return swissHourlySoundConfig == null || swissHourlySoundConfig.Value;
		}
		return false;
	}
}