Decompiled source of EternalFires v1.0.0

EternalFires.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EternalFires
{
	[BepInPlugin("com.bouns.eternalfires", "Eternal Fires", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "com.bouns.eternalfires";

		public const string NAME = "Eternal Fires";

		public const string VERSION = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> Fireplaces;

		internal static ConfigEntry<bool> Smelters;

		private void Awake()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch. false = vanilla fuel behaviour.");
			Fireplaces = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Fireplaces", true, "Campfires, hearths, bonfires, torches and braziers stay lit forever with no fuel.");
			Smelters = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Smelters", true, "Smelters, charcoal kilns and blast furnaces never run out of fuel (no more coal needed).");
			try
			{
				new Harmony("com.bouns.eternalfires").PatchAll();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Eternal Fires v1.0.0 loaded.");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Eternal Fires v1.0.0 FAILED to patch (Valheim version mismatch?): " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(Fireplace), "Awake")]
	internal static class Patch_Fireplace_Awake
	{
		private static readonly FieldInfo F_inf = AccessTools.Field(typeof(Fireplace), "m_infiniteFuel");

		private static void Postfix(Fireplace __instance)
		{
			if (Plugin.Enabled.Value && Plugin.Fireplaces.Value && !((Object)(object)__instance == (Object)null))
			{
				F_inf?.SetValue(__instance, true);
			}
		}
	}
	[HarmonyPatch(typeof(Smelter), "GetFuel")]
	internal static class Patch_Smelter_GetFuel
	{
		private static readonly FieldInfo F_max = AccessTools.Field(typeof(Smelter), "m_maxFuel");

		private static void Postfix(Smelter __instance, ref float __result)
		{
			if (Plugin.Enabled.Value && Plugin.Smelters.Value && !((Object)(object)__instance == (Object)null) && F_max != null)
			{
				__result = (int)F_max.GetValue(__instance);
			}
		}
	}
}