Decompiled source of TheCodFathersLegacy v1.0.9

TheCodFathersLegacy.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using PieceManager;
using ServerSync;
using TMPro;
using TheCodFathersLegacy.Functions;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.9")]
[assembly: AssemblyInformationalVersion("1.0.0+9aa97eb47e84f633e5e93a09d8fa5b1edbe34bc3")]
[assembly: AssemblyProduct("TheCodFathersLegacy")]
[assembly: AssemblyTitle("TheCodFathersLegacy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.9.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TheCodFathersLegacy
{
	[BepInPlugin("blacks7ar.TheCodFathersLegacy", "TheCodFathersLegacy", "1.0.9")]
	public class Plugin : BaseUnityPlugin
	{
		private enum Toggle
		{
			On = 1,
			Off = 0
		}

		private const string modGUID = "blacks7ar.TheCodFathersLegacy";

		public const string modName = "TheCodFathersLegacy";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "1.0.9";

		private static readonly Harmony _harmony = new Harmony("blacks7ar.TheCodFathersLegacy");

		private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.TheCodFathersLegacy")
		{
			DisplayName = "TheCodFathersLegacy",
			CurrentVersion = "1.0.9",
			MinimumRequiredVersion = "1.0.9",
			ModRequired = true
		};

		private static ConfigEntry<Toggle> _serverConfigLocked;

		private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool _synchronizedConfig = true)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (_synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			_configSync.AddConfigEntry<T>(val2).SynchronizedConfig = _synchronizedConfig;
			return val2;
		}

		public void Awake()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Localizer.Load();
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			_serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>()));
			_configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			PrefabsSetup.Init();
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.Save();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
		}

		public void Start()
		{
			PrefabsSetup.Start();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}
	}
}
namespace TheCodFathersLegacy.Functions
{
	public class CapelinTrap : MonoBehaviour, IHasHoverMenuExtended
	{
		public class ItemConversion
		{
			public ItemDrop m_from;

			public ItemDrop m_to;
		}

		public string m_name = "Capelin Trap";

		public string m_addBaitToolTip = "$tcfl_capelintrap_addbait";

		public Switch m_addBaitSwitch;

		public Transform m_outputPoint;

		public GameObject m_enabledObject;

		public int m_maxBait = 60;

		public float m_secPerFish = 180f;

		public bool m_spawnStack;

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

		public EffectList m_addBaitEffects = new EffectList();

		public EffectList m_produceEffects = new EffectList();

		public ZNetView m_nview;

		public Container m_container;

		private bool m_connected;

		public float m_addBaitTime = -1000f;

		private StringBuilder m_sb = new StringBuilder();

		private Collider[] m_sphereResults = (Collider[])(object)new Collider[32];

		public void Awake()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			m_nview = ((Component)this).GetComponent<ZNetView>();
			m_container = ((Component)this).GetComponentInChildren<Container>();
			SetItUp();
			SetConversion();
			if ((Object)(object)m_nview != (Object)null && m_nview.GetZDO() != null && Object.op_Implicit((Object)(object)m_addBaitSwitch))
			{
				Switch addBaitSwitch = m_addBaitSwitch;
				addBaitSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)addBaitSwitch.m_onUse, (Delegate?)new Callback(OnAddBait));
				m_addBaitSwitch.m_onHover = new TooltipCallback(OnHoverAddBait);
			}
			m_nview.Register<string>("RPC_AddBait", (Action<long, string>)RPC_AddBait);
			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("UpdateTrap", 1f, 1f);
		}

		public void SetConversion()
		{
			m_conversion.AddRange(new List<ItemConversion>
			{
				new ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBait").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitOcean").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitCave").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitForest").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitSwamp").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitPlains").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitMistlands").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitDeepNorth").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitAshlands").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				}
			});
		}

		public void SetItUp()
		{
			//IL_005a: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			m_addBaitSwitch = ((Component)((Component)this).transform.Find("add_bait")).GetComponent<Switch>();
			m_outputPoint = ((Component)this).transform.Find("output");
			m_enabledObject = ((Component)((Component)this).transform.Find("_enabled")).gameObject;
			m_addBaitEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2]
			{
				new EffectData
				{
					m_prefab = ZNetScene.instance.GetPrefab("sfx_mill_add"),
					m_enabled = true,
					m_variant = -1
				},
				new EffectData
				{
					m_prefab = ZNetScene.instance.GetPrefab("vfx_mill_add"),
					m_enabled = true,
					m_variant = -1,
					m_scale = true,
					m_inheritParentScale = true
				}
			};
			m_produceEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2]
			{
				new EffectData
				{
					m_prefab = ZNetScene.instance.GetPrefab("sfx_lootspawn"),
					m_enabled = true,
					m_variant = -1
				},
				new EffectData
				{
					m_prefab = ZNetScene.instance.GetPrefab("vfx_lootspawn"),
					m_enabled = true,
					m_variant = -1
				}
			};
		}

		public void DropAllItems()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			SpawnProcessed();
			while (GetQueueSize() > 0)
			{
				string queuedBait = GetQueuedBait();
				RemoveOneBait();
				ItemConversion itemConversion = GetItemConversion(queuedBait);
				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), false);
				}
			}
		}

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

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

		private bool IsItemAllowed(string itemName)
		{
			return m_conversion.Any((ItemConversion item) => ((Object)((Component)item.m_from).gameObject).name == itemName);
		}

		private ItemData FindFishBait(Inventory inventory)
		{
			return m_conversion.Select((ItemConversion item2) => inventory.GetItem(item2.m_from.m_itemData.m_shared.m_name, -1, false)).FirstOrDefault((Func<ItemData, bool>)((ItemData item) => item != null));
		}

		private bool OnAddBait(Switch sw, Humanoid user, ItemData item)
		{
			if (item == null)
			{
				item = FindFishBait(user.GetInventory());
				if (item == null)
				{
					((Character)user).Message((MessageType)2, "$tcfl_noproperbait", 0, (Sprite)null, false);
					return false;
				}
			}
			if (!IsItemAllowed(((Object)item.m_dropPrefab).name))
			{
				((Character)user).Message((MessageType)2, "$tcfl_baitnotallowed", 0, (Sprite)null, false);
				return false;
			}
			if (!m_connected)
			{
				((Character)user).Message((MessageType)2, "$tcfl_notproperlyplace", 0, (Sprite)null, false);
				return false;
			}
			ZLog.Log((object)("trying to add " + item.m_shared.m_name));
			if (GetQueueSize() >= m_maxBait)
			{
				((Character)user).Message((MessageType)2, "$tcfl_baitisfull", 0, (Sprite)null, false);
				return false;
			}
			((Character)user).Message((MessageType)2, "$tcfl_baitadded " + item.m_shared.m_name, 0, (Sprite)null, false);
			user.GetInventory().RemoveItem(item, 1);
			m_nview.InvokeRPC("RPC_AddBait", new object[1] { ((Object)item.m_dropPrefab).name });
			m_addBaitTime = Time.time;
			return true;
		}

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

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

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

		public void RPC_AddBait(long sender, string name)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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;
				}
				QueueBait(name);
				m_addBaitEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1, default(ZDOID));
				ZLog.Log((object)("Added bait " + name));
			}
		}

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

		private string GetQueuedBait()
		{
			if (GetQueueSize() != 0)
			{
				return m_nview.GetZDO().GetString(ZDOVars.s_item0, "");
			}
			return "";
		}

		public void RemoveOneBait()
		{
			int queueSize = GetQueueSize();
			if (queueSize != 0)
			{
				for (int i = 0; i < queueSize; i++)
				{
					string text = m_nview.GetZDO().GetString("item" + (i + 1), "");
					m_nview.GetZDO().Set("item" + i, text);
				}
				m_nview.GetZDO().Set(ZDOVars.s_queued, queueSize - 1, false);
			}
		}

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

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

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

		public void OnWater()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (m_connected)
			{
				return;
			}
			int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, 0.1f, m_sphereResults);
			for (int i = 0; i < num; i++)
			{
				if (((Component)m_sphereResults[i]).gameObject.layer == 4)
				{
					m_connected = true;
				}
			}
		}

		public void UpdateTrap()
		{
			if (!m_nview.IsValid())
			{
				return;
			}
			OnWater();
			UpdateState();
			if (!m_nview.IsOwner())
			{
				return;
			}
			double deltaTime = GetDeltaTime();
			float accumulator = GetAccumulator();
			accumulator += (float)deltaTime;
			if (accumulator > 3600f)
			{
				accumulator = 3600f;
			}
			while (accumulator >= 1f)
			{
				accumulator -= 1f;
				string queuedBait = GetQueuedBait();
				if ((m_maxBait == 0 || !(queuedBait == "")) && (m_secPerFish > 0f || m_connected) && !(queuedBait == ""))
				{
					float bakeTimer = GetBakeTimer();
					bakeTimer += 1f;
					SetBakeTimer(bakeTimer);
					if (bakeTimer >= m_secPerFish)
					{
						SetBakeTimer(0f);
						RemoveOneBait();
						QueueProcessed(queuedBait);
					}
				}
			}
			if (GetQueuedBait() == "")
			{
				SpawnProcessed();
			}
			SetAccumulator(accumulator);
		}

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

		public void SpawnProcessed()
		{
			if (m_nview.IsValid())
			{
				int num = m_nview.GetZDO().GetInt(ZDOVars.s_spawnAmount, 0);
				if (num > 0)
				{
					string bait = m_nview.GetZDO().GetString(ZDOVars.s_spawnOre, "");
					Spawn(bait, num);
					m_nview.GetZDO().Set(ZDOVars.s_spawnOre, "");
					m_nview.GetZDO().Set(ZDOVars.s_spawnAmount, 0, false);
				}
			}
		}

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

		public void Spawn(string bait, int stack)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			ItemConversion itemConversion = GetItemConversion(bait);
			if (itemConversion != null && !((Object)(object)itemConversion.m_to == (Object)null))
			{
				ZNetView.m_forceDisableInit = true;
				GameObject val = Object.Instantiate<GameObject>(((Component)itemConversion.m_to).gameObject, m_outputPoint.position, m_outputPoint.rotation);
				ZNetView.m_forceDisableInit = false;
				ItemDrop component = val.GetComponent<ItemDrop>();
				component.m_itemData.m_stack = stack;
				if (m_container.GetInventory().AddItem(component.m_itemData))
				{
					m_produceEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1, default(ZDOID));
					m_container.Save();
					m_container.GetInventory().Changed(false, false);
					Object.Destroy((Object)(object)val);
				}
			}
		}

		private ItemConversion GetItemConversion(string itemName)
		{
			return m_conversion.FirstOrDefault((ItemConversion item) => ((Object)((Component)item.m_from).gameObject).name == itemName);
		}

		public void UpdateState()
		{
			bool active = GetQueueSize() > 0 && m_connected;
			m_enabledObject.SetActive(active);
		}

		private string OnHoverAddBait()
		{
			m_sb.Clear();
			int queueSize = GetQueueSize();
			m_sb.Append($"{m_name} ({queueSize}/{m_maxBait}) " + GetQueuedBait());
			m_sb.Append("\n[<color=yellow><b>$KEY_Use</b></color>] " + m_addBaitToolTip);
			return Localization.instance.Localize(m_sb.ToString());
		}

		public bool TryGetItems(Player player, Switch switchRef, out List<string> items)
		{
			items = new List<string>();
			if (!CanUseItems(player, switchRef))
			{
				return true;
			}
			if ((Object)(object)switchRef == (Object)(object)m_addBaitSwitch)
			{
				items = m_conversion.Select((ItemConversion conversion) => conversion.m_from.m_itemData.m_shared.m_name).ToList();
			}
			return true;
		}

		public bool CanUseItems(Player player, Switch switchRef, bool sendErrorMessage = true)
		{
			if ((Object)(object)switchRef != (Object)(object)m_addBaitSwitch)
			{
				return false;
			}
			if (GetQueueSize() >= m_maxBait)
			{
				if (sendErrorMessage)
				{
					((Character)player).Message((MessageType)2, "$tcfl_baitisfull", 0, (Sprite)null, false);
				}
				return false;
			}
			if (!m_connected)
			{
				if (sendErrorMessage)
				{
					((Character)player).Message((MessageType)2, "$tcfl_notinwater", 0, (Sprite)null, false);
				}
				return false;
			}
			if (((Humanoid)player).GetInventory().CountItemsByName(m_conversion.Select((ItemConversion conversion) => conversion.m_from.m_itemData.m_shared.m_name).ToArray(), -1, true, false) > 0)
			{
				return true;
			}
			if (sendErrorMessage)
			{
				((Character)player).Message((MessageType)2, "$tcfl_noproperbait", 0, (Sprite)null, false);
			}
			return false;
		}
	}
	public class Demister : StatusEffect
	{
		public GameObject m_ballPrefab;

		public Vector3 m_offset = new Vector3(0.1f, 3.5f, 0.1f);

		public Vector3 m_offsetInterior = new Vector3(0.5f, 2.1f, 0f);

		public float m_maxDistance = 6f;

		public float m_ballAcceleration = 7f;

		public float m_ballMaxSpeed = 80f;

		public float m_ballFriction = 0.03f;

		public float m_noiseDistance = 1.5f;

		public float m_noiseDistanceInterior = 0.2f;

		public float m_noiseDistanceYScale = 0.4f;

		public float m_noiseSpeed = 0.5f;

		public float m_characterVelocityFactor = 3f;

		public float m_rotationSpeed = 8f;

		public int m_coverRayMask;

		public GameObject m_ballInstance;

		public Vector3 m_ballVel = new Vector3(0f, 0f, 0f);

		public void Awake()
		{
			((Object)this).name = "TCFL_Demister";
			base.m_name = "$item_demister";
			base.m_tooltip = "$item_demister_description";
		}

		public override void Setup(Character character)
		{
			((StatusEffect)this).Setup(character);
			if (m_coverRayMask == 0)
			{
				m_coverRayMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" });
			}
			m_ballPrefab = ZNetScene.instance.GetPrefab("demister_ball");
			GameObject ballPrefab = m_ballPrefab;
			if (ballPrefab != null)
			{
				ballPrefab.GetComponentInChildren<ParticleSystemForceField>();
			}
		}

		private bool IsUnderRoof()
		{
			//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)
			RaycastHit val = default(RaycastHit);
			return Physics.Raycast(base.m_character.GetCenterPoint(), Vector3.up, ref val, 4f, m_coverRayMask);
		}

		public override void UpdateStatusEffect(float dt)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			((StatusEffect)this).UpdateStatusEffect(dt);
			if (!Object.op_Implicit((Object)(object)m_ballInstance))
			{
				Vector3 val = base.m_character.GetCenterPoint() + ((Component)base.m_character).transform.forward * 0.5f;
				m_ballInstance = Object.Instantiate<GameObject>(m_ballPrefab, val, Quaternion.identity);
				return;
			}
			_ = base.m_character;
			bool num = IsUnderRoof();
			Vector3 position = ((Component)base.m_character).transform.position;
			Vector3 val2 = m_ballInstance.transform.position;
			Vector3 val3 = (num ? m_offsetInterior : m_offset);
			float num2 = (num ? m_noiseDistanceInterior : m_noiseDistance);
			Vector3 val4 = position + ((Component)base.m_character).transform.TransformVector(val3);
			float num3 = Time.time * m_noiseSpeed;
			val4 += new Vector3(Mathf.Sin(num3 * 4f), Mathf.Sin(num3 * 2f) * m_noiseDistanceYScale, Mathf.Cos(num3 * 5f)) * num2;
			float num4 = Vector3.Distance(val4, val2);
			Vector3 val5;
			if (num4 > m_maxDistance * 2f)
			{
				val2 = val4;
			}
			else if (num4 > m_maxDistance)
			{
				val5 = val2 - val4;
				Vector3 normalized = ((Vector3)(ref val5)).normalized;
				val2 = val4 + normalized * m_maxDistance;
			}
			val5 = val4 - val2;
			Vector3 normalized2 = ((Vector3)(ref val5)).normalized;
			m_ballVel += normalized2 * m_ballAcceleration * dt;
			if (((Vector3)(ref m_ballVel)).magnitude > m_ballMaxSpeed)
			{
				m_ballVel = ((Vector3)(ref m_ballVel)).normalized * m_ballMaxSpeed;
			}
			if (!num)
			{
				Vector3 velocity = base.m_character.GetVelocity();
				m_ballVel += velocity * m_characterVelocityFactor * dt;
			}
			m_ballVel -= m_ballVel * m_ballFriction;
			Vector3 position2 = val2 + m_ballVel * dt;
			m_ballInstance.transform.position = position2;
			Quaternion rotation = m_ballInstance.transform.rotation;
			rotation *= Quaternion.Euler(m_rotationSpeed, 0f, m_rotationSpeed * 0.5321f);
			m_ballInstance.transform.rotation = rotation;
		}

		public void RemoveEffects()
		{
			if (!((Object)(object)m_ballInstance == (Object)null))
			{
				ZNetView component = m_ballInstance.GetComponent<ZNetView>();
				if (component.IsValid())
				{
					component.ClaimOwnership();
					component.Destroy();
				}
			}
		}

		public override void OnApplicationQuit()
		{
			((StatusEffect)this).OnApplicationQuit();
			m_ballInstance = null;
		}

		public override void Stop()
		{
			((StatusEffect)this).Stop();
			RemoveEffects();
		}

		public override void OnDestroy()
		{
			((StatusEffect)this).OnDestroy();
			RemoveEffects();
		}
	}
	[HarmonyPatch]
	public static class Patches
	{
		private static int _comfortLevel = 4;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static void ZNetSceneAwake_Postfix(ZNetScene __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && __instance.m_prefabs.Count > 0)
			{
				SetupTrader();
				PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_CodFathers_Legacy").GetComponentInChildren<Container>().m_destroyedLootPrefab = __instance.GetPrefab("CargoCrate");
				GameObject prefab = __instance.GetPrefab("TCFL_CapelinTrap");
				if (!Object.op_Implicit((Object)(object)prefab.GetComponent<CapelinTrap>()))
				{
					prefab.AddComponent<CapelinTrap>();
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		private static void ObjectDBAwake_Postfix(ObjectDB __instance)
		{
			if ((Object)(object)__instance == (Object)null || __instance.m_items.Count <= 0)
			{
				return;
			}
			foreach (ItemDrop item in from item in __instance.m_items
				select item.GetComponent<ItemDrop>() into component
				where Object.op_Implicit((Object)(object)component)
				select component)
			{
				if (item.m_itemData.m_shared.m_name.EndsWith("_fish_raw"))
				{
					item.m_itemData.m_shared.m_value = 25;
				}
				if (item.m_itemData.m_shared.m_name.EndsWith("_smokedcapelin"))
				{
					item.m_itemData.m_shared.m_value = 100;
				}
				if (item.m_itemData.m_shared.m_name.EndsWith("_smokedfish"))
				{
					item.m_itemData.m_shared.m_value = 50;
				}
				if (item.m_itemData.m_shared.m_name.EndsWith("_capelin"))
				{
					item.m_itemData.m_shared.m_value = 75;
				}
			}
		}

		[HarmonyPriority(700)]
		[HarmonyPostfix]
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		private static void Awake_Postfix(ObjectDB __instance)
		{
			RegisterToFeaster(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SE_Rested), "CalculateComfortLevel", new Type[]
		{
			typeof(bool),
			typeof(Vector3)
		})]
		private static void CalculateComfortLevel_Postfix(ref int __result)
		{
			Player localPlayer = Player.m_localPlayer;
			if (Object.op_Implicit((Object)(object)localPlayer) && ((Character)localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("tcfl_featherfall_se")) && !((Character)localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")))
			{
				__result += 4;
			}
		}

		private static void SetupTrapConversion()
		{
			PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_CapelinTrap").GetComponent<CapelinTrap>().m_conversion.AddRange(new List<CapelinTrap.ItemConversion>
			{
				new CapelinTrap.ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBait").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new CapelinTrap.ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitOcean").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new CapelinTrap.ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitCave").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new CapelinTrap.ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitForest").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new CapelinTrap.ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitSwamp").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new CapelinTrap.ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitPlains").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new CapelinTrap.ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitMistlands").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new CapelinTrap.ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitDeepNorth").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				},
				new CapelinTrap.ItemConversion
				{
					m_from = ObjectDB.instance.GetItemPrefab("FishingBaitAshlands").GetComponent<ItemDrop>(),
					m_to = ObjectDB.instance.GetItemPrefab("TCFL_Capelin").GetComponent<ItemDrop>()
				}
			});
		}

		private static void SetupTrap(ZNetScene zNetScene)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			CapelinTrap component = PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_CapelinTrap").GetComponent<CapelinTrap>();
			component.m_addBaitSwitch = ((Component)((Component)component).gameObject.transform.Find("add_bait")).GetComponent<Switch>();
			component.m_outputPoint = ((Component)component).gameObject.transform.Find("output");
			component.m_enabledObject = ((Component)((Component)component).gameObject.transform.Find("_enabled")).gameObject;
			component.m_addBaitEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2]
			{
				new EffectData
				{
					m_prefab = zNetScene.GetPrefab("sfx_mill_add"),
					m_enabled = true,
					m_variant = -1
				},
				new EffectData
				{
					m_prefab = zNetScene.GetPrefab("vfx_mill_add"),
					m_enabled = true,
					m_variant = -1,
					m_scale = true,
					m_inheritParentScale = true
				}
			};
			component.m_produceEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2]
			{
				new EffectData
				{
					m_prefab = zNetScene.GetPrefab("sfx_lootspawn"),
					m_enabled = true,
					m_variant = -1
				},
				new EffectData
				{
					m_prefab = zNetScene.GetPrefab("vfx_lootspawn"),
					m_enabled = true,
					m_variant = -1
				}
			};
		}

		private static void SetupTrader()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Expected O, but got Unknown
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Expected O, but got Unknown
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Expected O, but got Unknown
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Expected O, but got Unknown
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Expected O, but got Unknown
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Expected O, but got Unknown
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Expected O, but got Unknown
			Trader componentInChildren = PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_CodFather_Trader").GetComponentInChildren<Trader>(true);
			componentInChildren.m_items.Clear();
			componentInChildren.m_items.AddRange(new List<TradeItem>
			{
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("TCFL_FishingRod").GetComponent<ItemDrop>(),
					m_stack = 1,
					m_price = 750,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("TCFL_TearOfMemories").GetComponent<ItemDrop>(),
					m_stack = 1,
					m_price = 3500,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("TCFL_GentleHeartCore").GetComponent<ItemDrop>(),
					m_stack = 1,
					m_price = 2000,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("TCFL_CodFathersHat").GetComponent<ItemDrop>(),
					m_stack = 1,
					m_price = 2000,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("TCFL_CodFatheresCoat").GetComponent<ItemDrop>(),
					m_stack = 1,
					m_price = 2000,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("TCFL_CodFathersTrousers").GetComponent<ItemDrop>(),
					m_stack = 1,
					m_price = 2000,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("TCFL_JigginKnife").GetComponent<ItemDrop>(),
					m_stack = 1,
					m_price = 1250,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("FishingBait").GetComponent<ItemDrop>(),
					m_stack = 20,
					m_price = 5,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("FishingBaitAshlands").GetComponent<ItemDrop>(),
					m_stack = 20,
					m_price = 10,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("FishingBaitCave").GetComponent<ItemDrop>(),
					m_stack = 20,
					m_price = 10,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("FishingBaitDeepNorth").GetComponent<ItemDrop>(),
					m_stack = 20,
					m_price = 10,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("FishingBaitForest").GetComponent<ItemDrop>(),
					m_stack = 20,
					m_price = 10,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("FishingBaitMistlands").GetComponent<ItemDrop>(),
					m_stack = 20,
					m_price = 10,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("FishingBaitOcean").GetComponent<ItemDrop>(),
					m_stack = 20,
					m_price = 10,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("FishingBaitPlains").GetComponent<ItemDrop>(),
					m_stack = 20,
					m_price = 10,
					m_requiredGlobalKey = ""
				},
				new TradeItem
				{
					m_prefab = ObjectDB.instance.GetItemPrefab("FishingBaitSwamp").GetComponent<ItemDrop>(),
					m_stack = 20,
					m_price = 10,
					m_requiredGlobalKey = ""
				}
			});
		}

		private static void AddToFeaster(this ObjectDB objectDB, GameObject gameObject, bool overWrite = true)
		{
			PieceTable buildPieces = objectDB.GetItemPrefab("Feaster").GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces;
			if (buildPieces.m_pieces.Contains(gameObject))
			{
				if (!overWrite)
				{
					return;
				}
				buildPieces.m_pieces.Remove(gameObject);
			}
			buildPieces.m_pieces.Add(gameObject);
		}

		private static bool ObjectDBAwake()
		{
			if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0)
			{
				return (Object)(object)ObjectDB.instance.GetItemPrefab("Wood") != (Object)null;
			}
			return false;
		}

		private static void RegisterToFeaster(ObjectDB objectDB)
		{
			if (ObjectDBAwake())
			{
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_BlueberryDuff"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_LiverNOnions"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_RoastedVegetables"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedBoarMeat"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedCapelin"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedChickenMeat"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedDeerMeat"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedFish"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedFishStew"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedNeckTail"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedSausage"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedSerpentMeat"));
				objectDB.AddToFeaster(PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("TCFL_SmokedSerpentStew"));
			}
		}
	}
	public static class PrefabsSetup
	{
		public static AssetBundle _codFatherBundle;

		public static Item _knife;

		public static BuildPiece _trap;

		public static void Init()
		{
			_codFatherBundle = PrefabManager.RegisterAssetBundle("codfatherbundle");
			new Item(_codFatherBundle, "TCFL_FishingRod").Configurable = Configurability.Stats;
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_FishingRodFloat"));
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_FishingRodFloatProjectile");
			FoodItems();
			new Item(_codFatherBundle, "TCFL_Capelin").Configurable = Configurability.Disabled;
			Piece();
			Item item = new Item(_codFatherBundle, "TCFL_CodFathersHat");
			item.Crafting.Add(ItemManager.CraftingTable.Forge, 1);
			item.RequiredItems.Add("Wisp", 1);
			item.RequiredItems.Add("LinenThread", 10);
			item.RequiredItems.Add("Coal", 10);
			item.RequiredItems.Add("Silver", 1);
			item.RequiredUpgradeItems.Add("Wisp", 1);
			item.RequiredUpgradeItems.Add("LinenThread", 5);
			item.Configurable = Configurability.Recipe | Configurability.Stats;
			ShaderReplacer.Replace(item.Prefab);
			Demister demister = ScriptableObject.CreateInstance<Demister>();
			ItemData itemData = item.Prefab.GetComponent<ItemDrop>().m_itemData;
			((StatusEffect)demister).m_icon = itemData.GetIcon();
			itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)demister;
			new Item(_codFatherBundle, "TCFL_GentleHeartCore").Configurable = Configurability.Disabled;
			_knife = new Item(_codFatherBundle, "TCFL_JigginKnife");
			_knife.Crafting.Add(ItemManager.CraftingTable.Forge, 1);
			_knife.RequiredItems.Add("Iron", 10);
			_knife.RequiredItems.Add("Silver", 10);
			_knife.RequiredItems.Add("Tar", 5);
			_knife.RequiredUpgradeItems.Add("Iron", 5);
			_knife.RequiredUpgradeItems.Add("Silver", 5);
			_knife.Configurable = Configurability.Recipe | Configurability.Stats;
			ShaderReplacer.Replace(_knife.Prefab);
			new Item(_codFatherBundle, "TCFL_TearOfMemories").Configurable = Configurability.Disabled;
			Item item2 = new Item(_codFatherBundle, "TCFL_CodFatheresCoat");
			item2.Crafting.Add(ItemManager.CraftingTable.Forge, 1);
			item2.RequiredItems.Add("Silver", 5);
			item2.RequiredItems.Add("JuteBlue", 20);
			item2.RequiredItems.Add("Cloudberry", 20);
			item2.RequiredItems.Add("LinenThread", 30);
			item2.RequiredUpgradeItems.Add("JuteBlue", 5);
			item2.RequiredUpgradeItems.Add("LinenThread", 5);
			item2.Configurable = Configurability.Recipe | Configurability.Stats;
			ShaderReplacer.Replace(item2.Prefab);
			FeatherFall(item2.Prefab.GetComponent<ItemDrop>());
			Item item3 = new Item(_codFatherBundle, "TCFL_CodFathersTrousers");
			item3.Crafting.Add(ItemManager.CraftingTable.Forge, 1);
			item3.RequiredItems.Add("ScaleHide", 2);
			item3.RequiredItems.Add("Cloudberry", 20);
			item3.RequiredItems.Add("LinenThread", 10);
			item3.RequiredItems.Add("AskHide", 10);
			item3.RequiredUpgradeItems.Add("LinenThread", 5);
			item3.RequiredUpgradeItems.Add("AskHide", 5);
			WindRun(item3.Prefab.GetComponent<ItemDrop>());
			Effects();
		}

		private static void Piece()
		{
			_trap = new BuildPiece(_codFatherBundle, "TCFL_CapelinTrap");
			_trap.Crafting.Set(PieceManager.CraftingTable.Workbench);
			_trap.Category.Set(BuildPieceCategory.Crafting);
			_trap.Usage.Set((UsageTagFlags)2);
			_trap.RequiredItems.Add("Wood", 10, recover: true);
			_trap.RequiredItems.Add("Flax", 10, recover: true);
			_trap.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(_trap.Prefab);
			BuildPiece buildPiece = new BuildPiece(_codFatherBundle, "TCFL_CodFather_Trader");
			buildPiece.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece.Category.Set(BuildPieceCategory.Misc);
			buildPiece.Usage.Set((UsageTagFlags)1);
			buildPiece.RequiredItems.Add("FineWood", 20, recover: true);
			buildPiece.RequiredItems.Add("JuteBlue", 5, recover: true);
			buildPiece.RequiredItems.Add("Cloudberry", 5, recover: true);
			buildPiece.RequiredItems.Add("FishRaw", 10, recover: true);
			buildPiece.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece.Prefab);
			BuildPiece buildPiece2 = new BuildPiece(_codFatherBundle, "TCFL_CodFathers_Legacy");
			buildPiece2.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece2.Category.Set(BuildPieceCategory.Misc);
			buildPiece2.Usage.Set((UsageTagFlags)2048);
			buildPiece2.RequiredItems.Add("TCFL_TearOfMemories", 1, recover: true);
			buildPiece2.RequiredItems.Add("FineWood", 100, recover: true);
			buildPiece2.RequiredItems.Add("Silver", 40, recover: true);
			buildPiece2.RequiredItems.Add("Eitr", 30, recover: true);
			buildPiece2.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece2.Prefab);
			BuildPiece buildPiece3 = new BuildPiece(_codFatherBundle, "TCFL_Smoker_LargeMeat");
			buildPiece3.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece3.Category.Set(BuildPieceCategory.Crafting);
			buildPiece3.Usage.Set((UsageTagFlags)2);
			buildPiece3.RequiredItems.Add("TCFL_GentleHeartCore", 1, recover: true);
			buildPiece3.RequiredItems.Add("FineWood", 20, recover: true);
			buildPiece3.RequiredItems.Add("Silver", 5, recover: true);
			buildPiece3.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece3.Prefab);
			if (!Object.op_Implicit((Object)(object)buildPiece3.Prefab.GetComponent<SmokerLarge>()))
			{
				buildPiece3.Prefab.RemoveComponent(typeof(CookingStation));
				buildPiece3.Prefab.AddComponent<SmokerLarge>();
			}
			BuildPiece buildPiece4 = new BuildPiece(_codFatherBundle, "TCFL_Smoker_SmallMeat");
			buildPiece4.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece4.Category.Set(BuildPieceCategory.Crafting);
			buildPiece4.Usage.Set((UsageTagFlags)2);
			buildPiece4.RequiredItems.Add("TCFL_GentleHeartCore", 1, recover: true);
			buildPiece4.RequiredItems.Add("FineWood", 20, recover: true);
			buildPiece4.RequiredItems.Add("Silver", 5, recover: true);
			buildPiece4.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece4.Prefab);
			if (!Object.op_Implicit((Object)(object)buildPiece4.Prefab.GetComponent<SmokerSmall>()))
			{
				buildPiece4.Prefab.RemoveComponent(typeof(CookingStation));
				buildPiece4.Prefab.AddComponent<SmokerSmall>();
			}
			BuildPiece buildPiece5 = new BuildPiece(_codFatherBundle, "TCFL_FeedOJiggs");
			buildPiece5.Crafting.Set(PieceManager.CraftingTable.None);
			buildPiece5.Category.Set(BuildPieceCategory.Feasts);
			buildPiece5.Usage.Set((UsageTagFlags)16384);
			buildPiece5.Tool.Add("Feaster");
			buildPiece5.RequiredItems.Add("TCFL_FeedOJiggs_Material", 1, recover: true);
			buildPiece5.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece5.Prefab);
			BuildPiece buildPiece6 = new BuildPiece(_codFatherBundle, "TCFL_CodFathersPainting");
			buildPiece6.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece6.Category.Set(BuildPieceCategory.Furniture);
			buildPiece6.Usage.Set((UsageTagFlags)512);
			buildPiece6.RequiredItems.Add("FineWood", 2, recover: true);
			buildPiece6.RequiredItems.Add("Blueberries", 2, recover: true);
			buildPiece6.RequiredItems.Add("Dandelion", 2, recover: true);
			buildPiece6.RequiredItems.Add("Coal", 2, recover: true);
			buildPiece6.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece6.Prefab);
		}

		private static void FoodItems()
		{
			Item item = new Item(_codFatherBundle, "TCFL_BlueberryDuff");
			item.Crafting.Add(ItemManager.CraftingTable.Cauldron, 4);
			item.RequiredItems.Add("Blueberries", 10);
			item.RequiredItems.Add("BarleyFlour", 10);
			item.RequiredItems.Add("Honey", 5);
			item.Configurable = Configurability.Recipe | Configurability.Stats;
			ShaderReplacer.Replace(item.Prefab);
			ShaderReplacer.Replace(new Item(_codFatherBundle, "TCFL_FeedOJiggs")
			{
				Configurable = Configurability.Stats
			}.Prefab);
			Item item2 = new Item(_codFatherBundle, "TCFL_FeedOJiggs_Material");
			item2.Crafting.Add(ItemManager.CraftingTable.FoodPreparationTable, 1);
			item2.RequiredItems.Add("TCFL_SmokedDeerMeat", 5);
			item2.RequiredItems.Add("TCFL_SmokedChickenMeat", 2);
			item2.RequiredItems.Add("TCFL_BlueberryDuff", 2);
			item2.RequiredItems.Add("TCFL_RoastedVegetables", 2);
			item2.Configurable = Configurability.Recipe;
			ShaderReplacer.Replace(item2.Prefab);
			Item item3 = new Item(_codFatherBundle, "TCFL_LiverNOnions");
			item3.Crafting.Add(ItemManager.CraftingTable.Cauldron, 4);
			item3.RequiredItems.Add("TCFL_SmokedDeerMeat", 6);
			item3.RequiredItems.Add("Onion", 2);
			item3.RequiredItems.Add("MushroomMagecap", 2);
			item3.Configurable = Configurability.Recipe | Configurability.Stats;
			ShaderReplacer.Replace(item3.Prefab);
			Item item4 = new Item(_codFatherBundle, "TCFL_RoastedVegetables");
			item4.Crafting.Add(ItemManager.CraftingTable.Cauldron, 4);
			item4.RequiredItems.Add("Turnip", 2);
			item4.RequiredItems.Add("Carrot", 2);
			item4.RequiredItems.Add("Dandelion", 2);
			item4.RequiredItems.Add("Thistle", 2);
			item4.Configurable = Configurability.Recipe | Configurability.Stats;
			ShaderReplacer.Replace(item4.Prefab);
			ShaderReplacer.Replace(new Item(_codFatherBundle, "TCFL_SmokedBoarMeat")
			{
				Configurable = Configurability.Stats
			}.Prefab);
			ShaderReplacer.Replace(new Item(_codFatherBundle, "TCFL_SmokedCapelin")
			{
				Configurable = Configurability.Stats
			}.Prefab);
			ShaderReplacer.Replace(new Item(_codFatherBundle, "TCFL_SmokedChickenMeat")
			{
				Configurable = Configurability.Stats
			}.Prefab);
			ShaderReplacer.Replace(new Item(_codFatherBundle, "TCFL_SmokedDeerMeat")
			{
				Configurable = Configurability.Stats
			}.Prefab);
			ShaderReplacer.Replace(new Item(_codFatherBundle, "TCFL_SmokedFish")
			{
				Configurable = Configurability.Stats
			}.Prefab);
			Item item5 = new Item(_codFatherBundle, "TCFL_SmokedFishStew");
			item5.Crafting.Add(ItemManager.CraftingTable.Cauldron, 4);
			item5.RequiredItems.Add("TCFL_SmokedFish", 2);
			item5.RequiredItems.Add("BreadDough", 1);
			item5.RequiredItems.Add("Onion", 1);
			item5.Configurable = Configurability.Recipe | Configurability.Stats;
			ShaderReplacer.Replace(item5.Prefab);
			ShaderReplacer.Replace(new Item(_codFatherBundle, "TCFL_SmokedNeckTail")
			{
				Configurable = Configurability.Stats
			}.Prefab);
			ShaderReplacer.Replace(new Item(_codFatherBundle, "TCFL_SmokedSausage")
			{
				Configurable = Configurability.Stats
			}.Prefab);
			ShaderReplacer.Replace(new Item(_codFatherBundle, "TCFL_SmokedSerpentMeat")
			{
				Configurable = Configurability.Stats
			}.Prefab);
			Item item6 = new Item(_codFatherBundle, "TCFL_SmokedSerpentStew");
			item6.Crafting.Add(ItemManager.CraftingTable.Cauldron, 4);
			item6.RequiredItems.Add("TCFL_SmokedSerpentMeat", 1);
			item6.RequiredItems.Add("Mushroom", 1);
			item6.RequiredItems.Add("Honey", 2);
			item6.Configurable = Configurability.Recipe | Configurability.Stats;
			ShaderReplacer.Replace(item6.Prefab);
		}

		private static void Effects()
		{
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_block_camshake");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_deadspeak_vo");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_Eat");
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_FeastMeadowsEat"));
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_FeastSmall");
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_FeastTemplate"));
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_float_hitwater"));
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_float_nibble"));
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_hit_camshake_knife");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_oven_add_food");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_oven_produce");
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_Potion_frostresist"));
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_swing_camshake");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_arrow_hit");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_build_hammer_metal");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_build_hammer_wood");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_chest_close");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_chest_open");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_crow_death");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_eat");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_feast_destroyed");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_fishingrod_linebreak");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_fishingrod_swing");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_gui_craftitem_cauldron");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_gui_craftitem_cauldron_end");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_haldor_greet");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_haldor_laugh");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_haldor_yea");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_knife_swing");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_metal_blocked");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_oven_burnt");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_oven_done");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_ship_waterimpact");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_unarmed_hit");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_wood_blocked");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_sfx_wood_destroyed");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_teq_sfx_ship_destroyed");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_teq_sfx_ship_destroyed1");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_teq_vfx_clubhit");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_teq_vfx_Damaged_Karve");
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_teq_vfx_Destroyed_Karve"));
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_arrowhit");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_blocked");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_cooking_station_transform");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_crow_death");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_HitSparks");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_Place_wood_pole");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_Place_workbench");
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_SawDust");
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_water_surface_fish"));
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_WaterImpact_Karve"));
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_vfx_watersplash_karve"));
			PrefabManager.RegisterPrefab(_codFatherBundle, "tcfl_fx_oven_add_wood");
		}

		public static void Start()
		{
			_knife.Snapshot();
			_trap.Snapshot();
		}

		private static void RemoveComponent(this GameObject gameObject, Type type)
		{
			Component component = gameObject.GetComponent(type);
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
		}

		private static void WindRun(ItemDrop item)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "tcfl_windrun_se";
			((StatusEffect)val).m_name = "$tcfl_windrun";
			((StatusEffect)val).m_icon = _codFatherBundle.LoadAsset<Sprite>("tcfl_grim_codfather_pants_icon");
			((StatusEffect)val).m_tooltip = ((StatusEffect)val).m_name;
			((StatusEffect)val).m_startMessageType = (MessageType)2;
			((StatusEffect)val).m_startMessage = ((StatusEffect)val).m_name + " started.";
			((StatusEffect)val).m_ttl = 0f;
			val.m_jumpStaminaUseModifier = -0.3f;
			val.m_jumpModifier = new Vector3(0f, 0.2f, 0f);
			item.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)val;
		}

		private static void FeatherFall(ItemDrop item)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "tcfl_featherfall_se";
			((StatusEffect)val).m_name = "$se_slowfall_name";
			((StatusEffect)val).m_icon = _codFatherBundle.LoadAsset<Sprite>("tcfl_grim_codfather_coat_icon");
			((StatusEffect)val).m_tooltip = "$se_slowfall_tooltip";
			((StatusEffect)val).m_startMessageType = (MessageType)2;
			((StatusEffect)val).m_startMessage = ((StatusEffect)val).m_name + " started.";
			((StatusEffect)val).m_ttl = 0f;
			val.m_maxMaxFallSpeed = 5f;
			val.m_fallDamageModifier = -1f;
			item.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)val;
		}
	}
	public static class ShaderReplacer
	{
		private static readonly List<GameObject> GOToSwap;

		static ShaderReplacer()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			GOToSwap = new List<GameObject>();
			new Harmony("blacks7ar.utilities.ShaderReplacer").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ShaderReplacer), "ReplaceShaderPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

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

		[HarmonyPriority(700)]
		private static void ReplaceShaderPatch()
		{
			foreach (Material item in from gameObject in GOToSwap
				select gameObject.GetComponentsInChildren<Renderer>(true) into renderers
				from renderer in renderers
				where (Object)(object)renderer != (Object)null
				from material in renderer.sharedMaterials
				where (Object)(object)material != (Object)null
				select material)
			{
				Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
				foreach (Shader val in array)
				{
					if (((Object)item.shader).name == ((Object)val).name)
					{
						item.shader = val;
					}
				}
			}
		}
	}
	public class SmokerLarge : MonoBehaviour, Interactable, Hoverable, IHasHoverMenuExtended
	{
		[Serializable]
		public class ItemConversion
		{
			public ItemDrop m_from;

			public ItemDrop m_to;

			public float m_cookTime = 10f;
		}

		[Serializable]
		public enum Status
		{
			NotDone,
			Done,
			Ready
		}

		public Switch m_addFoodSwitch;

		public Switch m_addFuelSwitch;

		public EffectList m_addEffect = new EffectList();

		public EffectList m_doneEffect = new EffectList();

		public EffectList m_pickEffect = new EffectList();

		public string m_addItemTooltip = "$tcfl_additem";

		public Transform m_spawnPoint;

		public float m_spawnForce = 5f;

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

		public Transform[] m_slots;

		public ParticleSystem[] m_donePs;

		public string m_name = "";

		public bool m_requiresFire = true;

		public ItemDrop m_fuelItem;

		public Transform[] m_fireCheckPoints;

		public float m_fireCheckRadius = 0.25f;

		public bool m_useFuel;

		public int m_maxFuel = 20;

		public int m_secPerFuel = 5000;

		public EffectList m_fuelAddedEffects = new EffectList();

		public GameObject m_haveFuelObject;

		public GameObject m_haveFireObject;

		public bool m_cheapFireCheck;

		public ZNetView m_nview;

		public ParticleSystem[] m_ps;

		public AudioSource[] m_as;

		public float m_hoverOffset;

		public void Awake()
		{
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			m_nview = ((Component)this).gameObject.GetComponent<ZNetView>();
			SetItUp();
			if (m_nview.GetZDO() != null)
			{
				m_ps = (ParticleSystem[])(object)new ParticleSystem[m_slots.Length];
				m_as = (AudioSource[])(object)new AudioSource[m_slots.Length];
				for (int i = 0; i < m_slots.Length; i++)
				{
					m_ps[i] = ((Component)m_slots[i]).GetComponent<ParticleSystem>();
					m_as[i] = ((Component)m_slots[i]).GetComponent<AudioSource>();
				}
				m_nview.Register<Vector3, int>("RPC_RemoveDoneItem", (Action<long, Vector3, int>)RPC_RemoveDoneItem);
				m_nview.Register<string>("RPC_AddItem", (Action<long, string>)RPC_AddItem);
				m_nview.Register("RPC_AddFuel", (Action<long>)RPC_AddFuel);
				m_nview.Register<int, string>("RPC_SetSlotVisual", (Action<long, int, string>)RPC_SetSlotVisual);
				if (Object.op_Implicit((Object)(object)m_addFoodSwitch))
				{
					m_addFoodSwitch.m_onUse = new Callback(OnAddFoodSwitch);
					m_addFoodSwitch.m_hoverText = HoverText();
				}
				if (Object.op_Implicit((Object)(object)m_addFuelSwitch))
				{
					m_addFuelSwitch.m_onUse = new Callback(OnAddFuelSwitch);
					m_addFuelSwitch.m_onHover = new TooltipCallback(OnHoverFuelSwitch);
				}
				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));
				}
				m_cheapFireCheck = m_fireCheckRadius == 0.25f;
				((MonoBehaviour)this).InvokeRepeating("UpdateCooking", 0f, 1f);
			}
		}

		public void SetConversion()
		{
			m_conversion.Add(new ItemConversion
			{
				m_from = ObjectDB.instance.GetItemPrefab("SerpentMeat").GetComponent<ItemDrop>(),
				m_to = ObjectDB.instance.GetItemPrefab("TCFL_SmokedSerpentMeat").GetComponent<ItemDrop>(),
				m_cookTime = 240f
			});
		}

		public void SetItUp()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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)
			//IL_006d: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Expected O, but got Unknown
			m_addFoodSwitch = ((Component)((Component)this).transform.Find("add_food")).GetComponent<Switch>();
			m_addFuelSwitch = ((Component)((Component)this).transform.Find("add_fuel")).GetComponent<Switch>();
			m_addEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("tcfl_fx_oven_add_food"),
					m_enabled = true,
					m_variant = -1
				}
			};
			m_doneEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[2]
			{
				new EffectData
				{
					m_prefab = PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("tcfl_sfx_oven_done"),
					m_enabled = true,
					m_variant = -1
				},
				new EffectData
				{
					m_prefab = PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("tcfl_vfx_cooking_station_transform"),
					m_enabled = true,
					m_variant = -1
				}
			};
			m_pickEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("tcfl_fx_oven_produce"),
					m_enabled = true,
					m_variant = -1
				}
			};
			m_spawnPoint = ((Component)this).transform.Find("SpawnPoint");
			SetConversion();
			m_slots = (Transform[])(object)new Transform[4]
			{
				((Component)this).transform.Find("large_slot1"),
				((Component)this).transform.Find("large_slot2"),
				((Component)this).transform.Find("large_slot3"),
				((Component)this).transform.Find("large_slot4")
			};
			m_donePs = (ParticleSystem[])(object)new ParticleSystem[4]
			{
				((Component)((Component)this).transform.Find("done_large1")).GetComponent<ParticleSystem>(),
				((Component)((Component)this).transform.Find("done_large2")).GetComponent<ParticleSystem>(),
				((Component)((Component)this).transform.Find("done_large3")).GetComponent<ParticleSystem>(),
				((Component)((Component)this).transform.Find("done_large4")).GetComponent<ParticleSystem>()
			};
			m_requiresFire = false;
			m_fireCheckPoints = (Transform[])(object)new Transform[1];
			m_useFuel = true;
			m_fuelItem = ObjectDB.instance.GetItemPrefab("Wood").GetComponent<ItemDrop>();
			m_fuelAddedEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = PrefabsSetup._codFatherBundle.LoadAsset<GameObject>("tcfl_fx_oven_add_wood"),
					m_enabled = true,
					m_variant = -1
				}
			};
			m_haveFuelObject = ((Component)((Component)this).transform.Find("HaveFuel")).gameObject;
			m_haveFireObject = ((Component)((Component)this).transform.Find("_smoker_enabled")).gameObject;
		}

		public void DropAllItems()
		{
			if ((Object)(object)m_fuelItem != (Object)null)
			{
				float fuel = GetFuel();
				for (int i = 0; i < (int)fuel; i++)
				{
					drop(m_fuelItem);
				}
				SetFuel(0f);
			}
			for (int j = 0; j < m_slots.Length; j++)
			{
				GetSlot(j, out var itemName, out var _, out var status);
				if (itemName == "")
				{
					continue;
				}
				switch (status)
				{
				case Status.Done:
				case Status.Ready:
					drop(GetItemConversion(itemName).m_to);
					break;
				case Status.NotDone:
				{
					GameObject prefab = ZNetScene.instance.GetPrefab(itemName);
					if ((Object)(object)prefab != (Object)null)
					{
						ItemDrop component = prefab.GetComponent<ItemDrop>();
						if (Object.op_Implicit((Object)(object)component))
						{
							drop(component);
						}
					}
					break;
				}
				}
				SetSlot(j, "", 0f, Status.NotDone);
			}
			void drop(ItemDrop item)
			{
				//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_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				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)item).gameObject, val, val2), false);
			}
		}

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

		public void UpdateCooking()
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			if (!m_nview.IsValid())
			{
				return;
			}
			bool flag = (m_requiresFire && IsFireLit()) || (m_useFuel && GetFuel() > 0f);
			if (m_nview.IsOwner())
			{
				float deltaTime = GetDeltaTime();
				if (flag)
				{
					UpdateFuel(deltaTime);
					for (int i = 0; i < m_slots.Length; i++)
					{
						GetSlot(i, out var itemName, out var cookedTime, out var status);
						if (itemName == "" || status == Status.Ready)
						{
							continue;
						}
						ItemConversion itemConversion = GetItemConversion(itemName);
						if (itemConversion == null)
						{
							SetSlot(i, "", 0f, Status.NotDone);
							continue;
						}
						cookedTime += deltaTime;
						if (cookedTime > itemConversion.m_cookTime * 2f)
						{
							m_doneEffect.Create(m_slots[i].position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
							SetSlot(i, ((Object)itemConversion.m_to).name, cookedTime, Status.Ready);
						}
						else if (cookedTime > itemConversion.m_cookTime && itemName == ((Object)itemConversion.m_from).name)
						{
							m_doneEffect.Create(m_slots[i].position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
							SetSlot(i, ((Object)itemConversion.m_to).name, cookedTime, Status.Done);
						}
						else
						{
							SetSlot(i, itemName, cookedTime, status);
						}
					}
				}
			}
			UpdateVisual(flag);
		}

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

		public void UpdateFuel(float dt)
		{
			if (m_useFuel)
			{
				float num = dt / (float)m_secPerFuel;
				float fuel = GetFuel();
				fuel -= num;
				if (fuel < 0f)
				{
					fuel = 0f;
				}
				SetFuel(fuel);
			}
		}

		public void UpdateVisual(bool fireLit)
		{
			for (int i = 0; i < m_slots.Length; i++)
			{
				GetSlot(i, out var itemName, out var _, out var status);
				SetSlotVisual(i, itemName, fireLit, status);
			}
			if (m_useFuel)
			{
				bool active = GetFuel() > 0f;
				if (Object.op_Implicit((Object)(object)m_haveFireObject))
				{
					m_haveFireObject.SetActive(fireLit);
				}
				if (Object.op_Implicit((Object)(object)m_haveFuelObject))
				{
					m_haveFuelObject.SetActive(active);
				}
			}
		}

		public void RPC_SetSlotVisual(long sender, int slot, string item)
		{
			SetSlotVisual(slot, item, fireLit: false, Status.NotDone);
		}

		public void SetSlotVisual(int i, string item, bool fireLit, Status status)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			if (item == "")
			{
				EmissionModule emission = m_ps[i].emission;
				((EmissionModule)(ref emission)).enabled = false;
				if (m_donePs.Length != 0)
				{
					EmissionModule emission2 = m_donePs[i].emission;
					((EmissionModule)(ref emission2)).enabled = false;
				}
				m_as[i].mute = true;
				if (m_slots[i].childCount > 0)
				{
					Object.Destroy((Object)(object)((Component)m_slots[i].GetChild(0)).gameObject);
				}
				return;
			}
			EmissionModule emission3 = m_ps[i].emission;
			((EmissionModule)(ref emission3)).enabled = fireLit && status != Status.Ready;
			if (m_donePs.Length != 0)
			{
				EmissionModule emission4 = m_donePs[i].emission;
				bool flag = fireLit;
				if (flag)
				{
					bool flag2 = (uint)(status - 1) <= 1u;
					flag = flag2;
				}
				((EmissionModule)(ref emission4)).enabled = flag;
			}
			m_as[i].mute = !fireLit;
			if (m_slots[i].childCount == 0 || ((Object)m_slots[i].GetChild(0)).name != item)
			{
				if (m_slots[i].childCount > 0)
				{
					Object.Destroy((Object)(object)((Component)m_slots[i].GetChild(0)).gameObject);
				}
				Transform obj = ObjectDB.instance.GetItemPrefab(item).transform.Find("attach");
				Transform val = m_slots[i];
				GameObject obj2 = Object.Instantiate<GameObject>(((Component)obj).gameObject, val.position, val.rotation, val);
				((Object)obj2).name = item;
				Renderer[] componentsInChildren = obj2.GetComponentsInChildren<Renderer>();
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					componentsInChildren[j].shadowCastingMode = (ShadowCastingMode)0;
				}
			}
		}

		public void RPC_RemoveDoneItem(long sender, Vector3 userPoint, int amount)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < m_slots.Length; i++)
			{
				GetSlot(i, out var itemName, out var _, out var _);
				if (!(itemName == "") && IsItemDone(itemName))
				{
					for (int j = 0; j < amount; j++)
					{
						SpawnItem(itemName, i, userPoint);
					}
					SetSlot(i, "", 0f, Status.NotDone);
					m_nview.InvokeRPC(ZNetView.Everybody, "RPC_SetSlotVisual", new object[2] { i, "" });
					break;
				}
			}
		}

		public bool HaveDoneItem()
		{
			for (int i = 0; i < m_slots.Length; i++)
			{
				GetSlot(i, out var itemName, out var _, out var _);
				if (itemName != "" && IsItemDone(itemName))
				{
					return true;
				}
			}
			return false;
		}

		public bool IsItemDone(string itemName)
		{
			ItemConversion itemConversion = GetItemConversion(itemName);
			if (itemConversion == null)
			{
				return false;
			}
			if (itemName == ((Object)itemConversion.m_to).name)
			{
				return true;
			}
			return false;
		}

		public void SpawnItem(string name, int slot, Vector3 userPoint)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(name);
			Vector3 val;
			Vector3 val2;
			if ((Object)(object)m_spawnPoint != (Object)null)
			{
				val = m_spawnPoint.position;
				val2 = m_spawnPoint.forward;
			}
			else
			{
				Vector3 position = m_slots[slot].position;
				Vector3 val3 = userPoint - position;
				val3.y = 0f;
				((Vector3)(ref val3)).Normalize();
				val = position + val3 * 0.5f;
				val2 = val3;
			}
			Quaternion val4 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
			GameObject obj = Object.Instantiate<GameObject>(itemPrefab, val, val4);
			ItemDrop.OnCreateNew(obj, false);
			obj.GetComponent<Rigidbody>().velocity = val2 * m_spawnForce;
			m_pickEffect.Create(val, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
		}

		public string GetHoverText()
		{
			if ((Object)(object)m_addFoodSwitch != (Object)null)
			{
				return "";
			}
			return Localization.instance.Localize(HoverText());
		}

		public string HoverText()
		{
			return m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] " + m_addItemTooltip + (ZInput.GamepadActive ? "" : ("\n[<color=yellow><b>1-8</b></color>] " + m_addItemTooltip));
		}

		public string GetHoverName()
		{
			return m_name;
		}

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

		public void RPC_AddFuel(long sender)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (m_nview.IsOwner())
			{
				ZLog.Log((object)"Add fuel");
				float fuel = GetFuel();
				SetFuel(fuel + 1f);
				m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1, default(ZDOID));
			}
		}

		public string OnHoverFuelSwitch()
		{
			float fuel = GetFuel();
			Localization instance = Localization.instance;
			string[] array = new string[9]
			{
				m_name,
				" (",
				m_fuelItem.m_itemData.m_shared.m_name,
				" ",
				Mathf.Ceil(fuel).ToString(),
				"/",
				null,
				null,
				null
			};
			int maxFuel = m_maxFuel;
			array[6] = maxFuel.ToString();
			array[7] = ")\n[<color=yellow><b>$KEY_Use</b></color>] $piece_smelter_add ";
			array[8] = m_fuelItem.m_itemData.m_shared.m_name;
			return instance.Localize(string.Concat(array));
		}

		public bool OnAddFoodSwitch(Switch caller, Humanoid user, ItemData item)
		{
			ZLog.Log((object)"add food switch");
			if (item == null)
			{
				return OnInteract(user);
			}
			return OnUseItem(user, item);
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold)
			{
				return false;
			}
			if ((Object)(object)m_addFoodSwitch == (Object)null)
			{
				return OnInteract(user);
			}
			return false;
		}

		public bool OnInteract(Humanoid user)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (HaveDoneItem())
			{
				((Character)Player.m_localPlayer).RaiseSkill((SkillType)105, 0.6f);
				int num = 1;
				float skillFactor = ((Character)Player.m_localPlayer).GetSkillFactor((SkillType)105);
				if (Random.value < skillFactor * InventoryGui.instance.m_craftBonusChance)
				{
					num += InventoryGui.instance.m_craftBonusAmount;
					DamageText.instance.ShowText((TextType)7, ((Component)this).transform.position + Vector3.up, "+1", true);
					InventoryGui.instance.m_craftBonusEffect.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
					ZLog.Log((object)"Bonus food cooking station!");
				}
				m_nview.InvokeRPC("RPC_RemoveDoneItem", new object[2]
				{
					((Component)user).transform.position,
					num
				});
				return true;
			}
			ItemData val = FindCookableItem(user.GetInventory());
			if (val == null)
			{
				((Character)user).Message((MessageType)2, "$msg_nocookitems", 0, (Sprite)null, false);
				return false;
			}
			((Character)Player.m_localPlayer).RaiseSkill((SkillType)105, 0.4f);
			return OnUseItem(user, val);
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			if ((Object)(object)m_addFoodSwitch == (Object)null)
			{
				return OnUseItem(user, item);
			}
			return false;
		}

		public bool OnUseItem(Humanoid user, ItemData item)
		{
			if (m_requiresFire && !IsFireLit())
			{
				((Character)user).Message((MessageType)2, "$msg_needfire", 0, (Sprite)null, false);
				user.UseIemBlockkMessage();
				return false;
			}
			if (GetFreeSlot() == -1)
			{
				((Character)user).Message((MessageType)2, "$msg_nocookroom", 0, (Sprite)null, false);
				user.UseIemBlockkMessage();
				return false;
			}
			return CookItem(user, item);
		}

		public bool IsFireLit()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (m_fireCheckPoints != null && m_fireCheckPoints.Length != 0)
			{
				Transform[] fireCheckPoints = m_fireCheckPoints;
				foreach (Transform val in fireCheckPoints)
				{
					if (m_cheapFireCheck)
					{