Decompiled source of balrond papayonpack v1.0.0

plugins/BalrondPapayonPack.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using LitJson2;
using UnityEngine;
using UpgradeWorld;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BalrondTreesNDecor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BalrondTreesNDecor")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cde312a0-cf19-4264-8616-e1c74774beed")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public static class BalrondHashCompat
{
	private static readonly MethodInfo _getStableHashCodeStringBool;

	private static readonly MethodInfo _getStableHashCodeString;

	private static readonly bool _initialized;

	static BalrondHashCompat()
	{
		try
		{
			Type typeFromHandle = typeof(StringExtensionMethods);
			_getStableHashCodeStringBool = typeFromHandle.GetMethod("GetStableHashCode", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2]
			{
				typeof(string),
				typeof(bool)
			}, null);
			_getStableHashCodeString = typeFromHandle.GetMethod("GetStableHashCode", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null);
			_initialized = true;
		}
		catch
		{
			_initialized = false;
		}
	}

	public static int StableHash(string value)
	{
		if (value == null)
		{
			return 0;
		}
		try
		{
			if (_getStableHashCodeStringBool != null)
			{
				return (int)_getStableHashCodeStringBool.Invoke(null, new object[2] { value, false });
			}
			if (_getStableHashCodeString != null)
			{
				return (int)_getStableHashCodeString.Invoke(null, new object[1] { value });
			}
		}
		catch
		{
		}
		return FallbackStableHash(value);
	}

	private static int FallbackStableHash(string value)
	{
		int num = 5381;
		int num2 = num;
		for (int i = 0; i < value.Length; i += 2)
		{
			num = ((num << 5) + num) ^ value[i];
			if (i == value.Length - 1)
			{
				break;
			}
			num2 = ((num2 << 5) + num2) ^ value[i + 1];
		}
		return num + num2 * 1566083941;
	}
}
internal static class Compatibility
{
	private const string AlienID = "ZenDragon.ZenWorldSettings";

	private static bool _isLoaded;

	private static bool _Check;

	public static bool IsLoaded()
	{
		if (!_Check)
		{
			_isLoaded = Chainloader.PluginInfos.ContainsKey("ZenDragon.ZenWorldSettings");
			if (_isLoaded)
			{
				Debug.Log((object)"Amazing Nature: Using ZenWorldSettings, Disabled Crypt Key consume");
			}
			_Check = true;
		}
		return _isLoaded;
	}
}
internal static class Compatibility2
{
	public const string AlienID = "ZenDragon.ZenCombat";

	private static bool _isLoaded;

	private static bool _Check;

	public static bool IsLoaded()
	{
		if (!_Check)
		{
			_isLoaded = Chainloader.PluginInfos.ContainsKey("ZenDragon.ZenCombat");
			if (_isLoaded)
			{
				Debug.Log((object)"Amazing Nature: Using ZenDragon.ZenCombat, Disabled Parry/Block changes");
			}
			_Check = true;
		}
		return _isLoaded;
	}
}
namespace UpgradeWorld
{
	public class CommandRegistration
	{
		public string name = "";

		public string description = "";

		public string[] commands = new string[0];

		public void AddCommand()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			new ConsoleCommand(name, description, (ConsoleEvent)delegate(ConsoleEventArgs args)
			{
				string[] array = commands;
				foreach (string text in array)
				{
					args.Context.TryRunCommand(text, false, false);
				}
			}, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	public static class Upgrade
	{
		private static List<CommandRegistration> registrations = new List<CommandRegistration>();

		public const string GUID = "upgrade_world";

		public static void Register(string name, string description, params string[] commands)
		{
			if (Chainloader.PluginInfos.ContainsKey("upgrade_world"))
			{
				registrations.Add(new CommandRegistration
				{
					name = name,
					description = description,
					commands = commands
				});
			}
		}

		private static void Postfix()
		{
			foreach (CommandRegistration registration in registrations)
			{
				registration.AddCommand();
			}
		}
	}
}
namespace BalrondTreesNDecor
{
	public class BalrondTranslator
	{
		public static Dictionary<string, Dictionary<string, string>> translations = new Dictionary<string, Dictionary<string, string>>();

		public static Dictionary<string, string> getLanguage(string language)
		{
			if (string.IsNullOrEmpty(language))
			{
				return null;
			}
			if (translations.TryGetValue(language, out var value))
			{
				return value;
			}
			return null;
		}
	}
	internal class VfxList
	{
		public static readonly string[] vfx = new string[19]
		{
			"ElderMushroomCap_bal", "ElderMushroomLog_bal", "Acai_log_bal", "IcedTree_log_bal", "ElderTreeLog_bal", "ElderTreeLogHalf_bal", "Acai_log_half_bal", "Wet_log_bal", "Wet_log_half_bal", "Cypress_log_bal",
			"Willow_log_bal", "Maple_log_bal", "Oak2_log_bal", "Oak2_log_half_bal", "Poplar_log_bal", "YewTreeLog_bal", "bigyggashoot_log_bal", "bigyggashoot_log_half_bal", "bigyggashoot_log_quarter_bal"
		};
	}
	internal class ClutterList
	{
		public static string[] clutter = new string[0];
	}
	public class ConversionChanges
	{
		private enum ConversionType
		{
			smelter,
			fermenter,
			cooking,
			balrondConverter
		}

		private List<GameObject> buildPieces = new List<GameObject>();

		private List<GameObject> items = new List<GameObject>();

		public static List<TutorialText> m_texts = new List<TutorialText>();

		public static List<BalrondConverter.ItemConversion> sawmillConverions = new List<BalrondConverter.ItemConversion>();

		public static List<BalrondConverter.ItemConversion> stonekilnConverions = new List<BalrondConverter.ItemConversion>();

		public static List<BalrondConverter.ItemConversion> tanneryConverions = new List<BalrondConverter.ItemConversion>();

		public static List<ItemConversion> kilnConverions = new List<ItemConversion>();

		public static List<ItemConversion> smelterConverions = new List<ItemConversion>();

		public static List<ItemConversion> furnaceConverions = new List<ItemConversion>();

		private static readonly string[] buildPieceNames = new string[18]
		{
			"portal_wood", "piece_workbench", "forge", "blackforge", "piece_magetable", "piece_artisanstation", "piece_stonecutter", "piece_banner01", "piece_banner02", "piece_banner03",
			"piece_banner04", "piece_banner05", "piece_banner06", "piece_banner07", "piece_banner08", "piece_banner09", "piece_banner10", "piece_banner11"
		};

		private string[] convertToBits = new string[41]
		{
			"WillowSeeds_bal", "WillowBark_bal", "YewBark_bal", "WoodNails_bal", "WaterLilySeeds_bal", "SwampTreeSeeds_bal", "Straw_bal", "StrawSeeds_bal", "Snowleaf_bal", "StrawThread_bal",
			"RedwoodSeeds_bal", "Plantain_bal", "PoplarSeeds_bal", "Peningar_bal", "Sage_bal", "Lavender_bal", "Mint_bal", "OilBase_bal", "Oil_bal", "Nettle_bal",
			"Moss_bal", "Mugwort_bal", "MushroomIcecap_bal", "MushroomInkcap_bal", "Iceberry_bal", "Ignicap_bal", "GarlicSeeds_bal", "Garlic_bal", "CypressSeeds_bal", "CabbageLeaf_bal",
			"CabbageSeeds_bal", "Cabbage_bal", "BirdFeed_bal", "Blackberries_bal", "AppleSeeds_bal", "BasicSeed_bal", "AcaiSeeds_bal", "MapleSeeds_bal", "WaterLily_bal", "Yarrow_bal",
			"MeatScrap_bal"
		};

		private string[] convertToCoal = new string[194]
		{
			"ClayBrickMold_bal", "AcidSludge_bal", "AncientRelic_bal", "AppleVinegar_bal", "Apple_bal", "BatWingCooked_bal", "BatWing_bal", "BeltForester_bal", "BeltMountaineer_bal", "BeltSailor_bal",
			"BlackMetalCultivator_bal", "BlackMetalHoe_bal", "BlackSkin_bal", "BlackTissue_bal", "Bloodfruit_bal", "Bloodshard_bal", "BoarHide_bal", "BoraxCrystal_bal", "BundleHut_bal", "CarvedCarcass_bal",
			"CarvedDeerSkull_bal", "CeramicMold_bal", "Cheese_bal", "CabbageSoup_bal", "ClamMeat_bal", "ClayBrick_bal", "ClayPot_bal", "Clay_bal", "CoalPowder_bal", "CookedCrowMeat_bal",
			"CookedDragonRibs_bal", "CorruptedEitr_bal", "CrabLegsCooked_bal", "CrabLegs_bal", "CrystalWood_bal", "CultInsignia_bal", "CursedBone_bal", "Darkbul_bal", "DeadEgo_bal", "DragonSoul_bal",
			"DrakeMeatCooked_bal", "DrakeMeat_bal", "DrakeSkin_bal", "DyeKit_bal", "EmberWood_bal", "EnrichedEitr_bal", "EnrichedSoil_bal", "FenringInsygnia_bal", "FenringMeatCooked_bal", "FenringMeat_bal",
			"FireGland_bal", "FishWrapsUncooked_bal", "ForsakenHeart_bal", "FoxFur_bal", "CarvedWood_bal", "WispCore_bal", "GoatMeatCooked_bal", "GoatMeat_bal", "GrayMushroom_bal", "GrilledCheese_bal",
			"HammerBlackmetal_bal", "HammerDverger_bal", "HammerIron_bal", "HammerMythic_bal", "HardWood_bal", "HelmetCrown_bal", "InfusedCarapace_bal", "JotunFinger_bal", "JuteThread_bal", "KingMug_bal",
			"MagmaStone_bal", "MeadBase_bal", "MedPack_bal", "MincedMeat_bal", "NeckSkin_bal", "NorthernFur_bal", "NumbMeal_bal", "PickaxeFlametal_bal", "RawCrowMeat_bal", "RawDragonRibs_bal",
			"RawSilkScrap_bal", "RawSilk_bal", "RawSteak_bal", "RedKelp_bal", "RefinedOil_bal", "Sapphire_bal", "SawBlade_bal", "Seaberries_bal", "SeekerBrain_bal", "SerpentEgg_bal",
			"SharkMeatCooked_bal", "SharkMeat_bal", "SilkReinforcedThread_bal", "SmallBloodSack_bal", "SoulCore_bal", "SpiceSet_bal", "SpiritShard_bal", "SteakCooked_bal", "StormScale_bal", "TarBase_bal",
			"ThornHeart_bal", "ThunderGland_bal", "TormentedSoul_bal", "TrollMeatCooked_bal", "TrollMeat_bal", "WatcherHeart_bal", "SurtlingCoreCasing_bal", "ApplePieUncooked_bal", "ApplePie_bal", "AshlandCurry_bal",
			"BlackBerryJuice_bal", "BloodfruitSoup_bal", "BloodyBearJerky_bal", "BloodyCreamPie_bal", "BloodyVial_bal", "BlueberryPieUncooked_bal", "BlueberryPie_bal", "Breakfast_bal", "Burger_bal", "ChickenMarsala_bal",
			"ChickenNuggets_bal", "DragonfireBarbecue_bal", "FishSkewer_bal", "FruitPunch_bal", "FruitSalad_bal", "GrilledShrooms_bal", "HappyMeal_bal", "HoneyGlazedApple_bal", "IceBerryPancake_bal", "KingsJam_bal",
			"Liverwurst_bal", "MagmaCoctail_bal", "MeadBaseWhiteCheese_bal", "SeaFoodPlatter_bal", "SpicyBurger_bal", "SpiecedDrakeChop_bal", "SurstrommingBase_bal", "Surstromming_bal", "SwampSkause_bal", "VegetablePuree_bal",
			"VegetableSoup_bal", "WhiteCheese_bal", "WinterStew_bal", "CarrotFries_bal", "PowderedSalt_bal", "PowderedPepper_bal", "BundlePortal_bal", "BundlePortalStone_bal", "HelmetLeatherCap_bal", "HelmetBronzeHorned_bal",
			"BlackBerryJuiceBase_bal", "MagmaCoctailBase_bal", "FruitPunchBase_bal", "VineBerryJuice_bal", "VineBerryJuiceBase_bal", "RostedTrollBits_bal", "RoastedFish_bal", "CabbageWrapDrake_bal", "Cotlet_bal", "RedStew_bal",
			"GoatStew_bal", "CrustedMeat_bal", "MeatBalls_bal", "MeatRoll_bal", "MagnaTarta_bal", "ShrededMeat_bal", "MincedFenringStew_bal", "CarrotCrowSalad_bal", "Bulion_bal", "CookedMeatScrap_bal",
			"WoodBucket_bal", "BeltVidar_bal", "BeltAssasin_bal", "TrophyBattleHog_bal", "TrophyGoat_bal", "TrophyNeckBrute_bal", "TrophyObsidianCrab_bal", "TrophyShark_bal", "TrophySouling_bal", "TrophyCorpseCollector_bal",
			"TrophyForsaken_bal", "TrophyGreywatcher_bal", "TrophyHaugbui_bal", "TrophySpectre_bal", "TrophyStormdrake_bal", "TrophyTrollAshlands_bal", "TrophyTrollSkeleton_bal", "TrophyStag_bal", "TrophyLeechPrimal_bal", "TrophyStagGhost_bal",
			"Larva_bal", "WaterJugEmpty_bal", "SwordFakeSilver_Bal", "MaceFakeSilver_bal"
		};

		private string[] arrowsNbolts = new string[10] { "BoltBlunt_bal", "BoltChitin_bal", "BoltFire_bal", "BoltSilver_bal", "BoltThunder_bal", "ArrowBlizzard_bal", "ArrowBlunt_bal", "ArrowBone_bal", "ArrowChitin_bal", "ArrowFlametal_bal" };

		public void editBuidlPieces(List<GameObject> allPrefabs)
		{
			buildPieces = allPrefabs;
			items = allPrefabs;
			editKiln();
			editFurnace();
		}

		private void EditRecipes()
		{
			string[] array = buildPieceNames;
			foreach (string name in array)
			{
				GameObject val = FindBuildPiece(name);
				if ((Object)(object)val != (Object)null)
				{
					ModifyBuildPiece(val);
				}
			}
		}

		private void ModifyBuildPiece(GameObject piece)
		{
			string name = ((Object)piece).name;
			string text = name;
			switch (text)
			{
			case "forge":
			case "piece_workbench":
			case "blackforge":
			case "piece_magetable":
			case "piece_artisanstation":
			case "piece_stonecutter":
				SetCraftingStationRequiresRoof(piece, requireRoof: false);
				return;
			}
			if (text.StartsWith("piece_banner"))
			{
				SetBannerRecipe(piece);
			}
		}

		private void SetCraftingStationRequiresRoof(GameObject piece, bool requireRoof)
		{
			CraftingStation component = piece.GetComponent<CraftingStation>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_craftRequireRoof = requireRoof;
			}
		}

		private void SetBannerRecipe(GameObject piece)
		{
			Piece component = piece.GetComponent<Piece>();
			component.m_resources = (Requirement[])(object)new Requirement[4]
			{
				CreateRequirement("DyeKit_bal", 1),
				CreateRequirement("FineWood", 2),
				CreateRequirement("LeatherScraps", 3),
				CreateRequirement("StrawThread_bal", 3)
			};
		}

		private Requirement CreateRequirement(string itemName, int amount)
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			return new Requirement
			{
				m_resItem = FindItem(itemName).GetComponent<ItemDrop>(),
				m_amount = amount,
				m_amountPerLevel = 0,
				m_recover = true
			};
		}

		private GameObject FindBuildPiece(string name)
		{
			return ((IEnumerable<GameObject>)buildPieces).FirstOrDefault((Func<GameObject, bool>)((GameObject x) => ((Object)x).name == name));
		}

		private GameObject FindItem(string name)
		{
			if (items == null)
			{
				items = ZNetScene.instance.m_prefabs;
			}
			GameObject val = items.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Debug.LogWarning((object)("Item Not Found - " + name + ", Replaced With Wood"));
			return items.Find((GameObject x) => ((Object)x).name == "Wood");
		}

		private void removeConversionFromSmelter(string fromItem, List<ItemConversion> list)
		{
			if (list != null && list.Count != 0)
			{
				list.RemoveAll((ItemConversion x) => x == null || (Object)(object)x.m_from == (Object)null || x.m_from.m_itemData == null || (Object)(object)x.m_from.m_itemData.m_dropPrefab == (Object)null || ((Object)x.m_from.m_itemData.m_dropPrefab).name == fromItem);
			}
		}

		private Requirement createReq(string name, int amount, int amountPerLevel)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			Requirement val = new Requirement();
			val.m_recover = true;
			ItemDrop component = FindItem(name).GetComponent<ItemDrop>();
			val.m_resItem = component;
			val.m_amount = amount;
			val.m_amountPerLevel = amountPerLevel;
			return val;
		}

		public void editLeatherRack(BalrondConverter leatherRack = null)
		{
			if (buildPieces != null && (Object)(object)leatherRack == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_leatherRack_bal");
				leatherRack = val.GetComponent<BalrondConverter>();
			}
			if (tanneryConverions.Count > 0)
			{
				leatherRack.m_conversion = tanneryConverions;
				return;
			}
			leatherRack.m_conversion = new List<BalrondConverter.ItemConversion>();
			addConversion(((Component)leatherRack).gameObject, "NeckSkin_bal", "NeckSkin_bal", ConversionType.balrondConverter, 0, 2);
			addConversion(((Component)leatherRack).gameObject, "DeerHide", "DeerHide", ConversionType.balrondConverter, 0, 2, 2);
			addConversion(((Component)leatherRack).gameObject, "BoarHide_bal", "BoarHide_bal", ConversionType.balrondConverter, 0, 2, 2);
			addConversion(((Component)leatherRack).gameObject, "BjornHide", "BjornHide", ConversionType.balrondConverter, 0, 2, 3);
			addConversion(((Component)leatherRack).gameObject, "TrollHide", "TrollHide", ConversionType.balrondConverter, 0, 2, 3);
			addConversion(((Component)leatherRack).gameObject, "DrakeSkin_bal", "DrakeSkin_bal", ConversionType.balrondConverter, 0, 2, 4);
			addConversion(((Component)leatherRack).gameObject, "WolfPelt", "WolfPelt", ConversionType.balrondConverter, 0, 2, 4);
			addConversion(((Component)leatherRack).gameObject, "LoxPelt", "LoxPelt", ConversionType.balrondConverter, 0, 2, 5);
			addConversion(((Component)leatherRack).gameObject, "AskHide", "AskHide", ConversionType.balrondConverter, 0, 2, 5);
		}

		public void editRefinery(Smelter refinery = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)refinery == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "eitrrefinery");
				refinery = val.GetComponent<Smelter>();
			}
			if (refinery.m_maxFuel == 20)
			{
				refinery.m_maxFuel = 60;
			}
			if (refinery.m_maxOre == 20)
			{
				refinery.m_maxOre = 60;
			}
			if (refinery.m_secPerProduct == 40f)
			{
				refinery.m_secPerProduct = 60f;
			}
			text += addConversion(((Component)refinery).gameObject, "Oil_bal", "RefinedOil_bal", ConversionType.smelter);
			text += addConversion(((Component)refinery).gameObject, "BlackTissue_bal", "CorruptedEitr_bal", ConversionType.smelter);
			buildConversionStationTutorialTag(((Component)refinery).gameObject, text);
		}

		public void editComposter(Smelter composter = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)composter == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "composter_bal");
				composter = val.GetComponent<Smelter>();
			}
			if (composter.m_conversion == null)
			{
				composter.m_conversion = new List<ItemConversion>();
			}
			addConversion(((Component)composter).gameObject, "TrophyFox_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyHabrok_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyHabrokBirb_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyCrow_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGreywatcher_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySouling_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyCorpseCollector_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyBjorn", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyBjornUndead", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyForsaken_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGoat_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyHaugbui_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyNeckBrute_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyObsidianCrab_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySpectre_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyStormdrake_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyShark_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyAbomination", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyBlob", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyBoar", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyBonemass", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyCultist", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyDeathsquito", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyDeer", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyDragonQueen", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyDraugr", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyDraugrElite", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyDvergr", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyEikthyr", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyFenring", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyFrostTroll", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGjall", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGoblin", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGoblinBrute", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGoblinKing", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGoblinShaman", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGreydwarf", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGreydwarfBrute", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGreydwarfShaman", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGrowth", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyHare", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyHatchling", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyLeech", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyLox", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyNeck", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySeeker", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySeekerBrute", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySeekerQueen", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySerpent", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySGolem", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySkeleton", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySkeletonPoison", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySurtling", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyTheElder", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyTick", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyUlv", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyWolf", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyWraith", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyTrollSkeleton_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyTrollAshlands_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyStag_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyBattleHog_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyBear_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyForestTroll_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyPolarBear_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyLeechPrimal_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyStagGhost_bal", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyBonemawSerpent", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyCharredArcher", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyCharredMage", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyCharredMelee", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyCultist_Hildir", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyDraugrFem", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyFader", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyFallenValkyrie", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGhost", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGoblinBruteBrosBrute", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyGoblinBruteBrosShaman", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyKvastur", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyMorgen", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophySkeletonHildir", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyVolture", "EnrichedSoil_bal", ConversionType.smelter);
			addConversion(((Component)composter).gameObject, "TrophyAsksvin", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "RottenMeat", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "RottenVegetable_bal", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "Pukeberries", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "StrawBundle_bal", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "Cabbage_bal", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "Turnip", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "Carrot", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "Onion", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "Garlic_bal", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "BirdFeed_bal", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "Apple_bal", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "PoisonApple_bal", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "BoneFragments", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "FishRaw", "EnrichedSoil_bal", ConversionType.smelter);
			buildConversionStationTutorialTag(((Component)composter).gameObject, text);
		}

		public void editSmelter(Smelter smelter = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)smelter == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "smelter");
				smelter = val.GetComponent<Smelter>();
			}
			if (smelter.m_maxFuel == 20)
			{
				smelter.m_maxFuel = 45;
			}
			if (smelter.m_maxOre == 10)
			{
				smelter.m_maxOre = 15;
			}
			if (smelter.m_secPerProduct == 30f)
			{
				smelter.m_secPerProduct = 40f;
			}
			if (smelter.m_fuelPerProduct == 2)
			{
				smelter.m_fuelPerProduct = 3;
			}
			if (smelterConverions.Count > 0)
			{
				smelter.m_conversion = smelterConverions;
				return;
			}
			if (smelter.m_conversion == null)
			{
				smelter.m_conversion = new List<ItemConversion>();
			}
			removeConversionFromSmelter("IronScrap", smelter.m_conversion);
			removeConversionFromSmelter("CopperScrap", smelter.m_conversion);
			removeConversionFromSmelter("BronzeScrap", smelter.m_conversion);
			text += "\n Scrap does not go into Furnace/Smelter.  Can be only converted in Smeltworks station";
			text += addConversion(((Component)smelter).gameObject, "SurtlingCoreCasing_bal", "SurtlingCore", ConversionType.smelter);
			text += addConversion(((Component)smelter).gameObject, "ZincOre_bal", "Zinc_bal", ConversionType.smelter);
			text += addConversion(((Component)smelter).gameObject, "CopperOre", "Copper", ConversionType.smelter);
			text += addConversion(((Component)smelter).gameObject, "LeadOre_bal", "Lead_bal", ConversionType.smelter);
			text += addConversion(((Component)smelter).gameObject, "TinOre", "Tin", ConversionType.smelter);
			text += addConversion(((Component)smelter).gameObject, "NickelOre_bal", "Nickel_bal", ConversionType.smelter);
			text += addConversion(((Component)smelter).gameObject, "IronOre", "Iron", ConversionType.smelter);
			text += addConversion(((Component)smelter).gameObject, "SilverOre", "Silver", ConversionType.smelter);
			text += addConversion(((Component)smelter).gameObject, "GoldOre_bal", "GoldBar_bal", ConversionType.smelter);
			buildConversionStationTutorialTag(((Component)smelter).gameObject, text, "smelter");
			smelterConverions = smelter.m_conversion;
		}

		public void editFurnace(Smelter furnace = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)furnace == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "blastfurnace");
				furnace = val.GetComponent<Smelter>();
			}
			if (furnaceConverions.Count > 0)
			{
				furnace.m_conversion = furnaceConverions;
				return;
			}
			if (furnace.m_conversion == null)
			{
				furnace.m_conversion = new List<ItemConversion>();
			}
			text += addConversion(((Component)furnace).gameObject, "CopperOre", "Copper", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "TinOre", "Tin", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "IronOre", "Iron", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "SilverOre", "Silver", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "BlackMetalOre_bal", "BlackMetal", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "FlametalOre", "Flametal", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "FlametalOreNew", "FlametalNew", ConversionType.smelter);
			furnaceConverions = furnace.m_conversion;
		}

		public void editSawMill(BalrondConverter sawmill = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)sawmill == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_sawmill_bal");
				sawmill = val.GetComponent<BalrondConverter>();
			}
			if (sawmillConverions.Count > 0)
			{
				sawmill.m_conversion = sawmillConverions;
				return;
			}
			sawmill.m_conversion.Clear();
			sawmill.m_conversion = new List<BalrondConverter.ItemConversion>();
			text += addConversion(((Component)sawmill).gameObject, "RoundLog", "Wood", ConversionType.balrondConverter, 0, 3);
			text += addConversion(((Component)sawmill).gameObject, "FineWood", "Wood", ConversionType.balrondConverter, 0, 4);
			text += addConversion(((Component)sawmill).gameObject, "ElderBark", "Wood", ConversionType.balrondConverter, 0, 2);
			text += addConversion(((Component)sawmill).gameObject, "YewBark_bal", "Wood", ConversionType.balrondConverter, 0, 2);
			text += addConversion(((Component)sawmill).gameObject, "WillowBark_bal", "Wood", ConversionType.balrondConverter, 0, 2);
			text += addConversion(((Component)sawmill).gameObject, "HardWood_bal", "FineWood", ConversionType.balrondConverter, 0, 3, 2);
			text += addConversion(((Component)sawmill).gameObject, "YggdrasilWood", "FineWood", ConversionType.balrondConverter, 0, 3);
			text += addConversion(((Component)sawmill).gameObject, "Blackwood", "FineWood", ConversionType.balrondConverter, 0, 4, 2);
			text += addConversion(((Component)sawmill).gameObject, "EmberWood_bal", "FineWood", ConversionType.balrondConverter, 0, 2, 2);
			text += addConversion(((Component)sawmill).gameObject, "CrystalWood_bal", "HardWood_bal", ConversionType.balrondConverter, 0, 2, 3);
			buildConversionStationTutorialTag(((Component)sawmill).gameObject, text);
			sawmillConverions = sawmill.m_conversion;
		}

		public void editStoneboundKiln(BalrondConverter kiln = null)
		{
			string text = "";
			if (buildPieces != null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "StoneboundKiln_bal");
				kiln = val.GetComponent<BalrondConverter>();
			}
			kiln.m_addOreTooltip = "$piece_smelter_add";
			if (stonekilnConverions.Count > 0)
			{
				kiln.m_conversion = stonekilnConverions;
				return;
			}
			text += "\n Stonebound Kiln accepts all items that Kiln does but requires fuel";
			text += addConversion(((Component)kiln).gameObject, "WoodBundle_bal", "Coal", ConversionType.balrondConverter, 60, 10, 2);
			text += addConversion(((Component)kiln).gameObject, "ClayMoldBundle_bal", "ClayBrick_bal", ConversionType.balrondConverter, 60, 10, 2);
			text += addConversion(((Component)kiln).gameObject, "CeramicMoldBundle_bal", "CeramicPlate", ConversionType.balrondConverter, 60, 40, 2);
			text += addConversion(((Component)kiln).gameObject, "Wood", "Coal", ConversionType.balrondConverter, 5, 1);
			text += addConversion(((Component)kiln).gameObject, "FineWood", "Coal", ConversionType.balrondConverter, 10, 1);
			text += addConversion(((Component)kiln).gameObject, "RoundLog", "Coal", ConversionType.balrondConverter, 10, 1);
			text += addConversion(((Component)kiln).gameObject, "TarBase_bal", "Tar", ConversionType.balrondConverter, 5, 1);
			text += addConversion(((Component)kiln).gameObject, "Moss_bal", "CoalPowder_bal", ConversionType.balrondConverter, 5, 1);
			text += addConversion(((Component)kiln).gameObject, "ElderBark", "CoalPowder_bal", ConversionType.balrondConverter, 5, 1);
			text += addConversion(((Component)kiln).gameObject, "YewBark_bal", "CoalPowder_bal", ConversionType.balrondConverter, 5, 1);
			text += addConversion(((Component)kiln).gameObject, "WillowBark_bal", "CoalPowder_bal", ConversionType.balrondConverter, 5, 1);
			text += addConversion(((Component)kiln).gameObject, "HardWood_bal", "Coal", ConversionType.balrondConverter, 10, 2);
			text += addConversion(((Component)kiln).gameObject, "YggdrasilWood", "Coal", ConversionType.balrondConverter, 10, 2);
			text += addConversion(((Component)kiln).gameObject, "Blackwood", "Coal", ConversionType.balrondConverter, 10, 2);
			text += addConversion(((Component)kiln).gameObject, "ClayBrickMold_bal", "ClayBrick_bal", ConversionType.balrondConverter, 5, 1);
			text += addConversion(((Component)kiln).gameObject, "CeramicMold_bal", "CeramicPlate", ConversionType.balrondConverter, 5, 1);
			buildConversionStationTutorialTag(((Component)kiln).gameObject, text);
			stonekilnConverions = kiln.m_conversion;
		}

		public void editFermenter(Fermenter fermenter = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)fermenter == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "fermenter");
				fermenter = val.GetComponent<Fermenter>();
			}
			fermenter.m_fermentationDuration = 2000f;
			text += addConversion(((Component)fermenter).gameObject, "MeadBaseWhiteCheese_bal", "WhiteCheese_bal", ConversionType.fermenter, 2);
			text += addConversion(((Component)fermenter).gameObject, "SurstrommingBase_bal", "Surstromming_bal", ConversionType.fermenter, 2);
			buildConversionStationTutorialTag(((Component)fermenter).gameObject, text);
		}

		public void editOven(CookingStation oven = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)oven == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_oven");
				oven = val.GetComponent<CookingStation>();
			}
			if (oven.m_conversion == null)
			{
				oven.m_conversion = new List<ItemConversion>();
			}
			text += addConversion(((Component)oven).gameObject, "FishWrapsUncooked_bal", "FishWraps", ConversionType.cooking, 50);
			text += addConversion(((Component)oven).gameObject, "ApplePieUncooked_bal", "ApplePie_bal", ConversionType.cooking, 50);
			text += addConversion(((Component)oven).gameObject, "BlueberryPieUncooked_bal", "BlueberryPie_bal", ConversionType.cooking, 50);
			buildConversionStationTutorialTag(((Component)oven).gameObject, text);
		}

		public void editCooking(CookingStation cookingStation = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)cookingStation == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_cookingstation");
				cookingStation = val.GetComponent<CookingStation>();
			}
			text += addConversion(((Component)cookingStation).gameObject, "BatWing_bal", "BatWingCooked_bal", ConversionType.cooking, 25);
			text += addConversion(((Component)cookingStation).gameObject, "GoatMeat_bal", "GoatMeatCooked_bal", ConversionType.cooking, 40);
			text += addConversion(((Component)cookingStation).gameObject, "RawCrowMeat_bal", "CookedCrowMeat_bal", ConversionType.cooking, 30);
			text += addConversion(((Component)cookingStation).gameObject, "RawSteak_bal", "SteakCooked_bal", ConversionType.cooking, 30);
			text += addConversion(((Component)cookingStation).gameObject, "SharkMeat_bal", "SharkMeatCooked_bal", ConversionType.cooking, 35);
			text += addConversion(((Component)cookingStation).gameObject, "CrabLegs_bal", "CrabLegsCooked_bal", ConversionType.cooking, 30);
			text += addConversion(((Component)cookingStation).gameObject, "TrollMeat_bal", "TrollMeatCooked_bal", ConversionType.cooking, 60);
			buildConversionStationTutorialTag(((Component)cookingStation).gameObject, text);
		}

		public void editIronCooking(CookingStation cookingStation = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)cookingStation == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_cookingstation_iron");
				cookingStation = val.GetComponent<CookingStation>();
			}
			text += addConversion(((Component)cookingStation).gameObject, "CrabLegs_bal", "CrabLegsCooked_bal", ConversionType.cooking, 25);
			text += addConversion(((Component)cookingStation).gameObject, "SharkMeat_bal", "SharkMeatCooked_bal", ConversionType.cooking, 30);
			text += addConversion(((Component)cookingStation).gameObject, "FenringMeat_bal", "FenringMeatCooked_bal", ConversionType.cooking, 60);
			text += addConversion(((Component)cookingStation).gameObject, "RawCrowMeat_bal", "CookedCrowMeat_bal", ConversionType.cooking, 30);
			text += addConversion(((Component)cookingStation).gameObject, "RawSteak_bal", "SteakCooked_bal", ConversionType.cooking, 20);
			text += addConversion(((Component)cookingStation).gameObject, "BatWing_bal", "BatWingCooked_bal", ConversionType.cooking, 20);
			text += addConversion(((Component)cookingStation).gameObject, "GoatMeat_bal", "GoatMeatCooked_bal", ConversionType.cooking, 35);
			text += addConversion(((Component)cookingStation).gameObject, "DrakeMeat_bal", "DrakeMeatCooked_bal", ConversionType.cooking, 30);
			text += addConversion(((Component)cookingStation).gameObject, "TrollMeat_bal", "TrollMeatCooked_bal", ConversionType.cooking, 60);
			buildConversionStationTutorialTag(((Component)cookingStation).gameObject, text);
		}

		public void editSmallIronCooking(CookingStation cookingStation = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)cookingStation == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_singleIronRack_bal");
				cookingStation = val.GetComponent<CookingStation>();
			}
			text += addConversion(((Component)cookingStation).gameObject, "RawMeat", "CookedMeat", ConversionType.cooking, 25);
			text += addConversion(((Component)cookingStation).gameObject, "NeckTail", "CookedNeckTail", ConversionType.cooking, 25);
			text += addConversion(((Component)cookingStation).gameObject, "FishRaw", "FishCooked", ConversionType.cooking, 25);
			text += addConversion(((Component)cookingStation).gameObject, "SerpentMeat", "SerpentMeatCooked", ConversionType.cooking, 60);
			text += addConversion(((Component)cookingStation).gameObject, "LoxMeat", "LoxMeatCooked", ConversionType.cooking, 60);
			text += addConversion(((Component)cookingStation).gameObject, "HareMeat", "HareMeatCooked", ConversionType.cooking, 60);
			text += addConversion(((Component)cookingStation).gameObject, "ChickenMeat", "ChickenCooked", ConversionType.cooking, 25);
			text += addConversion(((Component)cookingStation).gameObject, "AskvinMeat", "AskvinMeatCooked", ConversionType.cooking, 60);
			text += addConversion(((Component)cookingStation).gameObject, "VultureMeat", "VultureMeatCooked", ConversionType.cooking, 25);
			text += addConversion(((Component)cookingStation).gameObject, "CrabLegs_bal", "CrabLegsCooked_bal", ConversionType.cooking, 25);
			text += addConversion(((Component)cookingStation).gameObject, "SharkMeat_bal", "SharkMeatCooked_bal", ConversionType.cooking, 30);
			text += addConversion(((Component)cookingStation).gameObject, "FenringMeat_bal", "FenringMeatCooked_bal", ConversionType.cooking, 60);
			text += addConversion(((Component)cookingStation).gameObject, "RawCrowMeat_bal", "CookedCrowMeat_bal", ConversionType.cooking, 30);
			text += addConversion(((Component)cookingStation).gameObject, "RawSteak_bal", "SteakCooked_bal", ConversionType.cooking, 20);
			text += addConversion(((Component)cookingStation).gameObject, "BatWing_bal", "BatWingCooked_bal", ConversionType.cooking, 20);
			text += addConversion(((Component)cookingStation).gameObject, "GoatMeat_bal", "GoatMeatCooked_bal", ConversionType.cooking, 35);
			text += addConversion(((Component)cookingStation).gameObject, "DrakeMeat_bal", "DrakeMeatCooked_bal", ConversionType.cooking, 30);
			text += addConversion(((Component)cookingStation).gameObject, "TrollMeat_bal", "TrollMeatCooked_bal", ConversionType.cooking, 60);
			buildConversionStationTutorialTag(((Component)cookingStation).gameObject, text);
		}

		public void editWHeel(Smelter wheel = null)
		{
			string text = "";
			if (buildPieces != null && (Object)(object)wheel == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_spinningwheel");
				wheel = val.GetComponent<Smelter>();
			}
			if (wheel.m_maxOre == 40)
			{
				wheel.m_maxOre = 80;
			}
			if (wheel.m_secPerProduct == 30f)
			{
				wheel.m_secPerProduct = 25f;
			}
			text += addConversion(((Component)wheel).gameObject, "Straw_bal", "StrawThread_bal", ConversionType.smelter);
			text += addConversion(((Component)wheel).gameObject, "RawSilk_bal", "SilkReinforcedThread_bal", ConversionType.smelter);
			buildConversionStationTutorialTag(((Component)wheel).gameObject, text);
		}

		public void editSap(SapCollector sap = null)
		{
			if (buildPieces != null && (Object)(object)sap == (Object)null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_sapcollector");
				sap = val.GetComponent<SapCollector>();
			}
			if (sap.m_secPerUnit == 60f)
			{
				sap.m_secPerUnit = 90f;
			}
			if (sap.m_maxLevel == 10)
			{
				sap.m_maxLevel = 30;
			}
		}

		public void editWIndMIll(Smelter windmill = null)
		{
			string text = "";
			if (buildPieces != null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "windmill");
				windmill = val.GetComponent<Smelter>();
			}
			if (windmill.m_maxOre == 50)
			{
				windmill.m_maxOre = 60;
			}
			if (windmill.m_secPerProduct == 10f)
			{
				windmill.m_secPerProduct = 15f;
			}
		}

		public void editKiln(Smelter kiln = null)
		{
			string text = "";
			if (buildPieces != null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "charcoal_kiln");
				kiln = val.GetComponent<Smelter>();
			}
			kiln.m_addOreTooltip = "$piece_smelter_add";
			if (kilnConverions.Count > 0)
			{
				kiln.m_conversion = kilnConverions;
				return;
			}
			text += addConversion(((Component)kiln).gameObject, "StrawBundle_bal", "Coal", ConversionType.smelter);
			text += addConversion(((Component)kiln).gameObject, "FineWood", "Coal", ConversionType.smelter);
			text += addConversion(((Component)kiln).gameObject, "RoundLog", "Coal", ConversionType.smelter);
			text += addConversion(((Component)kiln).gameObject, "ElderBark", "Coal", ConversionType.smelter);
			text += addConversion(((Component)kiln).gameObject, "YggdrasilWood", "Coal", ConversionType.smelter);
			text += addConversion(((Component)kiln).gameObject, "Blackwood", "Coal", ConversionType.smelter);
			kilnConverions = kiln.m_conversion;
		}

		public void editPress(Smelter press = null)
		{
			string text = "";
			if (buildPieces != null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "oilpress_bal");
				press = val.GetComponent<Smelter>();
			}
			text += addConversion(((Component)press).gameObject, "OilBase_bal", "Oil_bal", ConversionType.smelter);
			text += addConversion(((Component)press).gameObject, "BlackBerryJuiceBase_bal", "BlackBerryJuice_bal", ConversionType.smelter);
			text += addConversion(((Component)press).gameObject, "FruitPunchBase_bal", "FruitPunch_bal", ConversionType.smelter);
			text += addConversion(((Component)press).gameObject, "VineBerryJuiceBase_bal", "VineBerryJuice_bal", ConversionType.smelter);
			text += addConversion(((Component)press).gameObject, "MagmaCoctailBase_bal", "MagmaCoctail_bal", ConversionType.smelter);
			text += addConversion(((Component)press).gameObject, "PaintBucket_bal", "DyeKit_bal", ConversionType.smelter);
			buildConversionStationTutorialTag(((Component)press).gameObject, text);
		}

		private void editBeehive()
		{
			GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "piece_beehive");
			Beehive component = val.GetComponent<Beehive>();
			component.m_maxHoney = 20;
		}

		private void editIncinerator(Incinerator incinerator = null)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			if (buildPieces != null)
			{
				GameObject val = buildPieces.Find((GameObject x) => ((Object)x).name == "incinerator");
				incinerator = val.GetComponent<Incinerator>();
			}
			IncineratorConversion val2 = new IncineratorConversion();
			val2.m_requireOnlyOneIngredient = true;
			val2.m_priority = 2;
			val2.m_requirements = new List<Requirement>();
			string[] array = convertToBits;
			foreach (string name in array)
			{
				val2.m_requirements.Add(new Requirement
				{
					m_amount = 1,
					m_resItem = FindItem(name).GetComponent<ItemDrop>()
				});
			}
			val2.m_result = FindItem("CoalPowder_bal").GetComponent<ItemDrop>();
			incinerator.m_conversions.Add(val2);
			IncineratorConversion val3 = new IncineratorConversion();
			val3.m_requireOnlyOneIngredient = true;
			val3.m_requirements = new List<Requirement>();
			string[] array2 = convertToCoal;
			foreach (string name2 in array2)
			{
				val3.m_requirements.Add(new Requirement
				{
					m_amount = 1,
					m_resItem = FindItem(name2).GetComponent<ItemDrop>()
				});
			}
			val3.m_result = FindItem("Coal").GetComponent<ItemDrop>();
			incinerator.m_conversions.Add(val3);
			IncineratorConversion val4 = new IncineratorConversion();
			val4.m_requireOnlyOneIngredient = true;
			val4.m_priority = 1;
			val4.m_requirements = new List<Requirement>();
			string[] array3 = arrowsNbolts;
			foreach (string name3 in array3)
			{
				val4.m_requirements.Add(new Requirement
				{
					m_amount = 20,
					m_resItem = FindItem(name3).GetComponent<ItemDrop>()
				});
			}
			val4.m_result = FindItem("Coal").GetComponent<ItemDrop>();
			incinerator.m_conversions.Add(val4);
		}

		private string addConversion(GameObject source, string nameIn, string nameOut, ConversionType type, int time = 0, int amount = 5, int cost = 1)
		{
			string result = "";
			switch (type)
			{
			case ConversionType.smelter:
				result = SmelterConversion(source, nameIn, nameOut);
				break;
			case ConversionType.fermenter:
				result = FermenterConversion(source, nameIn, nameOut, amount);
				break;
			case ConversionType.cooking:
				result = CookingConversion(source, nameIn, nameOut, time);
				break;
			case ConversionType.balrondConverter:
				result = BalrondConversion(source, nameIn, nameOut, amount, cost, time);
				break;
			}
			return result;
		}

		private void buildConversionStationTutorialTag(GameObject gameObject, string tutorialExtra, string tag = "workbench")
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			string text = "\n  <color=orange>BALROND AMAZING NATURE: </color>";
			TutorialText val = new TutorialText();
			val.m_name = "BAN conversions:" + ((Object)gameObject).name;
			val.m_globalKeyTrigger = "AmazingNature" + ((Object)gameObject).name;
			val.m_tutorialTrigger = tag;
			val.m_topic = "BAN-" + ((Object)gameObject).name;
			val.m_label = "BAN-" + ((Object)gameObject).name;
			val.m_isMunin = true;
			val.m_text = text + tutorialExtra;
			m_texts.Add(val);
		}

		private string createConversionSingleLine(ItemDrop m_from, ItemDrop m_to, int time = 0, int amount = 0)
		{
			string text = "\n $tag_convers_bal ";
			if (time > 0 && amount == 0)
			{
				return text + m_from.m_itemData.m_shared.m_name + " $tag_to_bal " + m_to.m_itemData.m_shared.m_name + " $tag_in_bal " + time + " $tag_seconds_bal";
			}
			if (time == 0 && amount > 0)
			{
				return text + m_from.m_itemData.m_shared.m_name + " $tag_to_bal " + amount + " " + m_to.m_itemData.m_shared.m_name;
			}
			if (time > 0 && amount > 0)
			{
				return text + m_from.m_itemData.m_shared.m_name + " $tag_to_bal " + amount + " " + m_to.m_itemData.m_shared.m_name + " $tag_in_bal " + time + " $tag_seconds_bal";
			}
			return text + m_from.m_itemData.m_shared.m_name + " $tag_to_bal " + m_to.m_itemData.m_shared.m_name;
		}

		private string BalrondConversion(GameObject source, string nameIn, string nameOut, int amount = 1, int cost = 1, int time = 0, List<GameObject> list = null)
		{
			BalrondConverter component = source.GetComponent<BalrondConverter>();
			if ((Object)(object)component == (Object)null)
			{
				return "";
			}
			if (component.m_conversion == null)
			{
				component.m_conversion = new List<BalrondConverter.ItemConversion>();
			}
			bool flag = false;
			foreach (BalrondConverter.ItemConversion item2 in component.m_conversion)
			{
				if (item2 != null && (Object)(object)item2.m_from != (Object)null && item2.m_from.m_itemData != null && (Object)(object)item2.m_from.m_itemData.m_dropPrefab != (Object)null && ((Object)item2.m_from.m_itemData.m_dropPrefab).name == nameIn)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				ItemDrop component2 = FindItem(nameIn).GetComponent<ItemDrop>();
				ItemDrop component3 = FindItem(nameOut).GetComponent<ItemDrop>();
				BalrondConverter.ItemConversion item = new BalrondConverter.ItemConversion
				{
					m_from = component2,
					m_to = component3,
					m_count = amount,
					m_fuelCost = cost,
					m_secPerProduct = time
				};
				component.m_conversion.Add(item);
				return createConversionSingleLine(component2, component3, 0, amount);
			}
			return "";
		}

		private string SmelterConversion(GameObject source, string nameIn, string nameOut)
		{
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			Smelter component = source.GetComponent<Smelter>();
			if ((Object)(object)component == (Object)null)
			{
				return "";
			}
			if (component.m_conversion == null)
			{
				component.m_conversion = new List<ItemConversion>();
			}
			bool flag = false;
			foreach (ItemConversion item2 in component.m_conversion)
			{
				if (item2 != null && (Object)(object)item2.m_from != (Object)null && item2.m_from.m_itemData != null && (Object)(object)item2.m_from.m_itemData.m_dropPrefab != (Object)null && ((Object)item2.m_from.m_itemData.m_dropPrefab).name == nameIn)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				ItemDrop component2 = FindItem(nameIn).GetComponent<ItemDrop>();
				ItemDrop component3 = FindItem(nameOut).GetComponent<ItemDrop>();
				ItemConversion item = new ItemConversion
				{
					m_from = component2,
					m_to = component3
				};
				component.m_conversion.Add(item);
				return createConversionSingleLine(component2, component3);
			}
			return "";
		}

		private string FermenterConversion(GameObject source, string nameIn, string nameOut, int amount = 1)
		{
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			Fermenter component = source.GetComponent<Fermenter>();
			if ((Object)(object)component == (Object)null)
			{
				return "";
			}
			if (component.m_conversion == null)
			{
				component.m_conversion = new List<ItemConversion>();
			}
			bool flag = false;
			foreach (ItemConversion item2 in component.m_conversion)
			{
				if (item2 != null && (Object)(object)item2.m_from != (Object)null && item2.m_from.m_itemData != null && (Object)(object)item2.m_from.m_itemData.m_dropPrefab != (Object)null && ((Object)item2.m_from.m_itemData.m_dropPrefab).name == nameIn)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				ItemDrop component2 = FindItem(nameIn).GetComponent<ItemDrop>();
				ItemDrop component3 = FindItem(nameOut).GetComponent<ItemDrop>();
				ItemConversion item = new ItemConversion
				{
					m_from = component2,
					m_to = component3,
					m_producedItems = amount
				};
				component.m_conversion.Add(item);
				return createConversionSingleLine(component2, component3, 0, amount);
			}
			return "";
		}

		private string CookingConversion(GameObject source, string nameIn, string nameOut, int time = 25)
		{
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			CookingStation component = source.GetComponent<CookingStation>();
			if ((Object)(object)component == (Object)null)
			{
				return "";
			}
			if (component.m_conversion == null)
			{
				component.m_conversion = new List<ItemConversion>();
			}
			bool flag = false;
			foreach (ItemConversion item2 in component.m_conversion)
			{
				if (item2 != null && (Object)(object)item2.m_from != (Object)null && item2.m_from.m_itemData != null && (Object)(object)item2.m_from.m_itemData.m_dropPrefab != (Object)null && ((Object)item2.m_from.m_itemData.m_dropPrefab).name == nameIn)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				ItemDrop component2 = FindItem(nameIn).GetComponent<ItemDrop>();
				ItemDrop component3 = FindItem(nameOut).GetComponent<ItemDrop>();
				ItemConversion item = new ItemConversion
				{
					m_from = component2,
					m_to = component3,
					m_cookTime = time
				};
				component.m_conversion.Add(item);
				return createConversionSingleLine(component2, component3, time);
			}
			return "";
		}
	}
	[Serializable]
	public class BalrondConverter : MonoBehaviour
	{
		[Serializable]
		public class ItemConversion
		{
			public ItemDrop m_from;

			public ItemDrop m_to;

			[Tooltip("How many of m_to to produce per 1 input")]
			public int m_count = 1;

			[Tooltip("Fuel units consumed per 1 input processed. Sawmill: 1. Tanning: bundles needed per hide.")]
			public int m_fuelCost = 1;

			[Tooltip("Seconds per product for THIS conversion. If 0, station uses m_defaultSecPerProduct (default 60).")]
			public float m_secPerProduct = 0f;
		}

		public string m_name = "BalrondConverter";

		public string prefabName = null;

		public string m_addOreTooltip = "$tag_sawmill_addWood";

		public string m_emptyOreTooltip = "$tag_sawmill_pickupWood";

		public Switch m_addWoodSwitch;

		public Switch m_addOreSwitch;

		public Switch m_emptyOreSwitch;

		public Transform m_outputPoint;

		public Transform m_roofCheckPoint;

		public GameObject m_enabledObject;

		public GameObject m_disabledObject;

		public GameObject m_haveFuelObject;

		public GameObject m_haveOreObject;

		public GameObject m_noOreObject;

		public Animator[] m_animators;

		[Header("Fuel")]
		public ItemDrop m_fuelItem;

		public int m_maxFuel = 1;

		public int m_usesPerBlade = 100;

		[Header("Input")]
		public int m_maxOre = 1;

		[Header("Timing")]
		public float m_defaultSecPerProduct = 60f;

		[Header("Output")]
		public bool m_spawnStack = true;

		public bool m_requiresRoof = false;

		public Windmill m_windmill;

		public SmokeSpawner m_smokeSpawner;

		public float m_addOreAnimationDuration;

		public List<ItemConversion> m_conversion = new List<ItemConversion>();

		public EffectList m_oreAddedEffects = new EffectList();

		public EffectList m_fuelAddedEffects = new EffectList();

		public EffectList m_produceEffects = new EffectList();

		private ZNetView m_nview;

		private float m_addedOreTime = -1000f;

		private readonly StringBuilder m_sb = new StringBuilder();

		private static readonly int s_fuelUnitsHash = BalrondHashCompat.StableHash("balrond_fuelUnits");

		private static readonly int s_currentOreHash = BalrondHashCompat.StableHash("balrond_currentOre");

		private static readonly int s_currentAmountHash = BalrondHashCompat.StableHash("balrond_currentAmount");

		private static readonly int s_jobOreHash = BalrondHashCompat.StableHash("balrond_jobOre");

		private static readonly int s_reservedFuelHash = BalrondHashCompat.StableHash("balrond_reservedFuel");

		private static readonly int s_startTimeHash = ZDOVars.s_startTime;

		private static readonly int s_accTimeHash = ZDOVars.s_accTime;

		private static readonly int s_bakeTimerHash = ZDOVars.s_bakeTimer;

		private static readonly int s_queuedHash = ZDOVars.s_queued;

		private void Awake()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			m_nview = ((Component)this).GetComponent<ZNetView>();
			if ((Object)(object)m_nview == (Object)null)
			{
				m_nview = ((Component)this).GetComponentInParent<ZNetView>();
			}
			if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid())
			{
				if (Object.op_Implicit((Object)(object)m_addOreSwitch))
				{
					Switch addOreSwitch = m_addOreSwitch;
					addOreSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)addOreSwitch.m_onUse, (Delegate?)new Callback(OnAddOre));
					m_addOreSwitch.m_onHover = new TooltipCallback(OnHoverAddOre);
				}
				if (Object.op_Implicit((Object)(object)m_addWoodSwitch))
				{
					Switch addWoodSwitch = m_addWoodSwitch;
					addWoodSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)addWoodSwitch.m_onUse, (Delegate?)new Callback(OnAddFuel));
					m_addWoodSwitch.m_onHover = new TooltipCallback(OnHoverAddFuel);
				}
				if (Object.op_Implicit((Object)(object)m_emptyOreSwitch))
				{
					Switch emptyOreSwitch = m_emptyOreSwitch;
					emptyOreSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)emptyOreSwitch.m_onUse, (Delegate?)new Callback(OnEmpty));
					Switch emptyOreSwitch2 = m_emptyOreSwitch;
					emptyOreSwitch2.m_onHover = (TooltipCallback)Delegate.Combine((Delegate?)(object)emptyOreSwitch2.m_onHover, (Delegate?)new TooltipCallback(OnHoverEmptyOre));
				}
				m_nview.Register<string>("AddOre", (Action<long, string>)RPC_AddOre);
				m_nview.Register("AddFuel", (Action<long>)RPC_AddFuel);
				m_nview.Register("ConverterEmptyProcessed", (Action<long>)RPC_ConverterEmptyProcessed);
				WearNTear component = ((Component)this).GetComponent<WearNTear>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.m_onDestroyed = (Action)Delegate.Combine(component.m_onDestroyed, new Action(OnDestroyed));
				}
				((MonoBehaviour)this).InvokeRepeating("UpdateBalrondConverter", 1f, 1f);
			}
		}

		private void EnsureConversionsLoaded()
		{
			if (m_conversion == null || m_conversion.Count <= 0)
			{
				if (prefabName == "piece_leatherRack_bal")
				{
					m_conversion = ConversionChanges.tanneryConverions;
				}
				else if (prefabName == "piece_sawmill_bal")
				{
					m_conversion = ConversionChanges.sawmillConverions;
				}
				else if (prefabName == "StoneboundKiln_bal")
				{
					m_conversion = ConversionChanges.stonekilnConverions;
				}
				if (m_conversion == null)
				{
					m_conversion = new List<ItemConversion>();
				}
			}
		}

		private int GetFuelUnits()
		{
			return (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid()) ? m_nview.GetZDO().GetInt(s_fuelUnitsHash, 0) : 0;
		}

		private void SetFuelUnits(int units)
		{
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid())
			{
				if (units < 0)
				{
					units = 0;
				}
				m_nview.GetZDO().Set(s_fuelUnitsHash, units, false);
			}
		}

		private int GetReservedFuelUnits()
		{
			return (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid()) ? m_nview.GetZDO().GetInt(s_reservedFuelHash, 0) : 0;
		}

		private void SetReservedFuelUnits(int units)
		{
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid())
			{
				if (units < 0)
				{
					units = 0;
				}
				m_nview.GetZDO().Set(s_reservedFuelHash, units, false);
			}
		}

		private int GetFuelUnitsCapacity()
		{
			int num = Mathf.Max(0, m_maxFuel);
			int num2 = Mathf.Max(1, m_usesPerBlade);
			return num * num2;
		}

		private bool HasAnyFuel()
		{
			return m_maxFuel == 0 || GetFuelUnits() > 0;
		}

		private string GetJobOre()
		{
			return (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid()) ? "" : m_nview.GetZDO().GetString(s_jobOreHash, "");
		}

		private void SetJobOre(string ore)
		{
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid())
			{
				m_nview.GetZDO().Set(s_jobOreHash, ore ?? "");
			}
		}

		private bool HasActiveJob()
		{
			return !string.IsNullOrEmpty(GetJobOre());
		}

		private int GetFuelCostForOre(string orePrefabName)
		{
			ItemConversion itemConversion = GetItemConversion(orePrefabName);
			if (itemConversion == null)
			{
				return 1;
			}
			return Mathf.Max(1, itemConversion.m_fuelCost);
		}

		private bool TryStartJobIfPossible()
		{
			if (HasActiveJob())
			{
				return true;
			}
			string queuedOre = GetQueuedOre();
			if (string.IsNullOrEmpty(queuedOre))
			{
				return false;
			}
			ItemConversion itemConversion = GetItemConversion(queuedOre);
			if (itemConversion == null)
			{
				ZLog.LogWarning((object)("[BalrondConverter] Missing conversion for '" + queuedOre + "', dropping it from queue."));
				RemoveOneOre();
				return false;
			}
			int num = Mathf.Max(1, itemConversion.m_fuelCost);
			if (m_maxFuel > 0 && GetFuelUnits() < num)
			{
				return false;
			}
			RemoveOneOre();
			SetJobOre(queuedOre);
			SetBakeTimer(0f);
			if (m_maxFuel > 0)
			{
				int fuelUnits = GetFuelUnits();
				SetFuelUnits(fuelUnits - num);
				SetReservedFuelUnits(GetReservedFuelUnits() + num);
			}
			return true;
		}

		private void CompleteJobAndSpawnOutput()
		{
			string jobOre = GetJobOre();
			if (!string.IsNullOrEmpty(jobOre))
			{
				SetReservedFuelUnits(0);
				QueueProcessed(jobOre);
				SetJobOre("");
				SetBakeTimer(0f);
			}
		}

		private int GetQueueSize()
		{
			return (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid()) ? m_nview.GetZDO().GetInt(s_queuedHash, 0) : 0;
		}

		private float GetBakeTimer()
		{
			return (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid()) ? 0f : m_nview.GetZDO().GetFloat(s_bakeTimerHash, 0f);
		}

		private void SetBakeTimer(float t)
		{
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid())
			{
				m_nview.GetZDO().Set(s_bakeTimerHash, t);
			}
		}

		private float GetAccumulator()
		{
			return (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid()) ? 0f : m_nview.GetZDO().GetFloat(s_accTimeHash, 0f);
		}

		private void SetAccumulator(float t)
		{
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid())
			{
				m_nview.GetZDO().Set(s_accTimeHash, t);
			}
		}

		private void QueueOre(string prefabName)
		{
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid())
			{
				int queueSize = GetQueueSize();
				m_nview.GetZDO().Set("item" + queueSize, prefabName);
				m_nview.GetZDO().Set(s_queuedHash, queueSize + 1, false);
			}
		}

		private string GetQueuedOre()
		{
			return (GetQueueSize() == 0 || !Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid()) ? "" : m_nview.GetZDO().GetString(ZDOVars.s_item0, "");
		}

		private string GetQueuedOreAt(int index)
		{
			if (index < 0 || !Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return "";
			}
			return m_nview.GetZDO().GetString("item" + index, "");
		}

		private void RemoveOneOre()
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return;
			}
			int queueSize = GetQueueSize();
			if (queueSize > 0)
			{
				for (int i = 0; i < queueSize; i++)
				{
					string @string = m_nview.GetZDO().GetString("item" + (i + 1), "");
					m_nview.GetZDO().Set("item" + i, @string);
				}
				m_nview.GetZDO().Set(s_queuedHash, queueSize - 1, false);
			}
		}

		private int GetProcessedQueueSize()
		{
			return (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid()) ? m_nview.GetZDO().GetInt(s_currentAmountHash, 0) : 0;
		}

		private void QueueProcessed(string fromOrePrefab)
		{
			ItemConversion itemConversion = GetItemConversion(fromOrePrefab);
			if (itemConversion == null)
			{
				ZLog.LogWarning((object)("[BalrondConverter] Missing conversion for '" + fromOrePrefab + "'"));
			}
			else if (!m_spawnStack)
			{
				Spawn(fromOrePrefab, itemConversion.m_count);
			}
			else
			{
				if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
				{
					return;
				}
				string @string = m_nview.GetZDO().GetString(s_currentOreHash, "");
				int @int = m_nview.GetZDO().GetInt(s_currentAmountHash, 0);
				if (!string.IsNullOrEmpty(@string))
				{
					if (@string != fromOrePrefab)
					{
						SpawnProcessed();
						m_nview.GetZDO().Set(s_currentOreHash, fromOrePrefab);
						m_nview.GetZDO().Set(s_currentAmountHash, itemConversion.m_count, false);
						return;
					}
					int num = @int + itemConversion.m_count;
					int num2 = itemConversion.m_to?.m_itemData?.m_shared?.m_maxStackSize ?? 1;
					if (num >= num2)
					{
						Spawn(fromOrePrefab, @int);
						Spawn(fromOrePrefab, itemConversion.m_count);
						m_nview.GetZDO().Set(s_currentOreHash, "");
						m_nview.GetZDO().Set(s_currentAmountHash, 0, false);
					}
					else
					{
						m_nview.GetZDO().Set(s_currentAmountHash, num, false);
					}
				}
				else
				{
					m_nview.GetZDO().Set(s_currentOreHash, fromOrePrefab);
					m_nview.GetZDO().Set(s_currentAmountHash, itemConversion.m_count, false);
				}
			}
		}

		private void SpawnProcessed()
		{
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid())
			{
				int @int = m_nview.GetZDO().GetInt(s_currentAmountHash, 0);
				if (@int > 0)
				{
					string @string = m_nview.GetZDO().GetString(s_currentOreHash, "");
					Spawn(@string, @int);
					m_nview.GetZDO().Set(s_currentOreHash, "");
					m_nview.GetZDO().Set(s_currentAmountHash, 0, false);
				}
			}
		}

		private void Spawn(string orePrefab, int stack)
		{
			//IL_002d: 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_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)
			ItemConversion itemConversion = GetItemConversion(orePrefab);
			if (itemConversion != null && !((Object)(object)itemConversion.m_to == (Object)null))
			{
				m_produceEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				GameObject val = Object.Instantiate<GameObject>(((Component)itemConversion.m_to).gameObject, m_outputPoint.position, m_outputPoint.rotation);
				ItemDrop component = val.GetComponent<ItemDrop>();
				if ((Object)(object)component != (Object)null)
				{
					component.m_itemData.m_stack = Mathf.Max(1, stack);
				}
			}
		}

		private bool IsItemAllowed(ItemData item)
		{
			return item != null && IsItemAllowed(((Object)item.m_dropPrefab).name);
		}

		private bool IsItemAllowed(string itemPrefabName)
		{
			foreach (ItemConversion item in m_conversion)
			{
				if ((Object)(object)item?.m_from != (Object)null && ((Object)((Component)item.m_from).gameObject).name == itemPrefabName)
				{
					return true;
				}
			}
			return false;
		}

		private ItemData FindProcessableItem(Inventory inventory)
		{
			foreach (ItemConversion item2 in m_conversion)
			{
				if (!((Object)(object)item2?.m_from == (Object)null))
				{
					ItemData item = inventory.GetItem(item2.m_from.m_itemData.m_shared.m_name, -1, false);
					if (item != null)
					{
						return item;
					}
				}
			}
			return null;
		}

		private ItemConversion GetItemConversion(string fromPrefabName)
		{
			foreach (ItemConversion item in m_conversion)
			{
				if ((Object)(object)item?.m_from != (Object)null && ((Object)((Component)item.m_from).gameObject).name == fromPrefabName)
				{
					return item;
				}
			}
			return null;
		}

		private float GetSecondsForConversion(string fromPrefabName)
		{
			float num = GetItemConversion(fromPrefabName)?.m_secPerProduct ?? 0f;
			if (num <= 0f)
			{
				num = m_defaultSecPerProduct;
			}
			if (num <= 0f)
			{
				num = 60f;
			}
			return num;
		}

		private bool OnAddOre(Switch sw, Humanoid user, ItemData item)
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return false;
			}
			if (GetQueueSize() >= m_maxOre)
			{
				((Character)user).Message((MessageType)2, "$msg_itsfull", 0, (Sprite)null);
				return false;
			}
			if (item != null && !IsItemAllowed(item))
			{
				((Character)user).Message((MessageType)2, "$msg_wontwork", 0, (Sprite)null);
				return false;
			}
			if (item == null)
			{
				item = FindProcessableItem(user.GetInventory());
				if (item == null)
				{
					((Character)user).Message((MessageType)2, "$msg_noprocessableitems", 0, (Sprite)null);
					return false;
				}
			}
			((Character)user).Message((MessageType)2, "$msg_added " + item.m_shared.m_name, 0, (Sprite)null);
			user.GetInventory().RemoveItem(item, 1);
			m_nview.InvokeRPC("AddOre", new object[1] { ((Object)item.m_dropPrefab).name });
			m_addedOreTime = Time.time;
			if (m_addOreAnimationDuration > 0f)
			{
				SetAnimation(active: true);
			}
			return true;
		}

		private void RPC_AddOre(long sender, string prefabNameToQueue)
		{
			//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.op_Implicit((Object)(object)m_nview) && m_nview.IsValid() && m_nview.IsOwner())
			{
				if (!IsItemAllowed(prefabNameToQueue))
				{
					ZLog.LogWarning((object)("[BalrondConverter] Item not allowed '" + prefabNameToQueue + "'"));
					return;
				}
				QueueOre(prefabNameToQueue);
				m_oreAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
			}
		}

		private bool OnAddFuel(Switch sw, Humanoid user, ItemData item)
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return false;
			}
			if (m_maxFuel == 0)
			{
				return false;
			}
			if ((Object)(object)m_fuelItem == (Object)null)
			{
				return false;
			}
			string name = ((Object)((Component)m_fuelItem).gameObject).name;
			string name2 = m_fuelItem.m_itemData.m_shared.m_name;
			if (item != null && ((Object)item.m_dropPrefab).name != name)
			{
				((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null);
				return false;
			}
			int fuelUnitsCapacity = GetFuelUnitsCapacity();
			int fuelUnits = GetFuelUnits();
			int num = Mathf.Max(1, m_usesPerBlade);
			if (fuelUnits > fuelUnitsCapacity - num)
			{
				((Character)user).Message((MessageType)2, "$msg_itsfull", 0, (Sprite)null);
				return false;
			}
			if (!user.GetInventory().HaveItem(name2, true))
			{
				((Character)user).Message((MessageType)2, "$msg_donthaveany " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null);
				return false;
			}
			((Character)user).Message((MessageType)2, "$msg_added " + m_fuelItem.m_itemData.m_shared.m_name, 0, (Sprite)null);
			user.GetInventory().RemoveItem(name2, 1, -1, true);
			m_nview.InvokeRPC("AddFuel", Array.Empty<object>());
			return true;
		}

		private void RPC_AddFuel(long sender)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid() && m_nview.IsOwner())
			{
				int num = Mathf.Max(1, m_usesPerBlade);
				int fuelUnitsCapacity = GetFuelUnitsCapacity();
				int fuelUnits = GetFuelUnits();
				fuelUnits = Mathf.Min(fuelUnitsCapacity, fuelUnits + num);
				SetFuelUnits(fuelUnits);
				m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1);
			}
		}

		private bool OnEmpty(Switch sw, Humanoid user, ItemData item)
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return false;
			}
			if (GetProcessedQueueSize() <= 0)
			{
				return false;
			}
			m_nview.InvokeRPC("ConverterEmptyProcessed", Array.Empty<object>());
			return true;
		}

		private void RPC_ConverterEmptyProcessed(long sender)
		{
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid() && m_nview.IsOwner())
			{
				SpawnProcessed();
			}
		}

		private double GetDeltaTime()
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid() || (Object)(object)ZNet.instance == (Object)null)
			{
				return 0.0;
			}
			DateTime time = ZNet.instance.GetTime();
			DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(s_startTimeHash, time.Ticks));
			double totalSeconds = (time - dateTime).TotalSeconds;
			m_nview.GetZDO().Set(s_startTimeHash, time.Ticks);
			return totalSeconds;
		}

		private void UpdateBalrondConverter()
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return;
			}
			UpdateState();
			if (!m_nview.IsOwner())
			{
				return;
			}
			double deltaTime = GetDeltaTime();
			float num = GetAccumulator() + (float)deltaTime;
			if (num > 3600f)
			{
				num = 3600f;
			}
			float num2 = (Object.op_Implicit((Object)(object)m_windmill) ? m_windmill.GetPowerOutput() : 1f);
			if (num2 <= 0f)
			{
				num2 = 0f;
			}
			while (num >= 1f)
			{
				num -= 1f;
				if (!HasActiveJob())
				{
					TryStartJobIfPossible();
				}
				string jobOre = GetJobOre();
				if (string.IsNullOrEmpty(jobOre))
				{
					continue;
				}
				float secondsForConversion = GetSecondsForConversion(jobOre);
				if (!(secondsForConversion <= 0f))
				{
					float num3 = 1f * num2;
					float num4 = GetBakeTimer() + num3;
					if (num4 < secondsForConversion)
					{
						SetBakeTimer(num4);
					}
					else
					{
						CompleteJobAndSpawnOutput();
					}
				}
			}
			if (GetQueuedOre() == "" && !HasActiveJob())
			{
				SpawnProcessed();
			}
			SetAccumulator(num);
		}

		private void UpdateState()
		{
			bool flag = IsActive();
			if (Object.op_Implicit((Object)(object)m_enabledObject))
			{
				m_enabledObject.SetActive(flag);
			}
			if (Object.op_Implicit((Object)(object)m_disabledObject))
			{
				m_disabledObject.SetActive(!flag);
			}
			if (Object.op_Implicit((Object)(object)m_haveFuelObject))
			{
				m_haveFuelObject.SetActive(HasAnyFuel() && !flag);
			}
			if (Object.op_Implicit((Object)(object)m_haveOreObject))
			{
				m_haveOreObject.SetActive(GetQueueSize() > 0 || HasActiveJob());
			}
			if (Object.op_Implicit((Object)(object)m_noOreObject))
			{
				m_noOreObject.SetActive(GetQueueSize() == 0 && !HasActiveJob());
			}
			if (m_addOreAnimationDuration > 0f && Time.time - m_addedOreTime < m_addOreAnimationDuration)
			{
				flag = true;
			}
			SetAnimation(flag);
		}

		private void SetAnimation(bool active)
		{
			if (m_animators == null)
			{
				return;
			}
			Animator[] animators = m_animators;
			foreach (Animator val in animators)
			{
				if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy)
				{
					val.SetBool("active", active);
					val.SetFloat("activef", active ? 1f : 0f);
				}
			}
		}

		public bool IsActive()
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return false;
			}
			if (!HasActiveJob() && GetQueueSize() <= 0)
			{
				return false;
			}
			if (HasActiveJob())
			{
				return true;
			}
			if (m_maxFuel == 0)
			{
				return true;
			}
			string queuedOre = GetQueuedOre();
			if (string.IsNullOrEmpty(queuedOre))
			{
				return false;
			}
			int fuelCostForOre = GetFuelCostForOre(queuedOre);
			return GetFuelUnits() >= fuelCostForOre;
		}

		private string OnHoverAddFuel()
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return Localization.instance.Localize(m_name);
			}
			string text = (Object.op_Implicit((Object)(object)m_fuelItem) ? m_fuelItem.m_itemData.m_shared.m_name : "Fuel");
			int perFuelItemUnits = GetPerFuelItemUnits();
			int fuelUnits = GetFuelUnits();
			int fuelUnitsCapacity = GetFuelUnitsCapacity();
			int queueSize = GetQueueSize();
			m_sb.Clear();
			m_sb.Append(m_name + "\n");
			m_sb.Append($"Fuel: {fuelUnits}/{fuelUnitsCapacity} units (+{perFuelItemUnits} per {text})");
			string queuedOre = GetQueuedOre();
			if (!string.IsNullOrEmpty(queuedOre))
			{
				string arg = GetItemConversion(queuedOre)?.m_from?.m_itemData?.m_shared?.m_name ?? queuedOre;
				int fuelCostForOre = GetFuelCostForOre(queuedOre);
				m_sb.Append($"\nNext: {arg} (cost {fuelCostForOre} units)");
				if (m_maxFuel > 0 && fuelUnits < fuelCostForOre)
				{
					m_sb.Append($"\nNeed {fuelCostForOre - fuelUnits} more units to start");
				}
				else if (queueSize > 0)
				{
					m_sb.Append("\nReady to start");
				}
			}
			else if (HasActiveJob())
			{
				string jobOre = GetJobOre();
				string text2 = GetItemConversion(jobOre)?.m_from?.m_itemData?.m_shared?.m_name ?? jobOre;
				m_sb.Append("\nProcessing: " + text2);
			}
			else if (prefabName == "piece_leatherRack_bal")
			{
				m_sb.Append("\nAdd a hide to see cost");
			}
			m_sb.Append("\n[<color=yellow><b>$KEY_Use</b></color>] Add " + text);
			return Localization.instance.Localize(m_sb.ToString());
		}

		private string OnHoverEmptyOre()
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return Localization.instance.Localize(m_name);
			}
			return Localization.instance.Localize($"{m_name} ({GetProcessedQueueSize()} Ready)\n" + "[<color=yellow><b>$KEY_Use</b></color>] " + m_emptyOreTooltip);
		}

		private string OnHoverAddOre()
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return Localization.instance.Localize(m_name);
			}
			int fuelUnits = GetFuelUnits();
			int fuelUnitsCapacity = GetFuelUnitsCapacity();
			int queueSize = GetQueueSize();
			m_sb.Clear();
			m_sb.Append($"{m_name} (Queue {queueSize}/{m_maxOre})");
			if (m_maxFuel > 0)
			{
				m_sb.Append($"\nFuel: {fuelUnits}/{fuelUnitsCapacity} units");
			}
			if (HasActiveJob())
			{
				string jobOre = GetJobOre();
				string arg = GetItemConversion(jobOre)?.m_from?.m_itemData?.m_shared?.m_name ?? jobOre;
				float secondsForConversion = GetSecondsForConversion(jobOre);
				m_sb.Append($"\nProcessing: {arg} ({Mathf.CeilToInt(secondsForConversion)}s)");
			}
			else
			{
				string queuedOre = GetQueuedOre();
				if (!string.IsNullOrEmpty(queuedOre))
				{
					string arg2 = GetItemConversion(queuedOre)?.m_from?.m_itemData?.m_shared?.m_name ?? queuedOre;
					int fuelCostForOre = GetFuelCostForOre(queuedOre);
					float secondsForConversion2 = GetSecondsForConversion(queuedOre);
					m_sb.Append($"\nNext: {arg2} (cost {fuelCostForOre} units, {Mathf.CeilToInt(secondsForConversion2)}s)");
					if (m_maxFuel > 0 && fuelUnits < fuelCostForOre)
					{
						m_sb.Append($"\nStatus: Need {fuelCostForOre - fuelUnits} more units");
					}
					else
					{
						m_sb.Append("\nStatus: Ready");
					}
				}
				else
				{
					m_sb.Append("\nStatus: " + m_addOreTooltip);
				}
			}
			m_sb.Append("\n[<color=yellow><b>$KEY_Use</b></color>] ");
			m_sb.Append(m_addOreTooltip);
			return Localization.instance.Localize(m_sb.ToString());
		}

		private int GetPerFuelItemUnits()
		{
			return Mathf.Max(1, m_usesPerBlade);
		}

		private void OnDestroyed()
		{
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid() && m_nview.IsOwner())
			{
				DropAllItems();
			}
		}

		private void DropAllItems()
		{
			//IL_0045: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			SpawnProcessed();
			string jobOre = GetJobOre();
			if (!string.IsNullOrEmpty(jobOre))
			{
				ItemConversion itemConversion = GetItemConversion(jobOre);
				if ((Object)(object)itemConversion?.m_from != (Object)null)
				{
					Vector3 val = ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f;
					Quaternion val2 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
					Object.Instantiate<GameObject>(((Component)itemConversion.m_from).gameObject, val, val2);
				}
				SetJobOre("");
				SetBakeTimer(0f);
			}
			if ((Object)(object)m_fuelItem != (Object)null && m_maxFuel > 0)
			{
				int num = GetFuelUnits() + GetReservedFuelUnits();
				SetFuelUnits(0);
				SetReservedFuelUnits(0);
				int num2 = Mathf.Max(1, m_usesPerBlade);
				int num3 = num / num2;
				for (int i = 0; i < num3; i++)
				{
					Vector3 val3 = ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f;
					Quaternion val4 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
					Object.Instantiate<GameObject>(((Component)m_fuelItem).gameObject, val3, val4);
				}
			}
			else
			{
				SetFuelUnits(0);
				SetReservedFuelUnits(0);
			}
			while (GetQueueSize() > 0)
			{
				string queuedOre = GetQueuedOre();
				RemoveOneOre();
				ItemConversion itemConversion2 = GetItemConversion(queuedOre);
				if ((Object)(object)itemConversion2?.m_from != (Object)null)
				{
					Vector3 val5 = ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f;
					Quaternion val6 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
					Object.Instantiate<GameObject>(((Component)itemConversion2.m_from).gameObject, val5, val6);
				}
			}
		}
	}
	public static class BalrondConverterInstaller
	{
		public const string SAWMILL_PREFAB = "piece_sawmill_bal";

		public const string TANNING_PREFAB = "piece_leatherRack_bal";

		public const string STONEKILN_PREFAB = "StoneboundKiln_bal";

		public const string SAWMILL_FUEL_PREFAB = "SawBlade_bal";

		public const string TANNING_FUEL_PREFAB = "PatchworkBundle_bal";

		public const string STONEKILN_FUEL_PREFAB = "SurtlingCore";

		public const string STONEKILN_WOOD_PREFAB = "WoodBundle_bal";

		public const string STONEKILN_CLAY_PREFAB = "ClayBundle_bal";

		private const int SAWMILL_MAX_FUEL_ITEMS = 1;

		private const int SAWMILL_USES_PER_FUEL_ITEM = 100;

		private const int SAWMILL_MAX_ORE = 10;

		private const float SAWMILL_DEFAULT_SECONDS = 60f;

		private const int STONEKILN_MAX_FUEL_ITEMS = 0;

		private const int STONEKILN_USES_PER_FUEL_ITEM = 100;

		private const int STONEKILN_MAX_ORE = 40;

		private const float STONEKILN_DEFAULT_SECONDS = 60f;

		private const int TANNING_MAX_FUEL_ITEMS = 25;

		private const int TANNING_USES_PER_FUEL_ITEM = 1;

		private const int TANNING_MAX_ORE = 5;

		private const float TANNING_DEFAULT_SECONDS = 60f;

		public static void SetBalrondConverter(ZNetScene zNetScene)
		{
			if ((Object)(object)zNetScene == (Object)null || zNetScene.m_prefabs == null)
			{
				Debug.LogWarning((object)"[Balrond] ZNetScene or prefabs list is null; cannot set up converters.");
				return;
			}
			GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "SawBlade_bal");
			GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "PatchworkBundle_bal");
			Dictionary<string, GameObject> prefabsByName = BuildPrefabMap(zNetScene.m_prefabs);
			SetupOneConverter(prefabsByName, zNetScene, "piece_sawmill_bal", ApplySawmillDefaults);
			SetupOneConverter(prefabsByName, zNetScene, "piece_leatherRack_bal", ApplyTanningDefaults);
			SetupOneConverter(prefabsByName, zNetScene, "StoneboundKiln_bal", ApplyStoneboudnKilnlDefaults);
		}

		private static Dictionary<string, GameObject> BuildPrefabMap(List<GameObject> prefabs)
		{
			Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>(StringComparer.Ordinal);
			for (int i = 0; i < prefabs.Count; i++)
			{
				GameObject val = prefabs[i];
				if (!((Object)(object)val == (Object)null) && !dictionary.ContainsKey(((Object)val).name))
				{
					dictionary.Add(((Object)val).name, val);
				}
			}
			return dictionary;
		}

		private static void SetupOneConverter(Dictionary<string, GameObject> prefabsByName, ZNetScene zNetScene, string stationPrefabName, Action<BalrondConverter, Dictionary<string, GameObject>> applyDefaults)
		{
			if (!prefabsByName.TryGetValue(stationPrefabName, out var value) || (Object)(object)value == (Object)null)
			{
				Debug.LogWarning((object)("[Balrond] Station prefab '" + stationPrefabName + "' not found in ZNetScene.m_prefabs."));
				return;
			}
			if ((Object)(object)value.GetComponent<BalrondConverter>() != (Object)null)
			{
				Debug.Log((object)("[Balrond] BalrondConverter already present on '" + stationPrefabName + "', skipping."));
				return;
			}
			Smelter component = value.GetComponent<Smelter>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogWarning((object)("[Balrond] Station prefab '" + stationPrefabName + "' has no Smelter component to transfer from."));
				return;
			}
			Debug.Log((object)("[Balrond] Installing BalrondConverter on '" + stationPrefabName + "'"));
			TransferSmelterToBalrondConverter(value, component, prefabsByName, stationPrefabName, zNetScene, applyDefaults);
		}

		private static void TransferSmelterToBalrondConverter(GameObject stationPrefab, Smelter smelter, Dictionary<string, GameObject> prefabsByName, string stationPrefabName, ZNetScene zNetScene, Action<BalrondConverter, Dictionary<string, GameObject>> applyDefaults)
		{
			BalrondConverter balrondConverter = stationPrefab.AddComponent<BalrondConverter>();
			GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "SawBlade_bal");
			GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "SurtlingCore");
			GameObject val3 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == "PatchworkBundle_bal");
			if (stationPrefabName == "piece_leatherRack_bal")
			{
				balrondConverter.m_fuelItem = val3.GetComponent<ItemDrop>();
			}
			if (stationPrefabName == "piece_sawmill_bal")
			{
				balrondConverter.m_fuelItem = val.GetComponent<ItemDrop>();
			}
			if (stationPrefabName == "StoneboundKiln_bal")
			{
				balrondConverter.m_fuelItem = val2.GetComponent<ItemDrop>();
			}
			balrondConverter.m_addOreAnimationDuration = 0f;
			balrondConverter.m_addOreSwitch = smelter.m_addOreSwitch;
			balrondConverter.m_addOreTooltip = smelter.m_addOreTooltip;
			balrondConverter.m_addWoodSwitch = smelter.m_addWoodSwitch;
			balrondConverter.m_emptyOreSwitch = smelter.m_emptyOreSwitch;
			balrondConverter.m_emptyOreTooltip = smelter.m_emptyOreTooltip;
			balrondConverter.m_animators = smelter.m_animators;
			balrondConverter.m_enabledObject = smelter.m_enabledObject;
			balrondConverter.m_disabledObject = smelter.m_disabledObject;
			balrondConverter.m_haveFuelObject = smelter.m_haveFuelObject;
			balrondConverter.m_haveOreObject = smelter.m_haveOreObject;
			balrondConverter.m_noOreObject = smelter.m_noOreObject;
			balrondConverter.m_outputPoint = smelter.m_outputPoint;
			balrondConverter.m_roofCheckPoint = smelter.m_roofCheckPoint;
			balrondConverter.m_requiresRoof = smelter.m_requiresRoof;
			balrondConverter.m_windmill = smelter.m_windmill;
			balrondConverter.m_smokeSpawner = smelter.m_smokeSpawner;
			balrondConverter.m_spawnStack = smelter.m_spawnStack;
			balrondConverter.m_oreAddedEffects = smelter.m_oreAddedEffects;
			balrondConverter.m_fuelAddedEffects = smelter.m_fuelAddedEffects;
			balrondConverter.m_produceEffects = smelter.m_produceEffects;
			balrondConverter.m_name = smelter.m_name;
			balrondConverter.m_defaultSecPerProduct = ((smelter.m_secPerProduct > 0f) ? smelter.m_secPerProduct : 60f);
			Object.DestroyImmediate((Object)(object)smelter);
			applyDefaults?.Invoke(balrondConverter, prefabsByName);
			balrondConverter.prefabName = stationPrefabName;
		}

		private static void DebugFuel(BalrondConverter conv, string fuelItem)
		{
			if (conv.m_maxFuel > 0 && (Object)(object)conv.m_fuelItem == (Object)null)
			{
				Debug.LogWarning((object)("[Balrond] " + fuelItem + " fuel item not found." + conv.m_name + " will not accept fuel."));
			}
		}

		private static void ApplySawmillDefaults(BalrondConverter conv, Dictionary<string, GameObject> prefabsByName)
		{
			conv.m_maxFuel = 1;
			conv.m_usesPerBlade = 100;
			conv.m_maxOre = 10;
			conv.m_defaultSecPerProduct = 60f;
			conv.m_addOreTooltip = "$tag_sawmill_addWood";
			conv.m_emptyOreTooltip = "$tag_sawmill_pickupWood";
			DebugFuel(conv, "SawBlade_bal");
		}

		private static void ApplyStoneboudnKilnlDefaults(BalrondConverter conv, Dictionary<string, GameObject> prefabsByName)
		{
			conv.m_maxFuel = 0;
			conv.m_usesPerBlade = 100;
			conv.m_maxOre = 40;
			conv.m_defaultSecPerProduct = 60f;
			DebugFuel(conv, "SurtlingCore");
		}

		private static void ApplyTanningDefaults(BalrondConverter conv, Dictionary<string, GameObject> prefabsByName)
		{
			conv.m_maxFuel = 25;
			conv.m_usesPerBlade = 1;
			conv.m_maxOre = 5;
			conv.m_defaultSecPerProduct = 60f;
			conv.m_addOreTooltip = "$tag_leatherrack_addLeather";
			conv.m_emptyOreTooltip = "$tag_leatherrack_pickupLeather";
			DebugFuel(conv, "PatchworkBundle_bal");
		}
	}
	public class DatabaseAddMethods
	{
		public void AddItems(List<GameObject> items)
		{
			foreach (GameObject item in items)
			{
				AddItem(item);
			}
		}

		public void AddRecipes(List<Recipe> recipes)
		{
			foreach (Recipe recipe in recipes)
			{
				AddRecipe(recipe);
			}
		}

		public void AddStatuseffects(List<StatusEffect> statusEffects)
		{
			foreach (StatusEffect statusEffect in statusEffects)
			{
				AddStatus(statusEffect);
			}
		}

		private bool IsObjectDBValid()
		{
			return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
		}

		private void AddStatus(StatusEffect status)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			if ((Object)(object)status != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.GetStatusEffect(status.m_nameHash) == (Object)null)
				{
					ObjectDB.instance.m_StatusEffects.Add(status);
				}
			}
			else
			{
				Debug.LogError((object)(Launch.projectName + ":  " + ((Object)status).name + " - Status not found"));
			}
		}

		private void AddRecipe(Recipe recipe)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			if ((Object)(object)recipe != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.m_recipes.Find((Recipe x) => ((Object)x).name == ((Object)recipe).name) == (Object)null && (Object)(object)recipe.m_item != (Object)null)
				{
					ObjectDB.instance.m_recipes.Add(recipe);
				}
			}
			else
			{
				Debug.LogError((object)(Launch.projectName + ":  " + ((Object)recipe).name + " - Recipe not found"));
			}
		}

		private void AddItem(GameObject newPrefab)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			ItemDrop component = newPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				if ((Object)(object)O