Decompiled source of balrond shipyard v1.4.9

plugins/BalrondShipyard.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 BalrondBiomes;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SailorBag")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SailorBag")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d18d2a38-6578-40b5-a296-30f8a379d6ab")]
[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]
namespace BalrondBiomes
{
	public class SE_WetImmunity : StatusEffect
	{
		public void Awake()
		{
			base.m_name = "Waterproof";
			((Object)this).name = "Waterproof";
			base.m_tooltip = "Immune to wet effect";
		}

		public override void UpdateStatusEffect(float dt)
		{
			((StatusEffect)this).UpdateStatusEffect(dt);
			if (base.m_character.GetSEMan().HaveStatusEffect("Wet".GetHashCode()))
			{
				base.m_character.GetSEMan().RemoveStatusEffect("Wet".GetHashCode(), false);
			}
		}
	}
}
namespace BalrondShipyard
{
	internal class AnchorSwitch : MonoBehaviour, Hoverable, Interactable
	{
		public string m_name = "";

		public EffectList m_activateEffect = new EffectList();

		public string turnOffMessage = "";

		public string turnOnMessage = "";

		public EffectList m_deactivateEffect = new EffectList();

		public ZNetView m_nview;

		public Ship m_ship;

		public GameObject m_disabled;

		public GameObject m_enabled;

		public GameObject m_resetPoint;

		public GameObject m_anchor;

		public Rigidbody rigidbody;

		public bool m_currrentStatus;

		private void Awake()
		{
			if (m_nview.IsValid())
			{
				if (m_name == "")
				{
					m_name = " Active Me";
				}
				m_nview.Register("RPC_ToggleAnchor", (Action<long>)RPC_ToggleAnchor);
				rigidbody = ((Component)m_ship).GetComponent<Rigidbody>();
				m_currrentStatus = IsEnabled();
				SetEnabled(m_currrentStatus);
			}
		}

		private void UpdateStatus()
		{
			if (m_currrentStatus != IsEnabled())
			{
				ToggleAnchor(0L);
				m_currrentStatus = IsEnabled();
			}
		}

		public string GetHoverText()
		{
			if (IsEnabled())
			{
				return Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] Pull Anchor");
			}
			return Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] Drop Anchor");
		}

		public string GetHoverName()
		{
			return m_name;
		}

		public void ToggleAnchor(long uid)
		{
			m_nview.InvokeRPC(ZNetView.Everybody, "RPC_ToggleAnchor", new object[1] { uid });
		}

		private void RPC_ToggleAnchor(long uid)
		{
			if (m_nview.IsOwner())
			{
				SetEnabled(!IsEnabled());
			}
		}

		public bool IsEnabled()
		{
			return m_nview.IsValid() && m_nview.GetZDO().GetBool("enabledAnchor", false);
		}

		private void SetEnabled(bool enabled)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			m_nview.GetZDO().Set("enabledAnchor", enabled);
			if (enabled)
			{
				m_activateEffect.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
			}
			else
			{
				m_deactivateEffect.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1);
			}
			if ((Object)(object)m_disabled != (Object)null && (Object)(object)m_enabled != (Object)null)
			{
				m_disabled.SetActive(!enabled);
				m_enabled.SetActive(enabled);
				if (enabled)
				{
					m_nview.InvokeRPC("Stop", Array.Empty<object>());
					rigidbody.constraints = (RigidbodyConstraints)122;
				}
				else
				{
					rigidbody.constraints = (RigidbodyConstraints)0;
				}
			}
			else
			{
				Debug.LogWarning((object)"[SHIPYARD] No object to Toggle");
			}
		}

		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;
			}
			ToggleAnchor(((Component)character).GetComponent<Player>().GetPlayerID());
			if (turnOffMessage != "" && turnOnMessage != "")
			{
				((Character)character).Message((MessageType)2, IsEnabled() ? turnOnMessage : turnOffMessage, 0, (Sprite)null);
			}
			else
			{
				((Character)character).Message((MessageType)2, m_name + " was " + (IsEnabled() ? "dropped" : "picked up"), 0, (Sprite)null);
			}
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}
	}
	[Serializable]
	public class FishnetTrap : MonoBehaviour
	{
		[Serializable]
		public class ItemConversion
		{
			public Biome m_biome;

			public ItemDrop m_from;

			public ItemDrop m_to;

			public int m_seconds;

			public List<ItemDrop> m_options;
		}

		public string m_name = "FishnetTrap";

		public string m_addOreTooltip = "Add Fishbait";

		public string m_emptyOreTooltip = "Empty the basket";

		public Switch m_addOreSwitch;

		public Switch m_emptyOreSwitch;

		public Transform m_outputPoint;

		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 int m_maxOre = 20;

		public float m_secPerProduct = 120f;

		public float m_addOreAnimationDuration;

		public List<ItemConversion> m_conversion;

		public EffectList m_oreAddedEffects = new EffectList();

		public EffectList m_fuelAddedEffects = new EffectList();

		public EffectList m_produceEffects = new EffectList();

		private ZNetView m_nview;

		private float m_addedOreTime = -1000f;

		private StringBuilder m_sb = new StringBuilder();

		public Container m_container;

		public GameObject m_full;

		public int m_maxFish = 50;

		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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			m_nview = ((Component)this).GetComponent<ZNetView>();
			if ((Object)(object)m_nview == (Object)null || m_nview.GetZDO() == null)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)m_addOreSwitch))
			{
				Switch addOreSwitch = m_addOreSwitch;
				addOreSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)addOreSwitch.m_onUse, (Delegate?)new Callback(OnAddOre));
				m_addOreSwitch.m_onHover = new TooltipCallback(OnHoverAddOre);
			}
			if (Object.op_Implicit((Object)(object)m_emptyOreSwitch))
			{
				Switch emptyOreSwitch = m_emptyOreSwitch;
				emptyOreSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)emptyOreSwitch.m_onUse, (Delegate?)new Callback(OnEmpty));
				Switch emptyOreSwitch2 = m_emptyOreSwitch;
				emptyOreSwitch2.m_onHover = (TooltipCallback)Delegate.Combine((Delegate?)(object)emptyOreSwitch2.m_onHover, (Delegate?)new TooltipCallback(OnHoverEmptyOre));
			}
			m_nview.Register<string>("AddOre", (Action<long, string>)RPC_AddOre);
			m_nview.Register("EmptyProcessed", (Action<long>)RPC_EmptyProcessed);
			if ((Object)(object)m_container == (Object)null)
			{
				Debug.LogWarning((object)"There is no container");
				return;
			}
			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("UpdateFishnetTrap", 1f, 1f);
		}

		private void DropAllItems()
		{
			//IL_002c: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			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);
					ItemDrop.OnCreateNew(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(item2.m_from.m_itemData.m_shared.m_name, -1, false);
				if (item != null)
				{
					return item;
				}
			}
			return null;
		}

		private bool OnAddOre(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("AddOre", 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.IsValid()) ? 0f : m_nview.GetZDO().GetFloat(ZDOVars.s_bakeTimer, 0f);
		}

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

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

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

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

		private void RPC_AddOre(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("EmptyProcessed", Array.Empty<object>());
			return true;
		}

		private void RPC_EmptyProcessed(long sender)
		{
			if (m_nview.IsOwner())
			{
			}
		}

		private double 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(ZDOVars.s_startTime, time.Ticks);
			return totalSeconds;
		}

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

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

		private void UpdateFishnetTrap()
		{
			if (!m_nview.IsValid())
			{
				return;
			}
			UpdateState();
			if (!m_nview.IsOwner() || !m_container.m_inventory.HaveEmptySlot())
			{
				return;
			}
			double deltaTime = GetDeltaTime();
			float num = GetAccumulator() + (float)deltaTime;
			if ((double)num > 3600.0)
			{
				num = 3600f;
			}
			float num2 = 1f;
			while ((double)num >= 1.0)
			{
				num -= 1f;
				string queuedOre = GetQueuedOre();
				if ((m_maxOre != 0 && !(queuedOre != "")) || !((double)m_secPerProduct > 0.0))
				{
					continue;
				}
				float num3 = 1f * num2;
				if (queuedOre != "")
				{
					float num4 = GetBakeTimer() + num3;
					SetBakeTimer(num4);
					if ((double)num4 >= (double)m_secPerProduct)
					{
						SetBakeTimer(0f);
						RemoveOneOre();
						QueueProcessed(queuedOre);
					}
				}
			}
			SetAccumulator(num);
		}

		private void QueueProcessed(string ore)
		{
			AddToContainer(ore, 1);
		}

		private void SpawnProcessed()
		{
			if (m_nview.IsValid())
			{
				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.IsValid() ? m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0) : 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);
				ItemDrop component = Object.Instantiate<GameObject>(((Component)itemConversion.m_to).gameObject, m_outputPoint.position, m_outputPoint.rotation).GetComponent<ItemDrop>();
				component.m_itemData.m_stack = stack;
				ItemDrop.OnCreateNew(component);
			}
		}

		private void AddToContainer(string ore, int stack)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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);
				ItemDrop fish = getFish(itemConversion);
				if ((Object)(object)fish == (Object)null)
				{
					Debug.LogWarning((object)"Something went wrong no fish found!");
				}
				ItemData val = fish.m_itemData.Clone();
				val.m_stack = stack;
				if (m_container.GetInventory().CanAddItem(val, 1))
				{
					m_container.GetInventory().AddItem(val);
				}
			}
		}

		private ItemDrop getFish(ItemConversion itemConversion)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!CheckBiome(itemConversion.m_biome))
			{
				int num = Random.Range(0, 100);
				if (num <= 10)
				{
					ItemConversion itemConversionByBiomes = GetItemConversionByBiomes(GetBiome());
					if (itemConversionByBiomes != null)
					{
						return itemConversionByBiomes.m_to;
					}
				}
				return itemConversion.m_options[Random.Range(0, itemConversion.m_options.Count)];
			}
			int num2 = Random.Range(0, 100);
			if (num2 >= 75)
			{
				return itemConversion.m_to;
			}
			return itemConversion.m_options[Random.Range(0, itemConversion.m_options.Count)];
		}

		private bool CheckBiome(Biome m_biome)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			return (Heightmap.FindBiome(((Component)this).transform.position) & m_biome) > 0;
		}

		private Biome GetBiome()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Heightmap.FindBiome(((Component)this).transform.position);
		}

		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 ItemConversion GetItemConversionByBiomes(Biome m_biome)
		{
			//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)
			foreach (ItemConversion item in m_conversion)
			{
				if (item.m_biome == m_biome)
				{
					return item;
				}
			}
			return null;
		}

		private void SetNetState()
		{
			if (!IsActive())
			{
				m_full.SetActive(false);
				return;
			}
			m_full.SetActive(true);
			int num = m_container.m_inventory.NrOfItemsIncludingStacks();
			if (num > 1)
			{
				((Component)m_full.transform.Find("low")).gameObject.SetActive(true);
			}
			else
			{
				((Component)m_full.transform.Find("low")).gameObject.SetActive(false);
			}
			if ((double)num >= (double)m_maxFish * 0.5)
			{
				((Component)m_full.transform.Find("mid")).gameObject.SetActive(true);
			}
			else
			{
				((Component)m_full.transform.Find("mid")).gameObject.SetActive(false);
			}
			if ((double)num >= (double)m_maxFish * 0.75)
			{
				((Component)m_full.transform.Find("max")).gameObject.SetActive(true);
			}
			else
			{
				((Component)m_full.transform.Find("max")).gameObject.SetActive(false);
			}
			if (num >= m_maxFish)
			{
				m_full.SetActive(false);
			}
		}

		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);
			}
			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);
			SetNetState();
		}

		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_maxOre == 0 || GetQueueSize() > 0;
		}

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

		private string OnHoverAddOre()
		{
			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());
		}
	}
	[BepInPlugin("balrond.astafaraios.BalrondShipyard", "BalrondShipyard", "1.4.9")]
	public class Launch : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ShipyardStation), "Awake")]
		public static class ShipyardStation_Awake_Path
		{
			public static void Prefix(ShipyardStation __instance)
			{
				__instance.m_conversions = list;
			}
		}

		[HarmonyPatch(typeof(FishnetTrap), "Awake")]
		public static class FishnetTrap_Awake_Path
		{
			public static void Prefix(FishnetTrap __instance)
			{
				__instance.m_conversion = fishConversions;
			}
		}

		[HarmonyPatch(typeof(ShipExtensionManager), "Awake")]
		public static class ShipExtensionManager_Awake_Path
		{
			public static void Prefix(ShipExtensionManager __instance)
			{
				if (((Object)((Component)__instance).gameObject).name == "Karve(Clone)")
				{
					setupKarvePath(__instance);
				}
				if (((Object)((Component)__instance).gameObject).name == "VikingShip(Clone)")
				{
					setupDrakkarPath(__instance);
				}
				if (((Object)((Component)__instance).gameObject).name == "Knarr(Clone)")
				{
					setupKnarrPath(__instance);
				}
				if (((Object)((Component)__instance).gameObject).name == "Holk(Clone)")
				{
					setupHolkPath(__instance);
				}
				if (((Object)((Component)__instance).gameObject).name == "VikingShip_Ashlands(Clone)")
				{
					setupAshlandsDrakkarPath(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[]
		{
			typeof(int),
			typeof(bool),
			typeof(int),
			typeof(float)
		})]
		public class AddStatusEffectPatch
		{
			public static bool Prefix(SEMan __instance, ref int nameHash)
			{
				return !__instance.HaveStatusEffect("Waterproof".GetHashCode()) || nameHash != "Wet".GetHashCode();
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public static class ZNetScene_Awake_Path
		{
			public static void Prefix(ZNetScene __instance)
			{
				//IL_0902: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance == (Object)null)
				{
					return;
				}
				if ((Object)(object)shipyard == (Object)null)
				{
					Debug.Log((object)"THERE IS NO SHIPYARD");
					return;
				}
				objectRecipes.initPieces(__instance.m_prefabs);
				GameObject val = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Hammer");
				PieceTable buildPieces = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces;
				setupRavenGuide(shipyard, __instance.m_prefabs);
				setupRavenGuide(scribeTable, __instance.m_prefabs);
				ashlandsUpdateFix();
				foreach (GameObject scroll in scrolls)
				{
					GameObject val2 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)scroll).name);
					if ((Object)(object)val2 != (Object)null)
					{
						Debug.Log((object)("[SHIP] Scroll already exists in Znet skipping: " + ((Object)scroll).name));
						continue;
					}
					if (((Object)scroll).name.Contains("Drakkar"))
					{
						scroll.GetComponent<ItemDrop>().m_itemData.m_shared.m_name.Replace("Drakkar", "Longship");
					}
					__instance.m_prefabs.Add(scroll);
				}
				foreach (GameObject item in items)
				{
					GameObject val3 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)item).name);
					if ((Object)(object)val3 != (Object)null)
					{
						Debug.Log((object)("[SHIP] Item already exists in Znet skipping: " + ((Object)item).name));
						continue;
					}
					if (((Object)item).name == "CapeSailor")
					{
						item.GetComponent<ItemDrop>().m_itemData.m_shared.m_equipStatusEffect = ObjectDB.instance.GetStatusEffect("Waterproof".GetHashCode());
					}
					__instance.m_prefabs.Add(item);
				}
				if (!wasLoaded)
				{
					shipExtensionFactory.init(__instance, scrolls);
					list = shipExtensionFactory.list;
					shipProcessor.list = shipExtensionFactory.list;
					listKarve = shipExtensionFactory.listKarve;
					listKnarr = shipExtensionFactory.listKnarr;
					listDrakkar = shipExtensionFactory.listDrakkar;
					listHolk = shipExtensionFactory.listHolk;
					listAshlandsDrakkar = shipExtensionFactory.listAshlandsDrakkar;
					objectRecipes.createHolkRecipe(dvergercarve);
					objectRecipes.createKnarrRecipe(karr);
					objectRecipes.createShipyardRecipe(shipyard);
					objectRecipes.createScribeTableRecipe(scribeTable);
					shipProcessor.setupShipyard(__instance, shipyard);
					buildPieces.m_pieces.Add(shipyard);
					buildPieces.m_pieces.Add(scribeTable);
					GameObject val4 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Karve");
					GameObject val5 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Raft");
					GameObject val6 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "VikingShip");
					GameObject val7 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "VikingShip_Ashlands");
					objectRecipes.createKarveRecipe(val4);
					objectRecipes.createDrakkarRecipe(val6);
					objectRecipes.createAshlandsDrakkarRecipe(val7);
					GameObject val8 = buildPieces.m_pieces.Find((GameObject x) => ((Object)x).name == ((Object)dvergercarve).name);
					if ((Object)(object)val8 == (Object)null)
					{
						buildPieces.m_pieces.Add(dvergercarve);
					}
					GameObject val9 = buildPieces.m_pieces.Find((GameObject x) => ((Object)x).name == ((Object)karr).name);
					if ((Object)(object)val9 == (Object)null)
					{
						buildPieces.m_pieces.Add(karr);
					}
					objectRecipes.editBuildPieceRecipes(pieces);
					foreach (GameObject piece2 in pieces)
					{
						GameObject val10 = buildPieces.m_pieces.Find((GameObject x) => ((Object)x).name == ((Object)piece2).name);
						if ((Object)(object)val10 != (Object)null)
						{
							Debug.Log((object)("[SHIP] Piece already exists in Hammer: " + ((Object)piece2).name));
						}
						else
						{
							buildPieces.m_pieces.Add(piece2);
						}
					}
					if ((Object)(object)val5 != (Object)null)
					{
						val5.GetComponent<Piece>().m_canBeRemoved = true;
						shipProcessor.addRaftExtensions(raftExtension, val5, __instance);
					}
					else
					{
						Debug.LogWarning((object)"[SHIP] NO KARVE TO EDIT");
					}
					if ((Object)(object)val4 != (Object)null)
					{
						GameObject gameObject = ((Component)val4.transform.Find("piece_chest")).gameObject;
						gameObject.GetComponent<Container>().m_width = 3;
						gameObject.GetComponent<Container>().m_height = 2;
						shipProcessor.addKarveExtensions(karveExtension, val4, __instance);
					}
					else
					{
						Debug.Log((object)"[SHIP] NO KARVE TO EDIT");
					}
					if ((Object)(object)karr != (Object)null)
					{
						shipProcessor.addKnarrExtensions(knarrExtension, karr, __instance);
					}
					else
					{
						Debug.Log((object)"[SHIP] NO KNARR TO EDIT");
					}
					if ((Object)(object)dvergercarve != (Object)null)
					{
						shipProcessor.addHolkExtensions(holkExtensions, dvergercarve, __instance);
					}
					else
					{
						Debug.Log((object)"[SHIP] NO HOLK TO EDIT");
					}
					if ((Object)(object)val7 != (Object)null)
					{
						GameObject gameObject2 = ((Component)val7.transform.Find("piece_chest")).gameObject;
						gameObject2.GetComponent<Container>().m_width = 8;
						gameObject2.GetComponent<Container>().m_height = 5;
						shipProcessor.addAshlandsDrakkarExtensions(ashlandsDrakkarExtensions, val7, __instance);
					}
					else
					{
						Debug.Log((object)"[SHIP] NO DRAKKAR TO EDIT");
					}
					if ((Object)(object)val6 != (Object)null)
					{
						GameObject gameObject3 = ((Component)val6.transform.Find("piece_chest")).gameObject;
						gameObject3.GetComponent<Container>().m_width = 6;
						gameObject3.GetComponent<Container>().m_height = 4;
						shipProcessor.addDrakkarExtensions(drakkarExtensions, val6, __instance);
					}
					else
					{
						Debug.Log((object)"[SHIP] NO LONGSHIP TO EDIT");
					}
					wasLoaded = true;
				}
				foreach (GameObject piece in pieces)
				{
					GameObject val11 = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)piece).name);
					if ((Object)(object)val11 != (Object)null)
					{
						Debug.Log((object)("[SHIP] Piece already exists in Znet: " + ((Object)piece).name));
					}
					else
					{
						__instance.m_prefabs.Add(piece);
					}
				}
				__instance.m_prefabs.Add(projectileAnchor);
				__instance.m_prefabs.Add(shipyard);
				__instance.m_prefabs.Add(scribeTable);
				((Component)dvergercarve.transform.Find("piece_chest")).GetComponent<Container>().m_destroyedLootPrefab = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "CargoCrate");
				__instance.m_prefabs.Add(dvergercarve);
				((Component)karr.transform.Find("piece_chest")).GetComponent<Container>().m_destroyedLootPrefab = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "CargoCrate");
				__instance.m_prefabs.Add(karr);
				if (!new ZNet().IsDedicated())
				{
					ShaderReplacment.runMaterialFix();
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		public static class Object_CopyOtherDB_Path
		{
			public static void Postfix()
			{
				if (!IsObjectDBValid())
				{
					return;
				}
				StatusEffect stat = (StatusEffect)(object)createWateproofStatusEffect();
				if ((Object)(object)ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == ((Object)stat).name) == (Object)null)
				{
					ObjectDB.instance.m_StatusEffects.Add(stat);
				}
				objectRecipes.recipes = recipes;
				objectRecipes.initItems(ObjectDB.instance.m_items);
				foreach (GameObject scroll in scrolls)
				{
					AddNewPrefab(scroll);
				}
				foreach (GameObject item in items)
				{
					AddNewPrefab(item);
				}
				List<Recipe> collection = recipeBuilder.createRecipes(ObjectDB.instance.m_items, scrolls, scribeTable, items);
				recipes.AddRange(collection);
				foreach (Recipe recipe in recipes)
				{
					AddRecipeToObjectDB(recipe);
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class Object_Awake_Path
		{
			public static void Postfix()
			{
				if (!IsObjectDBValid())
				{
					return;
				}
				StatusEffect stat = (StatusEffect)(object)createWateproofStatusEffect();
				if ((Object)(object)ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == ((Object)stat).name) == (Object)null)
				{
					ObjectDB.instance.m_StatusEffects.Add(stat);
				}
				objectRecipes.initItems(ObjectDB.instance.m_items);
				objectRecipes.recipes = recipes;
				foreach (GameObject scroll in scrolls)
				{
					AddNewPrefab(scroll);
				}
				foreach (GameObject item in items)
				{
					AddNewPrefab(item);
				}
				foreach (Recipe recipe in recipes)
				{
					AddRecipeToObjectDB(recipe);
				}
			}
		}

		private readonly Harmony harmony = new Harmony("balrond.astafaraios.BalrondShipyard");

		public const string PluginGUID = "balrond.astafaraios.BalrondShipyard";

		public const string PluginName = "BalrondShipyard";

		public const string PluginVersion = "1.4.9";

		private static AssetBundle assetBundle;

		public static GameObject karveExtension;

		public static GameObject knarrExtension;

		public static GameObject raftExtension;

		public static GameObject drakkarExtensions;

		public static GameObject ashlandsDrakkarExtensions;

		public static GameObject holkExtensions;

		public static GameObject shipyard;

		public static bool wasLoaded = false;

		public static ShipExtensionFactory shipExtensionFactory = new ShipExtensionFactory();

		public static List<ShipExtension> list = new List<ShipExtension>();

		public static List<ShipExtension> listKarve = new List<ShipExtension>();

		public static List<ShipExtension> listKnarr = new List<ShipExtension>();

		public static List<ShipExtension> listDrakkar = new List<ShipExtension>();

		public static List<ShipExtension> listAshlandsDrakkar = new List<ShipExtension>();

		public static List<ShipExtension> listHolk = new List<ShipExtension>();

		public static List<Texture> texturesKarve = new List<Texture>();

		public static List<Texture> texturesDrakkar = new List<Texture>();

		public static List<Texture> texturesRaft = new List<Texture>();

		public static List<GameObject> scrolls = new List<GameObject>();

		public static GameObject scribeTable;

		public static List<Recipe> recipes = new List<Recipe>();

		public static ShipProcessor shipProcessor = new ShipProcessor();

		public static ObjectRecipes objectRecipes = new ObjectRecipes();

		public static List<FishnetTrap.ItemConversion> fishConversions = new List<FishnetTrap.ItemConversion>();

		public static RecipeBuilder recipeBuilder = new RecipeBuilder();

		public static Sprite waterProofIco;

		public static List<GameObject> items = new List<GameObject>();

		public static string[] itemNames = new string[8] { "SailInk", "CoalPaste", "HelmetPirateBandana", "HelmetPirateHat", "SledgeAnchor", "CapeSailor", "ShieldSteering", "SwordSaber" };

		public static string[] scrollNames = new string[95]
		{
			"SchematicDrakkarAnchor", "SchematicDrakkarArmor", "SchematicDrakkarBarrels", "SchematicDrakkarCrates", "SchematicDrakkarLights", "SchematicDrakkarOar", "SchematicDrakkarShields", "SchematicDrakkarTent", "SchematicDrakkarHeadCernyx", "SchematicDrakkarHeadDragon",
			"SchematicDrakkarHeadOsberg", "SchematicDrakkarHeadSkull", "SchematicDrakkarSailBlack", "SchematicDrakkarSailBlue", "SchematicDrakkarSailGreen", "SchematicDrakkarSailDefault", "SchematicDrakkarSailTransparent", "SchematicDrakkarSailWhite", "SchematicDrakkarSailHound", "SchematicDrakkarSailDruid",
			"SchematicDrakkarSailWolf", "SchematicDrakkarSailRaven", "SchematicKarveAnchor", "SchematicKarveArmor", "SchematicKarveBag", "SchematicKarveLights", "SchematicKarveOars", "SchematicKarveShields", "SchematicKarveSailBlack", "SchematicKarveSailBlue",
			"SchematicKarveSailDefault", "SchematicKarveSailGreen", "SchematicKarveSailTransparent", "SchematicKarveSailWhite", "SchematicKarveSailHound", "SchematicKarveSailDruid", "SchematicKarveSailWolf", "SchematicKarveSailRaven", "SchematicKnarrAnchor", "SchematicKnarrArmor",
			"SchematicKnarrBag", "SchematicKnarrLights", "SchematicKnarrOars", "SchematicKnarrShields", "SchematicKnarrTent", "SchematicKnarrSailBlack", "SchematicKnarrSailBlue", "SchematicKnarrSailDefault", "SchematicKnarrSailDruid", "SchematicKnarrSailGreen",
			"SchematicKnarrSailHound", "SchematicKnarrSailRaven", "SchematicKnarrSailTransparent", "SchematicKnarrSailWhite", "SchematicKnarrSailWolf", "SchematicHolkAnchor", "SchematicHolkArmor", "SchematicHolkLights", "SchematicHolkOars", "SchematicHolkShields",
			"SchematicHolkTent", "SchematicHolkBag", "SchematicHolkRopes", "SchematicHolkSailBlack", "SchematicHolkSailBlue", "SchematicHolkSailGreen", "SchematicHolkSailDefault", "SchematicHolkSailTransparent", "SchematicHolkSailWhite", "SchematicHolkSailHound",
			"SchematicHolkSailDruid", "SchematicHolkSailWolf", "SchematicHolkSailRaven", "SchematicAshlandsDrakkarAnchor", "SchematicAshlandsDrakkarCrates", "SchematicAshlandsDrakkarLights", "SchematicAshlandsDrakkarOar", "SchematicAshlandsDrakkarShields", "SchematicAshlandsDrakkarTent", "SchematicAshlandsDrakkarRopes",
			"SchematicAshlandsDrakkarSailBlack", "SchematicAshlandsDrakkarSailBlue", "SchematicAshlandsDrakkarSailGreen", "SchematicAshlandsDrakkarSailDefault", "SchematicAshlandsDrakkarSailTransparent", "SchematicAshlandsDrakkarSailWhite", "SchematicAshlandsDrakkarSailHound", "SchematicAshlandsDrakkarSailDruid", "SchematicAshlandsDrakkarSailWolf", "SchematicAshlandsDrakkarSailRaven",
			"SchematicKnarrNamePlate", "SchematicKarveNamePlate", "SchematicHolkNamePlate", "SchematicAshlandsDrakkarNamePlate", "SchematicDrakkarNamePlate"
		};

		public static List<GameObject> pieces = new List<GameObject>();

		public static string[] piecesNames = new string[28]
		{
			"tar_wood_wall_log4", "tar_wood_wall_log2", "tar_wood_pole_log4", "tar_wood_pole_log2", "tar_wood_floor", "tar_ladder", "tar_wood_log_26", "tar_wood_log_45", "tar_wood_pole_log1", "tar_wood_ramp",
			"piece_chest_tarred", "piece_chest_cargo", "piece_iron_wall_torch", "decor_dragon", "bridge_rope", "bridge_rope_support", "bridge_rope_support_side", "cloth_roof", "cloth_roof_corner", "cloth_roof_corner2",
			"cloth_roof_triangle_sloope", "fishnet_wall", "piece_banner_sail1", "piece_banner_sail2", "piece_ropewall", "piece_ropewall_big", "piece_wisplampceiling", "FishnetTrap"
		};

		public static string[] sailNames = new string[10] { "default_drakkar", "blue_drakkar", "torn_drakkar", "green_drakkar", "transparent_drakkar", "white_drakkar", "sailCross", "yellow_drakkar", "sailDark", "sailVegvisir" };

		public static GameObject dvergercarve;

		public static GameObject karr;

		public static GameObject projectileAnchor;

		private static FieldInfo AttachAnimField = AccessTools.Field(typeof(Player), "m_attachAnimation");

		private void Awake()
		{
			init();
		}

		private void init()
		{
			LoadAllAssetBundles();
			shipProcessor.shipyard = shipyard;
			shipProcessor.texturesDrakkar = texturesDrakkar;
			shipProcessor.list = shipExtensionFactory.list;
			harmony.PatchAll();
		}

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

		private static 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;
		}

		public static void LoadAllAssetBundles()
		{
			assetBundle = GetAssetBundleFromResources("shipyardnew");
			LoadPrefabs();
		}

		public static AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}

		private static void LoadPrefabs()
		{
			string text = "Assets/Custom/BalrondShipyard/";
			waterProofIco = assetBundle.LoadAsset<Sprite>(text + "wateproof_ico.png");
			dvergercarve = assetBundle.LoadAsset<GameObject>(text + "prefabs/Holk.prefab");
			karr = assetBundle.LoadAsset<GameObject>(text + "prefabs/KnarrBal.prefab");
			((Object)karr).name = "Knarr";
			setupGateDoor(dvergercarve);
			ShaderReplacment.Replace(karr);
			ShaderReplacment.Replace(dvergercarve);
			raftExtension = assetBundle.LoadAsset<GameObject>(text + "prefabs/RaftExtension/RaftExtension.prefab");
			projectileAnchor = assetBundle.LoadAsset<GameObject>(text + "prefabs/projectile_anchor.prefab");
			karveExtension = assetBundle.LoadAsset<GameObject>(text + "prefabs/KarveExtensions/karveExtension.prefab");
			knarrExtension = ((Component)karr.transform.Find("knarrExtension")).gameObject;
			holkExtensions = ((Component)dvergercarve.transform.Find("DvergerExtension")).gameObject;
			ShaderReplacment.Replace(knarrExtension);
			ShaderReplacment.Replace(holkExtensions);
			shipyard = assetBundle.LoadAsset<GameObject>(text + "prefabs/pieces/ShipyardStation.prefab");
			drakkarExtensions = assetBundle.LoadAsset<GameObject>(text + "prefabs/DrakkarExtensions/DrakkarExtensions.prefab");
			ashlandsDrakkarExtensions = assetBundle.LoadAsset<GameObject>(text + "prefabs/AshlandsDrakkarExtensions.prefab");
			scribeTable = assetBundle.LoadAsset<GameObject>(text + "prefabs/pieces/piece_scribetable.prefab");
			ShaderReplacment.Replace(scribeTable);
			ShaderReplacment.Replace(karveExtension);
			ShaderReplacment.Replace(shipyard);
			ShaderReplacment.Replace(drakkarExtensions);
			ShaderReplacment.Replace(ashlandsDrakkarExtensions);
			string[] array = sailNames;
			foreach (string text2 in array)
			{
				Texture val = assetBundle.LoadAsset<Texture>(text + "sails/" + text2 + ".png");
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Sail not found: " + text2));
				}
				else
				{
					texturesDrakkar.Add(val);
				}
			}
			string[] array2 = piecesNames;
			foreach (string text3 in array2)
			{
				GameObject val2 = assetBundle.LoadAsset<GameObject>(text + "prefabs/pieces/" + text3 + ".prefab");
				if ((Object)(object)val2 == (Object)null)
				{
					Debug.LogWarning((object)("Not found: " + text3));
				}
				if (text3 == "FishnetTrap")
				{
					Object.DestroyImmediate((Object)(object)val2.GetComponent<Smelter>());
				}
				ShaderReplacment.Replace(val2);
				pieces.Add(val2);
			}
			string[] array3 = scrollNames;
			foreach (string text4 in array3)
			{
				GameObject val3 = assetBundle.LoadAsset<GameObject>(text + "prefabs/schematics/" + text4 + ".prefab");
				if ((Object)(object)val3 == (Object)null)
				{
					Debug.LogWarning((object)("Not found: " + text4));
				}
				ShaderReplacment.Replace(val3);
				scrolls.Add(val3);
			}
			string[] array4 = itemNames;
			foreach (string text5 in array4)
			{
				GameObject val4 = assetBundle.LoadAsset<GameObject>(text + "prefabs/items/" + text5 + ".prefab");
				if ((Object)(object)val4 == (Object)null)
				{
					Debug.LogWarning((object)("Not found: " + text5));
				}
				ShaderReplacment.Replace(val4);
				items.Add(val4);
			}
		}

		public static void setupGateDoor(GameObject gameObject)
		{
			GameObject gameObject2 = ((Component)gameObject.transform.Find("DvergerExtension/ramp_door")).gameObject;
			if ((Object)(object)gameObject2 == (Object)null)
			{
				Debug.LogWarning((object)"Cant find ramp !");
				return;
			}
			Door component = gameObject2.GetComponent<Door>();
			ShipRamp shipRamp = gameObject2.AddComponent<ShipRamp>();
			shipRamp.m_nview = gameObject.GetComponent<ZNetView>();
			shipRamp.m_name = component.m_name;
			shipRamp.m_openEffects = component.m_openEffects;
			shipRamp.m_openEnable = component.m_openEnable;
			shipRamp.m_closeEffects = component.m_closeEffects;
		}

		public static void setupRavenGuide(GameObject gameObject, List<GameObject> gameObjects)
		{
			GameObject gameObject2 = ((Component)gameObject.transform.Find("GuidePoint")).gameObject;
			GameObject val = gameObjects.Find((GameObject x) => ((Object)x).name == "piece_workbench");
			GameObject gameObject3 = ((Component)val.transform.Find("GuidePoint")).gameObject;
			GameObject ravenPrefab = gameObject3.GetComponent<GuidePoint>().m_ravenPrefab;
			if ((Object)(object)ravenPrefab == (Object)null)
			{
				Debug.LogWarning((object)"Ravens not found");
			}
			else
			{
				gameObject2.GetComponent<GuidePoint>().m_ravenPrefab = ravenPrefab;
			}
		}

		public static void setupDrakkarPath(ShipExtensionManager __instance)
		{
			//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)
			GameObject val = ((Component)((Component)__instance).transform.Find("DrakkarExtensions")).gameObject;
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)((Component)__instance).transform.Find("DrakkarExtensions(Clone)")).gameObject;
				if ((Object)(object)val == (Object)null)
				{
					val = Object.Instantiate<GameObject>(drakkarExtensions, Vector3.zero, Quaternion.identity);
					shipProcessor.setPosition(val, ((Component)__instance).gameObject);
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"I PATCHED AND NOT FOUND EXTENSIONS FOR DRAKKAR");
			}
			if ((Object)(object)val != (Object)null)
			{
				__instance.lights = ((Component)val.transform.Find("Lamps")).gameObject;
				__instance.anchor = ((Component)val.transform.Find("Anchor")).gameObject;
				__instance.oars = ((Component)val.transform.Find("Oars")).gameObject;
				__instance.shields = ((Component)val.transform.Find("shieldset")).gameObject;
				__instance.roof = ((Component)val.transform.Find("Roof")).gameObject;
				__instance.lampheat = ((Component)val.transform.Find("LampWarm")).gameObject;
				__instance.fishnet = ((Component)val.transform.Find("fishnet")).gameObject;
				__instance.armor = ((Component)val.transform.Find("carapacehull")).gameObject;
				__instance.ram = ((Component)val.transform.Find("BatteringRam")).gameObject;
				__instance.nameplate = ((Component)val.transform.Find("shipplate")).gameObject;
				__instance.nameplate.SetActive(false);
			}
			__instance.shipExtensions = listDrakkar;
			Transform val2 = ((Component)__instance).gameObject.transform.Find("ship").Find("visual");
			GameObject gameObject = ((Component)val2.Find("Customize")).gameObject;
			gameObject.SetActive(true);
			__instance.customize = gameObject;
			__instance.sail = ((Component)val2.Find("Mast").Find("Sail").Find("sail_full")).gameObject;
			__instance.textures = texturesDrakkar;
			shipProcessor.setupNamePlate(__instance.nameplate, ((Component)__instance).GetComponent<Ship>());
			shipProcessor.setupFishnet(__instance.fishnet, ((Component)__instance).GetComponent<Ship>());
			shipProcessor.setupShipHeads(((Component)__instance).gameObject);
			shipProcessor.setupShipLamps(__instance.customize);
			shipProcessor.setupShipShieldsAndCrates(__instance.customize);
			shipProcessor.setupShipTent(__instance.customize);
		}

		public static void setupAshlandsDrakkarPath(ShipExtensionManager __instance)
		{
			//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)
			GameObject val = ((Component)((Component)__instance).transform.Find("AshlandsDrakkarExtensions")).gameObject;
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)((Component)__instance).transform.Find("AshlandsDrakkarExtensions(Clone)")).gameObject;
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)"Extension not found on clone");
					val = Object.Instantiate<GameObject>(ashlandsDrakkarExtensions, Vector3.zero, Quaternion.identity);
					shipProcessor.setPosition(val, ((Component)__instance).gameObject);
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"I PATCHED AND NOT FOUND EXTENSIONS FOR HOLK");
			}
			Ship component = ((Component)__instance).GetComponent<Ship>();
			shipProcessor.addAshlandsDrakkarExtensions(val, ((Component)component).gameObject, ZNetScene.instance);
			__instance.textures = texturesDrakkar;
		}

		public static void setupHolkPath(ShipExtensionManager __instance)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = ((Component)((Component)__instance).transform.Find("DvergerExtension")).gameObject;
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"Extension not found on ship");
				val = ((Component)((Component)__instance).transform.Find("DvergerExtension(Clone)")).gameObject;
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)"Extension not found on clone");
					val = Object.Instantiate<GameObject>(holkExtensions, Vector3.zero, Quaternion.identity);
					shipProcessor.setPosition(val, ((Component)__instance).gameObject);
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"I PATCHED AND NOT FOUND EXTENSIONS FOR HOLK");
			}
			Ship component = ((Component)__instance).GetComponent<Ship>();
			shipProcessor.addHolkExtensions(val, ((Component)component).gameObject, ZNetScene.instance);
			__instance.textures = texturesDrakkar;
		}

		public static void setupKarvePath(ShipExtensionManager __instance)
		{
			GameObject val = ((Component)((Component)__instance).transform.Find("karveExtension")).gameObject;
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)((Component)__instance).transform.Find("karveExtension(Clone)")).gameObject;
				if ((Object)(object)val == (Object)null)
				{
					val = Object.Instantiate<GameObject>(karveExtension);
					shipProcessor.setPosition(val, ((Component)__instance).gameObject);
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"I PATCHED AND NOT FOUND EXTENSIONS FOR KARVE");
				return;
			}
			shipProcessor.addKarveExtensions(val, ((Component)__instance).gameObject, ZNetScene.instance);
			__instance.textures = texturesDrakkar;
		}

		public static void setupKnarrPath(ShipExtensionManager __instance)
		{
			GameObject val = ((Component)((Component)__instance).transform.Find("knarrExtension")).gameObject;
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)((Component)__instance).transform.Find("knarrExtension(Clone)")).gameObject;
				if ((Object)(object)val == (Object)null)
				{
					val = Object.Instantiate<GameObject>(knarrExtension);
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)"I PATCHED AND NOT FOUND EXTENSIONS FOR KNARR");
				return;
			}
			shipProcessor.addKnarrExtensions(val, ((Component)__instance).gameObject, ZNetScene.instance);
			__instance.textures = texturesDrakkar;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Ship), "OnTriggerEnter")]
		[HarmonyPatch(typeof(Ship), "OnTriggerExit")]
		public static void Ship_EnterExit(Collider collider, Ship __instance, List<Player> ___m_players)
		{
			if (Object.op_Implicit((Object)(object)((Component)collider).GetComponent<Player>()))
			{
				__instance.m_backwardForce = CalculateForce(___m_players.Count);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Ship), "UpdateOwner")]
		public static void Ship_UpdateOwner(Ship __instance, List<Player> ___m_players)
		{
			ShipExtensionManager component = ((Component)__instance).GetComponent<ShipExtensionManager>();
			if ((Object)(object)component != (Object)null && component.isOarActive())
			{
				int count = ___m_players.FindAll((Player p) => ((Character)p).IsAttached() && (string)AttachAnimField.GetValue(p) == "attach_chair").Count;
				__instance.m_backwardForce = CalculateForce(count);
				Debug.Log((object)("Ship ID:" + ((Object)__instance).GetInstanceID() + " sitting player count:" + count + " paddle force:" + __instance.m_backwardForce));
			}
		}

		public static bool isPaddleForceActive()
		{
			return true;
		}

		public static bool isLinear()
		{
			return true;
		}

		public static float CalculateForce(int playerCount)
		{
			if (playerCount <= 0 || !isPaddleForceActive())
			{
				return 0.5f;
			}
			if (isLinear())
			{
				return Mathf.Min(0.5f + 0.25f * (float)(playerCount - 1), 3f);
			}
			float num = 0.55f;
			float num2 = Mathf.Clamp(0.875f, 1E-05f, 0.99999f);
			return num * (float)((1.0 - (double)Mathf.Pow(num2, (float)playerCount)) / (1.0 - (double)num2));
		}

		public static void ashlandsUpdateFix()
		{
			//IL_001a: 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)
			ImpactEffect component = dvergercarve.GetComponent<ImpactEffect>();
			ImpactEffect component2 = karr.GetComponent<ImpactEffect>();
			component.m_hitType = (HitType)17;
			component2.m_hitType = (HitType)17;
			WearNTear component3 = dvergercarve.GetComponent<WearNTear>();
			WearNTear component4 = karr.GetComponent<WearNTear>();
			component3.m_burnable = true;
			component4.m_burnable = true;
			Rigidbody component5 = dvergercarve.GetComponent<Rigidbody>();
			Rigidbody component6 = karr.GetComponent<Rigidbody>();
			component5.automaticCenterOfMass = true;
			component5.automaticInertiaTensor = true;
			component5.useGravity = true;
			component6.automaticCenterOfMass = true;
			component6.automaticInertiaTensor = true;
			component6.useGravity = true;
			Ship component7 = dvergercarve.GetComponent<Ship>();
			Ship component8 = karr.GetComponent<Ship>();
			component7.m_ashDamageMsgTime = 10f;
			component8.m_ashDamageMsgTime = 10f;
			component7.m_ashdamageEffects = ((Component)((Component)component7).transform.Find("ashlandeffects")).gameObject;
			component8.m_ashdamageEffects = ((Component)((Component)component8).transform.Find("ashlandeffects")).gameObject;
		}

		public static SE_WetImmunity createWateproofStatusEffect()
		{
			SE_WetImmunity sE_WetImmunity = ScriptableObject.CreateInstance<SE_WetImmunity>();
			((Object)sE_WetImmunity).name = "Waterproof";
			((StatusEffect)sE_WetImmunity).m_icon = waterProofIco;
			return sE_WetImmunity;
		}

		private static void AddRecipeToObjectDB(Recipe recipe)
		{
			int num = ObjectDB.instance.m_recipes.RemoveAll((Recipe x) => ((Object)x).name == ((Object)recipe).name);
			if (num > 0)
			{
			}
			ObjectDB.instance.m_recipes.Add(recipe);
		}

		private static void AddNewPrefab(GameObject newPrefab)
		{
			if ((Object)(object)newPrefab == (Object)null)
			{
				return;
			}
			if (((Object)newPrefab).name == "CapeSailor")
			{
				newPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_equipStatusEffect = ObjectDB.instance.GetStatusEffect("Waterproof".GetHashCode());
			}
			ItemDrop component = newPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				if (((Object)newPrefab).name.Contains("Drakkar"))
				{
					component.m_itemData.m_shared.m_name.Replace("Drakkar", "Longship");
				}
				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[StringExtensionMethods.GetStableHashCode(((Object)newPrefab).name)] = newPrefab;
				}
			}
			else
			{
				Debug.LogError((object)(((Object)newPrefab).name + " - ItemDrop not found on prefab"));
			}
		}
	}
	public class ObjectRecipes
	{
		public List<GameObject> zNetItems;

		public List<GameObject> ObjectDbItems;

		public List<Recipe> recipes;

		public List<GameObject> hammerTables;

		private string[] fishBaitNames = new string[9] { "FishingBait", "FishingBaitSwamp", "FishingBaitPlains", "FishingBaitOcean", "FishingBaitMistlands", "FishingBaitForest", "FishingBaitDeepNorth", "FishingBaitCave", "FishingBaitAshlands" };

		public void initPieces(List<GameObject> items)
		{
			zNetItems = items;
		}

		public void initItems(List<GameObject> items)
		{
			ObjectDbItems = items;
			GameObject val = ObjectDbItems.Find((GameObject x) => ((Object)x).name == "Hammer");
			hammerTables = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces.FindAll((GameObject x) => (Object)(object)x.GetComponent<CraftingStation>() != (Object)null);
		}

		public void editBuildPieceRecipes(List<GameObject> buildables)
		{
			foreach (GameObject buildable in buildables)
			{
				if ((Object)(object)buildable == (Object)null)
				{
					Debug.LogWarning((object)"BUILD PIECE IS NULL SOMETHING DID NOT LOAD");
					continue;
				}
				List<Requirement> list = new List<Requirement>();
				Piece component = buildable.GetComponent<Piece>();
				if (((Object)buildable).name.Contains("tar_"))
				{
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					switch (((Object)buildable).name)
					{
					case "tar_wood_wall_log4":
						list.Add(GetRequirement("CoalPaste", 2, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 4, 0, zNetItems));
						break;
					case "tar_wood_wall_log2":
						list.Add(GetRequirement("CoalPaste", 1, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
						break;
					case "tar_wood_pole_log4":
						list.Add(GetRequirement("CoalPaste", 2, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 4, 0, zNetItems));
						break;
					case "tar_wood_pole_log2":
						list.Add(GetRequirement("CoalPaste", 1, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
						break;
					case "tar_wood_floor":
						list.Add(GetRequirement("CoalPaste", 1, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
						break;
					case "tar_ladder":
						list.Add(GetRequirement("CoalPaste", 2, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 3, 0, zNetItems));
						break;
					case "tar_wood_log_26":
						list.Add(GetRequirement("CoalPaste", 1, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
						break;
					case "tar_wood_log_45":
						list.Add(GetRequirement("CoalPaste", 1, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
						break;
					case "tar_wood_pole_log1":
						list.Add(GetRequirement("CoalPaste", 1, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 1, 0, zNetItems));
						break;
					case "tar_wood_ramp":
						list.Add(GetRequirement("CoalPaste", 1, 0, zNetItems));
						list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
						break;
					}
					component.m_resources = list.ToArray();
					continue;
				}
				component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "forge").GetComponent<CraftingStation>();
				switch (((Object)buildable).name)
				{
				case "decor_dragon":
					list.Add(GetRequirement("Coal", 1, 0, zNetItems));
					list.Add(GetRequirement("Iron", 1, 0, zNetItems));
					list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "piece_chest_cargo":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("CoalPaste", 2, 0, zNetItems));
					list.Add(GetRequirement("IronNails", 24, 0, zNetItems));
					list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "piece_chest_tarred":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("Tar", 5, 0, zNetItems));
					list.Add(GetRequirement("IronNails", 64, 0, zNetItems));
					list.Add(GetRequirement("FineWood", 20, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 10, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "piece_iron_wall_torch":
					list.Add(GetRequirement("CoalPaste", 1, 0, zNetItems));
					list.Add(GetRequirement("Iron", 1, 0, zNetItems));
					list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
					list.Add(GetRequirement("Tar", 2, 0, zNetItems));
					component.m_resources = list.ToArray();
					((Component)component).gameObject.GetComponent<Fireplace>().m_fuelItem = zNetItems.Find((GameObject x) => ((Object)x).name == "Tar").GetComponent<ItemDrop>();
					break;
				case "bridge_rope":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 3, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "bridge_rope_support":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 6, 0, zNetItems));
					list.Add(GetRequirement("RoundLog", 2, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "bridge_rope_support_side":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 3, 0, zNetItems));
					list.Add(GetRequirement("RoundLog", 1, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "cloth_roof":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 1, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 6, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "cloth_roof_corner":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 1, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 6, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "cloth_roof_corner2":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 1, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 6, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "cloth_roof_triangle_sloope":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 1, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 6, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "fishnet_wall":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 1, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 6, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "piece_banner_sail1":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 2, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 2, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "piece_banner_sail2":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 2, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 2, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "piece_ropewall":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 2, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 2, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "piece_ropewall_big":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 2, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 2, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "piece_wisplampceiling":
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("Wisp", 3, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 3, 0, zNetItems));
					list.Add(GetRequirement("BronzeNails", 8, 0, zNetItems));
					list.Add(GetRequirement("Iron", 1, 0, zNetItems));
					component.m_resources = list.ToArray();
					break;
				case "FishnetTrap":
					((Behaviour)component).enabled = false;
					component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
					list.Add(GetRequirement("FineWood", 4, 0, zNetItems));
					list.Add(GetRequirement("LeatherScraps", 8, 0, zNetItems));
					list.Add(GetRequirement("IronNails", 14, 0, zNetItems));
					list.Add(GetRequirement("CoalPaste", 4, 0, zNetItems));
					list.Add(GetRequirement("FishingBait", 10, 0, zNetItems));
					component.m_resources = list.ToArray();
					setupFishtrap(component);
					break;
				default:
					Debug.LogWarning((object)("Unknown piece: " + ((Object)buildable).name));
					break;
				}
			}
		}

		private void setupFishtrap(Piece piece)
		{
			FishnetTrap fishnetTrap = ((Component)piece).gameObject.GetComponent<FishnetTrap>();
			if ((Object)(object)fishnetTrap == (Object)null)
			{
				fishnetTrap = ((Component)piece).gameObject.AddComponent<FishnetTrap>();
				fishnetTrap.m_container = ((Component)((Component)piece).transform.Find("piece_chest")).GetComponent<Container>();
				fishnetTrap.m_addOreSwitch = ((Component)((Component)piece).transform.Find("add_ore")).GetComponent<Switch>();
				fishnetTrap.m_haveOreObject = ((Component)((Component)piece).transform.Find("have_ore")).gameObject;
				fishnetTrap.m_enabledObject = ((Component)((Component)piece).transform.Find("_enabled")).gameObject;
				fishnetTrap.m_full = ((Component)((Component)piece).transform.Find("full")).gameObject;
			}
			Launch.setupRavenGuide(((Component)fishnetTrap).gameObject, zNetItems);
			setupFishtrapConversions(fishnetTrap);
			fishnetTrap.m_container.m_destroyedLootPrefab = zNetItems.Find((GameObject x) => ((Object)x).name == "CargoCrate");
		}

		private void setupFishtrapConversions(FishnetTrap FishnetTrap)
		{
			List<FishnetTrap.ItemConversion> list = new List<FishnetTrap.ItemConversion>();
			string[] array = fishBaitNames;
			foreach (string name in array)
			{
				FishnetTrap.ItemConversion itemConversion = singleConversion(name);
				if (itemConversion != null)
				{
					list.Add(itemConversion);
				}
			}
			Launch.fishConversions = list;
			FishnetTrap.m_conversion = list;
		}

		private FishnetTrap.ItemConversion singleConversion(string name)
		{
			string[] othernames = new string[3] { "Fish1", "Fish2", "Fish3" };
			return name switch
			{
				"FishingBait" => setupFishConversion(name, "Fish2", othernames, (Biome)1), 
				"FishingBaitSwamp" => setupFishConversion(name, "Fish6", othernames, (Biome)2), 
				"FishingBaitPlains" => setupFishConversion(name, "Fish7", othernames, (Biome)16), 
				"FishingBaitOcean" => setupFishConversion(name, "Fish8", othernames, (Biome)256), 
				"FishingBaitMistlands" => setupFishConversion(name, "Fish12", othernames, (Biome)512), 
				"FishingBaitForest" => setupFishConversion(name, "Fish5", othernames, (Biome)8), 
				"FishingBaitDeepNorth" => setupFishConversion(name, "Fish10", othernames, (Biome)64), 
				"FishingBaitCave" => setupFishConversion(name, "Fish4_cave", othernames, (Biome)4), 
				"FishingBaitAshlands" => setupFishConversion(name, "Fish11", othernames, (Biome)32), 
				_ => null, 
			};
		}

		private FishnetTrap.ItemConversion setupFishConversion(string from, string to, string[] othernames, Biome biome)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			FishnetTrap.ItemConversion itemConversion = new FishnetTrap.ItemConversion();
			itemConversion.m_seconds = 0;
			itemConversion.m_biome = biome;
			itemConversion.m_from = zNetItems.Find((GameObject x) => ((Object)x).name == from).GetComponent<ItemDrop>();
			itemConversion.m_to = zNetItems.Find((GameObject x) => ((Object)x).name == to).GetComponent<ItemDrop>();
			itemConversion.m_options = new List<ItemDrop>();
			foreach (string name in othernames)
			{
				itemConversion.m_options.Add(zNetItems.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>());
			}
			return itemConversion;
		}

		public void createAshlandsDrakkarRecipe(GameObject shipyard)
		{
			Piece component = shipyard.GetComponent<Piece>();
			List<Requirement> list = new List<Requirement>();
			list.Add(GetRequirement("FineWood", 50, 0, zNetItems));
			list.Add(GetRequirement("IronNails", 160, 0, zNetItems));
			list.Add(GetRequirement("Tar", 30, 0, zNetItems));
			list.Add(GetRequirement("YggdrasilWood", 30, 0, zNetItems));
			list.Add(GetRequirement("CeramicPlate", 40, 0, zNetItems));
			component.m_resources = list.ToArray();
			component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
		}

		public void createDrakkarRecipe(GameObject shipyard)
		{
			Piece component = shipyard.GetComponent<Piece>();
			List<Requirement> list = new List<Requirement>();
			list.Add(GetRequirement("FineWood", 35, 0, zNetItems));
			list.Add(GetRequirement("IronNails", 120, 0, zNetItems));
			list.Add(GetRequirement("CoalPaste", 35, 0, zNetItems));
			list.Add(GetRequirement("TrollHide", 20, 0, zNetItems));
			list.Add(GetRequirement("ElderBark", 40, 0, zNetItems));
			component.m_resources = list.ToArray();
			component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
		}

		public void createKarveRecipe(GameObject shipyard)
		{
			Piece component = shipyard.GetComponent<Piece>();
			List<Requirement> list = new List<Requirement>();
			list.Add(GetRequirement("FineWood", 40, 0, zNetItems));
			list.Add(GetRequirement("BronzeNails", 100, 0, zNetItems));
			list.Add(GetRequirement("LeatherScraps", 16, 0, zNetItems));
			list.Add(GetRequirement("DeerHide", 10, 0, zNetItems));
			list.Add(GetRequirement("CoalPaste", 15, 0, zNetItems));
			component.m_resources = list.ToArray();
			component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
		}

		public void createKnarrRecipe(GameObject shipyard)
		{
			Piece component = shipyard.GetComponent<Piece>();
			List<Requirement> list = new List<Requirement>();
			list.Add(GetRequirement("FineWood", 40, 0, zNetItems));
			list.Add(GetRequirement("BronzeNails", 140, 0, zNetItems));
			list.Add(GetRequirement("LeatherScraps", 14, 0, zNetItems));
			list.Add(GetRequirement("TrollHide", 14, 0, zNetItems));
			list.Add(GetRequirement("CoalPaste", 25, 0, zNetItems));
			component.m_resources = list.ToArray();
			component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
		}

		public void createHolkRecipe(GameObject shipyard)
		{
			Piece component = shipyard.GetComponent<Piece>();
			List<Requirement> list = new List<Requirement>();
			list.Add(GetRequirement("YggdrasilWood", 40, 0, zNetItems));
			list.Add(GetRequirement("BlackMetal", 20, 0, zNetItems));
			list.Add(GetRequirement("ElderBark", 50, 0, zNetItems));
			list.Add(GetRequirement("LoxPelt", 12, 0, zNetItems));
			list.Add(GetRequirement("Tar", 20, 0, zNetItems));
			component.m_resources = list.ToArray();
			component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
		}

		public void createShipyardRecipe(GameObject shipyard)
		{
			Piece component = shipyard.GetComponent<Piece>();
			List<Requirement> list = new List<Requirement>();
			list.Add(GetRequirement("FineWood", 30, 0, zNetItems));
			list.Add(GetRequirement("Bronze", 20, 0, zNetItems));
			list.Add(GetRequirement("Coal", 25, 0, zNetItems));
			list.Add(GetRequirement("DeerHide", 10, 0, zNetItems));
			list.Add(GetRequirement("Resin", 30, 0, zNetItems));
			component.m_resources = list.ToArray();
			component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "forge").GetComponent<CraftingStation>();
		}

		public void createScribeTableRecipe(GameObject table)
		{
			Piece component = table.GetComponent<Piece>();
			List<Requirement> list = new List<Requirement>();
			list.Add(GetRequirement("FineWood", 15, 0, zNetItems));
			list.Add(GetRequirement("Wood", 15, 0, zNetItems));
			list.Add(GetRequirement("BronzeNails", 35, 0, zNetItems));
			list.Add(GetRequirement("LeatherScraps", 15, 0, zNetItems));
			list.Add(GetRequirement("Feathers", 10, 0, zNetItems));
			component.m_resources = list.ToArray();
			component.m_craftingStation = zNetItems.Find((GameObject x) => ((Object)x).name == "piece_workbench").GetComponent<CraftingStation>();
		}

		private Requirement GetRequirement(string name, int amount, int amountPerLevel = 0, List<GameObject> itemlist = null)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			Requirement val = new Requirement();
			val.m_amount = amount;
			val.m_amountPerLevel = amountPerLevel;
			val.m_recover = true;
			val.m_resItem = itemlist.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>();
			return val;
		}
	}
	public class RecipeBuilder
	{
		private List<GameObject> pieces;

		private List<GameObject> items;

		private List<GameObject> newItems;

		public List<Recipe> recipes = new List<Recipe>();

		private CraftingStation cauldron;

		private CraftingStation workbench;

		private CraftingStation forge;

		private CraftingStation blackforge;

		private CraftingStation stoneCutter;

		private CraftingStation artisian;

		private CraftingStation runeforge;

		private CraftingStation tannery;

		private CraftingStation fletcher;

		private CraftingStation grill;

		private CraftingStation alchemylab;

		private CraftingStation scribe;

		public List<Recipe> createRecipes(List<GameObject> items, List<GameObject> newItems, GameObject scribeTable, List<GameObject> aditionals)
		{
			this.items = items;
			this.newItems = newItems;
			this.newItems.AddRange(aditionals);
			pieces = items.Find((GameObject x) => ((Object)x).name == "Hammer").GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces;
			prepareTables();
			scribe = scribeTable.GetComponent<CraftingStation>();
			CraftingStation val = scribe;
			int minStationLevel = 1;
			foreach (GameObject newItem in newItems)
			{
				if (!(((Object)newItem).name == "SchematicDrakkarFishnet") && !(((Object)newItem).name == "SchematicDrakkarRam") && !(((Object)newItem).name == "SchematicHolkCage"))
				{
					Recipe val2 = ScriptableObject.CreateInstance<Recipe>();
					val2.m_craftingStation = val;
					val2.m_repairStation = val;
					val2.m_minStationLevel = minStationLevel;
					val2 = createResources(newItem, val2);
					recipes.Add(val2);
				}
			}
			return recipes;
		}

		private void prepareTables()
		{
			cauldron = FindStation(pieces, "piece_cauldron");
			workbench = FindStation(pieces, "piece_workbench");
			forge = FindStation(pieces, "forge");
			blackforge = FindStation(pieces, "blackforge");
			stoneCutter = FindStation(pieces, "piece_stonecutter");
			artisian = FindStation(pieces, "piece_artisanstation");
			runeforge = FindStation(pieces, "piece_runeforge");
			tannery = FindStation(pieces, "piece_tannery");
			fletcher = FindStation(pieces, "piece_fletcher");
			grill = FindStation(pieces, "piece_grill");
			alchemylab = FindStation(pieces, "piece_alchemylab");
		}

		private Recipe createResources(GameObject item, Recipe newRecipe)
		{
			((Object)newRecipe).name = "Recipe_" + ((Object)item).name;
			newRecipe.m_item = item.GetComponent<ItemDrop>();
			newRecipe.m_amount = 1;
			newRecipe.m_enabled = true;
			List<Requirement> list = new List<Requirement>();
			newRecipe.m_craftingStation = scribe;
			newRecipe.m_minStationLevel = 1;
			switch (((Object)item).name)
			{
			case "SailInk":
				newRecipe.m_craftingStation = scribe;
				newRecipe.m_repairStation = scribe;
				newRecipe.m_minStationLevel = 1;
				newRecipe.m_amount = 4;
				list.Add(createReq("Blueberries", 7));
				list.Add(createReq("Cloudberry", 4));
				list.Add(createReq("Raspberry", 7));
				list.Add(createReq("Coal", 7));
				list.Add(createReq("Carrot", 6));
				list.Add(createReq("Bloodbag", 5));
				list.Add(createReq("Guck", 4));
				list.Add(createReq("GiantBloodSack", 2));
				list.Add(createReq("Charredskull", 2));
				list.Add(createReq("CharredBone", 2));
				newRecipe.m_requireOnlyOneIngredient = true;
				break;
			case "ShieldSteering":
				newRecipe.m_craftingStation = workbench;
				newRecipe.m_repairStation = workbench;
				newRecipe.m_minStationLevel = 3;
				list.Add(createReq("FineWood", 10, 5));
				list.Add(createReq("Iron", 10, 5));
				list.Add(createReq("LeatherScraps", 12, 6));
				list.Add(createReq("CoalPaste", 6, 3));
				break;
			case "SwordSaber":
				newRecipe.m_craftingStation = workbench;
				newRecipe.m_repairStation = workbench;
				newRecipe.m_minStationLevel = 3;
				list.Add(createReq("RoundLog", 4, 2));
				list.Add(createReq("Iron", 12, 6));
				list.Add(createReq("CoalPaste", 4, 2));
				list.Add(createReq("LeatherScraps", 12, 6));
				break;
			case "CapeSailor":
				newRecipe.m_craftingStation = workbench;
				newRecipe.m_repairStation = workbench;
				newRecipe.m_minStationLevel = 3;
				list.Add(createReq("SerpentScale", 9, 4));
				list.Add(createReq("LeatherScraps", 12, 6));
				list.Add(createReq("CoalPaste", 6, 3));
				list.Add(createReq("TrollHide", 6, 3));
				break;
			case "CoalPaste":
				newRecipe.m_amount = 4;
				newRecipe.m_craftingStation = workbench;
				newRecipe.m_repairStation = workbench;
				newRecipe.m_minStationLevel = 3;
				list.Add(createReq("Coal", 2));
				list.Add(createReq("Resin", 4));
				break;
			case "HelmetPirateBandana":
				newRecipe.m_craftingStation = workbench;
				newRecipe.m_repairStation = workbench;
				newRecipe.m_minStationLevel = 3;
				list.Add(createReq("JuteRed", 8, 4));
				list.Add(createReq("LeatherScraps", 10, 5));
				list.Add(createReq("CoalPaste", 6, 3));
				list.Add(createReq("TrophySerpent", 1));
				break;
			case "HelmetPirateHat":
				newRecipe.m_craftingStation = workbench;
				newRecipe.m_repairStation = workbench;
				newRecipe.m_minStationLevel = 3;
				list.Add(createReq("HelmetPirateBandana", 1));
				list.Add(createReq("SailInk", 10, 5));
				list.Add(createReq("LoxPelt", 4, 2));
				list.Add(createReq("Feathers", 14, 7));
				break;
			case "SledgeAnchor":
				newRecipe.m_craftingStation = forge;
				newRecipe.m_repairStation = forge;
				list.Add(createReq("Iron", 38, 18));
				list.Add(createReq("LeatherScraps", 20, 10));
				list.Add(createReq("Chain", 2, 1));
				list.Add(createReq("TrophySerpent", 1));
				break;
			case "SchematicKnarrNamePlate":
			case "SchematicKarveNamePlate":
			case "SchematicHolkNamePlate":
			case "SchematicAshlandsDrakkarNamePlate":
			case "SchematicDrakkarNamePlate":
				list.Add(createReq("Wood", 2));
				list.Add(createReq("Coal", 2));
				break;
			case "SchematicDrakkarArmor":
				list.Add(createReq("Carapace", 20));
				list.Add(createReq("BlackMetal", 16));
				list.Add(createReq("Guck", 20));
				list.Add(createReq("Chain", 8));
				break;
			case "SchematicDrakkarAnchor":
				list.Add(createReq("Iron", 13));
				list.Add(createReq("CoalPaste", 20));
				list.Add(createReq("FineWood", 10));
				list.Add(createReq("Chain", 3));
				break;
			case "SchematicDrakkarBarrels":
				list.Add(createReq("IronNails", 57));
				list.Add(createReq("Resin", 30));
				list.Add(createReq("FineWood", 10));
				list.Add(createReq("Wood", 20));
				break;
			case "SchematicDrakkarCrates":
				list.Add(createReq("Tar", 6));
				list.Add(createReq("BlackMetal", 8));
				list.Add(createReq("FineWood", 25));
				list.Add(createReq("IronNails", 33));
				break;
			case "SchematicDrakkarLights":
				list.Add(createReq("FineWood", 10));
				list.Add(createReq("IronNails", 37));
				list.Add(createReq("Copper", 5));
				break;
			case "SchematicDrakkarFishnet":
				newRecipe.m_enabled = false;
				list.Add(createReq("Wood", 10));
				list.Add(createReq("FineWood", 5));
				list.Add(createReq("RoundLog", 10));
				break;
			case "SchematicDrakkarOar":
				list.Add(createReq("Wood", 10));
				list.Add(createReq("FineWood", 5));
				list.Add(createReq("RoundLog", 10));
				break;
			case "SchematicDrakkarRam":
				newRecipe.m_enabled = false;
				list.Add(createReq("Iron", 33));
				list.Add(createReq("MechanicalSpring", 5));
				list.Add(createReq("Tar", 20));
				list.Add(createReq("Carapace", 33));
				break;
			case "SchematicDrakkarShields":
				list.Add(createReq("IronNails", 88));
				list.Add(createReq("RoundLog", 12));
				list.Add(createReq("Resin", 20));
				list.Add(createReq("DeerHide", 15));
				break;
			case "SchematicDrakkarTent":
				list.Add(createReq("JuteRed", 5));
				list.Add(createReq("IronNails", 23));
				list.Add(createReq("FineWood", 10));
				list.Add(createReq("WolfPelt", 3));
				break;
			case "SchematicDrakkarHeadCernyx":
			case "SchematicDrakkarHeadDragon":
			case "SchematicDrakkarHeadOsberg":
			case "SchematicDrakkarHeadSkull":
				list.Add(createReq("FineWood", 4));
				list.Add(createReq("Tin", 2));
				break;
			case "SchematicKnarrArmor":
				list.Add(createReq("Carapace", 16));
				list.Add(createReq("BlackMetal", 14));
				list.Add(createReq("Guck", 16));
				list.Add(createReq("Chain", 4));
				break;
			case "SchematicKarveArmor":
				list.Add(createReq("Carapace", 12));
				list.Add(createReq("BlackMetal", 12));
				list.Add(createReq("Guck", 12));
				list.Add(createReq("Chain", 4));
				break;
			case "SchematicKnarrAnchor":
				list.Add(createReq("Bronze", 8));
				list.Add(createReq("CoalPaste", 6));
				list.Add(createReq("LeatherScraps", 16));
				list.Add(createReq("Wood", 14));
				break;
			case "SchematicKarveAnchor":
				list.Add(createReq("Bronze", 6));
				list.Add(createReq("CoalPaste", 4));
				list.Add(createReq("LeatherScraps", 12));
				list.Add(createReq("Wood", 10));
				break;
			case "SchematicKnarrBag":
				list.Add(createReq("LeatherScraps", 12));
				list.Add(createReq("Tin", 4));
				list.Add(createReq("BronzeNails", 20));
				list.Add(createReq("FineWood", 14));
				break;
			case "SchematicKarveBag":
				list.Add(createReq("LeatherScraps", 10));
				list.Add(createReq("Tin", 3));
				list.Add(createReq("BronzeNails", 15));
				list.Add(createReq("FineWood", 10));
				break;
			case "SchematicKnarrLights":
				list.Add(createReq("CoalPaste", 12));
				list.Add(createReq("BronzeNails", 35));
				list.Add(createReq("Tin", 6));
				list.Add(createReq("FineWood", 12));
				break;
			case "SchematicKarveLights":
				list.Add(createReq("CoalPaste", 8));
				list.Add(createReq("BronzeNails", 25));
				list.Add(createReq("Tin", 4));
				list.Add(createReq("FineWood", 8));
				break;
			case "SchematicKnarrOars":
				list.Add(createReq("Wood", 7));
				list.Add(createReq("FineWood", 4));
				list.Add(createReq("RoundLog", 6));
				list.Add(createReq("CoalPaste", 6));
				break;
			case "SchematicKarveOars":
				list.Add(createReq("Wood", 5));
				list.Add(createReq("FineWood", 2));
				list.Add(createReq("RoundLog", 4));
				list.Add(createReq("CoalPaste", 4));
				break;
			case "SchematicKnarrShields":
				list.Add(createReq("LeatherScraps", 20));
				list.Add(createReq("BronzeNails", 65));
				list.Add(createReq("Copper", 12));
				list.Add(createReq("RoundLog", 24));
				break;
			case "SchematicKarveShields":
				list.Add(createReq("LeatherScraps", 14));
				list.Add(createReq("BronzeNails", 50));
				list.Add(createReq("Copper", 8));
				list.Add(createReq("RoundLog", 20));
				break;
			case "SchematicKnarrTent":
				list.Add(createReq("TrollHide", 10));
				list.Add(createReq("BronzeNails", 35));
				list.Add(createReq("FineWood", 10));
				list.Add(createReq("Wood", 6));
				break;
			case "SchematicKarveSailWhite":
			case "SchematicKarveSailTransparent":
			case "SchematicKarveSailBlack":
			case "SchematicKarveSailBlue":
			case "SchematicKarveSailDefault":
			case "SchematicKarveSailGreen":
			case "SchematicKarveSailHound":
			case "SchematicKarveSailDruid":
			case "SchematicKarveSailWolf":
			case "SchematicKarveSailRaven":
				list.Add(createReq("CoalPaste", 2));
				list.Add(createReq("Wood", 5));
				list.Add(createReq("SailInk", 3));
				list.Add(createReq("LeatherScraps", 5));
				break;
			case "SchematicDrakkarSailBlack":
			case "SchematicDrakkarSailBlue":
			case "SchematicDrakkarSailGreen":
			case "SchematicDrakkarSailDefault":
			case "SchematicDrakkarSailTransparent":
			case "SchematicDrakkarSailWhite":
			case "SchematicDrakkarSailHound":
			case "SchematicDrakkarSailDruid":
			case "SchematicDrakkarSailWolf":
			case "SchematicDrakkarSailRaven":
				list.Add(createReq("CoalPaste", 5));
				list.Add(createReq("FineWood", 5));
				list.Add(createReq("SailInk", 4));
				list.Add(createReq("LeatherScraps", 8));
				break;
			case "SchematicAshlandsDrakkarAnchor":
				list.Add(createReq("FlametalNew", 13));
				list.Add(createReq("CoalPaste", 20));
				list.Add(createReq("Blackwood", 10));
				list.Add(createReq("Chain", 4));
				break;
			case "SchematicAshlandsDrakkarCrates":
				list.Add(createReq("CharcoalResin", 6));
				list.Add(createReq("FlametalNew", 8));
				list.Add(createReq("Blackwood", 25));
				list.Add(createReq("IronNails", 33));
				break;
			case "SchematicAshlandsDrakkarLights":
				list.Add(createReq("Blackwood", 10));
				list.Add(createReq("IronNails", 37));
				list.Add(createReq("FlametalNew", 5));
				list.Add(createReq("Wisp", 4));
				break;
			case "SchematicAshlandsDrakkarOar":
				list.Add(createReq("Wood", 10));
				list.Add(createReq("Blackwood", 5));
				list.Add(createReq("RoundLog", 10));
				break;
			case "SchematicAshlandsDrakkarShields":
				list.Add(createReq("FlametalNew", 14));
				list.Add(createReq("Blackwood", 20));
				list.Add(createReq("CharcoalResin", 20));
				list.Add(createReq("AskHide", 10));
				break;
			case "SchematicAshlandsDrakkarTent":
				list.Add(createReq("LinenThread", 25));
				list.Add(createReq("FlametalNew", 10));
				list.Add(createReq("Blackwood", 20));
				list.Add(createReq("AskHide", 10));
				break;
			case "SchematicAshlandsDrakkarRopes":
				list.Add(createReq("Wood", 20));
				list.Add(createReq("Blackwood", 5));
				list.Add(createReq("LeatherScraps", 20));
				list.Add(createReq("FlametalNew", 5));
				break;
			case "SchematicAshlandsDrakkarSailBlack":
			case "SchematicAshlandsDrakkarSailBlue":
			case "SchematicAshlandsDrakkarSailGreen":
			case "SchematicAshlandsDrakkarSailDefault":
			case "SchematicAshlandsDrakkarSailTransparent":
			case "SchematicAshlandsDrakkarSailWhite":
			case "SchematicAshlandsDrakkarSailHound":
			case "SchematicAshlandsDrakkarSailDruid":
			case "SchematicAshlandsDrakkarSailWolf":
			case "SchematicAshlandsDrakkarSailRaven":
				list.Add(createReq("CoalPaste", 4));
				list.Add(createReq("Blackwood", 6));
				list.Add(createReq("SailInk", 6));
				list.Add(createReq("LeatherScraps", 14));
				break;
			case "SchematicKnarrSailBlack":
			case "SchematicKnarrSailBlue":
			case "SchematicKnarrSailDefault":
			case "SchematicKnarrSailDruid":
			case "SchematicKnarrSailGreen":
			case "SchematicKnarrSailHound":
			case "SchematicKnarrSailRaven":
			case "SchematicKnarrSailTransparent":
			case "SchematicKnarrSailWhite":
			case "SchematicKnarrSailWolf":
				list.Add(createReq("CoalPaste", 3));
				list.Add(createReq("Wood", 4));
				list.Add(createReq("SailInk", 2));
				list.Add(createReq("LeatherScraps", 4));
				break;
			case "SchematicHolkArmor":
				list.Add(createReq("Carapace", 40));
				list.Add(createReq("BlackMetal", 24));
				list.Add(createReq("Guck", 30));
				list.Add(createReq("Chain", 10));
				break;
			case "SchematicHolkBag":
				list.Add(createReq("Tar", 10));
				list.Add(createReq("BlackMetal", 12));
				list.Add(createReq("YggdrasilWood", 15));
				list.Add(createReq("IronNails", 77));
				break;
			case "SchematicHolkAnchor":
				list.Add(createReq("Iron", 20));
				list.Add(createReq("Tar", 6));
				list.Add(createReq("YggdrasilWood", 10));
				list.Add(createReq("Chain", 5));
				break;
			case "SchematicHolkCage":
				newRecipe.m_enabled = false;
				list.Add(createReq("Tar", 10));
				list.Add(createReq("BlackMetal", 8));
				list.Add(createReq("FineWood", 25));
				list.Add(createReq("IronNails", 33));
				break;
			case "SchematicHolkLights":
				list.Add(createReq("YggdrasilWood", 10));
				list.Add(createReq("IronNails", 37));
				list.Add(createReq("Wisp", 4));
				break;
			case "SchematicHolkRopes":
				list.Add(createReq("Wood", 10));
				list.Add(createReq("YggdrasilWood", 5));
				list.Add(createReq("LeatherScraps", 10));
				list.Add(createReq("IronNails", 16));
				break;
			case "SchematicHolkOars":
				list.Add(createReq("Wood", 10));
				list.Add(createReq("FineWood", 10));
				list.Add(createReq("RoundLog", 10));
				list.Add(createReq("YggdrasilWood", 10));
				break;
			case "SchematicHolkShields":
				list.Add(createReq("Chain", 10));
				list.Add(createReq("RoundLog", 40));
				list.Add(createReq("BlackMetal", 30));
				list.Add(createReq("WolfPelt", 16));
				break;
			case "SchematicHolkTent":
				list.Add(createReq("YggdrasilWood", 14));
				list.Add(createReq("IronNails", 40));
				list.Add(createReq("Tar", 10));
				list.Add(createReq("BlackMetal", 3));
				break;
			case "SchematicHolkSailBlack":
			case "SchematicHolkSailBlue":
			case "SchematicHolkSailGreen":
			case "SchematicHolkSailDefault":
			case "SchematicHolkSailTransparent":
			case "SchematicHolkSailWhite":
			case "SchematicHolkSailHound":
			case "SchematicHolkSailDruid":
			case "SchematicHolkSailWolf":
			case "SchematicHolkSailRaven":
				list.Add(createReq("CoalPaste", 7));
				list.Add(createReq("YggdrasilWood", 4));
				list.Add(createReq("SailInk", 6));
				list.Add(createReq("LeatherScraps", 10));
				break;
			}
			newRecipe.m_repairStation = newRecipe.m_craftingStation;
			if (list.Count == 0)
			{
				Debug.LogWarning((object)(((Object)newRecipe).name + " IS EMPTY"));
			}
			newRecipe.m_resources = list.ToArray();
			return newRecipe;
		}

		private void createSailInkRecipes()
		{
			string[] array = new string[7] { "Cloudberry", "Blueberries", "Raspberry", "Coal", "Carrot", "Bloodbag", "Guck" };
			ItemDrop component = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "SailInk").GetComponent<ItemDrop>();
			string[] array2 = array;
			foreach (string fruit in array2)
			{
				ItemDrop component2 = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == fruit).GetComponent<ItemDrop>();
				if ((Object)(object)component2 != (Object)null)
				{
					Recipe val = ScriptableObject.CreateInstance<Recipe>();
					((Object)val).name = "Recipe_SailInk_" + fruit;
					val.m_craftingStation = scribe;
					val.m_repairStation = scribe;
					val.m_minStationLevel = 1;
					val.m_item = component;
					val.m_amount = 1;
					val = createSailInkRecipe(val, fruit);
					recipes.Add(val);
				}
			}
		}

		private Recipe createSailInkRecipe(Recipe newRecipe, string fruit)
		{
			List<Requirement> list = new List<Requirement>();
			switch (fruit)
			{
			case "Cloudberry":
				newRecipe.m_amount = 4;
				list.Add(createReq(fruit, 4));
				newRecipe.m_resources = list.ToArray();
				break;
			case "Iceberry":
				newRecipe.m_amount = 3;
				list.Add(createReq(fruit, 3));
				newRecipe.m_resources = list.ToArray();
				break;
			case "Blueberries":
				newRecipe.m_amount = 3;
				list.Add(createReq(fruit, 6));
				newRecipe.m_resources = list.ToArray();
				break;
			case "Blackberries":
				newRecipe.m_amount = 3;
				list.Add(createReq(fruit, 4));
				newRecipe.m_resources = list.ToArray();
				break;
			case "Raspberry":
				newRecipe.m_amount = 3;
				list.Add(createReq(fruit, 6));
				newRecipe.m_resources = list.ToArray();
				break;
			case "Coal":
				newRecipe.m_amount = 4;
				list.Add(createReq(fruit, 6));
				newRecipe.m_resources = list.ToArray();
				break;
			case "Carrot":
				newRecipe.m_amount = 3;
				list.Add(createReq(fruit, 5));
				newRecipe.m_resources = list.ToArray();
				break;
			case "Bloodbag":
				newRecipe.m_amount = 4;
				list.Add(createReq(fruit, 3));
				newRecipe.m_resources = list.ToArray();
				break;
			case "Guck":
				newRecipe.m_amount = 4;
				list.Add(createReq(fruit, 3));
				newRecipe.m_resources = list.ToArray();
				break;
			}
			return newRecipe;
		}

		private Requirement createReq(string name, int amount, int amountPerLevel = 0)
		{
			//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)
		{
			GameObject val = items.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(object)val == (Object)null)
			{
				val = newItems.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");
			}
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Debug.LogWarning((object)("Item Not Found At All - " + name + ", Replaced With Wood"));
			return items.Find((GameObject x) => ((Object)x).name == "Wood");
		}

		private CraftingStation FindStation(List<GameObject> list, string name)
		{
			GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
			if ((Object)(object)val != (Object)null)
			{
				return val.GetComponent<CraftingStation>();
			}
			return null;
		}
	}
	public class ShaderReplacment
	{
		public static List<GameObject> prefabsToReplaceShader = new List<GameObject>();

		public static List<Material> materialsInPrefabs = new List<Material>();

		public string[] shaderlist = new string[49]
		{
			"Custom/AlphaParticle", "Custom/Blob", "Custom/Bonemass", "Custom/Clouds", "Custom/Creature", "Custom/Decal", "Custom/Distortion", "Custom/Flow", "Custom/FlowOpaque", "Custom/Grass",
			"Custom/GuiScroll", "Custom/Heightmap", "Custom/icon", "Custom/InteriorSide", "Custom/LitGui", "Custom/LitParticles", "Custom/mapshader", "Custom/ParticleDecal", "Custom/Piece", "Custom/Player",
			"Custom/Rug", "Custom/ShadowBlob", "Custom/SkyboxProcedural", "Custom/SkyObject", "Custom/StaticRock", "Custom/Tar", "Custom/Trilinearmap", "Custom/UI/BGBlur", "Custom/Vegetation", "Custom/Water",
			"Custom/WaterBottom", "Custom/WaterMask", "Custom/Yggdrasil", "Custom/Yggdrasil/root", "Hidden/BlitCopyHDRTonemap", "Hidden/Dof/DepthOfFieldHdr", "Hidden/Dof/DX11Dof", "Hidden/Internal-Loading", "Hidden/Internal-UIRDefaultWorld", "Hidden/SimpleClear",
			"Hidden/SunShaftsComposite", "Lux Lit Particles/ Bumped", "Lux Lit Particles/ Tess Bumped", "Particles/Standard Surface2", "Particles/Standard Unlit2", "Standard TwoSided", "ToonDeferredShading2017", "Unlit/DepthWrite", "Unlit/Lighting"
		};

		public static List<Shader> shaders = new List<Shader>();

		private static readonly HashSet<Shader> CachedShaders = new HashSet<Shader>();

		public static bool debug = true;

		public static Shader findShader(string name)
		{
			Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
			if (array.Length == 0)
			{
				Debug.LogWarning((object)"SHADER LIST IS EMPTY!");
				return null;
			}
			if (debug)
			{
			}
			return shaders.Find((Shader x) => ((Object)x).name == name);
		}

		public static Shader GetShaderByName(string name)
		{
			return shaders.Find((Shader x) => ((Object)x).name == name.Trim());
		}

		public static void debugShaderList(List<Shader> shadersRes)
		{
			foreach (Shader shadersRe in shadersRes)
			{
				Debug.LogWarning((object)("SHADER NAME IS: " + ((Object)shadersRe).name));
			}
			debug = false;
		}

		public static void Replace(GameObject gameObject)
		{
			prefabsToReplaceShader.Add(gameObject);
			GetMaterialsInPrefab(gameObject);
		}

		public static void GetMaterialsInPrefab(GameObject gameObject)
		{
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				if (sharedMaterials == null || sharedMaterials.Length == 0)
				{
					continue;
				}
				Material[] array2 = sharedMaterials;
				foreach (Material val2 in array2)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						materialsInPrefabs.Add(val2);
					}
				}
			}
		}

		public static void getMeShaders()
		{
			AssetBundle[] array = Resources.FindObjectsOfTypeAll<AssetBundle>();
			AssetBundle[] array2 = array;
			foreach (AssetBundle val in array2)
			{
				IEnumerable<Shader> enumerable3;
				try
				{
					IEnumerable<Shader> enumerable2;
					if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val))
					{
						IEnumerable<Shader> enumerable = val.LoadAllAssets<Shader>();
						enumerable2 = enumerable;
					}
					else
					{
						enumerable2 = from shader in ((IEnumerable<string>)val.GetAllAssetNames()).Select((Func<string, Shader>)val.LoadAsset<Shader>)
							where (Object)(object)shader != (Object)null
							select shader;
					}
					enumerable3 = enumerable2;
				}
				catch (Exception)
				{
					continue;
				}
				if (enumerable3 == null)
				{
					continue;
				}
				foreach (Shader item in enumerable3)
				{
					CachedShaders.Add(item);
				}
			}
		}

		public static void runMaterialFix()
		{
			getMeShaders();
			shaders.AddRange(CachedShaders);
			foreach (Material materialsInPrefab in materialsInPrefabs)
			{
				Shader shader = materialsInPrefab.shader;
				if (!((Object)(object)shader == (Object)null))
				{
					string name = ((Object)shader).name;
					if (!(name == "Standard") && name.Contains("Balrond"))
					{
						setProperValue(materialsInPrefab, name);
					}
				}
			}
		}

		private static void setProperValue(Material material, string shaderName)
		{
			string name = shaderName.Replace("Balrond", "Custom");
			name = checkNaming(name);
			Shader shaderByName = GetShaderByName(name);
			if ((Object)(object)shaderByName == (Object)null)
			{
				Debug.LogWarning((object)("Shader not found " + name));
			}
			else
			{
				material.shader = shaderByName;
			}
		}

		private static string checkNaming(string name)
		{
			strin