Decompiled source of Eternal Fire v1.1.10

plugins/Digitalroot.Valheim.EternalFire.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Digitalroot.Modding.Framework.Common.Json;
using Digitalroot.Modding.Framework.Logging;
using Digitalroot.Modding.Framework.Utils;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Managers;
using Jotunn.Utils;
using SimpleJson;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Digitalroot.Valheim.EternalFire")]
[assembly: AssemblyDescription("Eternal Fire")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Digitalroot Technologies")]
[assembly: AssemblyProduct("Digitalroot Valheim Mods")]
[assembly: AssemblyCopyright("Copyright © Digitalroot Technologies 2021 - 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3ccc4dc1-5b17-47c1-b996-ca03b8639a61")]
[assembly: AssemblyFileVersion("1.1.10")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.10.0")]
[module: UnverifiableCode]
namespace Digitalroot.Valheim.EternalFire
{
	[BepInPlugin("digitalroot.mods.eternalfire", "Eternal Fire", "1.1.10")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin, ITraceableLogging
	{
		internal static class PluginConfigSection
		{
			internal const string General = "General";

			internal const string Advanced = "Advanced";

			internal const string Fireplaces = "Fireplaces";

			internal const string CookingStations = "CookingStations";

			internal const string Smelters = "Smelters";

			internal const string ShieldGenerators = "ShieldGenerators";

			internal const string Custom = "Custom";

			internal const string BoneAppetit = "BoneAppetit";

			internal const string IronFirePit = "IronFirePit";

			internal const string SnowLantern = "SnowLantern";

			internal const string CampFire = "CampFire";

			internal const string Sconce = "Sconce";

			internal const string StandingIronTorch = "StandingIronTorch";

			internal const string StandingWoodTorch = "StandingWoodTorch";

			internal const string StandingGreenBurningIronTorch = "StandingGreenBurningIronTorch";

			internal const string StandingBlueBurningIronTorch = "StandingBlueBurningIronTorch";

			internal const string StandingBrazier = "StandingBrazier";

			internal const string StandingBlueBrazier = "StandingBlueBrazier";

			internal const string HangingBrazier = "HangingBrazier";

			internal const string JackOTurnip = "JackOTurnip";

			internal const string HotTub = "HotTub";

			internal const string StoneOven = "StoneOven";

			internal const string BlastFurnace = "BlastFurnace";

			internal const string EitrRefinery = "EitrRefinery";

			internal const string ShieldGenerator = "ShieldGenerator";

			internal const string CustomPrefabs = "CustomPrefabs";

			internal const string SmokelessHearth = "rk_hearth";

			internal const string SmokelessHearthName = "Smokeless Hearth";

			internal const string SmokelessFirePit = "rk_campfire";

			internal const string SmokelessFirePitName = "Smokeless Campfire";

			internal const string SmokelessHangingBrazier = "rk_brazier";

			internal const string SmokelessHangingBrazierName = "Smokeless Hanging Brazier";

			internal const string BoneAppetitGuid = "com.rockerkitten.boneappetit";

			internal const string VPCGuid = "MidnightsFX.ValheimCommunityPatch";
		}

		private Harmony _harmony;

		public static readonly int CurrentFuelLevelKey = StringExtensionMethods.GetStableHashCode("digitalroot.mods.eternalfire_currentFuelLevel");

		public static readonly int IsEternalKey = StringExtensionMethods.GetStableHashCode("digitalroot.mods.eternalfire_isEternal");

		private static bool? _isVpcInstalled;

		private static ConfigEntry<bool> _configCandleResin;

		private static ConfigEntry<bool> _configSnowLantern;

		private static ConfigEntry<bool> _configSmokeLessFirePit;

		private static ConfigEntry<bool> _configSmokelessHearth;

		private static ConfigEntry<bool> _configPieceSmokelessBrazierCeiling01;

		private static ConfigEntry<bool> _configFirePit;

		private static ConfigEntry<bool> _configIronFirePit;

		private static ConfigEntry<bool> _configBonfire;

		private static ConfigEntry<bool> _configHearth;

		private static ConfigEntry<bool> _configPieceWallTorch;

		private static ConfigEntry<bool> _configPieceGroundTorch;

		private static ConfigEntry<bool> _configPieceGroundTorchWood;

		private static ConfigEntry<bool> _configPieceGroundTorchGreen;

		private static ConfigEntry<bool> _configPieceGroundTorchBlue;

		private static ConfigEntry<bool> _configPieceBrazierFloor01;

		private static ConfigEntry<bool> _configPieceBrazierFloor02;

		private static ConfigEntry<bool> _configPieceBrazierCeiling01;

		private static ConfigEntry<bool> _configPieceJackoTurnip;

		private static ConfigEntry<bool> _configPieceOven;

		private static ConfigEntry<bool> _configSmelter;

		private static ConfigEntry<bool> _configBlastFurnace;

		private static ConfigEntry<bool> _configEitrRefinery;

		private static ConfigEntry<bool> _configPieceBathtub;

		private static ConfigEntry<bool> _configPieceShieldGenerator;

		private static ConfigEntry<string> _configCustomInstance;

		private static readonly HashSet<string> UnknownPreFabs = new HashSet<string>();

		private readonly Dictionary<string, bool> _configCache = new Dictionary<string, bool>();

		private readonly HashSet<string> _customPrefabConfigCache = new HashSet<string>();

		public const string Version = "1.1.10";

		public const string Name = "Eternal Fire";

		public const string Guid = "digitalroot.mods.eternalfire";

		public const string Namespace = "Digitalroot.Valheim.EternalFire";

		public static Main Instance { get; private set; }

		public static bool IsVpcInstalled
		{
			get
			{
				bool valueOrDefault = _isVpcInstalled == true;
				if (!_isVpcInstalled.HasValue)
				{
					valueOrDefault = ValheimUtils.isModLoaded("MidnightsFX.ValheimCommunityPatch");
					_isVpcInstalled = valueOrDefault;
				}
				return _isVpcInstalled.Value;
			}
		}

		[UsedImplicitly]
		public static ConfigEntry<int> NexusId { get; private set; }

		public static ConfigEntry<string> TextColor { get; private set; }

		public static ConfigEntry<bool> DisplayDebugInfo { get; private set; }

		public string Source => "Digitalroot.Valheim.EternalFire";

		public bool EnableTrace { get; }

		public Main()
		{
			Instance = this;
			EnableTrace = false;
		}

		[UsedImplicitly]
		private void Awake()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Expected O, but got Unknown
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Expected O, but got Unknown
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Expected O, but got Unknown
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Expected O, but got Unknown
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Expected O, but got Unknown
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Expected O, but got Unknown
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Expected O, but got Unknown
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Expected O, but got Unknown
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Expected O, but got Unknown
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Expected O, but got Unknown
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Expected O, but got Unknown
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Expected O, but got Unknown
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Expected O, but got Unknown
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Expected O, but got Unknown
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Expected O, but got Unknown
			//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Expected O, but got Unknown
			//IL_060a: Unknown result type (might be due to invalid IL or missing references)
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_062f: Expected O, but got Unknown
			//IL_062f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Expected O, but got Unknown
			//IL_0673: Unknown result type (might be due to invalid IL or missing references)
			//IL_0678: Unknown result type (might be due to invalid IL or missing references)
			//IL_0684: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			//IL_0698: Expected O, but got Unknown
			//IL_0698: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Expected O, but got Unknown
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0701: Expected O, but got Unknown
			//IL_0701: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Expected O, but got Unknown
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_074a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0756: Unknown result type (might be due to invalid IL or missing references)
			//IL_0762: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Expected O, but got Unknown
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0774: Expected O, but got Unknown
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d3: Expected O, but got Unknown
			//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Expected O, but got Unknown
			//IL_0817: Unknown result type (might be due to invalid IL or missing references)
			//IL_081c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0828: Unknown result type (might be due to invalid IL or missing references)
			//IL_0834: Unknown result type (might be due to invalid IL or missing references)
			//IL_083c: Expected O, but got Unknown
			//IL_083c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0846: Expected O, but got Unknown
			//IL_0880: Unknown result type (might be due to invalid IL or missing references)
			//IL_0885: Unknown result type (might be due to invalid IL or missing references)
			//IL_0891: Unknown result type (might be due to invalid IL or missing references)
			//IL_089d: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a5: Expected O, but got Unknown
			//IL_08a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08af: Expected O, but got Unknown
			//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0906: Unknown result type (might be due to invalid IL or missing references)
			//IL_090e: Expected O, but got Unknown
			//IL_090e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0918: Expected O, but got Unknown
			//IL_0952: Unknown result type (might be due to invalid IL or missing references)
			//IL_0957: Unknown result type (might be due to invalid IL or missing references)
			//IL_0963: Unknown result type (might be due to invalid IL or missing references)
			//IL_096f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0977: Expected O, but got Unknown
			//IL_0977: Unknown result type (might be due to invalid IL or missing references)
			//IL_0981: Expected O, but got Unknown
			//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e4: Expected O, but got Unknown
			//IL_09e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ee: Expected O, but got Unknown
			//IL_0a33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a58: Expected O, but got Unknown
			//IL_0a58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a62: Expected O, but got Unknown
			//IL_0a9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac1: Expected O, but got Unknown
			//IL_0ac1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acb: Expected O, but got Unknown
			//IL_0b05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b16: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2a: Expected O, but got Unknown
			//IL_0b2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b34: Expected O, but got Unknown
			//IL_0b6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b98: Expected O, but got Unknown
			//IL_0b98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba2: Expected O, but got Unknown
			try
			{
				if (Instance.EnableTrace)
				{
					Log.Trace(Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
				}
				NexusId = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 2754, new ConfigDescription("Nexus mod ID for updates", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = false,
					ReadOnly = true
				} }));
				TextColor = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Text Color", "#FFFF0088", new ConfigDescription("#RGBA Color for Eternal Text (#RRGGBBAA)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdvanced = true
				} }));
				_configCandleResin = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "CandleResin", true, new ConfigDescription("Enable CandleResin", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configCandleResin.SettingChanged += SettingsChanged;
				_configSnowLantern = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "SnowLantern", true, new ConfigDescription("Enable Snow Lantern", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configSnowLantern.SettingChanged += SettingsChanged;
				_configFirePit = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "CampFire", true, new ConfigDescription("Enable Campfire", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configFirePit.SettingChanged += SettingsChanged;
				_configIronFirePit = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "IronFirePit", true, new ConfigDescription("Enable Iron Fire Pit", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configIronFirePit.SettingChanged += SettingsChanged;
				_configBonfire = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "Bonfire", true, new ConfigDescription("Enable Bonfire", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configBonfire.SettingChanged += SettingsChanged;
				_configPieceWallTorch = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "Sconce", true, new ConfigDescription("Enable Sconce", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceWallTorch.SettingChanged += SettingsChanged;
				_configPieceGroundTorch = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "StandingIronTorch", true, new ConfigDescription("Enable Standing Iron Torch", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceGroundTorch.SettingChanged += SettingsChanged;
				_configPieceGroundTorchWood = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "StandingWoodTorch", true, new ConfigDescription("Enable Standing Wood Torch", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceGroundTorchWood.SettingChanged += SettingsChanged;
				_configPieceGroundTorchGreen = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "StandingGreenBurningIronTorch", true, new ConfigDescription("Enable Standing Green Burning Iron Torch", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceGroundTorchGreen.SettingChanged += SettingsChanged;
				_configPieceGroundTorchBlue = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "StandingBlueBurningIronTorch", true, new ConfigDescription("Enable Standing Blue Burning Iron Torch", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceGroundTorchBlue.SettingChanged += SettingsChanged;
				_configPieceBrazierFloor01 = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "StandingBrazier", true, new ConfigDescription("Enable Standing Brazier", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceBrazierFloor01.SettingChanged += SettingsChanged;
				_configPieceBrazierFloor02 = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "StandingBlueBrazier", true, new ConfigDescription("Enable Standing Blue Brazier", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceBrazierFloor02.SettingChanged += SettingsChanged;
				_configPieceBrazierCeiling01 = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "HangingBrazier", true, new ConfigDescription("Enable Hanging Brazier", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceBrazierCeiling01.SettingChanged += SettingsChanged;
				_configPieceJackoTurnip = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "JackOTurnip", true, new ConfigDescription("Enable Jack-o-Turnip", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceJackoTurnip.SettingChanged += SettingsChanged;
				_configHearth = ((BaseUnityPlugin)this).Config.Bind<bool>("Fireplaces", "Hearth", true, new ConfigDescription("Enable Hearth", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configHearth.SettingChanged += SettingsChanged;
				_configPieceBathtub = ((BaseUnityPlugin)this).Config.Bind<bool>("Smelters", "HotTub", true, new ConfigDescription("Enable Hot Tub", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceBathtub.SettingChanged += SettingsChanged;
				_configPieceOven = ((BaseUnityPlugin)this).Config.Bind<bool>("CookingStations", "StoneOven", true, new ConfigDescription("Enable Stone Oven", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceOven.SettingChanged += SettingsChanged;
				_configSmelter = ((BaseUnityPlugin)this).Config.Bind<bool>("Smelters", "Smelter", false, new ConfigDescription("Enable Smelter", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configSmelter.SettingChanged += SettingsChanged;
				_configBlastFurnace = ((BaseUnityPlugin)this).Config.Bind<bool>("Smelters", "BlastFurnace", false, new ConfigDescription("Enable Blast Furnace", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configBlastFurnace.SettingChanged += SettingsChanged;
				_configEitrRefinery = ((BaseUnityPlugin)this).Config.Bind<bool>("Smelters", "EitrRefinery", false, new ConfigDescription("Enable Eitr Refinery", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configEitrRefinery.SettingChanged += SettingsChanged;
				_configPieceShieldGenerator = ((BaseUnityPlugin)this).Config.Bind<bool>("ShieldGenerators", "ShieldGenerator", false, new ConfigDescription("Enable Shield Generator", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceShieldGenerator.SettingChanged += SettingsChanged;
				_configCustomInstance = ((BaseUnityPlugin)this).Config.Bind<string>("Custom", "CustomPrefabs", "", new ConfigDescription("A comma-separated list of prefab names", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configCustomInstance.SettingChanged += SettingsChanged;
				bool value = ValheimUtils.isModLoaded("com.rockerkitten.boneappetit");
				_configSmokeLessFirePit = ((BaseUnityPlugin)this).Config.Bind<bool>("BoneAppetit", "SmokelessFirePit", true, new ConfigDescription("Enable Smokeless Campfire", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = value,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configSmokeLessFirePit.SettingChanged += SettingsChanged;
				_configSmokelessHearth = ((BaseUnityPlugin)this).Config.Bind<bool>("BoneAppetit", "SmokelessHearth", true, new ConfigDescription("Enable Smokeless Hearth", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = value,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configSmokelessHearth.SettingChanged += SettingsChanged;
				_configPieceSmokelessBrazierCeiling01 = ((BaseUnityPlugin)this).Config.Bind<bool>("BoneAppetit", "SmokelessHangingBrazier", true, new ConfigDescription("Enable Smokeless Hanging Brazier", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = value,
					ReadOnly = false,
					IsAdminOnly = true
				} }));
				_configPieceSmokelessBrazierCeiling01.SettingChanged += SettingsChanged;
				DisplayDebugInfo = ((BaseUnityPlugin)this).Config.Bind<bool>("Advanced", "DisplayDebugInfo", false, new ConfigDescription("Enable to display debug info on mouseover", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Browsable = true,
					ReadOnly = false,
					IsAdvanced = true
				} }));
				SynchronizationManager.OnConfigurationSynchronized += SynchronizationManager_OnConfigurationSynchronized;
				_harmony = Harmony.CreateAndPatchAll(typeof(Main).Assembly, "digitalroot.mods.eternalfire");
			}
			catch (Exception e)
			{
				Log.Error(Instance, e);
			}
		}

		[UsedImplicitly]
		private void OnDestroy()
		{
			try
			{
				if (Instance.EnableTrace)
				{
					Log.Trace(Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
				}
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
				SynchronizationManager.OnConfigurationSynchronized -= SynchronizationManager_OnConfigurationSynchronized;
			}
			catch (Exception e)
			{
				Log.Error(Instance, e);
			}
		}

		public static bool ConfigCheck(string instanceName)
		{
			if (Instance._configCache.Count == 0)
			{
				UpdateConfigCache();
				UpdateCustomPrefabConfigCache();
			}
			bool result = false;
			instanceName = instanceName.Replace("(Clone)", string.Empty);
			if (Instance._configCache.TryGetValue(instanceName, out var value))
			{
				result = value;
			}
			else if (Instance._customPrefabConfigCache.Contains(instanceName))
			{
				result = true;
			}
			else if (UnknownPreFabs.Add(instanceName) && Instance.EnableTrace)
			{
				Log.Trace(Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + "[" + instanceName + "] Unknown");
			}
			return result;
		}

		private void SettingsChanged(object sender, EventArgs e)
		{
			try
			{
				if (Instance.EnableTrace)
				{
					Log.Trace(Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
				}
				ConfigEntryBase val = (ConfigEntryBase)((sender is ConfigEntryBase) ? sender : null);
				if (val == null)
				{
					return;
				}
				switch (val.Definition.Key)
				{
				case "CampFire":
					UpdateConfigCache("fire_pit", _configFirePit.Value);
					return;
				case "IronFirePit":
					UpdateConfigCache("fire_pit_iron", _configIronFirePit.Value);
					return;
				case "Bonfire":
					UpdateConfigCache("bonfire", _configBonfire.Value);
					return;
				case "Hearth":
					UpdateConfigCache("hearth", _configHearth.Value);
					return;
				case "Sconce":
					UpdateConfigCache("piece_walltorch", _configPieceWallTorch.Value);
					return;
				case "StandingIronTorch":
					UpdateConfigCache("piece_groundtorch", _configPieceGroundTorch.Value);
					return;
				case "StandingWoodTorch":
					UpdateConfigCache("piece_groundtorch_wood", _configPieceGroundTorchWood.Value);
					return;
				case "StandingGreenBurningIronTorch":
					UpdateConfigCache("piece_groundtorch_green", _configPieceGroundTorchGreen.Value);
					return;
				case "StandingBlueBurningIronTorch":
					UpdateConfigCache("piece_groundtorch_blue", _configPieceGroundTorchBlue.Value);
					return;
				case "StandingBrazier":
					UpdateConfigCache("piece_brazierfloor01", _configPieceBrazierFloor01.Value);
					return;
				case "StandingBlueBrazier":
					UpdateConfigCache("piece_brazierfloor02", _configPieceBrazierFloor02.Value);
					return;
				case "HangingBrazier":
					UpdateConfigCache("piece_brazierceiling01", _configPieceBrazierCeiling01.Value);
					return;
				case "JackOTurnip":
					UpdateConfigCache("piece_jackoturnip", _configPieceJackoTurnip.Value);
					return;
				case "StoneOven":
					UpdateConfigCache("piece_oven", _configPieceOven.Value);
					return;
				case "Smelter":
					UpdateConfigCache("smelter", _configSmelter.Value);
					return;
				case "BlastFurnace":
					UpdateConfigCache("blastfurnace", _configBlastFurnace.Value);
					return;
				case "EitrRefinery":
					UpdateConfigCache("eitrrefinery", _configEitrRefinery.Value);
					return;
				case "HotTub":
					UpdateConfigCache("piece_bathtub", _configPieceBathtub.Value);
					return;
				case "CandleResin":
					UpdateConfigCache("Candle_resin", _configCandleResin.Value);
					return;
				case "SnowLantern":
					UpdateConfigCache("piece_snowlantern", _configSnowLantern.Value);
					return;
				case "ShieldGenerator":
					UpdateConfigCache("piece_shieldgenerator", _configPieceShieldGenerator.Value);
					return;
				case "SmokelessHearth":
					UpdateConfigCache("rk_hearth", _configSmokelessHearth.Value);
					return;
				case "SmokelessFirePit":
					UpdateConfigCache("rk_campfire", _configSmokeLessFirePit.Value);
					return;
				case "SmokelessHangingBrazier":
					UpdateConfigCache("rk_brazier", _configPieceSmokelessBrazierCeiling01.Value);
					return;
				case "CustomPrefabs":
					UpdateCustomPrefabConfigCache();
					return;
				}
				if (Instance.EnableTrace)
				{
					Log.Trace(Instance, $"Changed: [{val.Definition.Section}] {val.Definition.Key} = {val.BoxedValue}");
				}
			}
			catch (Exception e2)
			{
				Log.Error(Instance, e2);
			}
		}

		private void SynchronizationManager_OnConfigurationSynchronized(object sender, ConfigurationSynchronizationEventArgs e)
		{
			if (Instance.EnableTrace)
			{
				Log.Trace(Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
			}
			UpdateConfigCaches();
		}

		private void UpdateConfigCaches()
		{
			try
			{
				if (Instance.EnableTrace)
				{
					Log.Trace(Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
				}
				UpdateConfigCache();
				UpdateCustomPrefabConfigCache();
			}
			catch (Exception e)
			{
				Log.Error(Instance, e);
			}
		}

		private static void UpdateConfigCache()
		{
			if (Instance.EnableTrace)
			{
				Log.Trace(Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
			}
			UpdateConfigCache("fire_pit", _configFirePit.Value);
			UpdateConfigCache("fire_pit_iron", _configIronFirePit.Value);
			UpdateConfigCache("bonfire", _configBonfire.Value);
			UpdateConfigCache("hearth", _configHearth.Value);
			UpdateConfigCache("piece_walltorch", _configPieceWallTorch.Value);
			UpdateConfigCache("piece_groundtorch", _configPieceGroundTorch.Value);
			UpdateConfigCache("piece_groundtorch_wood", _configPieceGroundTorchWood.Value);
			UpdateConfigCache("piece_groundtorch_green", _configPieceGroundTorchGreen.Value);
			UpdateConfigCache("piece_groundtorch_blue", _configPieceGroundTorchBlue.Value);
			UpdateConfigCache("piece_brazierfloor01", _configPieceBrazierFloor01.Value);
			UpdateConfigCache("piece_brazierfloor02", _configPieceBrazierFloor02.Value);
			UpdateConfigCache("piece_brazierceiling01", _configPieceBrazierCeiling01.Value);
			UpdateConfigCache("piece_jackoturnip", _configPieceJackoTurnip.Value);
			UpdateConfigCache("piece_oven", _configPieceOven.Value);
			UpdateConfigCache("smelter", _configSmelter.Value);
			UpdateConfigCache("blastfurnace", _configBlastFurnace.Value);
			UpdateConfigCache("eitrrefinery", _configEitrRefinery.Value);
			UpdateConfigCache("piece_bathtub", _configPieceBathtub.Value);
			UpdateConfigCache("Candle_resin", _configCandleResin.Value);
			UpdateConfigCache("piece_snowlantern", _configSnowLantern.Value);
			UpdateConfigCache("piece_shieldgenerator", _configPieceShieldGenerator.Value);
			UpdateConfigCache("rk_hearth", _configSmokelessHearth.Value);
			UpdateConfigCache("rk_campfire", _configSmokeLessFirePit.Value);
			UpdateConfigCache("rk_brazier", _configPieceSmokelessBrazierCeiling01.Value);
		}

		private static void UpdateCustomPrefabConfigCache()
		{
			try
			{
				if (Instance.EnableTrace)
				{
					Log.Trace(Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
				}
				Instance._customPrefabConfigCache.Clear();
				if (string.IsNullOrWhiteSpace(_configCustomInstance?.Value))
				{
					return;
				}
				string[] array = _configCustomInstance.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
				for (int i = 0; i < array.Length; i++)
				{
					string text = array[i].Trim();
					if (text.Length > 0)
					{
						Instance._customPrefabConfigCache.Add(text);
						if (Instance.EnableTrace)
						{
							Log.Trace(Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [Added " + text + "]");
						}
					}
				}
			}
			catch (Exception e)
			{
				Log.Error(Instance, e);
			}
		}

		private static void UpdateConfigCache(string prefabName, bool value)
		{
			try
			{
				if (Instance.EnableTrace)
				{
					Log.Trace(Instance, string.Format("{0}.{1}.{2} [{3},{4}]", "Digitalroot.Valheim.EternalFire", MethodBase.GetCurrentMethod()?.DeclaringType?.Name, MethodBase.GetCurrentMethod()?.Name, prefabName, value));
				}
				Instance._configCache[prefabName] = value;
			}
			catch (Exception e)
			{
				Log.Error(Instance, e);
			}
		}
	}
	[UsedImplicitly]
	public class Patch
	{
		[HarmonyPatch(typeof(Fireplace))]
		public class PatchFireplace
		{
			[HarmonyPostfix]
			[HarmonyPatch(typeof(Fireplace), "Awake")]
			private static void PostfixAwake(Fireplace __instance, ZNetView ___m_nview)
			{
				try
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					if (!((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid())
					{
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_EnableEternal", (Action<long>)__instance.RPC_EnableEternal);
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_DisableEternal", (Action<long>)__instance.RPC_DisableEternal);
						if (Main.Instance.EnableTrace)
						{
							Log.Trace(Main.Instance, string.Format("{0}.{1}.{2} [Init.IsEternal: {3}]", "Digitalroot.Valheim.EternalFire", MethodBase.GetCurrentMethod()?.DeclaringType?.Name, MethodBase.GetCurrentMethod()?.Name, __instance.IsEternal()));
						}
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(Fireplace), "UpdateFireplace")]
			private static void PrefixUpdateFireplace(Fireplace __instance, ZNetView ___m_nview)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid())
					{
						return;
					}
					if (!___m_nview.HasOwner())
					{
						___m_nview.ClaimOwnership();
					}
					bool flag = (__instance.m_infiniteFuel = __instance.GetIsEternal());
					if (Main.ConfigCheck(((Object)__instance).name))
					{
						if (!flag)
						{
							if (Main.Instance.EnableTrace)
							{
								Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [InvokeRPC.RPC_EnableEternal]");
							}
							___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_EnableEternal", Array.Empty<object>());
						}
					}
					else if (flag)
					{
						if (Main.Instance.EnableTrace)
						{
							Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [InvokeRPC.RPC_DisableEternal]");
						}
						___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_DisableEternal", Array.Empty<object>());
					}
					if (__instance.IsEternal() && __instance.GetFuel() <= __instance.m_maxFuel - 1f)
					{
						if (Main.Instance.EnableTrace)
						{
							Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [Adding Fuel to " + ((Object)__instance).name + "]");
						}
						___m_nview.InvokeRPC("RPC_AddFuelAmount", new object[1] { __instance.m_maxFuel - __instance.GetFuel() });
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(Fireplace), "GetHoverText")]
			private static void PostfixGetHoverText(Fireplace __instance, ZNetView ___m_nview, ref string __result)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid())
					{
						return;
					}
					if (__instance.IsEternal() && __instance.m_infiniteFuel)
					{
						__result = __instance.m_name;
						if (((Object)__instance).name.Replace("(Clone)", string.Empty) == "Candle_resin")
						{
							__result += "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use";
						}
						else if (__instance.m_canRefill)
						{
							__result += "\n[<color=yellow><b>$KEY_HotbarUse</b></color>] $piece_useitem";
						}
						__result = __result + "\n<color=" + Main.TextColor.Value + "><b>$mod_eternal_fire_hover_text</b></color>";
						if (Main.DisplayDebugInfo.Value)
						{
							__result += $"\n( $piece_fire_fuel {Mathf.Ceil(___m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f))}/{__instance.m_maxFuel} )";
						}
						__result = Localization.instance.Localize(__result);
					}
					if (Main.DisplayDebugInfo.Value)
					{
						__result += $"\nIsEternalZdo: {__instance.GetIsEternal()}";
						__result += $"\nOriginalFuelLevelZdo: {__instance.GetOriginalFuelLevel()}";
						__result += $"\nIsVPCInstalled: {Main.IsVpcInstalled}";
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}
		}

		[HarmonyPatch(typeof(CookingStation))]
		public class PatchCookingStation
		{
			[HarmonyPostfix]
			[HarmonyPatch(typeof(CookingStation), "Awake")]
			private static void PostfixAwake(CookingStation __instance, ZNetView ___m_nview)
			{
				try
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					if (!((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid())
					{
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_EnableEternal", (Action<long>)__instance.RPC_EnableEternal);
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_DisableEternal", (Action<long>)__instance.RPC_DisableEternal);
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_SetFuelLevelMax", (Action<long>)__instance.RPC_SetFuelLevelMax);
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(CookingStation), "UpdateCooking")]
			private static void PrefixUpdateCooking(CookingStation __instance, ZNetView ___m_nview)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid() || (Object)(object)__instance.m_fuelItem == (Object)null || !__instance.m_useFuel)
					{
						return;
					}
					if (!___m_nview.HasOwner())
					{
						___m_nview.ClaimOwnership();
					}
					if (Main.ConfigCheck(((Object)__instance).name))
					{
						if (!__instance.IsEternal())
						{
							___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_EnableEternal", Array.Empty<object>());
						}
					}
					else if (__instance.IsEternal())
					{
						___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_DisableEternal", Array.Empty<object>());
					}
					if (__instance.IsEternal() && __instance.GetFuel() <= (float)__instance.m_maxFuel - 1f)
					{
						if (Main.Instance.EnableTrace)
						{
							Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [RPC_SetFuelLevelMax for " + ((Object)__instance).name + "]");
						}
						if (Main.IsVpcInstalled)
						{
							___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_SetFuelLevelMax", Array.Empty<object>());
						}
						else
						{
							___m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
						}
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(CookingStation), "OnHoverFuelSwitch")]
			private static void PostfixOnHoverFuelSwitch(CookingStation __instance, ZNetView ___m_nview, ref string __result)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid())
					{
						return;
					}
					if (__instance.IsEternal())
					{
						__result = "<color=" + Main.TextColor.Value + "><b>$mod_eternal_fire_hover_text</b></color>";
						if (Main.DisplayDebugInfo.Value)
						{
							__result += $"\n( $piece_fire_fuel {Mathf.Ceil(__instance.GetFuel())}/{__instance.m_maxFuel} )";
						}
						__result = Localization.instance.Localize(__result);
					}
					if (Main.DisplayDebugInfo.Value)
					{
						__result += $"\nIsEternalZdo: {__instance.GetIsEternal()}";
						__result += $"\nOriginalFuelLevelZdo: {__instance.GetOriginalFuelLevel()}";
						__result += $"\nIsVPCInstalled: {Main.IsVpcInstalled}";
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(CookingStation), "OnAddFuelSwitch")]
			private static bool PrefixOnAddFuelSwitch(CookingStation __instance, ZNetView ___m_nview, ref bool __result)
			{
				try
				{
					if (___m_nview.IsValid() && Main.ConfigCheck(((Object)__instance).name) && __instance.IsEternal())
					{
						__result = false;
						return false;
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(CookingStation))]
		public static class PatchCookingStation_DropAllItems_DropPatch
		{
			[UsedImplicitly]
			private static MethodBase TargetMethod()
			{
				try
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					return AccessTools.Method(typeof(CookingStation), "<DropAllItems>g__drop|1_0", (Type[])null, (Type[])null);
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
				return null;
			}

			[HarmonyPrefix]
			[UsedImplicitly]
			private static bool Prefix(CookingStation __instance, ZNetView ___m_nview, ItemDrop item, bool cheated)
			{
				try
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid())
					{
						return true;
					}
					if (__instance.IsEternal())
					{
						for (float num = __instance.m_nview.GetZDO().GetFloat(StringExtensionMethods.GetStableHashCode("digitalroot.mods.eternalfire_currentFuelLevel"), 0f); num >= 1f; num -= 1f)
						{
							CallOriginal(__instance, item, cheated);
						}
						__instance.SetOriginalFuelLevel(0f);
						return false;
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
				return true;
			}

			[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
			public static void CallOriginal(CookingStation instance, ItemDrop item, bool cheated)
			{
				throw new NotImplementedException("HarmonyReversePatch");
			}
		}

		[HarmonyPatch(typeof(Smelter))]
		public class PatchSmelter
		{
			[HarmonyPostfix]
			[HarmonyPatch(typeof(Smelter), "Awake")]
			private static void PostfixAwake(Smelter __instance, ZNetView ___m_nview)
			{
				try
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					if (!((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid())
					{
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_EnableEternal", (Action<long>)__instance.RPC_EnableEternal);
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_DisableEternal", (Action<long>)__instance.RPC_DisableEternal);
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_SetFuelLevelMax", (Action<long>)__instance.RPC_SetFuelLevelMax);
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(Smelter), "UpdateSmelter")]
			private static void PrefixUpdateSmelter(Smelter __instance, ZNetView ___m_nview)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid() || (Object)(object)__instance.m_fuelItem == (Object)null)
					{
						return;
					}
					if (!___m_nview.HasOwner())
					{
						___m_nview.ClaimOwnership();
					}
					if (Main.ConfigCheck(((Object)__instance).name))
					{
						if (!__instance.IsEternal())
						{
							___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_EnableEternal", Array.Empty<object>());
						}
					}
					else if (__instance.IsEternal())
					{
						___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_DisableEternal", Array.Empty<object>());
					}
					if (!__instance.IsEternal() || !(__instance.GetFuel() <= (float)__instance.m_maxFuel - 1f))
					{
						return;
					}
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [Adding Fuel for " + ((Object)__instance).name + "]");
						Log.Trace(Main.Instance, string.Format("{0}.{1}.{2} [__instance.GetFuel() : {3}]", "Digitalroot.Valheim.EternalFire", MethodBase.GetCurrentMethod()?.DeclaringType?.Name, MethodBase.GetCurrentMethod()?.Name, __instance.GetFuel()));
					}
					if (Main.IsVpcInstalled)
					{
						if (Main.Instance.EnableTrace)
						{
							Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [RPC_SetFuelLevelMax for " + ((Object)__instance).name + "]");
						}
						___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_SetFuelLevelMax", Array.Empty<object>());
					}
					else
					{
						if (Main.Instance.EnableTrace)
						{
							Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [RPC_AddFuel for " + ((Object)__instance).name + "]");
						}
						___m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(Smelter), "OnHoverAddFuel")]
			private static void PostfixOnHoverAddFuel(Smelter __instance, ZNetView ___m_nview, ref string __result)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid())
					{
						return;
					}
					if (__instance.IsEternal())
					{
						__result = "<color=" + Main.TextColor.Value + "><b>$mod_eternal_fire_hover_text</b></color>";
						if (Main.DisplayDebugInfo.Value)
						{
							__result += $"\n( $piece_fire_fuel {Mathf.Ceil(__instance.GetFuel())}/{__instance.m_maxFuel} )";
						}
						__result = Localization.instance.Localize(__result);
					}
					if (Main.DisplayDebugInfo.Value)
					{
						__result += $"\nIsEternalZdo: {__instance.GetIsEternal()}";
						__result += $"\nOriginalFuelLevelZdo: {__instance.GetOriginalFuelLevel()}";
						__result += $"\nIsVPCInstalled: {Main.IsVpcInstalled}";
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(Smelter), "OnAddFuel")]
			private static bool PrefixOnAddFuel(Smelter __instance, ZNetView ___m_nview, ref bool __result)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid())
					{
						return true;
					}
					if (__instance.IsEternal())
					{
						__result = false;
						return false;
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
				return true;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(Smelter), "DropAllItems")]
			private static void PrefixDropAllItems(Smelter __instance, ZNetView ___m_nview)
			{
				try
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					if (!((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid() && __instance.IsEternal())
					{
						__instance.SetFuel((__instance.GetOriginalFuelLevel() <= 1f) ? 0f : __instance.GetOriginalFuelLevel());
						__instance.SetOriginalFuelLevel(0f);
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}
		}

		[HarmonyPatch(typeof(ShieldGenerator))]
		public class PatchShieldGenerator
		{
			[HarmonyPostfix]
			[HarmonyPatch(typeof(ShieldGenerator), "Start")]
			private static void PostfixStart(ShieldGenerator __instance, ZNetView ___m_nview)
			{
				try
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					if (!((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid())
					{
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_EnableEternal", (Action<long>)__instance.RPC_EnableEternal);
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_DisableEternal", (Action<long>)__instance.RPC_DisableEternal);
						___m_nview.Register("digitalroot.mods.eternalfire_RPC_SetFuelLevelMax", (Action<long>)__instance.RPC_SetFuelLevelMax);
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(ShieldGenerator), "UpdateShield")]
			private static void PrefixUpdateShield(ShieldGenerator __instance, ZNetView ___m_nview)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid() || __instance.m_fuelItems == null || (float)__instance.m_fuelItems.Count < 1f)
					{
						return;
					}
					if (!___m_nview.HasOwner())
					{
						___m_nview.ClaimOwnership();
					}
					if (Main.ConfigCheck(((Object)__instance).name))
					{
						if (!__instance.IsEternal())
						{
							___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_EnableEternal", Array.Empty<object>());
						}
					}
					else if (__instance.IsEternal())
					{
						___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_DisableEternal", Array.Empty<object>());
					}
					if (!__instance.IsEternal() || !(__instance.GetFuel() <= (float)(__instance.m_maxFuel - 1)))
					{
						return;
					}
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [Adding Fuel for " + ((Object)__instance).name + "]");
						Log.Trace(Main.Instance, string.Format("{0}.{1}.{2} [__instance.GetFuel() : {3}]", "Digitalroot.Valheim.EternalFire", MethodBase.GetCurrentMethod()?.DeclaringType?.Name, MethodBase.GetCurrentMethod()?.Name, __instance.GetFuel()));
					}
					if (Main.IsVpcInstalled)
					{
						if (Main.Instance.EnableTrace)
						{
							Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [RPC_SetFuelLevelMax for " + ((Object)__instance).name + "]");
						}
						___m_nview.InvokeRPC("digitalroot.mods.eternalfire_RPC_SetFuelLevelMax", Array.Empty<object>());
					}
					else
					{
						if (Main.Instance.EnableTrace)
						{
							Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name + " [RPC_SetFuel for " + ((Object)__instance).name + "]");
						}
						__instance.SetFuel((float)__instance.m_maxFuel);
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(ShieldGenerator), "OnHoverAddFuel")]
			private static void PostfixOnHoverAddFuel(ShieldGenerator __instance, ZNetView ___m_nview, ref string __result)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid())
					{
						return;
					}
					if (__instance.IsEternal())
					{
						__result = __instance.m_name + "\n<color=" + Main.TextColor.Value + "><b>$mod_eternal_fire_hover_text</b></color>";
						if (Main.DisplayDebugInfo.Value)
						{
							__result += $"\n( $piece_shieldgenerator_add {Mathf.Ceil(__instance.GetFuel())}/{__instance.m_maxFuel} )";
						}
						__result = Localization.instance.Localize(__result);
					}
					if (Main.DisplayDebugInfo.Value)
					{
						__result += $"\nIsEternalZdo: {__instance.GetIsEternal()}";
						__result += $"\nOriginalFuelLevelZdo: {__instance.GetOriginalFuelLevel()}";
						__result += $"\nIsVPCInstalled: {Main.IsVpcInstalled}";
						__result += $"\nm_enableAttack: {__instance.m_enableAttack}";
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(ShieldGenerator), "OnAddFuel")]
			private static bool PrefixOnAddFuel(ShieldGenerator __instance, ZNetView ___m_nview, ref bool __result)
			{
				try
				{
					if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid())
					{
						return true;
					}
					if (__instance.IsEternal())
					{
						__result = false;
						return false;
					}
				}
				catch (Exception e)
				{
					Log.Error(Main.Instance, e);
				}
				return true;
			}
		}
	}
	[UsedImplicitly]
	public static class FireplaceExtensions
	{
		[UsedImplicitly]
		public static bool IsEternal(this Fireplace fireplace)
		{
			try
			{
				if (!fireplace.m_nview.IsValid())
				{
					return false;
				}
				return fireplace.GetIsEternal();
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return false;
		}

		[UsedImplicitly]
		public static void RPC_EnableEternal(this Fireplace fireplace, long sender)
		{
			try
			{
				if (!((Object)(object)fireplace.m_nview == (Object)null) && fireplace.m_nview.IsValid() && fireplace.m_nview.IsOwner() && Main.ConfigCheck(((Object)fireplace).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					bool num = fireplace.IsEternal();
					fireplace.SetIsEternal(value: true);
					if (!num)
					{
						fireplace.SetOriginalFuelLevel(fireplace.GetFuel());
						fireplace.SetFuel(fireplace.m_maxFuel);
					}
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void RPC_DisableEternal(this Fireplace fireplace, long sender)
		{
			try
			{
				if (!((Object)(object)fireplace.m_nview == (Object)null) && fireplace.m_nview.IsValid() && fireplace.m_nview.IsOwner() && !Main.ConfigCheck(((Object)fireplace).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					bool num = fireplace.IsEternal();
					fireplace.SetIsEternal(value: false);
					if (num)
					{
						fireplace.SetFuel((fireplace.GetOriginalFuelLevel() <= 1f) ? 0f : fireplace.GetOriginalFuelLevel());
						fireplace.SetOriginalFuelLevel(0f);
					}
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static float GetOriginalFuelLevel(this Fireplace fireplace)
		{
			if (!fireplace.m_nview.IsValid())
			{
				return 0f;
			}
			return fireplace.m_nview.GetZDO().GetFloat(Main.CurrentFuelLevelKey, 0f);
		}

		[UsedImplicitly]
		public static void SetOriginalFuelLevel(this Fireplace fireplace, float value)
		{
			if (fireplace.m_nview.IsValid())
			{
				fireplace.m_nview.GetZDO().Set(Main.CurrentFuelLevelKey, value);
			}
		}

		[UsedImplicitly]
		public static float GetFuel(this Fireplace fireplace)
		{
			if (!fireplace.m_nview.IsValid())
			{
				return 0f;
			}
			return fireplace.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f);
		}

		[UsedImplicitly]
		public static void SetIsEternal(this Fireplace fireplace, bool value)
		{
			try
			{
				if (Main.Instance.EnableTrace)
				{
					Log.Trace(Main.Instance, string.Format("{0}.{1}.{2} [value: {3}]", "Digitalroot.Valheim.EternalFire", MethodBase.GetCurrentMethod()?.DeclaringType?.Name, MethodBase.GetCurrentMethod()?.Name, value));
					Log.Trace(Main.Instance, string.Format("{0}.{1}.{2} [m_nview.IsValid: {3}]", "Digitalroot.Valheim.EternalFire", MethodBase.GetCurrentMethod()?.DeclaringType?.Name, MethodBase.GetCurrentMethod()?.Name, fireplace.m_nview.IsValid()));
					Log.Trace(Main.Instance, string.Format("{0}.{1}.{2} [m_nview.IsOwner: {3}]", "Digitalroot.Valheim.EternalFire", MethodBase.GetCurrentMethod()?.DeclaringType?.Name, MethodBase.GetCurrentMethod()?.Name, fireplace.m_nview.IsOwner()));
				}
				if (fireplace.m_nview.IsValid() && fireplace.m_nview.IsOwner())
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, string.Format("{0}.{1}.{2} [ZDO.Write(IsEternalKey): value = {3}]", "Digitalroot.Valheim.EternalFire", MethodBase.GetCurrentMethod()?.DeclaringType?.Name, MethodBase.GetCurrentMethod()?.Name, value));
					}
					fireplace.m_nview.GetZDO().Set(Main.IsEternalKey, value);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static bool GetIsEternal(this Fireplace fireplace)
		{
			if (!fireplace.m_nview.IsValid())
			{
				return false;
			}
			return fireplace.m_nview.GetZDO().GetBool(Main.IsEternalKey, false);
		}

		[UsedImplicitly]
		[Conditional("DEBUG")]
		public static void TriggerLocator(this Fireplace fireplace)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (fireplace.m_nview.IsValid() && fireplace.m_nview.IsOwner() && fireplace.m_fireworkItemList != null && fireplace.m_fireworkItemList.Length >= 4)
			{
				fireplace.m_fireworkItemList[3].m_fireworksEffects.Create(((Component)fireplace).transform.position, Quaternion.Euler(Random.Range(0f - fireplace.m_fireworksMaxRandomAngle, fireplace.m_fireworksMaxRandomAngle), 0f, Random.Range(0f - fireplace.m_fireworksMaxRandomAngle, fireplace.m_fireworksMaxRandomAngle)), (Transform)null, 1f, -1, default(ZDOID));
				fireplace.m_fuelAddedEffects.Create(((Component)fireplace).transform.position, ((Component)fireplace).transform.rotation, (Transform)null, 1f, -1, default(ZDOID));
			}
		}
	}
	[UsedImplicitly]
	public static class CookingStationExtensions
	{
		[UsedImplicitly]
		public static bool IsEternal(this CookingStation cookingStation)
		{
			try
			{
				if ((Object)(object)cookingStation.m_nview == (Object)null || !cookingStation.m_nview.IsValid())
				{
					return false;
				}
				return cookingStation.GetIsEternal();
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return false;
		}

		[UsedImplicitly]
		public static void RPC_EnableEternal(this CookingStation cookingStation, long sender)
		{
			try
			{
				if (!((Object)(object)cookingStation.m_nview == (Object)null) && cookingStation.m_nview.IsValid() && cookingStation.m_nview.IsOwner() && !cookingStation.IsEternal() && Main.ConfigCheck(((Object)cookingStation).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					cookingStation.SetOriginalFuelLevel(cookingStation.GetFuel());
					cookingStation.SetIsEternal(value: true);
					cookingStation.SetFuel((float)cookingStation.m_maxFuel);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void RPC_DisableEternal(this CookingStation cookingStation, long sender)
		{
			try
			{
				if (!((Object)(object)cookingStation.m_nview == (Object)null) && cookingStation.m_nview.IsValid() && cookingStation.m_nview.IsOwner() && cookingStation.IsEternal() && !Main.ConfigCheck(((Object)cookingStation).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					cookingStation.SetIsEternal(value: false);
					cookingStation.SetFuel((cookingStation.GetOriginalFuelLevel() <= 1f) ? 0f : cookingStation.GetOriginalFuelLevel());
					cookingStation.SetOriginalFuelLevel(0f);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void RPC_SetFuelLevelMax(this CookingStation cookingStation, long sender)
		{
			try
			{
				if (!((Object)(object)cookingStation.m_nview == (Object)null) && cookingStation.m_nview.IsValid() && cookingStation.m_nview.IsOwner() && cookingStation.IsEternal() && Main.ConfigCheck(((Object)cookingStation).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					cookingStation.SetFuel((float)cookingStation.m_maxFuel);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static float GetOriginalFuelLevel(this CookingStation cookingStation)
		{
			try
			{
				if (!cookingStation.m_nview.IsValid())
				{
					return 0f;
				}
				return cookingStation.m_nview.GetZDO().GetFloat(Main.CurrentFuelLevelKey, 0f);
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return 0f;
		}

		[UsedImplicitly]
		public static void SetOriginalFuelLevel(this CookingStation cookingStation, float value)
		{
			try
			{
				if (cookingStation.m_nview.IsValid())
				{
					cookingStation.m_nview.GetZDO().Set(Main.CurrentFuelLevelKey, value);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void SetIsEternal(this CookingStation cookingStation, bool value)
		{
			try
			{
				if (cookingStation.m_nview.IsValid())
				{
					cookingStation.m_nview.GetZDO().Set(Main.IsEternalKey, value);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static bool GetIsEternal(this CookingStation cookingStation)
		{
			try
			{
				if (!cookingStation.m_nview.IsValid())
				{
					return false;
				}
				return cookingStation.m_nview.GetZDO().GetBool(Main.IsEternalKey, false);
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return false;
		}
	}
	[UsedImplicitly]
	public static class SmelterExtensions
	{
		[UsedImplicitly]
		public static bool IsEternal(this Smelter smelter)
		{
			try
			{
				if ((Object)(object)smelter.m_nview == (Object)null || !smelter.m_nview.IsValid())
				{
					return false;
				}
				return smelter.GetIsEternal();
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return false;
		}

		[UsedImplicitly]
		public static void RPC_EnableEternal(this Smelter smelter, long sender)
		{
			try
			{
				if (!((Object)(object)smelter.m_nview == (Object)null) && smelter.m_nview.IsValid() && smelter.m_nview.IsOwner() && !smelter.IsEternal() && Main.ConfigCheck(((Object)smelter).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					smelter.SetOriginalFuelLevel(smelter.GetFuel());
					smelter.SetIsEternal(value: true);
					smelter.SetFuel((float)smelter.m_maxFuel);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void RPC_DisableEternal(this Smelter smelter, long sender)
		{
			try
			{
				if (!((Object)(object)smelter.m_nview == (Object)null) && smelter.m_nview.IsValid() && smelter.m_nview.IsOwner() && smelter.IsEternal() && !Main.ConfigCheck(((Object)smelter).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					smelter.SetIsEternal(value: false);
					smelter.SetFuel((smelter.GetOriginalFuelLevel() <= 1f) ? 0f : smelter.GetOriginalFuelLevel());
					smelter.SetOriginalFuelLevel(0f);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void RPC_SetFuelLevelMax(this Smelter smelter, long sender)
		{
			try
			{
				if (!((Object)(object)smelter.m_nview == (Object)null) && smelter.m_nview.IsValid() && smelter.m_nview.IsOwner() && smelter.IsEternal() && Main.ConfigCheck(((Object)smelter).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					smelter.SetFuel((float)smelter.m_maxFuel);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static float GetOriginalFuelLevel(this Smelter smelter)
		{
			try
			{
				if (!smelter.m_nview.IsValid())
				{
					return 0f;
				}
				return smelter.m_nview.GetZDO().GetFloat(Main.CurrentFuelLevelKey, 0f);
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return 0f;
		}

		[UsedImplicitly]
		public static void SetOriginalFuelLevel(this Smelter smelter, float value)
		{
			try
			{
				if (smelter.m_nview.IsValid())
				{
					smelter.m_nview.GetZDO().Set(Main.CurrentFuelLevelKey, value);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void SetIsEternal(this Smelter smelter, bool value)
		{
			try
			{
				if (smelter.m_nview.IsValid())
				{
					smelter.m_nview.GetZDO().Set(Main.IsEternalKey, value);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static bool GetIsEternal(this Smelter smelter)
		{
			try
			{
				if (!smelter.m_nview.IsValid())
				{
					return false;
				}
				return smelter.m_nview.GetZDO().GetBool(Main.IsEternalKey, false);
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return false;
		}
	}
	[UsedImplicitly]
	public static class ShieldGeneratorExtensions
	{
		[UsedImplicitly]
		public static bool IsEternal(this ShieldGenerator shieldGenerator)
		{
			try
			{
				if ((Object)(object)shieldGenerator.m_nview == (Object)null || !shieldGenerator.m_nview.IsValid())
				{
					return false;
				}
				return shieldGenerator.GetIsEternal();
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return false;
		}

		[UsedImplicitly]
		public static void RPC_EnableEternal(this ShieldGenerator shieldGenerator, long sender)
		{
			try
			{
				if (!((Object)(object)shieldGenerator.m_nview == (Object)null) && shieldGenerator.m_nview.IsValid() && shieldGenerator.m_nview.IsOwner() && !shieldGenerator.IsEternal() && Main.ConfigCheck(((Object)shieldGenerator).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					shieldGenerator.SetOriginalFuelLevel(shieldGenerator.GetFuel());
					shieldGenerator.SetIsEternal(value: true);
					shieldGenerator.SetFuel((float)shieldGenerator.m_maxFuel);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void RPC_DisableEternal(this ShieldGenerator shieldGenerator, long sender)
		{
			try
			{
				if (!((Object)(object)shieldGenerator.m_nview == (Object)null) && shieldGenerator.m_nview.IsValid() && shieldGenerator.m_nview.IsOwner() && shieldGenerator.IsEternal() && !Main.ConfigCheck(((Object)shieldGenerator).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					shieldGenerator.SetIsEternal(value: false);
					shieldGenerator.SetFuel((shieldGenerator.GetOriginalFuelLevel() <= 1f) ? 0f : shieldGenerator.GetOriginalFuelLevel());
					shieldGenerator.SetOriginalFuelLevel(0f);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void RPC_SetFuelLevelMax(this ShieldGenerator shieldGenerator, long sender)
		{
			try
			{
				if (!((Object)(object)shieldGenerator.m_nview == (Object)null) && shieldGenerator.m_nview.IsValid() && shieldGenerator.m_nview.IsOwner() && shieldGenerator.IsEternal() && Main.ConfigCheck(((Object)shieldGenerator).name))
				{
					if (Main.Instance.EnableTrace)
					{
						Log.Trace(Main.Instance, "Digitalroot.Valheim.EternalFire." + MethodBase.GetCurrentMethod()?.DeclaringType?.Name + "." + MethodBase.GetCurrentMethod()?.Name);
					}
					shieldGenerator.SetFuel((float)shieldGenerator.m_maxFuel);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static float GetOriginalFuelLevel(this ShieldGenerator shieldGenerator)
		{
			try
			{
				if (!shieldGenerator.m_nview.IsValid())
				{
					return 0f;
				}
				return shieldGenerator.m_nview.GetZDO().GetFloat(Main.CurrentFuelLevelKey, 0f);
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return 0f;
		}

		[UsedImplicitly]
		public static void SetOriginalFuelLevel(this ShieldGenerator shieldGenerator, float value)
		{
			try
			{
				if (shieldGenerator.m_nview.IsValid())
				{
					shieldGenerator.m_nview.GetZDO().Set(Main.CurrentFuelLevelKey, value);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static void SetIsEternal(this ShieldGenerator shieldGenerator, bool value)
		{
			try
			{
				if (shieldGenerator.m_nview.IsValid())
				{
					shieldGenerator.m_nview.GetZDO().Set(Main.IsEternalKey, value);
				}
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
		}

		[UsedImplicitly]
		public static bool GetIsEternal(this ShieldGenerator shieldGenerator)
		{
			try
			{
				if (!shieldGenerator.m_nview.IsValid())
				{
					return false;
				}
				return shieldGenerator.m_nview.GetZDO().GetBool(Main.IsEternalKey, false);
			}
			catch (Exception e)
			{
				Log.Error(Main.Instance, e);
			}
			return false;
		}
	}
}
namespace Digitalroot.Modding.Framework.Logging
{
	internal interface ITraceableLogging
	{
		string Source { get; }

		bool EnableTrace { get; }
	}
}
namespace Digitalroot.Modding.Framework.Utils
{
	internal static class ValheimUtils
	{
		[UsedImplicitly]
		public static bool IsDedicated => ZNet.instance.IsDedicated();

		[UsedImplicitly]
		public static bool IsServer => ZNet.instance.IsServer();

		[UsedImplicitly]
		public static bool IsHeadless()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			return (int)SystemInfo.graphicsDeviceType == 4;
		}

		[UsedImplicitly]
		[Obsolete("Use isModLoaded()", true)]
		public static bool DoesPluginExist(string pluginGuid)
		{
			return Chainloader.PluginInfos.Any((KeyValuePair<string, PluginInfo> keyValuePair) => keyValuePair.Value.Metadata.GUID == pluginGuid);
		}

		[UsedImplicitly]
		public static bool isModLoaded(string pluginGuid)
		{
			return Chainloader.PluginInfos.Any((KeyValuePair<string, PluginInfo> keyValuePair) => keyValuePair.Value.Metadata.GUID == pluginGuid);
		}

		[UsedImplicitly]
		public static Vector3 GetGroundHeight(int x, int z)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return ValheimUtils.GetGroundHeight(new Vector3Int(x, 500, z));
		}

		[UsedImplicitly]
		public static Vector3 GetGroundHeight(float x, float z)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return ValheimUtils.GetGroundHeight(new Vector3(x, 500f, z));
		}

		[UsedImplicitly]
		public static Vector3 GetGroundHeight(Vector3Int vector3)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3((float)((Vector3Int)(ref vector3)).x, ZoneSystem.instance.GetGroundHeight(Vector3Int.op_Implicit(vector3)), (float)((Vector3Int)(ref vector3)).z);
		}

		[UsedImplicitly]
		public static Vector3 GetGroundHeight(Vector3 vector3)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(vector3.x, ZoneSystem.instance.GetGroundHeight(vector3), vector3.z);
		}

		[UsedImplicitly]
		public static GameObject GetItemPrefab(string itemName)
		{
			if (!IsObjectDBReady())
			{
				return null;
			}
			return GetObjectDB().GetItemPrefab(itemName);
		}

		[UsedImplicitly]
		public static GameObject GetItemPrefab(int hash)
		{
			if (!IsObjectDBReady())
			{
				return null;
			}
			return GetObjectDB().GetItemPrefab(hash);
		}

		[UsedImplicitly]
		public static Player GetLocalPlayer()
		{
			return Player.m_localPlayer;
		}

		[UsedImplicitly]
		public static Vector3 GetLocalPlayersPosition()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)Player.m_localPlayer).transform.position;
		}

		[UsedImplicitly]
		public static ObjectDB GetObjectDB()
		{
			return ObjectDB.instance;
		}

		[UsedImplicitly]
		public static string GetPluginPath(Type modPluginType)
		{
			return Path.GetDirectoryName(modPluginType.Assembly.Location);
		}

		[UsedImplicitly]
		public static GameObject GetPrefab(string itemName)
		{
			if (!IsZNetSceneReady())
			{
				return null;
			}
			return ZNetScene.instance.GetPrefab(itemName);
		}

		[UsedImplicitly]
		public static GameObject GetPrefab(int hash)
		{
			if (!IsZNetSceneReady())
			{
				return null;
			}
			return ZNetScene.instance.GetPrefab(hash);
		}

		[UsedImplicitly]
		public static bool IsGameInMainScene()
		{
			return (Object)(object)ZNetScene.instance != (Object)null;
		}

		[UsedImplicitly]
		public static bool IsObjectDBReady()
		{
			if (!((Object)(object)GetObjectDB() != (Object)null) || GetObjectDB().m_items.Count == 0 || !((Object)(object)GetItemPrefab("Amber") != (Object)null))
			{
				return EnvironmentUtils.IsRunningFromNUnit;
			}
			return true;
		}

		[UsedImplicitly]
		public static bool IsPlayerReady()
		{
			return (Object)(object)GetLocalPlayer() != (Object)null;
		}

		[UsedImplicitly]
		public static bool IsZNetSceneReady()
		{
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				List<GameObject> list = ZNetScene.instance?.m_prefabs;
				if (list != null)
				{
					return list.Count > 0;
				}
				return false;
			}
			return false;
		}

		[UsedImplicitly]
		public static bool IsZNetReady()
		{
			return (Object)(object)ZNet.instance != (Object)null;
		}

		[UsedImplicitly]
		public static string Localize(string value)
		{
			return Localization.instance.Localize(value);
		}

		[UsedImplicitly]
		public static Vector3 GetStartTemplesPosition()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			LocationInstance val = default(LocationInstance);
			if (ZoneSystem.instance.FindClosestLocation("StartTemple", Vector3.zero, ref val))
			{
				Log.Trace(StaticSourceLogger.PreMadeTraceableInstance, $"[GetStartTemplesPosition] StartTemple at {val.m_position}");
				return val.m_position;
			}
			Log.Error(StaticSourceLogger.PreMadeTraceableInstance, "[GetStartTemplesPosition] Can't find StartTemple");
			return Vector3.zero;
		}

		[UsedImplicitly]
		public static void PrintToCenterOfScreen(string msg)
		{
			((Character)Player.m_localPlayer).Message((MessageType)2, msg, 0, (Sprite)null, false);
		}

		[UsedImplicitly]
		public static void PrintToTopLeftOfScreen(string msg)
		{
			((Character)Player.m_localPlayer).Message((MessageType)1, msg, 0, (Sprite)null, false);
		}

		[UsedImplicitly]
		public static GameObject Spawn([NotNull] string prefabName, Vector3 location, [CanBeNull] Transform parent = null)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			Log.Trace(StaticSourceLogger.PreMadeTraceableInstance, $"{EnvironmentUtils.Namespace}.{MethodBase.GetCurrentMethod()?.DeclaringType?.Name}.{MethodBase.GetCurrentMethod()?.Name}({prefabName}, {location}, {((parent != null) ? ((Object)parent).name : null)})");
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(prefabName));
			if (!((Object)(object)itemPrefab == (Object)null))
			{
				return Spawn(itemPrefab, location, parent);
			}
			return null;
		}

		[UsedImplicitly]
		public static GameObject Spawn([NotNull] GameObject prefab, Vector3 location, [CanBeNull] Transform parent = null)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			Log.Trace(StaticSourceLogger.PreMadeTraceableInstance, $"{EnvironmentUtils.Namespace}.{MethodBase.GetCurrentMethod()?.DeclaringType?.Name}.{MethodBase.GetCurrentMethod()?.Name}({((Object)prefab).name}, {location}, {((parent != null) ? ((Object)parent).name : null)})");
			if ((Object)(object)parent == (Object)null)
			{
				return Object.Instantiate<GameObject>(prefab, location, Quaternion.identity);
			}
			return Object.Instantiate<GameObject>(prefab, location, Quaternion.identity, parent);
		}

		public static AssetBundle LoadAssetBundleFromResources(string bundleName, Assembly resourceAssembly)
		{
			if (resourceAssembly == null)
			{
				throw new ArgumentNullException("resourceAssembly");
			}
			string text = null;
			try
			{
				text = resourceAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(bundleName));
			}
			catch (Exception)
			{
			}
			if (text == null)
			{
				Log.Error(StaticSourceLogger.PreMadeTraceableInstance, "AssetBundle " + bundleName + " not found in assembly manifest");
				return null;
			}
			using Stream stream = resourceAssembly.GetManifestResourceStream(text);
			return AssetBundle.LoadFromStream(stream);
		}
	}
}
namespace Digitalroot.Modding.Framework.Logging
{
	internal sealed class Log
	{
		private static readonly Dictionary<string, TraceLogger> TraceLoggers;

		[UsedImplicitly]
		private static Log Instance { get; }

		static Log()
		{
			TraceLoggers = new Dictionary<string, TraceLogger>();
			Instance = new Log();
		}

		private Log()
		{
			TraceLoggers.Add("Digitalroot", new TraceLogger("Digitalroot", enableTrace: false));
		}

		public static void RegisterSource(ITraceableLogging sender)
		{
			if ((!TraceLoggers.ContainsKey(sender.Source) || TraceLoggers[sender.Source].IsTraceEnabled != sender.EnableTrace) && (!TraceLoggers.ContainsKey(sender.Source) || sender.EnableTrace))
			{
				if (TraceLoggers.ContainsKey(sender.Source) && sender.EnableTrace)
				{
					TraceLoggers[sender.Source].EnableTrace();
				}
				else
				{
					TraceLoggers.Add(sender.Source, new TraceLogger(sender.Source, sender.EnableTrace));
				}
			}
		}

		private static TraceLogger GetTraceLogger(ITraceableLogging sender)
		{
			if (!TraceLoggers.ContainsKey(sender.Source))
			{
				return TraceLoggers["Digitalroot"];
			}
			return TraceLoggers[sender.Source];
		}

		[UsedImplicitly]
		public static void SetEnableTrace(ITraceableLogging sender, bool value)
		{
			if (value)
			{
				GetTraceLogger(sender).EnableTrace();
			}
			else
			{
				GetTraceLogger(sender).DisableTrace();
			}
		}

		[UsedImplicitly]
		public static void SetEnableTraceForAllLoggers(bool value)
		{
			foreach (TraceLogger value2 in TraceLoggers.Values)
			{
				if (value)
				{
					value2.EnableTrace();
				}
				else
				{
					value2.DisableTrace();
				}
			}
		}

		[UsedImplicitly]
		public static void Debug(ITraceableLogging sender, object value)
		{
			GetTraceLogger(sender).LoggerRef.LogDebug(value);
		}

		[UsedImplicitly]
		public static void Error(ITraceableLogging sender, Exception e, int i = 1)
		{
			Error(sender, "Message: " + e.Message);
			Error(sender, $"TargetSite: {e.TargetSite}");
			Error(sender, "StackTrace: " + e.StackTrace);
			Error(sender, "Source: " + e.Source);
			if (e.Data.Count > 0)
			{
				foreach (object key in e.Data.Keys)
				{
					Error(sender, $"key: {key}, value: {e.Data[key]}");
				}
			}
			if (e.InnerException != null)
			{
				Error(sender, $"--- InnerException [{i}][Start] ---");
				Error(sender, e.InnerException, ++i);
			}
		}

		[UsedImplicitly]
		public static void Error(ITraceableLogging sender, object value)
		{
			GetTraceLogger(sender).LoggerRef.LogError(value);
		}

		[UsedImplicitly]
		public static void Info(ITraceableLogging sender, object value)
		{
			GetTraceLogger(sender).LoggerRef.LogInfo(value);
		}

		[UsedImplicitly]
		public static void Fatal(ITraceableLogging sender, Exception e, int i = 1)
		{
			Fatal(sender, "Message: " + e.Message);
			Fatal(sender, $"TargetSite: {e.TargetSite}");
			Fatal(sender, "StackTrace: " + e.StackTrace);
			Fatal(sender, "Source: " + e.Source);
			if (e.Data.Count > 0)
			{
				foreach (object key in e.Data.Keys)
				{
					Fatal(sender, $"key: {key}, value: {e.Data[key]}");
				}
			}
			if (e.InnerException != null)
			{
				Fatal(sender, $"--- InnerException [{i}][Start] ---");
				Fatal(sender, e.InnerException, ++i);
			}
		}

		[UsedImplicitly]
		public static void Fatal(ITraceableLogging sender, object value)
		{
			GetTraceLogger(sender).LoggerRef.LogFatal(value);
		}

		[UsedImplicitly]
		public static void Message(ITraceableLogging sender, object value)
		{
			GetTraceLogger(sender).LoggerRef.LogMessage(value);
		}

		[UsedImplicitly]
		public static void Trace(ITraceableLogging sender, object value)
		{
			if (GetTraceLogger(sender).IsTraceEnabled || sender.EnableTrace)
			{
				GetTraceLogger(sender).LoggerRef.Log((LogLevel)63, value);
			}
		}

		[UsedImplicitly]
		public static void Warning(ITraceableLogging sender, object value)
		{
			GetTraceLogger(sender).LoggerRef.LogWarning(value);
		}
	}
	internal class TraceLogger
	{
		internal readonly ManualLogSource LoggerRef;

		private readonly string _source;

		private readonly FileInfo _traceFileInfo;

		public bool IsTraceEnabled { get; private set; }

		private DirectoryInfo AssemblyDirectory => new FileInfo(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)).Directory;

		public TraceLogger(string source, bool enableTrace)
		{
			_source = source;
			IsTraceEnabled = enableTrace;
			LoggerRef = Logger.CreateLogSource(_source);
			_traceFileInfo = new FileInfo(Path.Combine(Paths.BepInExRootPath ?? AssemblyDirectory.FullName, "logs", _source + ".Trace.log"));
			if (_traceFileInfo.DirectoryName != null)
			{
				Directory.CreateDirectory(_traceFileInfo.DirectoryName);
			}
			if (_traceFileInfo.Exists)
			{
				_traceFileInfo.Delete();
				_traceFileInfo.Refresh();
			}
			LoggerRef.LogEvent += OnLogEvent;
		}

		public void EnableTrace()
		{
			IsTraceEnabled = true;
		}

		public void DisableTrace()
		{
			IsTraceEnabled = false;
		}

		[UsedImplicitly]
		public void StopTrace()
		{
			LoggerRef.LogEvent -= OnLogEvent;
		}

		private void OnLogEvent(object sender, LogEventArgs e)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (e.Source.SourceName != _source || !IsTraceEnabled)
			{
				return;
			}
			using Mutex mutex = new Mutex(initiallyOwned: false, "Digitalroot.Modding.Log.TraceLogger." + _source);
			mutex.WaitOne();
			try
			{
				if (e.Data is string)
				{
					string contents = $"[{e.Level,-7}:{e.Source.SourceName,10}] {e.Data}{Environment.NewLine}";
					File.AppendAllText(_traceFileInfo.FullName, contents, Encoding.UTF8);
				}
				else
				{
					string contents2 = $"[{e.Level,-7}:{e.Source.SourceName,10}] {JsonSerializationProvider.Serialize(e.Data)}{Environment.NewLine}";
					File.AppendAllText(_traceFileInfo.FullName, contents2, Encoding.UTF8);
				}
			}
			finally
			{
				mutex.ReleaseMutex();
			}
		}
	}
}
namespace Digitalroot.Modding.Framework.Common.Json
{
	[UsedImplicitly]
	internal static class JsonSerializationProvider
	{
		public static T Deserialize<T>(string json)
		{
			return SimpleJson.DeserializeObject<T>(json, (IJsonSerializerStrategy)(object)new DigitalrootJsonSerializerStrategy());
		}

		public static string Serialize(object obj)
		{
			return SimpleJson.SerializeObject(obj, (IJsonSerializerStrategy)(object)new DigitalrootJsonSerializerStrategy());
		}
	}
	internal class DigitalrootJsonSerializerStrategy : PocoJsonSerializerStrategy
	{
		public override bool TrySerializeNonPrimitiveObject(object input, out object output)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (!(input is Vector3 val))
			{
				if (input is Quaternion val2)
				{
					output = new float[4] { val2.x, val2.y, val2.z, val2.w };
					return true;
				}
				return ((PocoJsonSerializerStrategy)this).TrySerializeNonPrimitiveObject(input, ref output);
			}
			output = new float[3] { val.x, val.y, val.z };
			return true;
		}

		public override object DeserializeObject(object value, Type type)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}
			if (value is string value2)
			{
				if (string.IsNullOrWhiteSpace(value2))
				{
					throw new ArgumentNullException("value");
				}
				if (type == typeof(Vector3))
				{
					if (!(((PocoJsonSerializerStrategy)this).DeserializeObject(value, typeof(float[])) is float[] array) || (array != null && array.Length != 3))
					{
						throw new ArgumentException(string.Format("The value '{0}' can be converted to a {1}.", value, "Vector3"), "value");
					}
					return (object)new Vector3(array[0], array[1], array[2]);
				}
				if (type == typeof(Quaternion))
				{
					if (!(((PocoJsonSerializerStrategy)this).DeserializeObject(value, typeof(float[])) is float[] array2) || (array2 != null && array2.Length != 4))
					{
						throw new ArgumentException(string.Format("The value '{0}' can be converted to a {1}.", value, "Quaternion"), "value");
					}
					return (object)new Quaternion(array2[0], array2[1], array2[2], array2[3]);
				}
				return ((PocoJsonSerializerStrategy)this).DeserializeObject(value, type);
			}
			throw new ArgumentException($"The value '{value}' can be converted to a {type.Name}.", "value");
		}
	}
}
namespace Digitalroot.Modding.Framework.Utils
{
	internal static class EnvironmentUtils
	{
		[UsedImplicitly]
		public static DirectoryInfo AssemblyDirectory => new FileInfo(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)).Directory;

		public static bool IsRunningFromNUnit => AppDomain.CurrentDomain.GetAssemblies().Any((Assembly a) => a.FullName.ToLowerInvariant().StartsWith("nunit.framework"));

		[UsedImplicitly]
		[Obsolete("Use ValheimUtils.IsDedicated", true)]
		public static bool IsDedicated => ValheimUtils.IsDedicated;

		[UsedImplicitly]
		[Obsolete("Use ValheimUtils.IsServer", true)]
		public static bool IsServer => ValheimUtils.IsServer;

		[UsedImplicitly]
		public static string Namespace => "Digitalroot.Modding.Framework";

		[UsedImplicitly]
		[Obsolete("Use ValheimUtils.IsHeadless", true)]
		public static bool IsHeadless()
		{
			return ValheimUtils.IsHeadless();
		}
	}
}
namespace Digitalroot.Modding.Framework.Logging
{
	[DebuggerDisplay("Source = {Source}, EnableTrace = {EnableTrace}", Name = "{Source}")]
	internal class StaticSourceLogger : ITraceableLogging
	{
		public static readonly StaticSourceLogger PreMadeTraceableInstance = new StaticSourceLogger(enableTrace: true);

		public static StaticSourceLogger PreMadeNonTraceableInstance = new StaticSourceLogger();

		public string Source { get; }

		public bool EnableTrace { get; }

		public StaticSourceLogger(bool enableTrace = false)
			: this("Digitalroot", enableTrace)
		{
		}

		public StaticSourceLogger(string source, bool enableTrace = false)
		{
			Source = source;
			EnableTrace = enableTrace;
		}
	}
}
internal class DigitalrootValheimEternalFire_ProcessedByFody
{
	internal const string FodyVersion = "6.6.0.0";

	internal const string ILMerge = "1.22.0.0";
}