Decompiled source of AutomaticFuel v1.6.2

plugins/AutomaticFuel.dll

Decompiled 19 hours 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.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 System.Threading;
using System.Threading.Tasks;
using AutomaticFuel.Patches;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.ObjectPool;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Callbacks;
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: AssemblyFileVersion("1.6.2")]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyProduct("AutomaticFuel")]
[assembly: AssemblyCompany("TastyChickenLegs")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("AutomaticFuel")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.2.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<c07daaf8-2d5c-4a60-9e16-6266c8969f53>Embedded]
	internal sealed class <c07daaf8-2d5c-4a60-9e16-6266c8969f53>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<c07daaf8-2d5c-4a60-9e16-6266c8969f53>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <94a23f46-4f69-4cc6-b31e-18e5c60139c5>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <94a23f46-4f69-4cc6-b31e-18e5c60139c5>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <94a23f46-4f69-4cc6-b31e-18e5c60139c5>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[<c07daaf8-2d5c-4a60-9e16-6266c8969f53>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <27b56a91-2c30-4165-a371-7110d2d11446>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <27b56a91-2c30-4165-a371-7110d2d11446>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(0)]
internal sealed class ConfigurationManagerAttributes
{
	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
namespace AutomaticFuel
{
	[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(0)]
	[BepInPlugin("TastyChickenLegs.AutomaticFuel", "AutomaticFuel", "1.6.2")]
	[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
	public class AutomaticFuelPlugin : BaseUnityPlugin
	{
		[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(0)]
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			public bool? Browsable = false;
		}

		[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(0)]
		private class AcceptableShortcuts : AcceptableValueBase
		{
			public AcceptableShortcuts()
				: base(typeof(KeyboardShortcut))
			{
			}

			public override object Clamp(object value)
			{
				return value;
			}

			public override bool IsValid(object value)
			{
				return true;
			}

			public override string ToDescriptionString()
			{
				return "# Acceptable values: " + string.Join(", ", KeyboardShortcut.AllKeyCodes);
			}
		}

		[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(0)]
		[HarmonyPatch(typeof(Container), "Awake")]
		private static class ContainerAwakePatch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Postfix(Container __instance, ZNetView ___m_nview)
			{
				TastyUtils.AddContainer(__instance, ___m_nview);
			}
		}

		[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(0)]
		[HarmonyPatch(typeof(Container), "OnDestroyed")]
		private static class ContainerOnDestroyedPatch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Prefix(Container __instance)
			{
				ContainerList.Remove(__instance);
			}
		}

		internal const string ModName = "AutomaticFuel";

		internal const string ModVersion = "1.6.2";

		internal const string Author = "TastyChickenLegs";

		private const string ModGUID = "TastyChickenLegs.AutomaticFuel";

		private static string ConfigFileName = "TastyChickenLegs.AutomaticFuel.cfg";

		private static string ConfigFileFullPath;

		private static readonly bool isDebug;

		internal static readonly List<Container> ContainerList;

		public static AutomaticFuelPlugin context;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		public static ConfigEntry<bool> _configEnabled;

		public static readonly ManualLogSource AutomaticFuelLogger;

		public static float timerOnFloatTime;

		public static float timerOffFloatTime;

		public static bool CandlesForeverLoaded;

		internal static string ConnectionError;

		private const string TargetModGuid = "Tastychickenlegs.CandlesForever";

		private readonly Harmony harmony = new Harmony("TastyChickenLegs.AutomaticFuel");

		private static readonly ConfigSync ConfigSync;

		[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(new byte[] { 1, 0, 1, 1, 1 })]
		private static readonly (string modGuid, string setting, string mkey, bool srchset, bool chngset)[] FuelMethodTable;

		protected void Start()
		{
		}

		public void Awake()
		{
			context = this;
			_serverConfigLocked = config("Base Settings", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			_configEnabled = config("Base Settings", "Mod Enabled", value: true, "Sets the mod to be enabled or not.");
			try
			{
				Localizer.Load();
			}
			catch (Exception arg)
			{
				AutomaticFuelLogger.LogError((object)$"[AutomaticFuel] localization init failed; text will fall back to English: {arg}");
			}
			Configs.Generate();
			Localizer.AddPlaceholder<KeyCode>("autofuel_hover_mode", "togglekey", Configs.stationToggleKey);
			Localizer.AddPlaceholder<KeyCode>("autofuel_hover_state", "togglekey", Configs.stationToggleKey);
			GogetTime();
			CleanConfig();
			harmony.PatchAll();
			LogPatchState();
			SetupWatcher();
			_ = _configEnabled.Value;
		}

		private static void LogPatchState()
		{
			(Type, string)[] array = new(Type, string)[7]
			{
				(typeof(Fireplace), "GetHoverText"),
				(typeof(Fireplace), "IsBurning"),
				(typeof(Fireplace), "UpdateFireplace"),
				(typeof(Smelter), "OnHoverAddOre"),
				(typeof(Smelter), "OnHoverAddFuel"),
				(typeof(Smelter), "UpdateSmelter"),
				(typeof(Smelter), "SetFuel")
			};
			for (int i = 0; i < array.Length; i++)
			{
				(Type, string) tuple = array[i];
				Type item = tuple.Item1;
				string item2 = tuple.Item2;
				MethodInfo methodInfo = AccessTools.Method(item, item2, (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					AutomaticFuelLogger.LogError((object)("[AutomaticFuel] patch audit: " + item.Name + "." + item2 + " NOT FOUND in the game assembly."));
				}
				else
				{
					Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo);
					int num = patchInfo?.Prefixes.Count ?? 0;
					int num2 = patchInfo?.Postfixes.Count ?? 0;
					AutomaticFuelLogger.LogInfo((object)($"[AutomaticFuel] patch audit: {item.Name}.{item2} -> prefixes={num} postfixes={num2}" + ((num + num2 == 0) ? "   <== NOTHING ATTACHED" : "")));
				}
			}
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(ConfigFileFullPath))
			{
				return;
			}
			try
			{
				AutomaticFuelLogger.LogDebug((object)"ReadConfigValues called");
				((BaseUnityPlugin)this).Config.Reload();
				GogetTime();
			}
			catch
			{
				AutomaticFuelLogger.LogError((object)("There was an issue loading your " + ConfigFileName));
				AutomaticFuelLogger.LogError((object)"Please check your config entries for spelling and format!");
			}
		}

		private void CleanConfig()
		{
			if (!File.Exists(ConfigFileFullPath))
			{
				return;
			}
			try
			{
				string text = File.ReadAllText(ConfigFileFullPath);
				if (string.IsNullOrEmpty(text))
				{
					return;
				}
				string[] array = text.Split(new char[1] { '\n' });
				List<string> list = new List<string>();
				bool flag = false;
				int num = 0;
				for (int i = 0; i < array.Length; i++)
				{
					string text2 = array[i];
					if (text2.EndsWith("\r"))
					{
						text2 = text2.Substring(0, text2.Length - 1);
					}
					string text3 = text2.Trim();
					if (string.IsNullOrEmpty(text3) || text3.StartsWith("[") || text3.StartsWith(";"))
					{
						list.Add(text2);
						flag = false;
					}
					else if (text3.StartsWith("##"))
					{
						flag = true;
						list.Add(text2);
					}
					else if (text3.StartsWith("#"))
					{
						list.Add(text2);
					}
					else if (text3.Contains("="))
					{
						if (flag)
						{
							list.Add(text2);
						}
						else
						{
							num++;
							AutomaticFuelLogger.LogInfo((object)("[AutoFuel] Cleaned orphaned config: " + text3));
						}
						flag = false;
					}
					else
					{
						list.Add(text2);
						flag = false;
					}
				}
				if (num > 0)
				{
					File.WriteAllLines(ConfigFileFullPath, list);
					AutomaticFuelLogger.LogInfo((object)$"[AutoFuel] Cleaned {num} orphaned config entr(y/ies)");
					((BaseUnityPlugin)this).Config.Reload();
				}
			}
			catch (Exception ex)
			{
				AutomaticFuelLogger.LogWarning((object)("[AutoFuel] Config cleanup skipped (" + ex.Message + ")"));
			}
		}

		public static void Dbgl(string str = "", bool pref = true)
		{
			if (isDebug)
			{
				Debug.Log((object)((pref ? (typeof(AutomaticFuelPlugin).Namespace + " ") : "") + str));
			}
		}

		private void Update()
		{
			//IL_0005: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(Configs.onoffToggle.Value) && !TastyUtils.IgnoreKeyPresses(extra: true))
			{
				Configs.isOn.Value = !Configs.isOn.Value;
				((BaseUnityPlugin)this).Config.Save();
				((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(TastyUtils.Loc("$autofuel_toggle_message"), Configs.isOn.Value), 0, (Sprite)null, false);
			}
			_ = Configs.stationToggleKey.Value;
			if (Input.GetKeyDown(Configs.stationToggleKey.Value) && !TastyUtils.IgnoreKeyPresses(extra: true))
			{
				TastyUtils.ToggleHoveredStation();
			}
		}

		internal ConfigEntry<T> config<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? TastyUtils.Loc("$autofuel_synced") : TastyUtils.Loc("$autofuel_not_synced")), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			ConfigSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		internal ConfigEntry<T> config<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		private static void GogetTime()
		{
			float num = Convert.ToSingle(Configs.timerOnHours.Value);
			num /= 24f;
			AutomaticFuelLogger.LogDebug((object)num);
			float num2 = Convert.ToSingle(Configs.timerOnMinutes.Value);
			num2 = num2 / 60f / 24f;
			AutomaticFuelLogger.LogDebug((object)num2);
			timerOnFloatTime = num2 + num;
			AutomaticFuelLogger.LogDebug((object)timerOnFloatTime);
			float num3 = Convert.ToSingle(Configs.timerOffHours.Value);
			num3 /= 24f;
			AutomaticFuelLogger.LogDebug((object)num3);
			float num4 = Convert.ToSingle(Configs.timerOffMinutes.Value);
			num4 = num4 / 60f / 24f;
			AutomaticFuelLogger.LogDebug((object)num4);
			timerOffFloatTime = num4 + num3;
			AutomaticFuelLogger.LogDebug((object)timerOffFloatTime);
		}

		static AutomaticFuelPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			isDebug = false;
			ContainerList = new List<Container>();
			_serverConfigLocked = null;
			AutomaticFuelLogger = Logger.CreateLogSource("AutomaticFuel");
			ConnectionError = "";
			ConfigSync = new ConfigSync("TastyChickenLegs.AutomaticFuel")
			{
				DisplayName = "AutomaticFuel",
				CurrentVersion = "1.6.2",
				MinimumRequiredVersion = "1.6.2"
			};
			FuelMethodTable = new(string, string, string, bool, bool)[1] { ("TastyChickeLegs.TimedTorchesStayLit", "General", "Mod Enabled", true, false) };
		}
	}
	[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
	[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(0)]
	public class TastyUtils
	{
		public const string ToggleZdoKey = "AF_toggleOn";

		[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)]
		private static readonly MethodInfo ContainerSaveMethod = AccessTools.Method(typeof(Container), "Save", (Type[])null, (Type[])null);

		[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)]
		private static readonly MethodInfo InventoryChangedMethod = AccessTools.Method(typeof(Inventory), "Changed", new Type[2]
		{
			typeof(bool),
			typeof(bool)
		}, (Type[])null);

		[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(new byte[] { 2, 1 })]
		private static readonly FieldRef<Smelter, bool> SmelterBlockedSmoke = AccessTools.FieldRefAccess<Smelter, bool>("m_blockedSmoke");

		public const string RpcSmelterToggle = "AF_ToggleOnOff";

		public const string RpcFireCycle = "AF_CycleFire";

		public static bool IsStationOn(ZNetView nv)
		{
			if ((Object)(object)nv == (Object)null || !nv.IsValid() || nv.GetZDO() == null)
			{
				return true;
			}
			return nv.GetZDO().GetInt("AF_toggleOn", 1) != 0;
		}

		public static void SetSmelterBlockedSmoke(Smelter smelter, bool value)
		{
			if (!((Object)(object)smelter == (Object)null) && SmelterBlockedSmoke != null)
			{
				SmelterBlockedSmoke.Invoke(smelter) = value;
			}
		}

		public static void TakeOneFromContainer(Container container, string itemName)
		{
			if (!((Object)(object)container == (Object)null))
			{
				Inventory inventory = container.GetInventory();
				if (inventory != null)
				{
					inventory.RemoveItem(itemName, 1, -1, false);
					ContainerSaveMethod?.Invoke(container, new object[0]);
					InventoryChangedMethod?.Invoke(inventory, new object[2] { true, false });
				}
			}
		}

		public static bool ClaimDroppedItem(ItemDrop item)
		{
			ZNetView val = ((item != null) ? ((Component)item).GetComponent<ZNetView>() : null);
			if ((Object)(object)val == (Object)null || !val.IsValid())
			{
				return false;
			}
			if (!val.IsOwner())
			{
				val.ClaimOwnership();
			}
			return val.IsOwner();
		}

		public static Component FindHoveredStation()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return null;
			}
			GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject();
			if ((Object)(object)hoverObject == (Object)null)
			{
				return null;
			}
			Component componentInParent = (Component)(object)hoverObject.GetComponentInParent<Smelter>();
			if (Object.op_Implicit((Object)(object)componentInParent))
			{
				return componentInParent;
			}
			componentInParent = (Component)(object)hoverObject.GetComponentInParent<Fireplace>();
			if (Object.op_Implicit((Object)(object)componentInParent))
			{
				return componentInParent;
			}
			componentInParent = (Component)(object)hoverObject.GetComponentInParent<CookingStation>();
			if (Object.op_Implicit((Object)(object)componentInParent))
			{
				return componentInParent;
			}
			componentInParent = (Component)(object)hoverObject.GetComponentInParent<Windmill>();
			if (Object.op_Implicit((Object)(object)componentInParent))
			{
				return componentInParent;
			}
			return null;
		}

		public static bool IgnoreKeyPresses(bool extra = false)
		{
			if (!extra)
			{
				if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog())
				{
					Chat instance = Chat.instance;
					if (instance == null)
					{
						return false;
					}
					return instance.HasFocus();
				}
				return true;
			}
			if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog())
			{
				Chat instance2 = Chat.instance;
				if ((instance2 == null || !instance2.HasFocus()) && !StoreGui.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible())
				{
					TextViewer instance3 = TextViewer.instance;
					if (instance3 == null)
					{
						return false;
					}
					return instance3.IsVisible();
				}
			}
			return true;
		}

		public static Fireplace FindHoveredFireplace()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return null;
			}
			GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject();
			if ((Object)(object)hoverObject == (Object)null)
			{
				return null;
			}
			Fireplace componentInParent = hoverObject.GetComponentInParent<Fireplace>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				return componentInParent;
			}
			return null;
		}

		public static void ToggleHoveredStation()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject();
			if ((Object)(object)hoverObject == (Object)null)
			{
				return;
			}
			Fireplace componentInParent = hoverObject.GetComponentInParent<Fireplace>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				ToggleFireplaceMode(componentInParent);
				return;
			}
			Smelter componentInParent2 = hoverObject.GetComponentInParent<Smelter>();
			if ((Object)(object)componentInParent2 != (Object)null)
			{
				ToggleStationOnOff((Component)(object)componentInParent2);
			}
		}

		public static string Loc(string key)
		{
			if (Localization.instance == null)
			{
				return key;
			}
			return Localization.instance.Localize(key);
		}

		private static void Notify(string text)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				((Character)localPlayer).Message((MessageType)2, text, 0, (Sprite)null, false);
			}
		}

		public static string StationName(Component station, string fallback)
		{
			try
			{
				Traverse val = Traverse.Create((object)station).Field("m_name");
				if (val.FieldExists())
				{
					string value = val.GetValue<string>();
					if (!string.IsNullOrEmpty(value))
					{
						return (Localization.instance != null) ? Localization.instance.Localize(value) : value;
					}
				}
			}
			catch (Exception)
			{
			}
			string text = (((Object)(object)station != (Object)null) ? ((Object)station.gameObject).name : null);
			if (string.IsNullOrEmpty(text))
			{
				return fallback;
			}
			string prefabName = GetPrefabName(text);
			if (!string.IsNullOrEmpty(prefabName))
			{
				return prefabName;
			}
			return fallback;
		}

		private static void ToggleFireplaceMode(Fireplace fireplace)
		{
			ZNetView component = ((Component)fireplace).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid() || component.GetZDO() == null)
			{
				Notify(Loc("$autofuel_not_owner"));
				return;
			}
			if (!component.IsOwner())
			{
				component.InvokeRPC("AF_CycleFire", Array.Empty<object>());
				return;
			}
			string text = Configs.TorchModeLabel(Configs.CycleTorchMode(component), ((Object)((Component)component).gameObject).name);
			string text2 = StationName((Component)(object)fireplace, "Fire");
			Notify(Loc("$autofuel_station_state").Replace("{name}", text2).Replace("{state}", text));
			AutomaticFuelPlugin.AutomaticFuelLogger.LogInfo((object)("[AutomaticFuel] " + text2 + " -> " + text));
		}

		public static bool ToggleStationOnOff(Component station)
		{
			ZNetView val = (((Object)(object)station != (Object)null) ? station.GetComponent<ZNetView>() : null);
			if ((Object)(object)val == (Object)null || !val.IsValid() || val.GetZDO() == null)
			{
				Notify(Loc("$autofuel_not_owner"));
				return true;
			}
			if (!val.IsOwner())
			{
				val.InvokeRPC("AF_ToggleOnOff", Array.Empty<object>());
				return IsStationOn(val);
			}
			int num = ((val.GetZDO().GetInt("AF_toggleOn", 1) == 0) ? 1 : 0);
			val.GetZDO().Set("AF_toggleOn", num);
			string text = Configs.StationStateLabel(num == 1);
			string text2 = StationName(station, "Station");
			Notify(Loc("$autofuel_station_autofuel").Replace("{name}", text2).Replace("{state}", text));
			AutomaticFuelPlugin.AutomaticFuelLogger.LogInfo((object)("[AutomaticFuel] " + text2 + " -> " + text));
			return num == 1;
		}

		public static void ApplySmelterToggle(ZNetView nv)
		{
			if (!((Object)(object)nv == (Object)null) && nv.IsValid() && nv.IsOwner())
			{
				Smelter component = ((Component)nv).GetComponent<Smelter>();
				if ((Object)(object)component != (Object)null)
				{
					ToggleStationOnOff((Component)(object)component);
				}
			}
		}

		public static void ApplyFireCycle(ZNetView nv)
		{
			if (!((Object)(object)nv == (Object)null) && nv.IsValid() && nv.IsOwner())
			{
				Fireplace component = ((Component)nv).GetComponent<Fireplace>();
				if ((Object)(object)component != (Object)null)
				{
					ToggleFireplaceMode(component);
				}
			}
		}

		public static void RegisterToggleRpcs(ZNetView nv)
		{
			if (!((Object)(object)nv == (Object)null) && nv.IsValid())
			{
				nv.Register("AF_ToggleOnOff", (Action<long>)delegate
				{
					ApplySmelterToggle(nv);
				});
				nv.Register("AF_CycleFire", (Action<long>)delegate
				{
					ApplyFireCycle(nv);
				});
			}
		}

		public static string GetPrefabName(string name)
		{
			char[] anyOf = new char[2] { '(', ' ' };
			int num = name.IndexOfAny(anyOf);
			if (num >= 0)
			{
				return name.Substring(0, num);
			}
			return name;
		}

		public static void AddContainer(Container container, ZNetView nview)
		{
			try
			{
				ManualLogSource automaticFuelLogger = AutomaticFuelPlugin.AutomaticFuelLogger;
				object[] obj = new object[4]
				{
					((Object)container).name,
					(Object)(object)nview != (Object)null,
					((nview != null) ? nview.GetZDO() : null) != null,
					null
				};
				long? obj2;
				if (nview == null)
				{
					obj2 = null;
				}
				else
				{
					ZDO zDO = nview.GetZDO();
					obj2 = ((zDO != null) ? new long?(zDO.GetLong(StringExtensionMethods.GetStableHashCode("creator"), 0L)) : ((long?)null));
				}
				obj[3] = obj2;
				automaticFuelLogger.LogDebug((object)string.Format("Checking {0} {1} {2} {3}", obj));
				if (container.GetInventory() != null && ((nview != null) ? nview.GetZDO() : null) != null && (((Object)container).name.StartsWith("piece_", StringComparison.Ordinal) || ((Object)container).name.StartsWith("Container", StringComparison.Ordinal) || nview.GetZDO().GetLong(StringExtensionMethods.GetStableHashCode("creator"), 0L) != 0L))
				{
					AutomaticFuelPlugin.AutomaticFuelLogger.LogDebug((object)("Adding " + ((Object)container).name));
					Configs.ContainerList.Add(container);
				}
			}
			catch
			{
			}
		}

		public static List<Container> GetNearbyContainers(Vector3 center, float range)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			List<Container> list = new List<Container>();
			foreach (Container item in Configs.ContainerList.Where([<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(0)] (Container container) => (Object)(object)container != (Object)null && (Object)(object)((Component)container).GetComponentInParent<Piece>() != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)((container != null) ? ((Component)container).transform : null) != (Object)null && container.GetInventory() != null && (range <= 0f || Vector3.Distance(center, ((Component)container).transform.position) < range) && container.CheckAccess(Player.m_localPlayer.GetPlayerID())))
			{
				if (PrivateArea.CheckAccess(((Component)item).transform.position, 0f, false, false))
				{
					if (!PrivateArea.InsideFactionArea(((Component)item).transform.position, (Faction)0))
					{
						item.Load();
						list.Add(item);
					}
					else
					{
						item.Load();
						list.Add(item);
					}
				}
			}
			return list;
		}

		public static void changeConfig(string ttconfig, string section, string key, bool value, bool changeto)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(Paths.ConfigPath, ttconfig + ".cfg");
			if (File.Exists(text))
			{
				ConfigFile val = new ConfigFile(text, true);
				val.Bind<bool>(section, key, value, "Modified by Automatic Fuel").Value = changeto;
				val.Save();
				AutomaticFuelPlugin.AutomaticFuelLogger.LogInfo((object)("Successfully modified the target mod's configuration!" + ttconfig + section + key + value + changeto));
			}
			else
			{
				AutomaticFuelPlugin.AutomaticFuelLogger.LogWarning((object)"Target config file not found. Is the mod installed?");
			}
		}
	}
	[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(0)]
	[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
	public static class Reflection
	{
		public static TR InvokeStaticMethod<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T, [<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] TR>(string methodName, params object[] args)
		{
			return Traverse.Create<T>().Method(methodName, args).GetValue<TR>(args);
		}

		public static void InvokeStaticMethod<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T>(string methodName, params object[] args)
		{
			Traverse.Create<T>().Method(methodName, args).GetValue(args);
		}

		public static TR InvokeStaticMethod<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T, [<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] TR>(string methodName)
		{
			return Traverse.Create<T>().Method(methodName, Array.Empty<object>()).GetValue<TR>();
		}

		public static void InvokeStaticMethod<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T>(string methodName)
		{
			Traverse.Create<T>().Method(methodName, Array.Empty<object>()).GetValue();
		}

		public static T InvokeMethod<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T>(object instance, string methodName, params object[] args)
		{
			return Traverse.Create(instance).Method(methodName, args).GetValue<T>(args);
		}

		public static void InvokeMethod(object instance, string methodName, params object[] args)
		{
			Traverse.Create(instance).Method(methodName, args).GetValue(args);
		}

		public static T InvokeMethod<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T>(object instance, string methodName)
		{
			return Traverse.Create(instance).Method(methodName, Array.Empty<object>()).GetValue<T>();
		}

		public static void InvokeMethod(object instance, string methodName)
		{
			Traverse.Create(instance).Method(methodName, Array.Empty<object>()).GetValue();
		}

		public static TType GetStaticField<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] TClass, [<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] TType>(string fieldName)
		{
			return Traverse.Create<TClass>().Field<TType>(fieldName).Value;
		}

		public static TType SetStaticField<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] TClass, [<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] TType>(string fieldName, TType value)
		{
			return Traverse.Create<TClass>().Field<TType>(fieldName).Value = value;
		}

		public static T GetField<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T>(object instance, string fieldName)
		{
			return Traverse.Create(instance).Field<T>(fieldName).Value;
		}

		public static void SetField<[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(2)] T>(object instance, string fieldName, T value)
		{
			Traverse.Create(instance).Field<T>(fieldName).Value = value;
		}
	}
}
namespace AutomaticFuel.GameClasses
{
	internal class Fireplace_Patches
	{
		[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
		[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(0)]
		[HarmonyPatch(typeof(Fireplace), "UpdateFireplace")]
		private static class Fireplace_UpdateFireplace_Patch
		{
			private static readonly HashSet<string> _loggedRefuelErrors = new HashSet<string>();

			private static void Postfix(Fireplace __instance, ZNetView ___m_nview)
			{
				if (__instance.m_piece.m_name.StartsWith("$piece_candle", StringComparison.Ordinal))
				{
					__instance.m_halfThreshold = 1f;
				}
				if (Configs.ConfigCheck(((Object)__instance).name))
				{
					__instance.m_infiniteFuel = true;
					return;
				}
				if ((double)(Time.time - Configs.lastFuel) < 0.1)
				{
					Configs.fuelCount++;
					RefuelTorch(__instance, ___m_nview, Configs.fuelCount * 33);
				}
				else
				{
					Configs.fuelCount = 0;
					Configs.lastFuel = Time.time;
					RefuelTorch(__instance, ___m_nview, 0);
				}
				__instance.m_infiniteFuel = false;
			}

			public static async void RefuelTorch(Fireplace fireplace, ZNetView znview, int delay)
			{
				try
				{
					await Task.Delay(delay);
					if (!Object.op_Implicit((Object)(object)fireplace) || !Object.op_Implicit((Object)(object)znview) || !znview.IsValid() || !AutomaticFuelPlugin._configEnabled.Value || !TastyUtils.IsStationOn(znview))
					{
						return;
					}
					float num = znview.GetZDO().GetFloat("fuel", -1f);
					if (num < 0f)
					{
						return;
					}
					int num2 = (int)(fireplace.m_maxFuel - Mathf.Ceil(num));
					List<Container> nearbyContainers = TastyUtils.GetNearbyContainers(((Component)fireplace).transform.position, Configs.fireplaceRange.Value);
					if (Configs.nofloorpickup.Value)
					{
						Collider[] array = Physics.OverlapSphere(((Component)fireplace).transform.position + Vector3.up, Configs.dropRange.Value, LayerMask.GetMask(new string[1] { "item" }));
						foreach (Collider val in array)
						{
							if (!Object.op_Implicit((Object)(object)((val != null) ? val.attachedRigidbody : null)))
							{
								continue;
							}
							ItemDrop component = ((Component)val.attachedRigidbody).GetComponent<ItemDrop>();
							int num3;
							if (component == null)
							{
								num3 = 1;
							}
							else
							{
								ZNetView component2 = ((Component)component).GetComponent<ZNetView>();
								num3 = ((((component2 != null) ? new bool?(component2.IsValid()) : ((bool?)null)) != true) ? 1 : 0);
							}
							if (num3 != 0)
							{
								continue;
							}
							string prefabName = TastyUtils.GetPrefabName(((Object)((Component)component).gameObject).name);
							if (!((Object)(object)fireplace.m_fuelItem != (Object)null) || num2 <= 0 || !(component.m_itemData.m_shared.m_name == fireplace.m_fuelItem.m_itemData.m_shared.m_name) || Configs.fuelDisallowTypes.Value.Split(new char[1] { ',' }).Contains(prefabName))
							{
								continue;
							}
							AutomaticFuelPlugin.Dbgl("auto adding fuel " + prefabName + " from ground");
							int num4 = Mathf.Min(component.m_itemData.m_stack, num2);
							num2 -= num4;
							for (int j = 0; j < num4; j++)
							{
								if (component.m_itemData.m_stack <= 1)
								{
									if (znview.GetZDO() == null)
									{
										Object.Destroy((Object)(object)((Component)component).gameObject);
									}
									else
									{
										ZNetScene.instance.Destroy(((Component)component).gameObject);
									}
									znview.InvokeRPC("RPC_AddFuel", new object[0]);
									if (!Configs.distributedFilling.Value)
									{
										break;
									}
									return;
								}
								ItemData itemData = component.m_itemData;
								itemData.m_stack--;
								znview.InvokeRPC("RPC_AddFuel", new object[0]);
								Traverse.Create((object)component).Method("Save", Array.Empty<object>()).GetValue();
								if (Configs.distributedFilling.Value)
								{
									return;
								}
							}
						}
					}
					foreach (Container item2 in nearbyContainers)
					{
						if (!Object.op_Implicit((Object)(object)fireplace.m_fuelItem) || num2 <= 0)
						{
							continue;
						}
						List<ItemData> list = new List<ItemData>();
						item2.GetInventory().GetAllItems(fireplace.m_fuelItem.m_itemData.m_shared.m_name, list);
						foreach (ItemData item3 in list)
						{
							if (item3 != null && (!Configs.leaveLastItem.Value || item3.m_stack > 1) && !((Object)(object)item3.m_dropPrefab == (Object)null) && !Configs.fuelDisallowTypes.Value.Split(new char[1] { ',' }).Contains(((Object)item3.m_dropPrefab).name))
							{
								num2--;
								AutomaticFuelPlugin.Dbgl($"container at {((Component)item2).transform.position} has {item3.m_stack} {((Object)item3.m_dropPrefab).name}, taking one");
								znview.InvokeRPC("RPC_AddFuel", new object[0]);
								TastyUtils.TakeOneFromContainer(item2, fireplace.m_fuelItem.m_itemData.m_shared.m_name);
								if (Configs.distributedFilling.Value)
								{
									return;
								}
							}
						}
					}
				}
				catch (Exception ex)
				{
					string item = ex.GetType().Name + ": " + ex.Message;
					if (_loggedRefuelErrors.Add(item))
					{
						AutomaticFuelPlugin.AutomaticFuelLogger.LogError((object)$"[AutoFuel] fireplace refuel failed: {ex}");
					}
				}
			}
		}
	}
}
namespace AutomaticFuel.Patches
{
	[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(0)]
	[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
	internal class Configs
	{
		public static ConfigEntry<bool> fe_fire_pit;

		private static ConfigEntry<bool> fe_bonfire;

		private static ConfigEntry<bool> fe_hearth;

		private static ConfigEntry<bool> fe_piece_walltorch;

		private static ConfigEntry<bool> fe_piece_groundtorch;

		private static ConfigEntry<bool> fe_piece_groundtorch_wood;

		private static ConfigEntry<bool> fe_piece_groundtorch_green;

		private static ConfigEntry<bool> fe_piece_groundtorch_blue;

		private static ConfigEntry<bool> fe_piece_brazierfloor01;

		private static ConfigEntry<bool> fe_piece_brazierceiling01;

		private static ConfigEntry<bool> fe_piece_jackoturnip;

		public static ConfigEntry<bool> fe_piece_oven;

		private static ConfigEntry<bool> fe_smelter;

		private static ConfigEntry<bool> fe_blastfurnace;

		private static ConfigEntry<bool> fe_eitrrefinery;

		private static ConfigEntry<bool> fe_piece_bathtub;

		private static ConfigEntry<string> fe_custom_instance;

		public static ConfigEntry<float> dropRange;

		public static ConfigEntry<float> fireplaceRange;

		public static ConfigEntry<float> smelterOreRange;

		public static ConfigEntry<float> smelterFuelRange;

		public static ConfigEntry<bool> configAlwaysOnInDarkBiomes;

		public static ConfigEntry<bool> keepOnInRain;

		public static ConfigEntry<bool> autoPopCookedFood;

		public static ConfigEntry<bool> fe_piece_walltorch_timer;

		public static ConfigEntry<bool> fe_piece_groundtorch_timer;

		public static ConfigEntry<bool> fe_piece_groundtorch_wood_timer;

		public static ConfigEntry<bool> fe_piece_groundtorch_green_timer;

		public static ConfigEntry<bool> fe_piece_groundtorch_blue_timer;

		public static ConfigEntry<bool> fe_piece_brazierfloor01_timer;

		public static ConfigEntry<bool> fe_piece_brazierceiling01_timer;

		public static ConfigEntry<bool> fe_piece_jackoturnip_timer;

		private static ConfigEntry<string> fe_custom_instance_timer;

		public static ConfigEntry<int> timerOnMinutes;

		public static ConfigEntry<int> timerOnHours;

		public static ConfigEntry<int> timerOffMinutes;

		public static ConfigEntry<int> timerOffHours;

		public static float timerOnFloatTime;

		public static float timerOffFloatTime;

		public static ConfigEntry<bool> fe_fire_pit_smoke;

		private static ConfigEntry<bool> fe_hearth_smoke;

		private static ConfigEntry<bool> fe_piece_brazierfloor01_smoke;

		private static ConfigEntry<bool> fe_piece_brazierceiling01_smoke;

		private static ConfigEntry<bool> fe_smelter_smoke;

		internal static ConfigEntry<bool> fe_oven;

		private static ConfigEntry<bool> fe_bonfire_smoke;

		public static ConfigEntry<KeyCode> stationToggleKey;

		public static ConfigEntry<bool> configBlastFurnaceTakesAll;

		public static ConfigEntry<bool> nofloorpickup;

		public static ConfigEntry<bool> configStackSmelters;

		internal static readonly List<Container> ContainerList = new List<Container>();

		public static ConfigEntry<bool> isOn;

		public static ConfigEntry<bool> turnOffKiln;

		public static ConfigEntry<bool> turnOffWindmills;

		public static ConfigEntry<bool> turnOffSpinningWheel;

		public static float lastFuel;

		public static int fuelCount;

		public static string toggleString = "Automatic Fuel: {0}";

		public static ConfigEntry<int> restrictKilnOutputAmount;

		public static ConfigEntry<bool> restrictKilnOutput;

		public static ConfigEntry<string> fuelDisallowTypes;

		public static ConfigEntry<string> oreDisallowTypes;

		public static ConfigEntry<bool> distributedFilling;

		public static ConfigEntry<bool> leaveLastItem;

		public static ConfigEntry<KeyCode> onoffToggle;

		public static ConfigEntry<bool> windMillFast;

		public static ConfigEntry<bool> keepTall;

		public static ConfigEntry<bool> fe_piece_candle;

		public static ConfigEntry<bool> fe_piece_shieldGenerator;

		public static ConfigEntry<bool> turnOffHud;

		public const string ToggleZdoKey = "TT_toggleOn";

		private static readonly string[] TimerCapablePrefixes = new string[4] { "piece_groundtorch", "piece_walltorch", "piece_brazier", "piece_jackoturnip" };

		internal static void Generate()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Expected O, but got Unknown
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Expected O, but got Unknown
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Expected O, but got Unknown
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Expected O, but got Unknown
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Expected O, but got Unknown
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Expected O, but got Unknown
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Expected O, but got Unknown
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Expected O, but got Unknown
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Expected O, but got Unknown
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Expected O, but got Unknown
			//IL_068f: Unknown result type (might be due to invalid IL or missing references)
			//IL_069a: Expected O, but got Unknown
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Expected O, but got Unknown
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Expected O, but got Unknown
			//IL_079a: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a5: Expected O, but got Unknown
			//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fe: Expected O, but got Unknown
			//IL_084c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0857: Expected O, but got Unknown
			//IL_08a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b0: Expected O, but got Unknown
			//IL_08fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0909: Expected O, but got Unknown
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0966: Expected O, but got Unknown
			//IL_09b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bf: Expected O, but got Unknown
			//IL_0a22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2d: Expected O, but got Unknown
			//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9a: Expected O, but got Unknown
			//IL_0afc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b07: Expected O, but got Unknown
			//IL_0b6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b75: Expected O, but got Unknown
			//IL_0bc3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bce: Expected O, but got Unknown
			//IL_0c1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c27: Expected O, but got Unknown
			//IL_0c75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c80: Expected O, but got Unknown
			//IL_0cce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd9: Expected O, but got Unknown
			//IL_0d27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d32: Expected O, but got Unknown
			//IL_0d80: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d8b: Expected O, but got Unknown
			//IL_0dd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de4: Expected O, but got Unknown
			//IL_0e32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e3d: Expected O, but got Unknown
			//IL_0e91: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e9b: Expected O, but got Unknown
			//IL_0ee9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef4: Expected O, but got Unknown
			//IL_0f42: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f4d: Expected O, but got Unknown
			//IL_0f9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa6: Expected O, but got Unknown
			//IL_0ff4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fff: Expected O, but got Unknown
			//IL_104d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1058: Expected O, but got Unknown
			//IL_10a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_10b1: Expected O, but got Unknown
			//IL_1111: Unknown result type (might be due to invalid IL or missing references)
			//IL_111c: Expected O, but got Unknown
			//IL_117c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1187: Expected O, but got Unknown
			//IL_11e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_11f2: Expected O, but got Unknown
			//IL_1252: Unknown result type (might be due to invalid IL or missing references)
			//IL_125d: Expected O, but got Unknown
			//IL_12b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_12c1: Expected O, but got Unknown
			//IL_130f: Unknown result type (might be due to invalid IL or missing references)
			//IL_131a: Expected O, but got Unknown
			//IL_1368: Unknown result type (might be due to invalid IL or missing references)
			//IL_1373: Expected O, but got Unknown
			//IL_13c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_13d0: Expected O, but got Unknown
			//IL_1422: Unknown result type (might be due to invalid IL or missing references)
			//IL_142d: Expected O, but got Unknown
			//IL_147b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1486: Expected O, but got Unknown
			//IL_14d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_14df: Expected O, but got Unknown
			//IL_1536: Unknown result type (might be due to invalid IL or missing references)
			//IL_1540: Expected O, but got Unknown
			//IL_158e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1599: Expected O, but got Unknown
			//IL_15e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_15f2: Expected O, but got Unknown
			//IL_1640: Unknown result type (might be due to invalid IL or missing references)
			//IL_164b: Expected O, but got Unknown
			//IL_1699: Unknown result type (might be due to invalid IL or missing references)
			//IL_16a4: Expected O, but got Unknown
			//IL_16f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_16fd: Expected O, but got Unknown
			fe_fire_pit = AutomaticFuelPlugin.context.config("Eternal Fuel Firepit", "Camp Fire Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_fire_pit_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_firepit"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_fire_pit_name")
				}
			}));
			fe_bonfire = AutomaticFuelPlugin.context.config("Eternal Fuel Firepit", "Bonfire Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_bonfire_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_firepit"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_bonfire_name")
				}
			}));
			fe_hearth = AutomaticFuelPlugin.context.config("Eternal Fuel Firepit", "Hearth Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_hearth_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_firepit"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_hearth_name")
				}
			}));
			fe_piece_walltorch = AutomaticFuelPlugin.context.config("Eternal Fuel Torches", "Wall Torch Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_walltorch_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_walltorch_name")
				}
			}));
			fe_piece_groundtorch = AutomaticFuelPlugin.context.config("Eternal Fuel Torches", "Iron Torch Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_name")
				}
			}));
			fe_piece_groundtorch_wood = AutomaticFuelPlugin.context.config("Eternal Fuel Torches", "Wood Torch Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_wood_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_wood_name")
				}
			}));
			fe_piece_groundtorch_green = AutomaticFuelPlugin.context.config("Eternal Fuel Torches", "Green Torch Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_green_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_green_name")
				}
			}));
			fe_piece_groundtorch_blue = AutomaticFuelPlugin.context.config("Eternal Fuel Torches", "Blue Torch Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_blue_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_blue_name")
				}
			}));
			fe_piece_brazierfloor01 = AutomaticFuelPlugin.context.config("Eternal Fuel Torches", "Standing Brazier Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierfloor01_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierfloor01_name")
				}
			}));
			fe_piece_brazierceiling01 = AutomaticFuelPlugin.context.config("Eternal Fuel Torches", "Ceiling Brazier Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierceiling01_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierceiling01_name")
				}
			}));
			fe_piece_jackoturnip = AutomaticFuelPlugin.context.config("Eternal Fuel Torches", "JackOTurnip Keep Lit", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_jackoturnip_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_jackoturnip_name")
				}
			}));
			fe_piece_oven = AutomaticFuelPlugin.context.config("Eternal Fuel Misc", "Stone Oven Keep Fueled", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_oven_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_misc"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_oven_name")
				}
			}));
			fe_piece_bathtub = AutomaticFuelPlugin.context.config("Eternal Fuel Misc", "HotTub Keep Fueled", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_bathtub_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_misc"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_bathtub_name")
				}
			}));
			fe_smelter = AutomaticFuelPlugin.context.config("Eternal Fuel Smelters", "Smelter Keep Fueled", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_smelter_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_smelters"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_smelter_name")
				}
			}));
			fe_blastfurnace = AutomaticFuelPlugin.context.config("Eternal Fuel Smelters", "BlastFurnace Keep Fueled", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_blastfurnace_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_smelters"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_blastfurnace_name")
				}
			}));
			fe_eitrrefinery = AutomaticFuelPlugin.context.config("Eternal Fuel Smelters", "EitrRefinery Keep Fueled", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_eitrrefinery_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_smelters"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_eitrrefinery_name")
				}
			}));
			fe_custom_instance = AutomaticFuelPlugin.context.config("Custom", "Eternal Fuel Custom", "", new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_custom_instance_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_custom"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_custom_instance_name")
				}
			}));
			isOn = AutomaticFuelPlugin.context.config("Base Settings", "IsOn", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_isOn_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_base_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_isOn_name")
				}
			}));
			fe_piece_walltorch_timer = AutomaticFuelPlugin.context.config("Timed Torches", "Wall Torch on Timer", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_walltorch_timer_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timed_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_walltorch_timer_name")
				}
			}));
			fe_piece_groundtorch_timer = AutomaticFuelPlugin.context.config("Timed Torches", "Iron Torch On Timer", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_timer_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timed_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_timer_name")
				}
			}));
			fe_piece_groundtorch_wood_timer = AutomaticFuelPlugin.context.config("Timed Torches", "Wood Torch on Timer", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_wood_timer_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timed_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_wood_timer_name")
				}
			}));
			fe_piece_groundtorch_green_timer = AutomaticFuelPlugin.context.config("Timed Torches", "Green Torch on Timer", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_green_timer_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timed_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_green_timer_name")
				}
			}));
			fe_piece_groundtorch_blue_timer = AutomaticFuelPlugin.context.config("Timed Torches", "Blue Torch on Timer", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_blue_timer_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timed_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_groundtorch_blue_timer_name")
				}
			}));
			fe_piece_brazierfloor01_timer = AutomaticFuelPlugin.context.config("Timed Torches", "Standing Brazier on Timer", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierfloor01_timer_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timed_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierfloor01_timer_name")
				}
			}));
			fe_piece_brazierceiling01_timer = AutomaticFuelPlugin.context.config("Timed Torches", "Ceiling Brazier on Timer", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierceiling01_timer_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timed_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierceiling01_timer_name")
				}
			}));
			fe_piece_jackoturnip_timer = AutomaticFuelPlugin.context.config("Timed Torches", "Jackoturnip on Timer", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_jackoturnip_timer_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timed_torches"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_jackoturnip_timer_name")
				}
			}));
			fe_custom_instance_timer = AutomaticFuelPlugin.context.config("Custom", "Custom Items on Timers", "", new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_custom_instance_timer_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_custom"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_custom_instance_timer_name")
				}
			}));
			keepOnInRain = AutomaticFuelPlugin.context.config("Base Settings", "Keep on when wet", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_keepOnInRain_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_base_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_keepOnInRain_name")
				}
			}));
			timerOnHours = AutomaticFuelPlugin.context.config("Timer Settings", "Timer On Hours (Night Time)", 17, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_timerOnHours_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 24), new object[2]
			{
				null,
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timer_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_timerOnHours_name"),
					Order = 12
				}
			}));
			timerOnMinutes = AutomaticFuelPlugin.context.config("Timer Settings", "Timer On Mins (Night Time)", 0, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_timerOnMinutes_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 60), new object[2]
			{
				null,
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timer_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_timerOnMinutes_name"),
					Order = 11
				}
			}));
			timerOffHours = AutomaticFuelPlugin.context.config("Timer Settings", "Timer Off Hours (Day Time)", 5, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_timerOffHours_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 24), new object[2]
			{
				null,
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timer_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_timerOffHours_name"),
					Order = 10
				}
			}));
			timerOffMinutes = AutomaticFuelPlugin.context.config("Timer Settings", "Timer Off Mins (Day Time)", 30, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_timerOffMinutes_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 60), new object[2]
			{
				null,
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_timer_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_timerOffMinutes_name"),
					Order = 9
				}
			}));
			fe_fire_pit_smoke = AutomaticFuelPlugin.context.config("Smoke Settings", "Camp Fire Enable Smoke", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_fire_pit_smoke_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smoke_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_fire_pit_smoke_name")
				}
			}));
			fe_hearth_smoke = AutomaticFuelPlugin.context.config("Smoke Settings", "Hearth Enable Smoke", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_hearth_smoke_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smoke_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_hearth_smoke_name")
				}
			}));
			fe_piece_brazierfloor01_smoke = AutomaticFuelPlugin.context.config("Smoke Settings", "Standing Brazier Enable Smoke", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierfloor01_smoke_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smoke_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierfloor01_smoke_name")
				}
			}));
			fe_piece_brazierceiling01_smoke = AutomaticFuelPlugin.context.config("Smoke Settings", "Ceiling Brazier Enable Smoke", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierceiling01_smoke_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smoke_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_brazierceiling01_smoke_name")
				}
			}));
			fe_smelter_smoke = AutomaticFuelPlugin.context.config("Smoke Settings", "Smelter Enable Smoke", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_smelter_smoke_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smoke_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_smelter_smoke_name")
				}
			}));
			fe_oven = AutomaticFuelPlugin.context.config("Smoke Settings", "Oven Enable Smoke", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_oven_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smoke_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_oven_name")
				}
			}));
			fe_bonfire_smoke = AutomaticFuelPlugin.context.config("Smoke Settings", "Bonfire Enable Smoke", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_bonfire_smoke_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smoke_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_bonfire_smoke_name")
				}
			}));
			configAlwaysOnInDarkBiomes = AutomaticFuelPlugin.context.config("Base Settings", "Always On In Dark Biomes", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_configAlwaysOnInDarkBiomes_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_base_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_configAlwaysOnInDarkBiomes_name")
				}
			}));
			stationToggleKey = ((BaseUnityPlugin)AutomaticFuelPlugin.context).Config.Bind<KeyCode>("Base Settings", "StationToggleKey", (KeyCode)98, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_stationToggleKey_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_base_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_stationToggleKey_name")
				}
			}));
			configBlastFurnaceTakesAll = AutomaticFuelPlugin.context.config("Smelters", "BlastFurnaceTakesAll", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_configBlastFurnaceTakesAll_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelters"),
					DispName = TastyUtils.Loc("$autofuel_cfg_configBlastFurnaceTakesAll_name")
				}
			}));
			nofloorpickup = AutomaticFuelPlugin.context.config("Base Settings", "Use Dropped Items for Fuel", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_nofloorpickup_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_base_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_nofloorpickup_name")
				}
			}));
			configStackSmelters = AutomaticFuelPlugin.context.config("Smelters", "AllowStackSmelters", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_configStackSmelters_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelters"),
					DispName = TastyUtils.Loc("$autofuel_cfg_configStackSmelters_name")
				}
			}));
			turnOffKiln = AutomaticFuelPlugin.context.config("Smelters", "Turn Off Kiln", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_turnOffKiln_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelters"),
					DispName = TastyUtils.Loc("$autofuel_cfg_turnOffKiln_name")
				}
			}));
			turnOffWindmills = AutomaticFuelPlugin.context.config("Misc Settings", "Turn Off Windmills", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_turnOffWindmills_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_misc_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_turnOffWindmills_name")
				}
			}));
			turnOffSpinningWheel = AutomaticFuelPlugin.context.config("Misc Settings", "Turn Off SpinningWheel", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_turnOffSpinningWheel_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_misc_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_turnOffSpinningWheel_name")
				}
			}));
			dropRange = AutomaticFuelPlugin.context.config("Base Settings", "DropRange", 15f, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_dropRange_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[2]
			{
				null,
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_base_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_dropRange_name")
				}
			}));
			fireplaceRange = AutomaticFuelPlugin.context.config("Misc Settings", "FireplaceRange", 25f, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fireplaceRange_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[2]
			{
				null,
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_misc_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fireplaceRange_name")
				}
			}));
			smelterOreRange = AutomaticFuelPlugin.context.config("Smelter Settings", "SmelterOreRange", 25f, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_smelterOreRange_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[2]
			{
				null,
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelter_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_smelterOreRange_name")
				}
			}));
			smelterFuelRange = AutomaticFuelPlugin.context.config("Smelter Settings", "SmelterFuelRange", 25f, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_smelterFuelRange_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[2]
			{
				null,
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelter_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_smelterFuelRange_name")
				}
			}));
			restrictKilnOutputAmount = AutomaticFuelPlugin.context.config("Smelter Settings", "RestrictKilnOutputAmount", 50, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_restrictKilnOutputAmount_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), new object[2]
			{
				null,
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelter_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_restrictKilnOutputAmount_name")
				}
			}));
			restrictKilnOutput = AutomaticFuelPlugin.context.config("Smelter Settings", "RestrictKilnOutput", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_restrictKilnOutput_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelter_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_restrictKilnOutput_name")
				}
			}));
			windMillFast = AutomaticFuelPlugin.context.config("Misc Settings", "Faster Windmill", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_windMillFast_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_misc_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_windMillFast_name")
				}
			}));
			fuelDisallowTypes = AutomaticFuelPlugin.context.config("Smelter Settings", "FuelDisallowTypes", "RoundLog,FineWood", new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fuelDisallowTypes_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelter_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fuelDisallowTypes_name")
				}
			}));
			oreDisallowTypes = AutomaticFuelPlugin.context.config("Smelter Settings", "OreDisallowTypes", "RoundLog,FineWood", new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_oreDisallowTypes_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelter_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_oreDisallowTypes_name")
				}
			}));
			distributedFilling = AutomaticFuelPlugin.context.config("Smelter Settings", "DistributedFueling", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_distributedFilling_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelter_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_distributedFilling_name")
				}
			}));
			leaveLastItem = AutomaticFuelPlugin.context.config("Smelter Settings", "LeaveLastItem", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_leaveLastItem_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelter_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_leaveLastItem_name")
				}
			}));
			onoffToggle = ((BaseUnityPlugin)AutomaticFuelPlugin.context).Config.Bind<KeyCode>("Base Settings", "Mod ToggleKey", (KeyCode)291, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_onoffToggle_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_base_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_onoffToggle_name")
				}
			}));
			autoPopCookedFood = AutomaticFuelPlugin.context.config("Smelters", "AutoPopCookedFood", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_autoPopCookedFood_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_smelters"),
					DispName = TastyUtils.Loc("$autofuel_cfg_autoPopCookedFood_name")
				}
			}));
			keepTall = AutomaticFuelPlugin.context.config("Base Settings", "KeepTallSize", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_keepTall_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_base_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_keepTall_name")
				}
			}));
			fe_piece_candle = AutomaticFuelPlugin.context.config("Eternal Fuel Misc", "Candle Keep Lit", value: true, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_candle_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_misc"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_candle_name")
				}
			}));
			fe_piece_shieldGenerator = AutomaticFuelPlugin.context.config("Eternal Fuel Misc", "Shield Generator Keep Lit", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_fe_piece_shieldGenerator_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_eternal_fuel_misc"),
					DispName = TastyUtils.Loc("$autofuel_cfg_fe_piece_shieldGenerator_name")
				}
			}));
			turnOffHud = AutomaticFuelPlugin.context.config("Base Settings", "Turn off Hud", value: false, new ConfigDescription(TastyUtils.Loc("$autofuel_cfg_turn_off_hud_desc"), (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = TastyUtils.Loc("$autofuel_section_base_settings"),
					DispName = TastyUtils.Loc("$autofuel_cfg_turn_off_hud_name")
				}
			}));
			AuditConfigBindings();
		}

		internal static void AuditConfigBindings()
		{
			try
			{
				AuditConfigBindingsCore();
			}
			catch (Exception ex)
			{
				AutomaticFuelPlugin.AutomaticFuelLogger.LogWarning((object)("[AutomaticFuel] Config audit itself failed and was ignored: " + ex));
			}
		}

		private static void AuditConfigBindingsCore()
		{
			List<string> list = new List<string>();
			Type[] array = new Type[2]
			{
				typeof(Configs),
				typeof(AutomaticFuelPlugin)
			};
			foreach (Type type in array)
			{
				FieldInfo[] fields;
				try
				{
					fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				}
				catch (Exception)
				{
					continue;
				}
				FieldInfo[] array2 = fields;
				foreach (FieldInfo fieldInfo in array2)
				{
					Type fieldType = fieldInfo.FieldType;
					if (!fieldType.IsGenericType || fieldType.GetGenericTypeDefinition() != typeof(ConfigEntry<>))
					{
						continue;
					}
					try
					{
						if (fieldInfo.GetValue(null) == null)
						{
							list.Add(type.Name + "." + fieldInfo.Name);
						}
					}
					catch (Exception)
					{
					}
				}
			}
			if (list.Count == 0)
			{
				AutomaticFuelPlugin.AutomaticFuelLogger.LogInfo((object)"[AutomaticFuel] Config audit: every ConfigEntry field is bound.");
			}
			else
			{
				AutomaticFuelPlugin.AutomaticFuelLogger.LogError((object)($"[AutomaticFuel] Config audit: {list.Count} ConfigEntry field(s) were never bound and are NULL -> " + string.Join(", ", list) + ". Any patch that reads .Value on one of these throws NullReferenceException. Each needs a config(...) / Config.Bind(...) call next to its declaration. (Entries listed here that are never read anywhere are harmless dead declarations.)"));
			}
		}

		public static bool SupportsTimer(string instanceName)
		{
			if (ConfigCheckTimerOne(instanceName))
			{
				return true;
			}
			return false;
		}

		public static int ModeCount(string instanceName)
		{
			if (!SupportsTimer(instanceName))
			{
				return 2;
			}
			return 3;
		}

		public static int DefaultTorchMode(string instanceName)
		{
			if (!SupportsTimer(instanceName))
			{
				return 1;
			}
			return 2;
		}

		public static string TorchModeLabel(int mode, string instanceName)
		{
			if (!SupportsTimer(instanceName))
			{
				if (mode != 0)
				{
					return TastyUtils.Loc("$autofuel_mode_on");
				}
				return TastyUtils.Loc("$autofuel_mode_off");
			}
			return mode switch
			{
				1 => TastyUtils.Loc("$autofuel_mode_on"), 
				0 => TastyUtils.Loc("$autofuel_mode_off"), 
				_ => TastyUtils.Loc("$autofuel_mode_timer"), 
			};
		}

		public static string StationStateLabel(bool on)
		{
			if (!on)
			{
				return TastyUtils.Loc("$autofuel_mode_off");
			}
			return TastyUtils.Loc("$autofuel_mode_on");
		}

		public static bool ConfigCheck(string instanceName)
		{
			bool result = false;
			switch (instanceName)
			{
			case "fire_pit(Clone)":
				result = fe_fire_pit.Value;
				break;
			case "fire_pit_iron(Clone)":
				result = fe_fire_pit.Value;
				break;
			case "bonfire(Clone)":
				result = fe_bonfire.Value;
				break;
			case "hearth(Clone)":
				result = fe_hearth.Value;
				break;
			case "piece_walltorch(Clone)":
				result = fe_piece_walltorch.Value;
				break;
			case "piece_groundtorch(Clone)":
				result = fe_piece_groundtorch.Value;
				break;
			case "piece_groundtorch_wood(Clone)":
				result = fe_piece_groundtorch_wood.Value;
				break;
			case "piece_groundtorch_green(Clone)":
				result = fe_piece_groundtorch_green.Value;
				break;
			case "piece_groundtorch_blue(Clone)":
				result = fe_piece_groundtorch_blue.Value;
				break;
			case "piece_brazierfloor01(Clone)":
				result = fe_piece_brazierfloor01.Value;
				break;
			case "piece_brazierfloor02(Clone)":
				result = fe_piece_brazierfloor01.Value;
				break;
			case "piece_brazierceiling01(Clone)":
				result = fe_piece_brazierceiling01.Value;
				break;
			case "piece_jackoturnip(Clone)":
				result = fe_piece_jackoturnip.Value;
				break;
			case "piece_oven(Clone)":
				result = fe_piece_oven.Value;
				break;
			case "smelter(Clone)":
				result = fe_smelter.Value;
				break;
			case "blastfurnace(Clone)":
				result = fe_blastfurnace.Value;
				break;
			case "eitrrefinery(Clone)":
				result = fe_eitrrefinery.Value;
				break;
			case "piece_bathtub(Clone)":
				result = fe_piece_bathtub.Value;
				break;
			case "Candle_resin(Clone)":
				result = fe_piece_candle.Value;
				break;
			case "piece_shieldgenerator(Clone)":
				result = fe_piece_shieldGenerator.Value;
				break;
			}
			if (fe_custom_instance.Value.Split(new char[1] { ',' }).Contains(instanceName.Remove(instanceName.Length - 7)))
			{
				result = true;
			}
			return result;
		}

		public static bool ConfigCheckTimerOne(string instanceName)
		{
			bool result = false;
			switch (instanceName)
			{
			case "piece_walltorch(Clone)":
				result = fe_piece_walltorch_timer.Value;
				break;
			case "piece_groundtorch(Clone)":
				result = fe_piece_groundtorch_timer.Value;
				break;
			case "piece_groundtorch_wood(Clone)":
				result = fe_piece_groundtorch_wood_timer.Value;
				break;
			case "piece_groundtorch_green(Clone)":
				result = fe_piece_groundtorch_green_timer.Value;
				break;
			case "piece_groundtorch_blue(Clone)":
				result = fe_piece_groundtorch_blue_timer.Value;
				break;
			case "piece_brazierfloor01(Clone)":
				result = fe_piece_brazierfloor01_timer.Value;
				break;
			case "piece_brazierceiling01(Clone)":
				result = fe_piece_brazierceiling01_timer.Value;
				break;
			case "piece_brazierceiling02(Clone)":
				result = fe_piece_brazierceiling01_timer.Value;
				break;
			case "piece_jackoturnip(Clone)":
				result = fe_piece_jackoturnip_timer.Value;
				break;
			}
			if (fe_custom_instance_timer.Value.Split(new char[1] { ',' }).Contains(instanceName.Remove(instanceName.Length - 7)))
			{
				result = true;
			}
			return result;
		}

		public static bool ConfigCheckGiveMeSmoke(string instanceName)
		{
			bool result = false;
			switch (instanceName)
			{
			case "fire_pit(Clone)":
				result = fe_fire_pit_smoke.Value;
				break;
			case "fire_pit_iron(Clone)":
				result = fe_fire_pit_smoke.Value;
				break;
			case "hearth(Clone)":
				result = fe_hearth_smoke.Value;
				break;
			case "piece_brazierfloor01(Clone)":
				result = fe_piece_brazierfloor01_smoke.Value;
				break;
			case "piece_brazierfloor02(Clone)":
				result = fe_piece_brazierfloor01_smoke.Value;
				break;
			case "piece_brazierceiling01(Clone)":
				result = fe_piece_brazierceiling01_smoke.Value;
				break;
			case "smelter(Clone)":
				result = fe_smelter_smoke.Value;
				break;
			case "piece_oven(Clone)":
				result = fe_oven.Value;
				break;
			case "bonfire(Clone)":
				result = fe_bonfire_smoke.Value;
				break;
			}
			return result;
		}

		public static bool IsKnownItem(string instanceName)
		{
			string text = NormalizePrefabName(instanceName);
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			switch (text)
			{
			case "piece_groundtorch":
			case "piece_jackoturnip":
			case "piece_groundtorch_blue":
			case "piece_brazierceiling01":
			case "piece_groundtorch_wood":
			case "piece_brazierfloor01":
			case "piece_brazierfloor02":
			case "piece_walltorch":
			case "piece_groundtorch_green":
				return true;
			default:
			{
				string text2 = ((fe_custom_instance_timer != null) ? fe_custom_instance_timer.Value : null);
				if (!string.IsNullOrEmpty(text2))
				{
					string[] array = text2.Split(new char[1] { ',' });
					for (int i = 0; i < array.Length; i++)
					{
						if (string.Equals(NormalizePrefabName(array[i]), text, StringComparison.OrdinalIgnoreCase))
						{
							return true;
						}
					}
				}
				return false;
			}
			}
		}

		private static string NormalizePrefabName(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			name = name.Trim();
			int num = name.IndexOf("(Clone)", StringComparison.OrdinalIgnoreCase);
			if (num >= 0)
			{
				name = name.Substring(0, num);
			}
			name = name.Trim();
			if (name.Length != 0)
			{
				return name;
			}
			return null;
		}

		public static int GetTorchMode(ZNetView nv)
		{
			if ((Object)(object)nv == (Object)null || !nv.IsValid() || nv.GetZDO() == null)
			{
				return 1;
			}
			string name = ((Object)((Component)nv).gameObject).name;
			int num = nv.GetZDO().GetInt("TT_toggleOn", DefaultTorchMode(name));
			if (!SupportsTimer(name) && num > 1)
			{
				num = 1;
			}
			return num;
		}

		public static void SetTorchMode(ZNetView nv, int mode)
		{
			if (!((Object)(object)nv == (Object)null) && nv.IsValid() && nv.GetZDO() != null)
			{
				nv.GetZDO().Set("TT_toggleOn", mode);
			}
		}

		public static int CycleTorchMode(ZNetView nv)
		{
			if ((Object)(object)nv == (Object)null || !nv.IsValid() || nv.GetZDO() == null)
			{
				return 1;
			}
			string name = ((Object)((Component)nv).gameObject).name;
			int num = (GetTorchMode(nv) + 1) % ModeCount(name);
			SetTorchMode(nv, num);
			return num;
		}
	}
	internal class CookingStationPatch
	{
		[HarmonyPatch(typeof(CookingStation), "UpdateVisual")]
		private class CookingStationSmoke_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Postfix(CookingStation __instance, ref bool fireLit)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)__instance).name.Contains("piece_FrostFoundry"))
				{
					return;
				}
				string text = default(string);
				float num = default(float);
				Status val = default(Status);
				bool flag = default(bool);
				for (int i = 0; i < __instance.m_slots.Length; i++)
				{
					__instance.GetSlot(i, ref text, ref num, ref val, ref flag);
					__instance.SetSlotVisual(i, text, fireLit, val);
				}
				((Component)__instance).GetComponent<ZNetView>();
				if (!Configs.fe_piece_oven.Value)
				{
					return;
				}
				bool active = __instance.GetFuel() > 0f;
				if (Object.op_Implicit((Object)(object)__instance.m_haveFireObject))
				{
					__instance.m_haveFireObject.SetActive(fireLit);
				}
				if (Object.op_Implicit((Object)(object)__instance.m_haveFuelObject))
				{
					__instance.m_haveFuelObject.SetActive(active);
				}
				if (((Object)__instance).name.Contains("piece_oven(Clone)"))
				{
					if (!Configs.fe_oven.Value)
					{
						((Behaviour)((Component)Utils.FindChild(((Component)__instance).transform, "SmokeSpawner", (IterativeSearchType)0)).gameObject.GetComponent<SmokeSpawner>()).enabled = false;
					}
					else
					{
						((Behaviour)((Component)Utils.FindChild(((Component)__instance).transform, "SmokeSpawner", (IterativeSearchType)0)).gameObject.GetComponent<SmokeSpawner>()).enabled = true;
					}
				}
			}
		}

		[HarmonyPatch]
		internal class CookingStation_SetFuel_Patch
		{
			[HarmonyPatch(typeof(CookingStation))]
			[HarmonyPatch("SetFuel")]
			[HarmonyPrefix]
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void CookingStation_SetFuel(CookingStation __instance, ref float fuel)
			{
				if (!((Object)__instance).name.Contains("piece_FrostFoundry") && Configs.fe_piece_oven.Value && Configs.fe_piece_oven.Value)
				{
					fuel = __instance.m_maxFuel;
				}
			}
		}

		[HarmonyPatch]
		internal class CookingStation_Awake_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			[HarmonyPatch(typeof(CookingStation))]
			private static void CookingStation_Awake(CookingStation __instance, ref ZNetView ___m_nview)
			{
				if (((Behaviour)___m_nview).isActiveAndEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Character)Player.m_localPlayer).IsTeleporting() && !((Object)__instance).name.Contains("piece_FrostFoundry") && Configs.fe_piece_oven.Value)
				{
					ZDO zDO = ___m_nview.GetZDO();
					if (zDO != null && Configs.fe_piece_oven.Value)
					{
						zDO.Set("fuel", __instance.m_maxFuel);
					}
				}
			}
		}

		[HarmonyPatch(typeof(CookingStation), "Update")]
		internal static class CookingStation_Refuel_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Postfix(CookingStation __instance)
			{
				if (!((Object)(object)__instance == (Object)null) && !((Object)__instance).name.Contains("piece_FrostFoundry") && Configs.fe_piece_oven.Value && AutomaticFuelPlugin._configEnabled.Value && Configs.isOn.Value)
				{
					ZNetView nview = __instance.m_nview;
					if (!((Object)(object)nview == (Object)null) && nview.IsValid() && nview.IsOwner() && __instance.GetFuel() < (float)__instance.m_maxFuel)
					{
						__instance.SetFuel((float)__instance.m_maxFuel);
					}
				}
			}
		}

		[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(0)]
		[HarmonyPatch(typeof(CookingStation), "UpdateCooking")]
		[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
		internal class CookingStation_AutoPopDoneFood_Patch
		{
			private static void Postfix(CookingStation __instance)
			{
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)__instance).name.Contains("piece_FrostFoundry") || !Configs.autoPopCookedFood.Value || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)__instance == (Object)null || (Object)(object)__instance.m_nview == (Object)null || !__instance.m_nview.IsOwner() || !__instance.m_nview.IsValid() || !Configs.isOn.Value)
				{
					return;
				}
				try
				{
					for (int i = 0; i < __instance.m_slots.Length; i++)
					{
						if (!HasDoneItem(__instance))
						{
							break;
						}
						__instance.RPC_RemoveDoneItem(0L, ((Component)__instance).transform.position, 1);
					}
				}
				catch (Exception)
				{
				}
			}

			private static bool HasDoneItem(CookingStation station)
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Invalid comparison between Unknown and I4
				string text = default(string);
				float num = default(float);
				Status val = default(Status);
				bool flag = default(bool);
				for (int i = 0; i < station.m_slots.Length; i++)
				{
					station.GetSlot(i, ref text, ref num, ref val, ref flag);
					if (text != "" && (int)val == 1)
					{
						return true;
					}
				}
				return false;
			}
		}
	}
	internal class Interface_Patch
	{
		[HarmonyPatch(typeof(Fireplace), "GetHoverText")]
		private class Fireplace_GetHoverText_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Postfix(Fireplace __instance, ref string __result, ref string ___m_name)
			{
				if (!((Object)(object)__instance == (Object)null) && !Configs.turnOffHud.Value)
				{
					ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
					if (!((Object)(object)component == (Object)null) && component.IsValid())
					{
						string newValue = Configs.TorchModeLabel(Configs.GetTorchMode(component), ((Object)__instance).name);
						__result = __result + "\n" + TastyUtils.Loc("$autofuel_hover_mode").Replace("{mode}", newValue);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Smelter), "OnHoverAddOre")]
		private static class Smelter_GetHoverText_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Postfix(Smelter __instance, ref string __result)
			{
				if (!Configs.turnOffHud.Value && !((Object)(object)__instance == (Object)null) && !string.IsNullOrEmpty(__result) && AutomaticFuelPlugin._configEnabled.Value && Configs.isOn.Value)
				{
					ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
					if (!((Object)(object)component == (Object)null) && component.IsValid())
					{
						string newValue = Configs.StationStateLabel(TastyUtils.IsStationOn(component));
						__result = __result + "\n" + TastyUtils.Loc("$autofuel_hover_state").Replace("{state}", newValue);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Smelter), "OnHoverAddFuel")]
		private static class Smelter_GetHoverTextFuel_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Postfix(Smelter __instance, ref string __result)
			{
				if (!Configs.turnOffHud.Value && !((Object)(object)__instance == (Object)null) && !string.IsNullOrEmpty(__result) && AutomaticFuelPlugin._configEnabled.Value && Configs.isOn.Value)
				{
					ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
					if (!((Object)(object)component == (Object)null) && component.IsValid())
					{
						string newValue = Configs.StationStateLabel(TastyUtils.IsStationOn(component));
						__result = __result + "\n" + TastyUtils.Loc("$autofuel_hover_state").Replace("{state}", newValue);
					}
				}
			}
		}

		[HarmonyPatch(typeof(ZNetView), "Awake")]
		private static class ZNetView_Awake_RpcPatch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Postfix(ZNetView __instance)
			{
				TastyUtils.RegisterToggleRpcs(__instance);
			}
		}
	}
	internal class KeepFueledPatch
	{
		[HarmonyPatch]
		internal class CookingStation_SetFuel_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			[HarmonyPatch(typeof(CookingStation))]
			[HarmonyPrefix]
			[HarmonyPatch("SetFuel")]
			private static void CookingStation_SetFuel(CookingStation __instance, ref float fuel)
			{
				if (Configs.ConfigCheck(((Object)__instance).name))
				{
					fuel = __instance.m_maxFuel;
				}
			}
		}

		[HarmonyPatch]
		internal class Smelter_SetFuel_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			[HarmonyPatch(typeof(Smelter))]
			[HarmonyPatch("SetFuel")]
			[HarmonyPrefix]
			private static void Smelter_SetFuel(Smelter __instance, ref float fuel)
			{
				if (Configs.ConfigCheck(((Object)__instance).name))
				{
					fuel = __instance.m_maxFuel;
				}
			}
		}

		[HarmonyPatch]
		internal class CookingStation_Awake_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			[HarmonyPatch(typeof(CookingStation))]
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void CookingStation_Awake(CookingStation __instance, ref ZNetView ___m_nview)
			{
				if (((Behaviour)___m_nview).isActiveAndEnabled && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Character)Player.m_localPlayer).IsTeleporting() && Configs.ConfigCheck(((Object)__instance).name))
				{
					Refuel(___m_nview);
				}
			}
		}

		[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
		public static async void Refuel(ZNetView znview)
		{
			await Task.Delay(33);
			znview.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
		}
	}
	internal class NoSmokePatch
	{
		[HarmonyPatch(typeof(Smelter), "UpdateSmoke")]
		private class SmelterUpdateSmoke_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Postfix(Smelter __instance)
			{
				if (Configs.ConfigCheckGiveMeSmoke(((Object)__instance).name))
				{
					if ((Object)(object)__instance.m_smokeSpawner != (Object)null)
					{
						((Behaviour)__instance.m_smokeSpawner).enabled = true;
					}
				}
				else if ((Object)(object)__instance.m_smokeSpawner != (Object)null)
				{
					((Behaviour)__instance.m_smokeSpawner).enabled = false;
					__instance.m_blockedSmoke = false;
				}
			}
		}
	}
	internal class Sgenerator_Patches
	{
		[HarmonyPatch(typeof(ShieldGenerator), "UpdateShield")]
		private static class ShieldGenerator_ShieldUpdate_Patch
		{
			[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
			private static void Postfix(ShieldGenerator __instance, ZNetView ___m_nview)
			{
				if ((double)(Time.time - Configs.lastFuel) < 0.1)
				{
					Configs.fuelCount++;
					_ = Configs.fuelCount;
					RefuelGen(__instance, ___m_nview, 0);
				}
				else
				{
					Configs.fuelCount = 0;
					Configs.lastFuel = Time.time;
					RefuelGen(__instance, ___m_nview, 0);
				}
			}
		}

		[<94a23f46-4f69-4cc6-b31e-18e5c60139c5>Nullable(1)]
		private static readonly HashSet<string> _loggedRefuelErrors = new HashSet<string>();

		[<27b56a91-2c30-4165-a371-7110d2d11446>NullableContext(1)]
		public static async void RefuelGen(ShieldGenerator __instance, ZNetView znview, int delay)
		{
			try
			{
				await Task.Delay(delay);
				if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)znview) || !znview.IsValid())
				{
					return;
				}
				float num = znview.GetZDO().GetFloat("fuel", -1f);
				int num2 = (int)((float)__instance.m_maxFuel - Mathf.Ceil(num));
				if (Configs.ConfigCheck(((Object)__instance).name))
				{
					__instance.SetFuel((float)__instance.m_maxFuel);
				}
				else
				{
					if (num < 0f)
					{
						return;
					}
					List<Container> nearbyContainers = TastyUtils.GetNearbyContainers(((Component)__instance).transform.position, Configs.smelterFuelRange.Value);
					if (Configs.nofloorpickup.Value)
					{
						Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position + Vector3.up, Configs.dropRange.Value, LayerMask.GetMask(new string[1] { "item" }));
						foreach (Collider val in array)
						{
							if (!Object.op_Implicit((Object)(object)((val != null) ? val.attachedRigidbody : null)))
							{
								continue;
							}
							ItemDrop component = ((Component)val.attachedRigidbody).GetComponent<ItemDrop>();
							int num3;
							if (component == null)
							{
								num3 = 1;
							}
							else
							{
								ZNetView component2 = ((Component)component).GetComponent<ZNetView>();
								num3 = ((((component2 != null) ? new bool?(component2.IsValid()) : ((bool?)null)) != true) ? 1 : 0);
							}
							if (num3 != 0)
							{
								continue;
							}
							string prefabName = TastyUtils.GetPrefabName(((Object)((Component)component).gameObject).name);
							foreach (ItemDrop fuelItem in __instance.m_fuelItems)
							{
								if (!(component.m_itemData.m_shared.m_name == fuelItem.m_itemData.m_shared.m_name) || num2 <= 0 || Configs.fuelDisallowTypes.Value.Split(new char[1] { ',' }).Contains(prefabName))
								{
									continue;
								}
								AutomaticFuelPlugin.Dbgl("auto adding fuel " + prefabName + " from ground");
								if (!TastyUtils.ClaimDroppedItem(component))
								{
									continue;
								}
								int num4 = Mathf.Min(component.m_itemData.m_stack, num2);
								num2 -= num4;
								for (int j = 0; j < num4; j++)
								{
									znview.InvokeRPC("RPC_AddFuel", new object[0]);
									component.RemoveOne();
									if (Configs.distributedFilling.Value)
									{
										return;
									}
								}
							}
						}
					}
					{
						foreach (Container item2 in nearbyContainers)
						{
							foreach (ItemDrop fuelItem2 in __instance.m_fuelItems)
							{
								if (!Object.op_Implicit((Object)(object)fuelItem2) || num2 <= 0)
								{
									continue;
								}
								List<ItemData> list = new List<ItemData>();
								item2.GetInventory().GetAllItems(fuelItem2.m_itemData.m_shared.m_name, list);
								foreach (ItemData item3 in list)
								{
									if (item3 != null && (!Configs.leaveLastItem.Value || item3.m_stack > 1) && !((Object)(object)item3.m_dropPrefab == (Object)null) && !Configs.fuelDisallowTypes.Value.Split(new char[1] { ',' }).Contains(((Object)item3.m_dropPrefab).name))
									{
										num2--;
										AutomaticFuelPlugin.Dbgl($"container at {((Component)item2).transform.position} has {item3.m_stack} {((Object)item3.m_dropPrefab).name}, taking one");
										znview.InvokeRPC("RPC_AddFuel", new object[0]);
										TastyUtils.T