Decompiled source of balrond amazing nature v0.6.2

plugins/BalrondAmazingNature.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 BalrondNature.CustomComponents;
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("BalrondNature")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BalrondNature")]
[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 class OfferingStation : MonoBehaviour, Hoverable, Interactable
{
	public string m_name = "Offer station";

	public string m_useItemText = "Use";

	public ItemDrop m_requiredItem;

	public int m_requiredItemAmount = 1;

	public string m_statusEffectName = "";

	public bool m_spawnStatusEffect = true;

	public GameObject m_aoePrefab;

	public GameObject m_spawnPoint = null;

	public bool m_spawnItem = false;

	public ItemDrop m_itemPrefab;

	public Transform m_itemSpawnPoint;

	public string m_setGlobalKey = "";

	public float m_SpawnDelay = 2f;

	public float m_spawnOffset = 0f;

	[Header("Effects")]
	public EffectList m_fuelAddedEffects = new EffectList();

	public EffectList m_spawnStartEffects = new EffectList();

	public EffectList m_spawnFinishEffects = new EffectList();

	public GameObject m_enabledObject;

	public GameObject m_disabledObject;

	public GameObject m_haveFuelObject;

	public Transform m_roofCheckPoint;

	public bool m_requiresRoof = false;

	public bool m_canBeOutside = true;

	public Switch m_addWoodSwitch;

	public bool m_useFuel = false;

	public ItemDrop m_fuelItem;

	public int m_maxFuel = 0;

	public float m_secPerFuel = 2000f;

	public bool m_requireFire = false;

	public Transform[] m_fireCheckPoints;

	public float m_fireCheckRadius = 0.25f;

	private bool m_blockedSmoke;

	public SmokeSpawner m_smokeSpawner;

	public Animator[] m_animators;

	private ZNetView m_nview;

	private string m_requiredItemName;

	private void Awake()
	{
		m_nview = ((Component)this).GetComponent<ZNetView>();
		if ((Object)(object)m_nview == (Object)null || m_nview.GetZDO() == null)
		{
			ZLog.Log((object)"Missing ZnetView Component");
			return;
		}
		validateAoe();
		m_requiredItemName = m_requiredItem.m_itemData.m_shared.m_name;
		if (Object.op_Implicit((Object)(object)m_addWoodSwitch))
		{
		}
		((MonoBehaviour)this).InvokeRepeating("UpdateOfferingStation", 1f, 1f);
	}

	private bool validateAoe()
	{
		if ((Object)(object)m_aoePrefab.GetComponent<Aoe>() == (Object)null)
		{
			ZLog.Log((object)"m_aoePrefab Missing Aoe Component");
			return false;
		}
		return true;
	}

	public string GetHoverText()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false))
		{
			return Localization.instance.Localize(m_name + "\n$piece_noaccess");
		}
		return Localization.instance.Localize(m_name + "\n[<color=yellow><b>1-8</b></color>] \n" + m_useItemText) + " " + Localization.instance.Localize(((Component)m_requiredItem).GetComponent<ItemDrop>().m_itemData.m_shared.m_name) + " amount: " + m_requiredItemAmount;
	}

	public string GetHoverName()
	{
		return m_name;
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		if (hold || IsSpawnQueued())
		{
			return false;
		}
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return true;
		}
		if (m_blockedSmoke)
		{
			((Character)user).Message((MessageType)2, "Smoke blocked", 0, (Sprite)null);
			return false;
		}
		if (!IsActive())
		{
			return false;
		}
		if (Spawn(GetSpawnPosition()))
		{
			((Character)user).Message((MessageType)2, "$msg_offerdone", 0, (Sprite)null);
			if (Object.op_Implicit((Object)(object)m_itemSpawnPoint))
			{
				m_fuelAddedEffects.Create(m_itemSpawnPoint.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
			}
		}
		return true;
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		if (IsSpawnQueued())
		{
			return true;
		}
		if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
		{
			return true;
		}
		if (m_blockedSmoke)
		{
			((Character)user).Message((MessageType)2, "Smoke blocked", 0, (Sprite)null);
			return false;
		}
		if (!IsActive())
		{
			return false;
		}
		if ((Object)(object)m_requiredItem == (Object)null)
		{
			return false;
		}
		if (item.m_shared.m_name == m_requiredItemName)
		{
			int num = user.GetInventory().CountItems(m_requiredItemName, -1, true);
			if (num < m_requiredItemAmount)
			{
				((Character)user).Message((MessageType)2, "$msg_incompleteoffering: " + Localization.instance.Localize(m_requiredItemName) + " " + num + " / " + m_requiredItemAmount, 0, (Sprite)null);
				return true;
			}
			if (m_spawnStatusEffect && (Object)(object)m_aoePrefab == (Object)null)
			{
				Debug.LogWarning((object)"Missing Status Effect Prefab[AoE]");
				return true;
			}
			if (m_spawnItem && (Object)(object)m_itemPrefab == (Object)null)
			{
				Debug.LogWarning((object)"Missing ItemDrop Prefab");
				return true;
			}
			bool flag = false;
			if (((Object)(object)m_aoePrefab != (Object)null && m_spawnStatusEffect) || ((Object)(object)m_itemPrefab != (Object)null && m_spawnItem))
			{
				flag = Spawn(GetSpawnPosition());
			}
			if (flag)
			{
				user.GetInventory().RemoveItem(item.m_shared.m_name, m_requiredItemAmount, -1, true);
				((Character)user).ShowRemovedMessage(m_requiredItem.m_itemData, m_requiredItemAmount);
				((Character)user).Message((MessageType)2, "$msg_offerdone", 0, (Sprite)null);
				if (Object.op_Implicit((Object)(object)m_itemSpawnPoint))
				{
					m_fuelAddedEffects.Create(m_itemSpawnPoint.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				}
				if (!string.IsNullOrEmpty(m_setGlobalKey))
				{
					ZoneSystem.instance.SetGlobalKey(m_setGlobalKey);
				}
			}
			return flag;
		}
		((Character)user).Message((MessageType)2, "$msg_offerwrong", 0, (Sprite)null);
		return true;
	}

	public bool IsActive()
	{
		return (m_maxFuel == 0 || (double)GetFuel() > 0.0) && !m_blockedSmoke;
	}

	private void UpdateGameObjectState()
	{
		bool flag = IsActive();
		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((double)GetFuel() > 0.0);
		}
		SetAnimation(flag);
	}

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

	private float GetDeltaTime()
	{
		DateTime time = ZNet.instance.GetTime();
		DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong("StartTime", time.Ticks));
		double totalSeconds = (time - dateTime).TotalSeconds;
		m_nview.GetZDO().Set("StartTime", time.Ticks);
		return (float)totalSeconds;
	}

	private void UpdateFuel(float dt)
	{
		if (m_useFuel)
		{
			float num = dt / m_secPerFuel;
			float num2 = GetFuel() - num;
			if ((double)num2 < 0.0)
			{
				num2 = 0f;
			}
			SetFuel(num2);
		}
	}

	private void RPC_AddFuel(long sender)
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		if (m_nview.IsOwner())
		{
			SetFuel(GetFuel() + 1f);
			m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1);
		}
	}

	private void UpdateOfferingStation()
	{
		if (m_nview.IsValid())
		{
		}
	}

	private Vector3 GetSpawnPosition()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		return ((Object)(object)m_spawnPoint != (Object)null) ? m_spawnPoint.transform.position : ((Component)this).transform.position;
	}

	private bool Spawn(Vector3 point)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		m_spawnStartEffects.Create(point, Quaternion.identity, (Transform)null, 1f, -1);
		((MonoBehaviour)this).Invoke("DelayedSpawn", m_SpawnDelay);
		return true;
	}

	private void UpdateSmoke()
	{
		if ((Object)(object)m_smokeSpawner != (Object)null)
		{
			m_blockedSmoke = m_smokeSpawner.IsBlocked();
		}
		else
		{
			m_blockedSmoke = false;
		}
	}

	private float GetFuel()
	{
		return m_nview.GetZDO().GetFloat("fuel", 0f);
	}

	private void SetFuel(float fuel)
	{
		m_nview.GetZDO().Set("fuel", fuel);
	}

	private bool OnAddFuel(Switch sw, Humanoid user, ItemData item)
	{
		if (!m_useFuel)
		{
			((Character)user).Message((MessageType)2, "No fuel required", 0, (Sprite)null);
			return false;
		}
		if (item != null && item.m_shared.m_name != m_fuelItem.m_itemData.m_shared.m_name)
		{
			((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null);
			return false;
		}
		if (!user.GetInventory().HaveItem(m_fuelItem.m_itemData.m_shared.m_name, 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(m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true);
		m_nview.InvokeRPC("AddFuel", Array.Empty<object>());
		return true;
	}

	private bool IsSpawnQueued()
	{
		return ((MonoBehaviour)this).IsInvoking("DelayedSpawn");
	}

	private void DelayedSpawn()
	{
		//IL_0013: 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_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		if (m_spawnStatusEffect)
		{
			Aoe component = Object.Instantiate<GameObject>(m_aoePrefab, GetSpawnPosition(), Quaternion.identity).GetComponent<Aoe>();
			component.m_statusEffect = m_statusEffectName;
		}
		if (m_spawnItem)
		{
			Object.Instantiate<GameObject>(((Component)m_itemPrefab).gameObject, GetSpawnPosition(), Quaternion.identity);
		}
		m_spawnFinishEffects.Create(GetSpawnPosition(), Quaternion.identity, (Transform)null, 1f, -1);
	}
}
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 BalrondNature
{
	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)
		{
			Dictionary<string, string> result = null;
			try
			{
				result = translations[language];
			}
			catch (Exception)
			{
			}
			return result;
		}
	}
	internal class ClutterList
	{
		public static string[] clutter = new string[96]
		{
			"ormbunke_bal", "magicGrass1", "magicGrass2", "DesertPlant6_1", "DesertPlant6_2", "DesertPlant6_3", "StalagmiteFloor_1", "StalagmiteFloor_2", "StalagmiteFloor_3", "StalagmiteFloor_4",
			"Mushroom_52", "Mushroom_51", "iceweed1", "iceweed2", "iceweed3", "iceweed4", "Mushroom_6G3", "Mushroom_6G2", "Mushroom_3G1", "Mushroom_3G2",
			"Mushroom_3G3", "Mushroom_31", "Mushroom_32", "Mushroom_33", "Mushroom_34", "Mushroom_35", "IvyLowerF1", "IvyLowerF2", "IvyLowerF3", "mistlandsBush6",
			"PlantG6", "PlantG7", "PlantG8", "seaBush10", "seaBush11", "seaBush6", "seaBush8", "seaBush9", "Seaweed2_1", "Seaweed2_2",
			"Seaweed2_3", "AshGrass 1", "AshGrass 2", "AshGrass 3", "DeepNorthGrass", "DesertPlantsGrassCurl_1", "DesertPlantsGrassCurl_2", "DesertPlantsGrassCurl_3", "Coral1_Bowl_1", "Coral1_Bowl_2",
			"CoralTussocks1_1", "CoralTussocks1_2", "CoralTussocks1_G1", "SeaweedAshlands1", "SeaweedAshlands2", "SeaweedAshlands3", "Tentacles 1", "Tentacles 2", "Tentacles 3", "plant_dn1",
			"plant_dn2", "plant_dn3", "plant_dn4", "plant_dn5", "plant_dn6", "Coral4_G1", "Coral4_G2", "Coral_dn1", "Coral_dn2", "Coral_dn3",
			"Coral_dn4", "PlantG17_1", "PlantG17_1_F", "PlantG17_2", "PlantG17_2_F", "PlantG_19", "PlantGS4_1", "PlantFlowerF7_1", "PlantFlowerF7_2", "PlantFlowerF7_3",
			"PlantFlowerS8_1", "PlantFlower2_1", "PlantFlower2_2", "PlantFlower2_3", "Swampy1", "Swampy2", "Swampy3", "Swampy4", "Swampy5", "Swampy6",
			"Swampy7", "Swampy8", "Swampy9", "Swampy10", "Swampy11", "Swampy12"
		};
	}
	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>();

		private string[] buildPiecesNames = 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"
		};

		public void editBuidlPieces(List<GameObject> allprefabs)
		{
			buildPieces = allprefabs;
			items = allprefabs;
			editFermenter();
			editOven();
			editKiln();
			editWHeel();
			editWIndMIll();
			editSap();
			editBeehive();
			editSmelter();
			editComposter();
			editFurnace();
			editRefinery();
			editCooking();
			editIronCooking();
			editSawMill();
			editLeatherRack();
			EditRecipes();
		}

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

		private void changeBuildPiece(GameObject buildPiece)
		{
			switch (((Object)buildPiece).name)
			{
			case "portal_wood":
				ChangeRecipe(buildPiece);
				break;
			case "forge":
			case "piece_workbench":
			case "blackforge":
			case "piece_magetable":
			case "piece_artisanstation":
			case "piece_stonecutter":
				ChcangeCraftingStation(buildPiece, requireRoof: false);
				break;
			case "piece_banner01":
			case "piece_banner02":
			case "piece_banner03":
			case "piece_banner04":
			case "piece_banner05":
			case "piece_banner06":
			case "piece_banner07":
			case "piece_banner08":
			case "piece_banner09":
			case "piece_banner10":
			case "piece_banner11":
				setBannerRecipe(buildPiece);
				break;
			}
		}

		private void setBannerRecipe(GameObject gameObject)
		{
			Piece component = gameObject.GetComponent<Piece>();
			component.m_resources = createResources(gameObject);
		}

		private void ChangeChest(GameObject gameObject, int height, int width)
		{
			Container component = gameObject.GetComponent<Container>();
			component.m_width = width;
			component.m_height = height;
		}

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

		private GameObject FindBuildPiece(string name)
		{
			return buildPieces.Find((GameObject x) => ((Object)x).name == name);
		}

		private void ChangeRecipe(GameObject gameObject)
		{
			Piece component = gameObject.GetComponent<Piece>();
			component.m_resources = createResources(gameObject);
		}

		private Requirement[] createResources(GameObject item)
		{
			List<Requirement> list = new List<Requirement>();
			switch (((Object)item).name)
			{
			case "portal_wood":
				list.Add(createReq("FineWood", 16, 0));
				list.Add(createReq("SurtlingCore", 4, 0));
				list.Add(createReq("GreydwarfEye", 10, 0));
				list.Add(createReq("Ruby", 1, 0));
				break;
			case "piece_banner01":
			case "piece_banner02":
			case "piece_banner03":
			case "piece_banner04":
			case "piece_banner05":
			case "piece_banner06":
			case "piece_banner07":
			case "piece_banner08":
			case "piece_banner09":
			case "piece_banner10":
			case "piece_banner11":
				list.Add(createReq("DyeKit_bal", 1, 0));
				list.Add(createReq("FineWood", 2, 0));
				list.Add(createReq("LeatherScraps", 3, 0));
				list.Add(createReq("StrawThread_bal", 3, 0));
				break;
			}
			return list.ToArray();
		}

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

		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");
		}

		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>();
			}
			leatherRack.m_conversion.Clear();
			leatherRack.m_conversion = new List<BalrondConverter.ItemConversion>();
			addConversion(((Component)leatherRack).gameObject, "PatchworkDeer_bal", "DeerHide", ConversionType.balrondConverter, 30, 2);
			addConversion(((Component)leatherRack).gameObject, "PatchworkBoar_bal", "BoarHide_bal", ConversionType.balrondConverter, 30, 2);
			addConversion(((Component)leatherRack).gameObject, "PatchworkTroll_bal", "TrollHide", ConversionType.balrondConverter, 30, 2);
			addConversion(((Component)leatherRack).gameObject, "PatchworkWolf_bal", "WolfPelt", ConversionType.balrondConverter, 30, 2);
			addConversion(((Component)leatherRack).gameObject, "PatchworkLox_bal", "LoxPelt", ConversionType.balrondConverter, 30, 2);
			addConversion(((Component)leatherRack).gameObject, "PatchworkAsk_bal", "AskHide", ConversionType.balrondConverter, 30, 2);
		}

		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>();
			}
			text += addConversion(((Component)composter).gameObject, "TrophyAbomination", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyBlob", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyBoar", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyBonemass", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyCultist", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyDeathsquito", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyDeer", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyDragonQueen", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyDraugr", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyDraugrElite", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyDvergr", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyEikthyr", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyFenring", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyFrostTroll", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyGjall", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyGoblin", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyGoblinBrute", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyGoblinKing", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyGoblinShaman", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyGreydwarf", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyGreydwarfBrute", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyGreydwarfShaman", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyGrowth", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyHare", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyHatchling", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyLeech", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyLox", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyNeck", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophySeeker", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophySeekerBrute", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophySeekerQueen", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophySerpent", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophySGolem", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophySkeleton", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophySkeletonPoison", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophySurtling", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyTheElder", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyTick", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyUlv", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyWolf", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "TrophyWraith", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "RottenMeat", "EnrichedSoil_bal", ConversionType.smelter);
			text += addConversion(((Component)composter).gameObject, "Pukeberries", "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 (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 += addConversion(((Component)smelter).gameObject, "CopperOre", "Copper", 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);
		}

		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 (furnace.m_maxFuel == 20)
			{
				furnace.m_maxFuel = 60;
			}
			if (furnace.m_maxOre == 10)
			{
				furnace.m_maxOre = 30;
			}
			if (furnace.m_secPerProduct == 30f)
			{
				furnace.m_secPerProduct = 20f;
			}
			if (furnace.m_conversion == null)
			{
				furnace.m_conversion = new List<ItemConversion>();
			}
			removeConversionFromSmelter("BlackMetalScrap", furnace.m_conversion);
			text += addConversion(((Component)furnace).gameObject, "CopperOre", "Copper", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "TinOre", "Tin", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "NickelOre_bal", "Nickel_bal", 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, "GoldOre_bal", "GoldBar_bal", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "BlackMetalOre_bal", "BlackMetal", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "DarkIron_bal", "DarkSteel_bal", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "CobaltOre_bal", "Cobalt_bal", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "FlametalOre", "Flametal", ConversionType.smelter);
			text += addConversion(((Component)furnace).gameObject, "FlametalOreNew", "FlametalNew", ConversionType.smelter);
			buildConversionStationTutorialTag(((Component)furnace).gameObject, text);
		}

		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>();
			}
			sawmill.m_conversion.Clear();
			sawmill.m_conversion = new List<BalrondConverter.ItemConversion>();
			text += addConversion(((Component)sawmill).gameObject, "RoundLog", "Wood", ConversionType.balrondConverter, 30, 3);
			text += addConversion(((Component)sawmill).gameObject, "FineWood", "Wood", ConversionType.balrondConverter, 30, 4);
			text += addConversion(((Component)sawmill).gameObject, "ElderBark", "Wood", ConversionType.balrondConverter, 30, 2);
			text += addConversion(((Component)sawmill).gameObject, "HardWood_bal", "FineWood", ConversionType.balrondConverter, 35, 3);
			text += addConversion(((Component)sawmill).gameObject, "SoftWood_bal", "FineWood", ConversionType.balrondConverter, 35, 2);
			text += addConversion(((Component)sawmill).gameObject, "YggdrasilWood", "SoftWood_bal", ConversionType.balrondConverter, 35, 3);
			text += addConversion(((Component)sawmill).gameObject, "Blackwood", "FineWood", ConversionType.balrondConverter, 35, 4);
			text += addConversion(((Component)sawmill).gameObject, "EmberWood_bal", "YggdrasilWood", ConversionType.balrondConverter, 40, 2);
			text += addConversion(((Component)sawmill).gameObject, "CrystalWood_bal", "HardWood_bal", ConversionType.balrondConverter, 40, 2);
			buildConversionStationTutorialTag(((Component)sawmill).gameObject, text);
		}

		public void editFermenter(Fermenter fermenter = null)
		{
			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;
		}

		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);
			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);
			text += addConversion(((Component)cookingStation).gameObject, "RawSteak_bal", "SteakCooked_bal", ConversionType.cooking);
			text += addConversion(((Component)cookingStation).gameObject, "SharkMeat_bal", "SharkMeatCooked_bal", ConversionType.cooking, 35);
			text += addConversion(((Component)cookingStation).gameObject, "CrabLegs_bal", "CrabLegsCooked_bal", ConversionType.cooking);
			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);
			text += addConversion(((Component)cookingStation).gameObject, "FenringMeat_bal", "FenringMeatCooked_bal", ConversionType.cooking, 60);
			text += addConversion(((Component)cookingStation).gameObject, "RawCrowMeat_bal", "CookedCrowMeat_bal", ConversionType.cooking);
			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);
			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;
			}
			text += addConversion(((Component)windmill).gameObject, "Coal", "CoalPowder_bal", ConversionType.smelter);
			text += addConversion(((Component)windmill).gameObject, "OilBase_bal", "Oil_bal", ConversionType.smelter);
			buildConversionStationTutorialTag(((Component)windmill).gameObject, text);
		}

		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>();
			}
			if (kiln.m_maxOre == 25)
			{
				kiln.m_maxOre = 50;
			}
			if (kiln.m_secPerProduct == 15f)
			{
				kiln.m_secPerProduct = 10f;
			}
			kiln.m_addOreTooltip = "$piece_smelter_add";
			text += addConversion(((Component)kiln).gameObject, "TarBase_bal", "Tar", ConversionType.smelter);
			text += addConversion(((Component)kiln).gameObject, "Moss_bal", "Coal", ConversionType.smelter);
			text += addConversion(((Component)kiln).gameObject, "Clay_bal", "ClayBrick_bal", ConversionType.smelter);
			text += addConversion(((Component)kiln).gameObject, "CeramicMold_bal", "CeramicPlate", ConversionType.smelter);
			buildConversionStationTutorialTag(((Component)kiln).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 string addConversion(GameObject source, string nameIn, string nameOut, ConversionType type, int time = 30, int amount = 5)
		{
			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);
				break;
			}
			return result;
		}

		private void buildConversionStationTutorialTag(GameObject gameObject, string tutorialExtra)
		{
			//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 = "workbench";
			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, List<GameObject> list = null)
		{
			BalrondConverter component = source.GetComponent<BalrondConverter>();
			string result = "";
			List<BalrondConverter.ItemConversion> source2 = new List<BalrondConverter.ItemConversion>();
			if (component.m_conversion.Count() != 0)
			{
				List<BalrondConverter.ItemConversion> list2 = component.m_conversion.FindAll((BalrondConverter.ItemConversion x) => (Object)(object)x.m_from != (Object)null);
				List<BalrondConverter.ItemConversion> list3 = list2.FindAll((BalrondConverter.ItemConversion x) => x.m_from.m_itemData != null);
				List<BalrondConverter.ItemConversion> list4 = list3.FindAll((BalrondConverter.ItemConversion x) => (Object)(object)x.m_from.m_itemData.m_dropPrefab != (Object)null);
				source2 = list4.FindAll((BalrondConverter.ItemConversion x) => ((Object)x.m_from.m_itemData.m_dropPrefab).name != nameIn);
			}
			if (source2.Count() == 0)
			{
				BalrondConverter.ItemConversion itemConversion = new BalrondConverter.ItemConversion();
				itemConversion.m_from = FindItem(nameIn).GetComponent<ItemDrop>();
				itemConversion.m_to = FindItem(nameOut).GetComponent<ItemDrop>();
				result = createConversionSingleLine(itemConversion.m_from, itemConversion.m_to, 0, amount);
				itemConversion.m_count = amount;
				component.m_conversion.Add(itemConversion);
			}
			return result;
		}

		private string SmelterConversion(GameObject source, string nameIn, string nameOut)
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			string result = "";
			Smelter component = source.GetComponent<Smelter>();
			List<ItemConversion> source2 = new List<ItemConversion>();
			if (component.m_conversion.Count() != 0)
			{
				List<ItemConversion> list = component.m_conversion.FindAll((ItemConversion x) => (Object)(object)x.m_from != (Object)null);
				List<ItemConversion> list2 = list.FindAll((ItemConversion x) => x.m_from.m_itemData != null);
				List<ItemConversion> list3 = list2.FindAll((ItemConversion x) => (Object)(object)x.m_from.m_itemData.m_dropPrefab != (Object)null);
				source2 = list3.FindAll((ItemConversion x) => ((Object)x.m_from.m_itemData.m_dropPrefab).name != nameIn);
			}
			if (source2.Count() == 0)
			{
				ItemConversion val = new ItemConversion();
				val.m_from = FindItem(nameIn).GetComponent<ItemDrop>();
				val.m_to = FindItem(nameOut).GetComponent<ItemDrop>();
				result = createConversionSingleLine(val.m_from, val.m_to);
				component.m_conversion.Add(val);
			}
			return result;
		}

		private string FermenterConversion(GameObject source, string nameIn, string nameOut, int amount = 1)
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			Fermenter component = source.GetComponent<Fermenter>();
			string result = "";
			List<ItemConversion> source2 = new List<ItemConversion>();
			if (component.m_conversion.Count() != 0)
			{
				List<ItemConversion> list = component.m_conversion.FindAll((ItemConversion x) => (Object)(object)x.m_from != (Object)null);
				List<ItemConversion> list2 = list.FindAll((ItemConversion x) => x.m_from.m_itemData != null);
				List<ItemConversion> list3 = list2.FindAll((ItemConversion x) => (Object)(object)x.m_from.m_itemData.m_dropPrefab != (Object)null);
				source2 = list3.FindAll((ItemConversion x) => ((Object)x.m_from.m_itemData.m_dropPrefab).name != nameIn);
			}
			if (source2.Count() == 0)
			{
				ItemConversion val = new ItemConversion();
				val.m_from = FindItem(nameIn).GetComponent<ItemDrop>();
				val.m_to = FindItem(nameOut).GetComponent<ItemDrop>();
				val.m_producedItems = amount;
				component.m_conversion.Add(val);
				result = createConversionSingleLine(val.m_from, val.m_to, 0, amount);
			}
			return result;
		}

		private string CookingConversion(GameObject source, string nameIn, string nameOut, int time = 25)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			string result = "";
			CookingStation component = source.GetComponent<CookingStation>();
			List<ItemConversion> source2 = new List<ItemConversion>();
			if (component.m_conversion.Count() != 0)
			{
				List<ItemConversion> list = component.m_conversion.FindAll((ItemConversion x) => (Object)(object)x.m_from != (Object)null);
				List<ItemConversion> list2 = list.FindAll((ItemConversion x) => x.m_from.m_itemData != null);
				List<ItemConversion> list3 = list2.FindAll((ItemConversion x) => (Object)(object)x.m_from.m_itemData.m_dropPrefab != (Object)null);
				source2 = list3.FindAll(delegate(ItemConversion x)
				{
					object obj;
					if (x == null)
					{
						obj = null;
					}
					else
					{
						ItemDrop from = x.m_from;
						if (from == null)
						{
							obj = null;
						}
						else
						{
							ItemData itemData = from.m_itemData;
							obj = ((itemData != null) ? ((Object)itemData.m_dropPrefab).name : null);
						}
					}
					return obj != null;
				});
			}
			if (source2.Count() == 0)
			{
				ItemConversion val = new ItemConversion();
				val.m_from = FindItem(nameIn).GetComponent<ItemDrop>();
				val.m_to = FindItem(nameOut).GetComponent<ItemDrop>();
				val.m_cookTime = time;
				component.m_conversion.Add(val);
				result = createConversionSingleLine(val.m_from, val.m_to, time);
			}
			return result;
		}
	}
	[Serializable]
	public class BalrondConverter : MonoBehaviour
	{
		[Serializable]
		public class ItemConversion
		{
			public ItemDrop m_from;

			public ItemDrop m_to;

			public int m_count;
		}

		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;

		public ItemDrop m_fuelItem;

		public int m_maxOre = 1;

		public int m_maxFuel = 1;

		public float m_fuelPerProduct = 0f;

		public float m_secPerProduct = 30f;

		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 bool m_haveRoof;

		private bool m_blockedSmoke;

		private float m_addedOreTime = -1000f;

		private StringBuilder m_sb = new StringBuilder();

		private void Awake()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			m_nview = ((Component)this).GetComponent<ZNetView>();
			if (!((Object)(object)m_nview == (Object)null) && m_nview.GetZDO() != null)
			{
				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(OnAddWood));
					m_addOreSwitch.m_onHover = new TooltipCallback(OnHoverAddWood);
				}
				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(OnAddPowerSource));
					m_addWoodSwitch.m_onHover = new TooltipCallback(OnHoverAddPowerSource);
				}
				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>("AddWood", (Action<long, string>)RPC_AddWood);
				m_nview.Register("AddPowerSource", (Action<long>)RPC_AddPowerSource);
				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 DropAllItems()
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			SpawnProcessed();
			if ((Object)(object)m_fuelItem != (Object)null)
			{
				float @float = m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f);
				if (@float > 1f)
				{
					for (int i = 0; i < (int)@float; i++)
					{
						Object.Instantiate<GameObject>(((Component)m_fuelItem).gameObject, ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f));
					}
				}
			}
			while (GetQueueSize() > 0)
			{
				string queuedOre = GetQueuedOre();
				RemoveOneOre();
				ItemConversion itemConversion = GetItemConversion(queuedOre);
				if (itemConversion != 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);
				}
			}
		}

		private void OnDestroyed()
		{
			if (m_nview.IsOwner())
			{
				DropAllItems();
			}
		}

		private bool IsItemAllowed(ItemData item)
		{
			return IsItemAllowed(((Object)item.m_dropPrefab).name);
		}

		private bool IsItemAllowed(string itemName)
		{
			foreach (ItemConversion item in m_conversion)
			{
				if (((Object)((Component)item.m_from).gameObject).name == itemName)
				{
					return true;
				}
			}
			return false;
		}

		private ItemData FindCookableItem(Inventory inventory)
		{
			foreach (ItemConversion item2 in m_conversion)
			{
				ItemData item = inventory.GetItem(((Object)((Component)item2.m_from).gameObject).name, -1, true);
				if (item != null)
				{
					return item;
				}
			}
			return null;
		}

		private bool OnAddWood(Switch sw, Humanoid user, ItemData item)
		{
			if (item == null)
			{
				item = FindCookableItem(user.GetInventory());
				if (item == null)
				{
					((Character)user).Message((MessageType)2, "$msg_noprocessableitems", 0, (Sprite)null);
					return false;
				}
			}
			if (!IsItemAllowed(((Object)item.m_dropPrefab).name))
			{
				((Character)user).Message((MessageType)2, "$msg_wontwork", 0, (Sprite)null);
				return false;
			}
			ZLog.Log((object)("trying to add " + item.m_shared.m_name));
			if (GetQueueSize() >= m_maxOre)
			{
				((Character)user).Message((MessageType)2, "$msg_itsfull", 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("AddWood", new object[1] { ((Object)item.m_dropPrefab).name });
			m_addedOreTime = Time.time;
			if ((double)m_addOreAnimationDuration > 0.0)
			{
				SetAnimation(active: true);
			}
			return true;
		}

		private float GetBakeTimer()
		{
			return m_nview.GetZDO().GetFloat(ZDOVars.s_bakeTimer, 0f);
		}

		private void SetBakeTimer(float t)
		{
			m_nview.GetZDO().Set(ZDOVars.s_bakeTimer, t);
		}

		private float GetFuel()
		{
			return m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f);
		}

		private void SetFuel(float fuel)
		{
			m_nview.GetZDO().Set(ZDOVars.s_fuel, fuel);
		}

		private int GetQueueSize()
		{
			return m_nview.GetZDO().GetInt(ZDOVars.s_queued, 0);
		}

		private void RPC_AddWood(long sender, string name)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (m_nview.IsOwner())
			{
				if (!IsItemAllowed(name))
				{
					ZLog.Log((object)("Item not allowed " + name));
					return;
				}
				QueueOre(name);
				m_oreAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				ZLog.Log((object)("Added ore " + name));
			}
		}

		private void QueueOre(string name)
		{
			int queueSize = GetQueueSize();
			m_nview.GetZDO().Set("item" + queueSize, name);
			m_nview.GetZDO().Set(ZDOVars.s_queued, queueSize + 1, false);
		}

		private string GetQueuedOre()
		{
			return (GetQueueSize() == 0) ? "" : m_nview.GetZDO().GetString(ZDOVars.s_item0, "");
		}

		private void RemoveOneOre()
		{
			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(ZDOVars.s_queued, queueSize - 1, false);
			}
		}

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

		private void RPC_ConverterEmptyProcessed(long sender)
		{
			if (m_nview.IsOwner())
			{
				SpawnProcessed();
			}
		}

		private bool OnAddPowerSource(Switch sw, Humanoid user, ItemData item)
		{
			if (item != null && item.m_shared.m_name != m_fuelItem.m_itemData.m_shared.m_name)
			{
				((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null);
				return false;
			}
			if ((double)GetFuel() > (double)(m_maxFuel - 1))
			{
				((Character)user).Message((MessageType)2, "$msg_itsfull", 0, (Sprite)null);
				return false;
			}
			if (!user.GetInventory().HaveItem(m_fuelItem.m_itemData.m_shared.m_name, 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(m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true);
			m_nview.InvokeRPC("AddPowerSource", Array.Empty<object>());
			return true;
		}

		private void RPC_AddPowerSource(long sender)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (m_nview.IsOwner())
			{
				SetFuel(GetFuel() + 1f);
				m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1);
			}
		}

		private double GetDeltaTime()
		{
			DateTime time = ZNet.instance.GetTime();
			DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(ZDOVars.s_startTime, time.Ticks));
			double totalSeconds = (time - dateTime).TotalSeconds;
			m_nview.GetZDO().Set(ZDOVars.s_startTime, time.Ticks);
			return totalSeconds;
		}

		private float GetAccumulator()
		{
			return m_nview.GetZDO().GetFloat(ZDOVars.s_accTime, 0f);
		}

		private void SetAccumulator(float t)
		{
			m_nview.GetZDO().Set(ZDOVars.s_accTime, t);
		}

		private void UpdateRoof()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (m_requiresRoof)
			{
				m_haveRoof = Cover.IsUnderRoof(m_roofCheckPoint.position);
			}
		}

		private void UpdateSmoke()
		{
			if ((Object)(object)m_smokeSpawner != (Object)null)
			{
				m_blockedSmoke = m_smokeSpawner.IsBlocked();
			}
			else
			{
				m_blockedSmoke = false;
			}
		}

		private void UpdateBalrondConverter()
		{
			if (!m_nview.IsValid())
			{
				return;
			}
			UpdateState();
			if (!m_nview.IsOwner())
			{
				return;
			}
			double deltaTime = GetDeltaTime();
			float num = GetAccumulator() + (float)deltaTime;
			if ((double)num > 3600.0)
			{
				num = 3600f;
			}
			float num2 = (Object.op_Implicit((Object)(object)m_windmill) ? m_windmill.GetPowerOutput() : 1f);
			while ((double)num >= 1.0)
			{
				num -= 1f;
				float fuel = GetFuel();
				string queuedOre = GetQueuedOre();
				if ((m_maxFuel != 0 && !((double)fuel > 0.0)) || (m_maxOre != 0 && !(queuedOre != "")) || !((double)m_secPerProduct > 0.0))
				{
					continue;
				}
				float num3 = 1f * num2;
				if (m_maxFuel > 0)
				{
					float num4 = m_secPerProduct / m_fuelPerProduct;
					float num5 = fuel - num3 / num4;
					if ((double)num5 < 9.99999974737875E-05)
					{
						num5 = 0f;
					}
					SetFuel(num5);
				}
				if (queuedOre != "")
				{
					float num6 = GetBakeTimer() + num3;
					SetBakeTimer(num6);
					if ((double)num6 >= (double)m_secPerProduct)
					{
						SetBakeTimer(0f);
						RemoveOneOre();
						QueueProcessed(queuedOre);
					}
				}
			}
			if (GetQueuedOre() == "" || ((double)m_maxFuel > 0.0 && (double)GetFuel() == 0.0))
			{
				SpawnProcessed();
			}
			SetAccumulator(num);
		}

		private void QueueProcessed(string ore)
		{
			if (!m_spawnStack)
			{
				Spawn(ore, 1);
				return;
			}
			ItemConversion itemConversion = GetItemConversion(ore);
			string @string = m_nview.GetZDO().GetString(ZDOVars.s_spawnOre, "");
			int @int = m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0);
			if (@string.Length > 0)
			{
				if (@string != ore)
				{
					SpawnProcessed();
					m_nview.GetZDO().Set(ZDOVars.s_spawnOre, ore);
					m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, itemConversion.m_count, false);
					return;
				}
				int num = @int + itemConversion.m_count;
				if (itemConversion == null || num >= itemConversion.m_to.m_itemData.m_shared.m_maxStackSize)
				{
					Spawn(ore, @int);
					Spawn(ore, itemConversion.m_count);
					m_nview.GetZDO().Set(ZDOVars.s_spawnOre, "");
					m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 0, false);
				}
				else
				{
					m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, num, false);
				}
			}
			else
			{
				m_nview.GetZDO().Set(ZDOVars.s_spawnOre, ore);
				m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, itemConversion.m_count, false);
			}
		}

		private void SpawnProcessed()
		{
			int @int = m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0);
			if (@int > 0)
			{
				Spawn(m_nview.GetZDO().GetString(ZDOVars.s_spawnOre, ""), @int);
				m_nview.GetZDO().Set(ZDOVars.s_spawnOre, "");
				m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 0, false);
			}
		}

		private int GetProcessedQueueSize()
		{
			return m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0);
		}

		private void Spawn(string ore, int stack)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			ItemConversion itemConversion = GetItemConversion(ore);
			if (itemConversion != null)
			{
				m_produceEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
				Object.Instantiate<GameObject>(((Component)itemConversion.m_to).gameObject, m_outputPoint.position, m_outputPoint.rotation).GetComponent<ItemDrop>().m_itemData.m_stack = stack;
			}
		}

		private ItemConversion GetItemConversion(string itemName)
		{
			foreach (ItemConversion item in m_conversion)
			{
				if (((Object)((Component)item.m_from).gameObject).name == itemName)
				{
					return item;
				}
			}
			return null;
		}

		private void UpdateState()
		{
			bool flag = IsActive();
			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((double)GetFuel() > 0.0 && !flag);
			}
			if (Object.op_Implicit((Object)(object)m_haveOreObject))
			{
				m_haveOreObject.SetActive(GetQueueSize() > 0);
			}
			if (Object.op_Implicit((Object)(object)m_noOreObject))
			{
				m_noOreObject.SetActive(GetQueueSize() == 0);
			}
			if ((double)m_addOreAnimationDuration > 0.0 && (double)Time.time - (double)m_addedOreTime < (double)m_addOreAnimationDuration)
			{
				flag = true;
			}
			SetAnimation(flag);
		}

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

		public bool IsActive()
		{
			return (m_maxFuel == 0 || (double)GetFuel() > 0.0) && (m_maxOre == 0 || GetQueueSize() > 0);
		}

		private string OnHoverAddPowerSource()
		{
			return Localization.instance.Localize($"{m_name} ({m_fuelItem.m_itemData.m_shared.m_name} {Mathf.Ceil(GetFuel())}/{m_maxFuel})\n[<color=yellow><b>$KEY_Use</b></color>] Add {m_fuelItem.m_itemData.m_shared.m_name}");
		}

		private string OnHoverEmptyOre()
		{
			return Localization.instance.Localize($"{m_name} ({GetProcessedQueueSize()} Ready) \n[<color=yellow><b>$KEY_Use</b></color>] {m_emptyOreTooltip}");
		}

		private string OnHoverAddWood()
		{
			m_sb.Clear();
			m_sb.Append($"{m_name} ({GetQueueSize()}/{m_maxOre}) ");
			m_sb.Append("\n[<color=yellow><b>$KEY_Use</b></color>] " + m_addOreTooltip);
			return Localization.instance.Localize(m_sb.ToString());
		}
	}
	public class FueledHive : MonoBehaviour, Hoverable, Interactable
	{
		[Serializable]
		public class ItemConversion
		{
			public ItemDrop m_from;

			public int value;
		}

		public string m_name = "$tag_piece_birdhouse";

		public Transform m_spawnPoint;

		public GameObject m_beeEffect;

		public bool m_effectOnlyInDaylight = true;

		[BitMask(typeof(Biome))]
		public Biome m_biome;

		public float m_secPerUnit = 12f;

		public int m_producedItemAmount = 20;

		public ItemDrop m_producedItem;

		public EffectList m_spawnEffect = new EffectList();

		[Header("Texts")]
		public string m_extractText = "$tag_pickFeathers";

		public string m_checkText = "$tag_birdAreBusy";

		public string m_areaText = "$piece_beehive_area";

		public string m_freespaceText = "$piece_beehive_freespace";

		public string m_sleepText = "$tag_birdAreSleeping";

		public string m_happyText = "$tag_birdAreHappy";

		public string m_hungryText = "$tag_birdAreHungry";

		public string m_notConnectedText;

		public string m_blockedText;

		public ZNetView m_nview;

		public Piece m_piece;

		public ItemDrop m_fuelItem;

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

		public EffectList m_fuelAddedEffects = new EffectList();

		public int m_maxFuel = 10;

		public void Awake()
		{
			m_nview = ((Component)this).GetComponent<ZNetView>();
			m_piece = ((Component)this).GetComponent<Piece>();
			if (m_nview.GetZDO() != null)
			{
				if (m_nview.IsOwner() && m_nview.GetZDO().GetLong(ZDOVars.s_lastTime, 0L) == 0)
				{
					m_nview.GetZDO().Set(ZDOVars.s_lastTime, ZNet.instance.GetTime().Ticks);
				}
				m_nview.Register("RPC_ExtractFeathers", (Action<long>)RPC_ExtractFeathers);
				m_nview.Register("RPC_AddFuel", (Action<long>)RPC_AddFuel);
				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("UpdateBirds", 0f, 10f);
			}
		}

		public string GetHoverText()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false))
			{
				return Localization.instance.Localize(m_name + "\n$piece_noaccess");
			}
			int featherAmount = GetFeatherAmount();
			if (featherAmount <= 0)
			{
				return Localization.instance.Localize($"{m_name} ({m_fuelItem.m_itemData.m_shared.m_name} {Mathf.Ceil(GetFuel())}/{m_maxFuel})\n[<color=yellow><b>1-8</b></color>] $piece_smelter_add {m_fuelItem.m_itemData.m_shared.m_name}") + Localization.instance.Localize(" ( $piece_container_empty )\n[<color=yellow><b>$KEY_Use</b></color>] " + m_checkText);
			}
			return Localization.instance.Localize($"{m_name} ({m_fuelItem.m_itemData.m_shared.m_name} {Mathf.Ceil(GetFuel())}/{m_maxFuel})\n[<color=yellow><b>1-8</b></color>] $piece_smelter_add {m_fuelItem.m_itemData.m_shared.m_name}") + Localization.instance.Localize($" ( {m_producedItem.m_itemData.m_shared.m_name} x {featherAmount} )\n[<color=yellow><b>$KEY_Use</b></color>] {m_extractText}");
		}

		public string GetHoverName()
		{
			return m_name;
		}

		public bool Interact(Humanoid character, bool repeat, bool alt)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (repeat)
			{
				return false;
			}
			if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
			{
				return true;
			}
			if (GetFeatherAmount() > 0)
			{
				Extract();
				Game.instance.IncrementPlayerStat((PlayerStatType)76, 1f);
			}
			else
			{
				if (!HaveFuel())
				{
					((Character)character).Message((MessageType)2, m_hungryText, 0, (Sprite)null);
					return true;
				}
				if (!EnvMan.IsDaylight() && m_effectOnlyInDaylight)
				{
					((Character)character).Message((MessageType)2, m_sleepText, 0, (Sprite)null);
					return true;
				}
				((Character)character).Message((MessageType)2, m_happyText, 0, (Sprite)null);
			}
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			if (item != null && !IsItemAllowed(item))
			{
				((Character)user).Message((MessageType)2, "$msg_wrongitem", 0, (Sprite)null);
				return false;
			}
			if ((double)GetFuel() > (double)(m_maxFuel - 1))
			{
				((Character)user).Message((MessageType)2, "$msg_itsfull", 0, (Sprite)null);
				return false;
			}
			((Character)user).Message((MessageType)2, "$msg_added " + item.m_shared.m_name, 0, (Sprite)null);
			user.GetInventory().RemoveItem(item.m_shared.m_name, 1, -1, true);
			m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
			return true;
		}

		public void Extract()
		{
			m_nview.InvokeRPC("RPC_ExtractFeathers", Array.Empty<object>());
		}

		public void RPC_ExtractFeathers(long caller)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			int featherAmount = GetFeatherAmount();
			if (featherAmount <= 0)
			{
				return;
			}
			m_spawnEffect.Create(m_spawnPoint.position, Quaternion.identity, (Transform)null, 1f, -1);
			for (int i = 0; i < featherAmount; i++)
			{
				Vector2 val = Random.insideUnitCircle * 0.5f;
				ItemDrop component = ((Component)Object.Instantiate<ItemDrop>(m_producedItem, m_spawnPoint.position + new Vector3(val.x, 0.25f * (float)i, val.y), Quaternion.identity)).GetComponent<ItemDrop>();
				if (component != null)
				{
					component.SetStack(Game.instance.ScaleDrops(m_producedItem.m_itemData, 1));
				}
			}
			ResetLevel();
		}

		public float GetTimeSinceLastUpdate()
		{
			DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(ZDOVars.s_lastTime, ZNet.instance.GetTime().Ticks));
			DateTime time = ZNet.instance.GetTime();
			TimeSpan timeSpan = time - dateTime;
			m_nview.GetZDO().Set(ZDOVars.s_lastTime, time.Ticks);
			double num = timeSpan.TotalSeconds;
			if (num < 0.0)
			{
				num = 0.0;
			}
			return (float)num;
		}

		public void ResetLevel()
		{
			m_nview.GetZDO().Set(ZDOVars.s_level, 0, false);
		}

		public void IncreseLevel(int i)
		{
			int num = Mathf.Clamp(GetFeatherAmount() + i, 0, m_producedItemAmount);
			m_nview.GetZDO().Set(ZDOVars.s_level, num, false);
		}

		public int GetFeatherAmount()
		{
			return m_nview.GetZDO().GetInt(ZDOVars.s_level, 0);
		}

		public void UpdateBirds()
		{
			bool flag = HaveFuel();
			if (m_nview.IsOwner() && flag)
			{
				float timeSinceLastUpdate = GetTimeSinceLastUpdate();
				float num = m_nview.GetZDO().GetFloat(ZDOVars.s_product, 0f) + timeSinceLastUpdate;
				if ((double)num > (double)m_secPerUnit)
				{
					SetFuel(GetFuel() - 0.1f);
					IncreseLevel((int)((double)num / (double)m_secPerUnit));
					num = 0f;
				}
				m_nview.GetZDO().Set(ZDOVars.s_product, num);
			}
		}

		private void OnDestroyed()
		{
			if (m_nview.IsOwner())
			{
				DropAllItems();
			}
		}

		private void DropAllItems()
		{
			//IL_0059: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_fuelItem != (Object)null)
			{
				float num = ((m_nview.GetZDO() == null) ? 0f : m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f));
				for (int i = 0; i < (int)num; i++)
				{
					ItemDrop.OnCreateNew(Object.Instantiate<GameObject>(((Component)m_fuelItem).gameObject, ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)));
				}
			}
		}

		private float GetFuel()
		{
			return (!m_nview.IsValid()) ? 0f : m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f);
		}

		private bool HaveFuel()
		{
			return GetFuel() > 0f;
		}

		private void SetFuel(float fuel)
		{
			if (m_nview.IsValid())
			{
				m_nview.GetZDO().Set(ZDOVars.s_fuel, fuel);
			}
		}

		private void RPC_AddFuel(long sender)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (m_nview.IsOwner())
			{
				SetFuel(GetFuel() + 1f);
				m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1);
			}
		}

		private bool IsItemAllowed(ItemData item)
		{
			return IsItemAllowed(((Object)item.m_dropPrefab).name);
		}

		private bool IsItemAllowed(string itemName)
		{
			return ((Object)m_fuelItem).name == itemName;
		}
	}
	public class NatureSpawner : MonoBehaviour
	{
		public static List<PlantSeeder> plantSeeders = new List<PlantSeeder>();

		public const float dt = 2f;

		public GameObject m_prefab;

		public float m_spawnIntervalSec = 600f;

		public float m_triggerDistance = 200f;

		public float m_spawnRadius = 80f;

		public float m_nearRadius = 25f;

		public float m_farRadius = 100f;

		public int m_maxNear = 2;

		public int m_maxTotal = 6;

		public bool m_onGroundOnly = true;

		public EffectList m_spawnEffects = new EffectList();

		public ZNetView m_nview;

		public float m_spawnTimer;

		public void Awake()
		{
			m_nview = ((Component)this).GetComponent<ZNetView>();
			m_spawnIntervalSec = Random.Range(300, 600);
			m_triggerDistance = Random.Range(300, 600);
			m_spawnRadius = m_triggerDistance * 0.8f;
			m_farRadius = m_triggerDistance;
			m_nearRadius = m_triggerDistance / 4f;
			((MonoBehaviour)this).InvokeRepeating("UpdateSpawn", 10f, 10f);
		}

		public double TimeSincePlanted()
		{
			DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(ZDOVars.s_plantTime, ZNet.instance.GetTime().Ticks));
			return (ZNet.instance.GetTime() - dateTime).TotalSeconds;
		}

		public void UpdateSpawn()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (m_nview.IsOwner() && !ZNetScene.instance.OutsideActiveArea(((Component)this).transform.position) && Player.IsPlayerInRange(((Component)this).transform.position, m_triggerDistance))
			{
				m_spawnTimer += 10f;
				if (!((double)m_spawnTimer <= (double)m_spawnIntervalSec))
				{
					m_spawnTimer = 0f;
					SpawnOne();
				}
			}
		}

		public bool SpawnOne()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_prefab == (Object)null)
			{
				Debug.Log((object)("Prefab is null on tree: " + ((Object)((Component)this).gameObject).name));
				return false;
			}
			GetInstances(out var near, out var total);
			if (near >= m_maxNear || total >= m_maxTotal)
			{
				return false;
			}
			if ((Object)(object)m_prefab == (Object)null || !FindSpawnPoint(m_prefab, out var point))
			{
				return false;
			}
			GameObject val = Object.Instantiate<GameObject>(m_prefab, point, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f));
			plantSeeders = plantSeeders.FindAll((PlantSeeder x) => (Object)(object)x != (Object)null);
			return true;
		}

		public bool FindSpawnPoint(GameObject prefab, out Vector3 point)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			prefab.GetComponent<BaseAI>();
			float num = default(float);
			for (int i = 0; i < 10; i++)
			{
				Vector3 val = ((Component)this).transform.position + Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f) * Vector3.forward * Random.Range(0f, m_spawnRadius);
				if (ZoneSystem.instance.FindFloor(val, ref num) && (!m_onGroundOnly || !ZoneSystem.instance.IsBlocked(val)))
				{
					val.y = num + 0.1f;
					point = val;
					return true;
				}
			}
			point = Vector3.zero;
			return false;
		}

		public void GetInstances(out int near, out int total)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			near = 0;
			total = 0;
			Vector3 position = ((Component)this).transform.position;
			foreach (PlantSeeder plantSeeder in plantSeeders)
			{
				if (!((Object)(object)plantSeeder == (Object)null) && IsSpawnPrefab(plantSeeder))
				{
					double num = Utils.DistanceXZ(((Component)plantSeeder).transform.position, position);
					if (num < (double)m_nearRadius)
					{
						near++;
					}
					if (num < (double)m_farRadius)
					{
						total++;
					}
				}
			}
		}

		public bool IsSpawnPrefab(PlantSeeder go)
		{
			if ((Object)(object)go == (Object)null)
			{
				return false;
			}
			string name = ((Object)go).name;
			if (Utils.CustomStartsWith(name, ((Object)m_prefab).name))
			{
				return true;
			}
			return false;
		}

		public void OnDrawGizmosSelected()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			Gizmos.color = Color.red;
			Gizmos.DrawWireSphere(((Component)this).transform.position, m_spawnRadius);
			Gizmos.color = Color.yellow;
			Gizmos.DrawWireSphere(((Component)this).transform.position, m_nearRadius);
		}
	}
	public class DestructableTimeedDestruction : MonoBehaviour
	{
		public float m_timeout = 1f;

		public bool m_triggerOnAwake;

		[Tooltip("If there are objects that you always want to destroy, even if there is no owner, check this. For instance, fires in the ashlands may be created by cinder rain outside of ownership-zones, so they must be deleted even if no owner exists.")]
		public bool m_forceTakeOwnershipAndDestroy;

		public ZNetView m_nview;

		public Destructible m_destructible;

		public void Awake()
		{
			m_destructible = ((Component)this).GetComponent<Destructible>();
			m_nview = ((Component)this).GetComponent<ZNetView>();
			if (m_triggerOnAwake)
			{
				Trigger();
			}
		}

		public void Trigger()
		{
			((MonoBehaviour)this).InvokeRepeating("DestroyNow", m_timeout, 1f);
		}

		public void Trigger(float timeout)
		{
			((MonoBehaviour)this).InvokeRepeating("DestroyNow", timeout, 1f);
		}

		public void DestroyNow()
		{
			m_destructible.Destroy((HitData)null);
		}
	}
	public class PlantSeeder : SlowUpdate
	{
		public GameObject m_prefabToGrow;

		public float m_growTime = 3600f;

		public float m_growTimeMax = 6000f;

		public float m_minScale = 0.75f;

		public float m_maxScale = 1.25f;

		public float m_growRadius = 0.5f;

		public ZNetView m_nview;

		public float m_updateTime;

		public float m_spawnTime;

		public int m_seed;

		public string m_name = "PlantSeeder";

		public bool m_destroyIfCantGrow;

		public EffectList m_growEffect = new EffectList();

		public override void Awake()
		{
			((SlowUpdate)this).Awake();
			m_nview = ((Component)this).gameObject.GetComponent<ZNetView>();
			if (m_nview.GetZDO() != null)
			{
				m_seed = m_nview.GetZDO().GetInt(ZDOVars.s_seed, 0);
				if (m_seed == 0)
				{
					m_seed = (int)(((ZDOID)(ref m_nview.GetZDO().m_uid)).ID + ((ZDOID)(ref m_nview.GetZDO().m_uid)).UserID);
					m_nview.GetZDO().Set(ZDOVars.s_seed, m_seed, true);
				}
				if (m_nview.IsOwner() && m_nview.GetZDO().GetLong(ZDOVars.s_plantTime, 0L) == 0)
				{
					m_nview.GetZDO().Set(ZDOVars.s_plantTime, ZNet.instance.GetTime().Ticks);
				}
				m_spawnTime = Time.time;
				NatureSpawner.plantSeeders.Add(this);
			}
		}

		public double TimeSincePlanted()
		{
			DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(ZDOVars.s_plantTime, ZNet.instance.GetTime().Ticks));
			return (ZNet.instance.GetTime() - dateTime).TotalSeconds;
		}

		public override void SUpdate()
		{
			if (m_nview.IsValid() && !((double)Time.time - (double)m_updateTime < 10.0))
			{
				m_updateTime = Time.time;
				double num = TimeSincePlanted();
				float growTime = GetGrowTime();
				if (m_nview.IsOwner() && !((double)Time.time - (double)m_spawnTime <= 10.0) && !(num <= (double)growTime))
				{
					Grow();
				}
			}
		}

		public GameObject Grow()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefabToGrow = m_prefabToGrow;
			Vector3 position = ((Component)this).transform.position;
			Quaternion rotation = ((Component)this).transform.rotation;
			Vector3 val = position;
			Quaternion val2 = rotation;
			GameObject val3 = Object.Instantiate<GameObject>(prefabToGrow, val, val2);
			Plant component = val3.GetComponent<Plant>();
			component.m_destroyIfCantGrow = true;
			component.m_growRadius = 1f;
			ZLog.Log((object)("Starting to grow plant- " + ((Object)prefabToGrow).name + " -with rotation: " + ((object)(Quaternion)(ref rotation)).ToString()));
			ZNetView component2 = val3.GetComponent<ZNetView>();
			float num = Random.Range(m_minScale, m_maxScale);
			Vector3 localScale = default(Vector3);
			((Vector3)(ref localScale))..ctor(num, num, num);
			component2.SetLocalScale(localScale);
			if (Object.op_Implicit((Object)(object)m_nview))
			{
				NatureSpawner.plantSeeders.Remove(this);
				m_growEffect.Create(((Component)this).transform.position, rotation, (Transform)null, num, -1);
				m_nview.Destroy();
			}
			return val3;
		}

		public float GetGrowTime()
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			State state = Random.state;
			Random.InitState(m_seed);
			float value = Random.value;
			Random.state = state;
			return Mathf.Lerp(m_growTime, m_growTimeMax, value);
		}
	}
	public class TerrainMover : MonoBehaviour
	{
		private void Awake()
		{
			Transform parent = ((Component)this).transform.parent;
			if ((Object)(object)parent != (Object)null)
			{
				Transform parent2 = parent.parent;
				((Component)this).transform.parent = parent2;
			}
			Object.DestroyImmediate((Object)(object)this);
		}
	}
	public class TreeBeeSpawner : MonoBehaviour
	{
		public GameObject m_prefab;

		public TreeBase m_treeBase;

		public ZNetView m_nview;

		public int m_chance = 90;

		public int m_spawnIntervalSec = 20;

		public float offsetX = 0f;

		public float offsetY = 0f;

		public float offsetZ = 0f;

		public float m_spawnTimer;

		public GameObject m_spawnOnDamage;

		private GameObject m_hive;

		private EffectData m_effectData;

		public bool m_hasFollen = false;

		public void Awake()
		{
			m_nview = ((Component)this).GetComponent<ZNetView>();
			m_treeBase = ((Component)this).GetComponent<TreeBase>();
			((MonoBehaviour)this).InvokeRepeating("UpdateSpawn", 10f, 10f);
			m_spawnIntervalSec = Random.Range(120, 240);
			if ((Object)(object)m_prefab != (Object)null)
			{
				SpawnOnDamaged component = m_prefab.GetComponent<SpawnOnDamaged>();
				if ((Object)(object)component != (Object)null)
				{
					m_spawnOnDamage = component.m_spawnOnDamage;
				}
			}
			AddBeeAoEToHit();
		}

		public double TimeSincePlanted()
		{
			DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(ZDOVars.s_plantTime, ZNet.instance.GetTime().Ticks));
			return (ZNet.instance.GetTime() - dateTime).TotalSeconds;
		}

		public void Damage(HitData hit)
		{
			m_nview.InvokeRPC("RPC_Damage", new object[1] { hit });
		}

		public void UpdateSpawn()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_hive == (Object)null)
			{
				toggleActive(active: false);
			}
			if (m_nview.IsOwner() && !ZNetScene.instance.OutsideActiveArea(((Component)this).transform.position))
			{
				m_spawnTimer += 10f;
				if (!((double)m_spawnTimer <= (double)m_spawnIntervalSec))
				{
					m_spawnTimer = 0f;
					SpawnOne();
				}
			}
		}

		public bool SpawnOne()
		{
			if ((Object)(object)m_prefab == (Object)null || (Object)(object)m_hive != (Object)null)
			{
				return false;
			}
			int num = Random.Range(1, 100);
			if (num <= m_chance)
			{
				spawnHive();
			}
			return true;
		}

		public void hiveFall()
		{
			if ((Object)(object)m_hive != (Object)null && !m_hasFollen)
			{
				m_hive.GetComponent<StaticPhysics>().m_fall = true;
				m_hive.GetComponent<WearNTear>().m_noSupportWear = false;
				m_hasFollen = true;
			}
		}

		public bool HasHive()
		{
			return (Object)(object)m_hive != (Object)null;
		}

		private void spawnHive()
		{
			//IL_0012: 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)
			GameObject val = Object.Instantiate<GameObject>(m_prefab, m_treeBase.m_logSpawnPoint.position, Quaternion.Euler(0f, 90f, 0f));
			StaticPhysics val2 = val.AddComponent<StaticPhysics>();
			val2.m_fall = false;
			val2.m_pushUp = true;
			toggleActive(active: true);
			m_hive = val;
		}

		private void toggleActive(bool active)
		{
			if (m_effectData != null)
			{
				m_effectData.m_enabled = active;
			}
		}

		private void AddBeeAoEToHit()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if ((Object)(object)m_spawnOnDamage != (Object)null)
			{
				m_effectData = new EffectData();
				m_effectData.m_prefab = m_spawnOnDamage;
				m_effectData.m_enabled = true;
				m_effectData.m_variant = -1;
				CollectionExtensions.AddItem<EffectData>((IEnumerable<EffectData>)m_treeBase.m_hitEffect.m_effectPrefabs, m_effectData);
			}
		}
	}
	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.Log((object)(Launch.projectName + ":  " + ((Object)status).name + " - Status already in the game"));
				}
			}
			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)
				{
					if ((Object)(object)recipe.m_item != (Object)null)
					{
						ObjectDB.instance.m_recipes.Add(recipe);
					}
				}
				else
				{
					Debug.Log((object)(Launch.projectName + ":  " + ((Object)recipe).name + " - Recipe with this name already in the Game"));
				}
			}
			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)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null)
				{
					ObjectDB.instance.m_items.Add(newPrefab);
					Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance);
					dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab;
				}
				else
				{
					Debug.Log((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop already exist"));
				}
			}
			else
			{
				Debug.LogError((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
			}
		}
	}
	public class FxReplacment
	{
		public void ReplaceOnObject(GameObject gameObject, ZNetScene zNetScene)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			SpawnArea component = gameObject.GetComponent<SpawnArea>();
			if ((Object)(object)component != (Object)null)
			{
				EffectList spawnEffects = component.m_spawnEffects;
				if (spawnEffects != null)
				{
					findEffectsAndChange(spawnEffects.m_effectPrefabs, zNetScene);
				}
			}
			Destructible component2 = gameObject.GetComponent<Destructible>();
			if ((Object)(object)component2 != (Object)null)
			{
				EffectList hitEffect = component2.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
				}
				EffectList destroyedEffect = component2.m_destroyedEffect;
				if (destroyedEffect != null)
				{
					findEffectsAndChange(destroyedEffect.m_effectPrefabs, zNetScene);
				}
			}
			Projectile component3 = gameObject.GetComponent<Projectile>();
			if ((Object)(object)component3 != (Object)null)
			{
				EffectList hitEffects = component3.m_hitEffects;
				if (hitEffects != null)
				{
					findEffectsAndChange(hitEffects.m_effectPrefabs, zNetScene);
				}
				EffectList hitWaterEffects = component3.m_hitWaterEffects;
				if (hitWaterEffects != null)
				{
					findEffectsAndChange(hitWaterEffects.m_effectPrefabs, zNetScene);
				}
				EffectList spawnOnHitEffects = component3.m_spawnOnHitEffects;
				if (spawnOnHitEffects != null)
				{
					findEffectsAndChange(spawnOnHitEffects.m_effectPrefabs, zNetScene);
				}
			}
		}

		public void ReplaceOnVegetation(GameObject gameObject, ZNetScene zNetScene)
		{
			Pickable component = gameObject.GetComponent<Pickable>();
			if ((Object)(object)component != (Object)null)
			{
				fixPlant(component, zNetScene);
			}
			Destructible component2 = gameObject.GetComponent<Destructible>();
			if ((Object)(object)component2 != (Object)null)
			{
				fixPDestructable(component2, zNetScene);
			}
			MineRock5 component3 = gameObject.GetComponent<MineRock5>();
			if ((Object)(object)component3 != (Object)null)
			{
				fixMineRock5(component3, zNetScene);
			}
			MineRock component4 = gameObject.GetComponent<MineRock>();
			if ((Object)(object)component4 != (Object)null)
			{
				fixMineRock(component4, zNetScene);
			}
		}

		private void fixPlant(Pickable pickable, ZNetScene zNetScene)
		{
			EffectList pickEffector = pickable.m_pickEffector;
			if (pickEffector != null)
			{
				findEffectsAndChange(pickEffector.m_effectPrefabs, zNetScene);
			}
		}

		private void fixPDestructable(Destructible minerock5, ZNetScene zNetScene)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs, zNetScene);
			}
		}

		private void fixMineRock5(MineRock5 minerock5, ZNetScene zNetScene)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs, zNetScene);
			}
		}

		private void fixMineRock(MineRock minerock5, ZNetScene zNetScene)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs, zNetScene);
			}
		}

		public void ReplaceOnMonster(GameObject gameObject, ZNetScene zNetScene)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				Debug.LogWarning((object)(Launch.projectName + ":: GameObject not found"));
				return;
			}
			Humanoid component = gameObject.GetComponent<Humanoid>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogWarning((object)(Launch.projectName + ":: GameObject not found"));
				return;
			}
			EffectList dropEffects = component.m_dropEffects;
			if (dropEffects != null)
			{
				findEffectsAndChange(dropEffects.m_effectPrefabs, zNetScene);
			}
			EffectList backstabHitEffects = ((Character)component).m_backstabHitEffects;
			if (backstabHitEffects != null)
			{
				findEffectsAndChange(backstabHitEffects.m_effectPrefabs, zNetScene);
			}
			EffectList consumeItemEffects = component.m_consumeItemEffects;
			if (consumeItemEffects != null)
			{
				findEffectsAndChange(consumeItemEffects.m_effectPrefabs, zNetScene);
			}
			EffectList critHitEffects = ((Character)component).m_critHitEffects;
			if (critHitEffects != null)
			{
				findEffectsAndChange(critHitEffects.m_effectPrefabs, zNetScene);
			}
			EffectList deathEffects = ((Character)component).m_deathEffects;
			if (deathEffects != null)
			{
				findEffectsAndChange(deathEffects.m_effectPrefabs, zNetScene);
			}
			EffectList hitEffects = ((Character)component).m_hitEffects;
			if (hitEffects != null)
			{
				findEffectsAndChange(hitEffects.m_effectPrefabs, zNetScene);
			}
			EffectList jumpEffects = ((Character)component).m_jumpEffects;
			if (jumpEffects != null)
			{
				findEffectsAndChange(jumpEffects.m_effectPrefabs, zNetScene);
			}
			EffectList perfectBlockEffect = component.m_perfectBlockEffect;
			if (perfectBlockEffect != null)
			{
				findEffectsAndChange(perfectBlockEffect.m_effectPrefabs, zNetScene);
			}
			EffectList pickupEffects = component.m_pickupEffects;
			if (pickupEffects != null)
			{
				findEffectsAndChange(pickupEffects.m_effectPrefabs, zNetScene);
			}
			EffectList slideEffects = ((Character)component).m_slideEffects;
			if (slideEffects != null)
			{
				findEffectsAndChange(slideEffects.m_effectPrefabs, zNetScene);
			}
			EffectList tarEffects = ((Character)component).m_tarEffects;
			if (tarEffects != null)
			{
				findEffectsAndChange(tarEffects.m_effectPrefabs,