using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Jotunn.Managers;
using UnityEngine;
using ValheimInfiniteFire.common;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ValheimInfiniteFire")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ValheimInfiniteFire")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ValheimInfiniteFire
{
[BepInPlugin("MidnightsFX.InfiniteFire", "InfiniteFire", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class ValheimInfiniteFire : BaseUnityPlugin
{
public const string PluginGUID = "MidnightsFX.InfiniteFire";
public const string PluginName = "InfiniteFire";
public const string PluginVersion = "1.0.0";
public ValConfig cfg;
public static ManualLogSource Log;
public void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
cfg = new ValConfig(((BaseUnityPlugin)this).Config);
PrefabManager.OnVanillaPrefabsAvailable += FindAllFireTypes;
Logger.LogDebug("Lets Light it up");
}
public static void FindAllFireTypes()
{
Fireplace[] array = Resources.FindObjectsOfTypeAll<Fireplace>();
foreach (Fireplace val in array)
{
string prefabname = Utils.GetPrefabName(((Object)((Component)val).gameObject).name);
string text = prefabname + "-" + Localization.instance.Localize(val.m_name);
ConfigEntry<bool> enableFire = ValConfig.BindServerConfig("InfiniteFire", text ?? "", value: true, "Enable infinite fuel for this.");
Logger.LogDebug($"Registering {text} with infinitefire {enableFire.Value}");
val.m_infiniteFuel = enableFire.Value;
enableFire.SettingChanged += delegate
{
foreach (Fireplace item in from fp in Resources.FindObjectsOfTypeAll<Fireplace>()
where ((Object)((Component)fp).gameObject).name.StartsWith(prefabname)
select fp)
{
Logger.LogDebug($"Updating {((Object)item).name} to InfiniteFire:{enableFire.Value}");
item.m_infiniteFuel = enableFire.Value;
}
};
}
}
}
}
namespace ValheimInfiniteFire.common
{
internal static class Logger
{
public static LogLevel Level = (LogLevel)16;
public static void enableDebugLogging(object sender, EventArgs e)
{
//IL_0016: 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)
if (ValConfig.EnableDebugMode.Value)
{
Level = (LogLevel)32;
}
else
{
Level = (LogLevel)16;
}
}
public static void CheckEnableDebugLogging()
{
//IL_0016: 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)
if (ValConfig.EnableDebugMode.Value)
{
Level = (LogLevel)32;
}
else
{
Level = (LogLevel)16;
}
}
public static void LogDebug(string message)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)Level >= 32)
{
ValheimInfiniteFire.Log.LogInfo((object)message);
}
}
public static void LogInfo(string message)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)Level >= 16)
{
ValheimInfiniteFire.Log.LogInfo((object)message);
}
}
public static void LogWarning(string message)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
if ((int)Level >= 4)
{
ValheimInfiniteFire.Log.LogWarning((object)message);
}
}
public static void LogError(string message)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
if ((int)Level >= 2)
{
ValheimInfiniteFire.Log.LogError((object)message);
}
}
}
internal class ValConfig
{
public static ConfigFile cfg;
public static ConfigEntry<bool> EnableDebugMode;
public ValConfig(ConfigFile cf)
{
cfg = cf;
cfg.SaveOnConfigSet = true;
CreateConfigValues(cf);
}
private void CreateConfigValues(ConfigFile Config)
{
//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_002c: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
EnableDebugMode = Config.Bind<bool>("Client config", "EnableDebugMode", false, new ConfigDescription("Enables Debug logging.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdvanced = true
} }));
EnableDebugMode.SettingChanged += Logger.enableDebugLogging;
Logger.CheckEnableDebugLogging();
}
public static ConfigEntry<bool> BindServerConfig(string catagory, string key, bool value, string description, AcceptableValueBase acceptableValues = null, bool advanced = false)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_002d: Expected O, but got Unknown
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
return cfg.Bind<bool>(catagory, key, value, new ConfigDescription(description, acceptableValues, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true,
IsAdvanced = advanced
} }));
}
}
}