Decompiled source of BrickWalls v0.3.3

plugins\BrickWalls.dll

Decompiled 2 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BrickWalls")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BrickWalls")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace BrickWalls
{
	[BepInPlugin("org.bepinex.plugins.bid.brickwalls", "BrickWalls", "0.3.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class BrickWalls : BaseUnityPlugin
	{
		public const string PluginGUID = "org.bepinex.plugins.bid.brickwalls";

		public const string PluginName = "BrickWalls";

		public const string PluginVersion = "0.3.3";

		public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

		public static ConfigEntry<float> ClayMinAltitudeConfig;

		public static ConfigEntry<float> ClayMaxAltitudeConfig;

		public static ConfigEntry<float> ClayMinConfig;

		public static ConfigEntry<float> ClayMaxConfig;

		private Dictionary<string, Material> Materials = new Dictionary<string, Material>();

		private readonly Harmony harmony = new Harmony("org.bepinex.plugins.bid.brickwalls");

		private static string CategoryName;

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogInfo((object)"BrickWalls has landed");
			CategoryName = "bricks";
			PrefabManager.OnVanillaPrefabsAvailable += AddClonedItems;
			CreateConfigValues();
			new Harmony("org.bepinex.plugins.bid.brickwalls").PatchAll();
		}

		private void CreateConfigValues()
		{
			//IL_002f: 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_003c: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			ClayMinAltitudeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "ClayMinAltitude", -0.5f, new ConfigDescription("Min altitude clay will spawn", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			ClayMaxAltitudeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "ClayMaxAltitude", 1f, new ConfigDescription("Max altitude clay will spawn", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			ClayMinConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "ClayMin", 1f, new ConfigDescription("Min amount per zone", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			ClayMaxConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "ClayMax", 10f, new ConfigDescription("values 0-1: chance to place clay; value 1+: max amount per zone", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr)
			{
				_ = attr.InitialSynchronization;
			};
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}

		private void ChangeMaterial(GameObject obj, Material matNew, Material matWorn, Material matBroken)
		{
			WearNTear component = obj.GetComponent<WearNTear>();
			Transform val = obj.transform.Find("new");
			component.m_new = ((Component)val).gameObject;
			MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshRenderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Renderer)componentsInChildren[i]).material = matNew;
			}
			val = obj.transform.Find("worn");
			component.m_worn = ((Component)val).gameObject;
			componentsInChildren = ((Component)val).GetComponentsInChildren<MeshRenderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Renderer)componentsInChildren[i]).material = matWorn;
			}
			val = obj.transform.Find("broken");
			component.m_broken = ((Component)val).gameObject;
			componentsInChildren = ((Component)val).GetComponentsInChildren<MeshRenderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Renderer)componentsInChildren[i]).material = matBroken;
			}
		}

		private void LoadMaterial(AssetBundle brickWallsAssetBundle, string name, int scale = 1)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Material val = brickWallsAssetBundle.LoadAsset<Material>(name);
			if (scale != 1)
			{
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor((float)scale, (float)scale);
				Material val3 = new Material(val);
				val3.SetTextureScale("_MainTex", val2);
				Materials.Add(name + scale, val3);
			}
			else
			{
				Materials.Add(name, val);
			}
		}

		private Material GetMaterial(string name)
		{
			return Materials[name];
		}

		private void LoadMaterials(AssetBundle brickWallsAssetBundle)
		{
			LoadMaterial(brickWallsAssetBundle, "mat_clay_ore");
			LoadMaterial(brickWallsAssetBundle, "mat_claywhite_ore");
			LoadMaterial(brickWallsAssetBundle, "Color_clay_new");
			LoadMaterial(brickWallsAssetBundle, "Color_clay_worn");
			LoadMaterial(brickWallsAssetBundle, "Color_clay_broken");
			LoadMaterial(brickWallsAssetBundle, "Color_claywhite_new");
			LoadMaterial(brickWallsAssetBundle, "Color_claywhite_worn");
			LoadMaterial(brickWallsAssetBundle, "Color_claywhite_broken");
			LoadMaterial(brickWallsAssetBundle, "Color_clay_new", 3);
			LoadMaterial(brickWallsAssetBundle, "Color_clay_worn", 3);
			LoadMaterial(brickWallsAssetBundle, "Color_clay_broken", 3);
			LoadMaterial(brickWallsAssetBundle, "Color_claywhite_new", 3);
			LoadMaterial(brickWallsAssetBundle, "Color_claywhite_worn", 3);
			LoadMaterial(brickWallsAssetBundle, "Color_claywhite_broken", 3);
			LoadMaterial(brickWallsAssetBundle, "roof_clay_new");
			LoadMaterial(brickWallsAssetBundle, "roof_claywhite_new");
			LoadMaterial(brickWallsAssetBundle, "roof_clay_worn");
			LoadMaterial(brickWallsAssetBundle, "roof_claywhite_worn");
			LoadMaterial(brickWallsAssetBundle, "roof_clay_broken");
			LoadMaterial(brickWallsAssetBundle, "roof_claywhite_broken");
		}

		private GameObject AddOre(string name)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			string name2 = "item_" + name;
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("ClayOre" + name, "CopperOre");
			((Object)val).name = name2;
			ItemData itemData = val.GetComponent<ItemDrop>().m_itemData;
			itemData.m_shared.m_name = "$item_" + name + "ore";
			itemData.m_shared.m_description = "$item_" + name + "ore_description";
			itemData.m_shared.m_weight = 2f;
			itemData.m_shared.m_maxStackSize = 50;
			itemData.m_shared.m_teleportable = true;
			((Component)val.transform.GetChild(0)).GetComponentInChildren<Renderer>().sharedMaterial = GetMaterial("mat_" + name + "_ore");
			CustomItem val2 = new CustomItem(val, true);
			ItemManager.Instance.AddItem(val2);
			val.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0] = RenderManager.Instance.Render(val, RenderManager.IsometricRotation);
			return val;
		}

		private void AddMine(AssetBundle brickWallsAssetBundle, string name, GameObject drop, Biome biome)
		{
			//IL_0072: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_01e8: 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_025e: Expected O, but got Unknown
			Texture val = brickWallsAssetBundle.LoadAsset<Texture>(name + "small");
			Material val2 = null;
			GameObject val3 = PrefabManager.Instance.CreateClonedPrefab("vfx_" + name + "_Destroyed_large", "vfx_RockDestroyed_large");
			GameObject val4 = PrefabManager.Instance.CreateClonedPrefab("rock_" + name, "rock4_coast");
			GameObject val5 = PrefabManager.Instance.CreateClonedPrefab("rock_" + name + "_frac", "rock4_coast_frac");
			DropData value = default(DropData);
			value.m_item = drop;
			val5.GetComponent<MineRock5>().m_dropItems.m_drops[0] = value;
			Renderer[] componentsInChildren = val4.GetComponentsInChildren<Renderer>();
			foreach (Renderer val6 in componentsInChildren)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = new Material(val6.sharedMaterial);
					val2.SetTexture("_MainTex", val);
					((Object)val2).name = "material_" + name;
				}
				val6.sharedMaterial = val2;
			}
			componentsInChildren = val5.GetComponentsInChildren<Renderer>();
			foreach (Renderer val7 in componentsInChildren)
			{
				Material[] sharedMaterials = val7.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					sharedMaterials[j] = val2;
				}
				val7.sharedMaterials = sharedMaterials;
			}
			componentsInChildren = ((Component)val3.transform.GetChild(0)).GetComponentsInChildren<Renderer>();
			foreach (Renderer val8 in componentsInChildren)
			{
				Material[] sharedMaterials2 = val8.sharedMaterials;
				for (int k = 0; k < sharedMaterials2.Length; k++)
				{
					sharedMaterials2[k] = val2;
				}
				val8.sharedMaterials = sharedMaterials2;
			}
			MineRock5 component = val5.GetComponent<MineRock5>();
			EffectData val9 = new EffectData();
			val9.m_prefab = val3;
			component.m_destroyedEffect.m_effectPrefabs[1] = val9;
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val5, false));
			val4.GetComponent<Destructible>().m_spawnWhenDestroyed = val5;
			VegetationConfig val10 = new VegetationConfig();
			val10.Biome = biome;
			val10.BlockCheck = true;
			val10.ScaleMax = 0.15f;
			val10.MinAltitude = ClayMinAltitudeConfig.Value;
			val10.MaxAltitude = ClayMaxAltitudeConfig.Value;
			val10.Min = ClayMinConfig.Value;
			val10.Max = ClayMaxConfig.Value;
			val10.GroundOffset = -0.5f;
			CustomVegetation val11 = new CustomVegetation(val4, false, val10);
			ZoneManager.Instance.AddCustomVegetation(val11);
		}

		private void AddRoofClone(string materialname, string roofname)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Expected O, but got Unknown
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Expected O, but got Unknown
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab(materialname + "_" + roofname, "darkwood_" + roofname);
			val.GetComponent<Piece>().m_name = "$piece_" + materialname + "_" + roofname;
			MeshRenderer[] componentsInChildren = ((Component)val.transform.Find("New")).GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val2 in componentsInChildren)
			{
				string text = "roof_mat_" + materialname + "_new";
				Material val3 = null;
				if (!Materials.ContainsKey(text))
				{
					val3 = new Material(((Renderer)val2).sharedMaterial);
					val3.SetTexture("_MainTex", GetMaterial("roof_" + materialname + "_new").mainTexture);
					Materials.Add(text, val3);
				}
				val3 = GetMaterial(text);
				((Renderer)val2).sharedMaterial = val3;
			}
			componentsInChildren = ((Component)val.transform.Find("Worn")).GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val4 in componentsInChildren)
			{
				string text2 = "roof_mat_" + materialname + "_worn";
				Material val5 = null;
				if (!Materials.ContainsKey(text2))
				{
					val5 = new Material(((Renderer)val4).sharedMaterial);
					val5.SetTexture("_MainTex", GetMaterial("roof_" + materialname + "_worn").mainTexture);
					Materials.Add(text2, val5);
				}
				val5 = GetMaterial(text2);
				((Renderer)val4).sharedMaterial = val5;
			}
			componentsInChildren = ((Component)val.transform.Find("Broken")).GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val6 in componentsInChildren)
			{
				string text3 = "roof_mat_" + materialname + "_broken";
				Material val7 = null;
				if (!Materials.ContainsKey(text3))
				{
					val7 = new Material(((Renderer)val6).sharedMaterial);
					val7.SetTexture("_MainTex", GetMaterial("roof_" + materialname + "_broken").mainTexture);
					Materials.Add(text3, val7);
				}
				val7 = GetMaterial(text3);
				((Renderer)val6).sharedMaterial = val7;
			}
			PieceManager instance = PieceManager.Instance;
			PieceConfig val8 = new PieceConfig();
			val8.PieceTable = "Hammer";
			val8.Requirements = (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig
				{
					Item = "item_" + materialname + "_brick",
					Recover = true,
					Amount = 2
				},
				new RequirementConfig
				{
					Item = "Wood",
					Recover = true,
					Amount = 2
				}
			};
			val8.Icon = RenderManager.Instance.Render(val, RenderManager.IsometricRotation);
			val8.CraftingStation = "piece_stonecutter";
			val8.Category = CategoryName;
			instance.AddPiece(new CustomPiece(val, true, val8));
		}

		private void addArch(string material)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Expected O, but got Unknown
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(3f, 3f);
			GameObject val2 = PrefabManager.Instance.CreateClonedPrefab(material + "_arch", "stone_arch");
			val2.GetComponent<Piece>().m_name = "$piece_" + material + "_arch";
			Renderer[] componentsInChildren = ((Component)val2.transform.Find("New")).GetComponentsInChildren<Renderer>();
			foreach (Renderer val3 in componentsInChildren)
			{
				Material[] sharedMaterials = val3.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					sharedMaterials[j] = GetMaterial("Color_" + material + "_new3");
					sharedMaterials[j].SetTextureScale("_MainTex", val);
				}
				val3.sharedMaterials = sharedMaterials;
			}
			componentsInChildren = ((Component)val2.transform.Find("Worn")).GetComponentsInChildren<Renderer>();
			foreach (Renderer val4 in componentsInChildren)
			{
				Material[] sharedMaterials2 = val4.sharedMaterials;
				for (int k = 0; k < sharedMaterials2.Length; k++)
				{
					sharedMaterials2[k] = GetMaterial("Color_" + material + "_worn3");
					sharedMaterials2[k].SetTextureScale("_MainTex", val);
				}
				val4.sharedMaterials = sharedMaterials2;
			}
			componentsInChildren = ((Component)val2.transform.Find("Broken")).GetComponentsInChildren<Renderer>();
			foreach (Renderer val5 in componentsInChildren)
			{
				Material[] sharedMaterials3 = val5.sharedMaterials;
				for (int l = 0; l < sharedMaterials3.Length; l++)
				{
					sharedMaterials3[l] = GetMaterial("Color_" + material + "_broken3");
					sharedMaterials3[l].SetTextureScale("_MainTex", val);
				}
				val5.sharedMaterials = sharedMaterials3;
			}
			Vector3 localScale = val2.transform.localScale;
			localScale.z *= 0.5f;
			val2.transform.localScale = localScale;
			PieceManager instance = PieceManager.Instance;
			PieceConfig val6 = new PieceConfig();
			val6.PieceTable = "Hammer";
			val6.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "item_" + material + "_brick",
					Recover = true,
					Amount = 6
				}
			};
			val6.Icon = RenderManager.Instance.Render(val2, RenderManager.IsometricRotation);
			val6.CraftingStation = "piece_stonecutter";
			val6.Category = CategoryName;
			instance.AddPiece(new CustomPiece(val2, true, val6));
		}

		private void AddItemAndConversion(AssetBundle brickWallsAssetBundle, string name)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0053: 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_0070: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			string text = "brick_" + name + "_item";
			GameObject val = brickWallsAssetBundle.LoadAsset<GameObject>(text);
			CustomItem val2 = new CustomItem(val, true);
			((Object)val).name = "item_" + name + "_brick";
			val.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0] = RenderManager.Instance.Render(val, RenderManager.IsometricRotation);
			ItemManager.Instance.AddItem(val2);
			SmelterConversionConfig val3 = new SmelterConversionConfig();
			((ConversionConfig)val3).FromItem = "item_" + name;
			((ConversionConfig)val3).ToItem = "item_" + name + "_brick";
			((ConversionConfig)val3).Station = "CharcoalKiln";
			ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)(object)val3));
		}

		private void AddBrickPiece(AssetBundle brickWallsAssetBundle, string asset, string material, int cost = 3)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("vfx_ClayDestroyed_large" + asset + material, "vfx_RockDestroyed");
			Renderer[] componentsInChildren = ((Component)val.transform.GetChild(0)).GetComponentsInChildren<Renderer>();
			foreach (Renderer val2 in componentsInChildren)
			{
				Material[] sharedMaterials = val2.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					sharedMaterials[j] = GetMaterial("mat_" + material + "_ore");
				}
				val2.sharedMaterials = sharedMaterials;
			}
			GameObject val3 = brickWallsAssetBundle.LoadAsset<GameObject>(asset);
			val3 = PrefabManager.Instance.CreateClonedPrefab(asset + "_" + material, val3);
			val3.GetComponent<Piece>().m_name = "$piece_" + asset + "_" + material;
			WearNTear component = val3.GetComponent<WearNTear>();
			EffectData val4 = new EffectData();
			val4.m_prefab = val;
			component.m_destroyedEffect.m_effectPrefabs[1] = val4;
			ChangeMaterial(val3, GetMaterial("Color_" + material + "_new"), GetMaterial("Color_" + material + "_worn"), GetMaterial("Color_" + material + "_broken"));
			PieceManager instance = PieceManager.Instance;
			GameObject obj = val3;
			PieceConfig val5 = new PieceConfig();
			val5.PieceTable = "Hammer";
			val5.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "item_" + material + "_brick",
					Recover = true,
					Amount = cost
				}
			};
			val5.Icon = RenderManager.Instance.Render(val3, RenderManager.IsometricRotation);
			val5.CraftingStation = "piece_stonecutter";
			val5.Category = CategoryName;
			instance.AddPiece(new CustomPiece(obj, true, val5));
		}

		private void AddClonedItems()
		{
			AssetBundle val = AssetUtils.LoadAssetBundleFromResources("brickwalls");
			if ((Object)(object)val == (Object)null)
			{
				MonoBehaviour.print((object)"Error loading assetbundle bricks");
				return;
			}
			try
			{
				LoadMaterials(val);
				GameObject drop = AddOre("clay");
				GameObject drop2 = AddOre("claywhite");
				AddMine(val, "clay", drop, (Biome)9);
				AddMine(val, "claywhite", drop2, (Biome)16);
				AddItemAndConversion(val, "clay");
				AddItemAndConversion(val, "claywhite");
				AddBrickPiece(val, "ClayBrickHalf", "clay", 1);
				AddBrickPiece(val, "ClayBrick", "clay", 1);
				AddBrickPiece(val, "ClayBrick1x1", "clay");
				AddBrickPiece(val, "ClayBrick2x1", "clay", 4);
				AddBrickPiece(val, "ClayBrick4x2", "clay", 6);
				AddBrickPiece(val, "ClayBrickPillar", "clay", 5);
				AddBrickPiece(val, "ClayBrickFloor", "clay", 6);
				AddBrickPiece(val, "ClayBrickStair", "clay", 8);
				addArch("clay");
				AddRoofClone("clay", "roof");
				AddRoofClone("clay", "roof_45");
				AddRoofClone("clay", "roof_icorner");
				AddRoofClone("clay", "roof_icorner_45");
				AddRoofClone("clay", "roof_ocorner");
				AddRoofClone("clay", "roof_ocorner_45");
				AddRoofClone("clay", "roof_top");
				AddRoofClone("clay", "roof_top_45");
				AddBrickPiece(val, "ClayBrickHalf", "claywhite", 1);
				AddBrickPiece(val, "ClayBrick", "claywhite", 1);
				AddBrickPiece(val, "ClayBrick1x1", "claywhite");
				AddBrickPiece(val, "ClayBrick2x1", "claywhite", 4);
				AddBrickPiece(val, "ClayBrick4x2", "claywhite", 6);
				AddBrickPiece(val, "ClayBrickPillar", "claywhite", 5);
				AddBrickPiece(val, "ClayBrickFloor", "claywhite", 6);
				AddBrickPiece(val, "ClayBrickStair", "claywhite", 8);
				addArch("claywhite");
				AddRoofClone("claywhite", "roof");
				AddRoofClone("claywhite", "roof_45");
				AddRoofClone("claywhite", "roof_icorner");
				AddRoofClone("claywhite", "roof_icorner_45");
				AddRoofClone("claywhite", "roof_ocorner");
				AddRoofClone("claywhite", "roof_ocorner_45");
				AddRoofClone("claywhite", "roof_top");
				AddRoofClone("claywhite", "roof_top_45");
				Materials.Clear();
			}
			finally
			{
				val.Unload(false);
			}
			PrefabManager.OnVanillaPrefabsAvailable -= AddClonedItems;
		}
	}
}
namespace BrickWalls.Patches
{
	[HarmonyPatch(typeof(Smelter), "Spawn")]
	internal class Smelter_Spawn_patch
	{
		private static void Postfix(string ore, int stack, Transform ___m_outputPoint)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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)
			if (ore.Equals("item_clay"))
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("item_clay_brick");
				if ((Object)(object)itemPrefab != (Object)null)
				{
					Object.Instantiate<GameObject>(itemPrefab, ___m_outputPoint.position, ___m_outputPoint.rotation).GetComponent<ItemDrop>().m_itemData.m_stack = stack;
				}
			}
			else if (ore.Equals("item_claywhite"))
			{
				GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab("item_claywhite_brick");
				if ((Object)(object)itemPrefab2 != (Object)null)
				{
					Object.Instantiate<GameObject>(itemPrefab2, ___m_outputPoint.position, ___m_outputPoint.rotation).GetComponent<ItemDrop>().m_itemData.m_stack = stack;
				}
			}
		}
	}
}