using System; using System.Collections.Generic; 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; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("BlueBrazierFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BlueBrazierFix")] [assembly: AssemblyTitle("BlueBrazierFix")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 BlueBrazierFix { [BepInPlugin("communityfixes.valheim.bluebrazier.nsslf", "BlueBrazierFix", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "communityfixes.valheim.bluebrazier.nsslf"; public const string PluginName = "BlueBrazierFix"; public const string PluginVersion = "1.0.0"; public const string OriginalModGuid = "TastyChickenLegs.NoSmokeStayLit"; private const string ConfigsTypeName = "NoSmokeStayLit.Patches.Configs"; private const string BlueBrazierInstance = "piece_brazierfloor02(Clone)"; private static readonly IReadOnlyDictionary SettingFields = new Dictionary(StringComparer.Ordinal) { ["ConfigCheck"] = "fe_piece_brazierfloor01", ["ConfigCheckTimerOne"] = "fe_piece_brazierfloor01_timer", ["ConfigCheckGiveMeSmoke"] = "fe_piece_brazierfloor01_smoke" }; private static ManualLogSource? _log; private Harmony? _harmony; private void Awake() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown _log = ((BaseUnityPlugin)this).Logger; Type type = AccessTools.TypeByName("NoSmokeStayLit.Patches.Configs"); if ((object)type == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find NoSmokeStayLit.Patches.Configs. Is NoSmokeStayLit installed and enabled?"); return; } _harmony = new Harmony("communityfixes.valheim.bluebrazier.nsslf"); HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(Plugin), "ApplyStandingBrazierSetting", (Type[])null, (Type[])null)); int num = 0; foreach (string key in SettingFields.Keys) { MethodInfo methodInfo = AccessTools.Method(type, key, new Type[1] { typeof(string) }, (Type[])null); if ((object)methodInfo == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not find NoSmokeStayLit.Patches.Configs." + key + "; that behavior will not be mapped.")); continue; } _harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } ((BaseUnityPlugin)this).Logger.LogInfo((object)((num == SettingFields.Count) ? "Blue standing braziers now follow NoSmokeStayLit's standing-brazier settings." : $"Applied {num} of {SettingFields.Count} blue-brazier compatibility mappings.")); } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private static void ApplyStandingBrazierSetting(string instanceName, MethodBase __originalMethod, ref bool __result) { if (!string.Equals(instanceName, "piece_brazierfloor02(Clone)", StringComparison.Ordinal) || __result || !SettingFields.TryGetValue(__originalMethod.Name, out string value)) { return; } try { if (AccessTools.Field(__originalMethod.DeclaringType, value)?.GetValue(null) is ConfigEntry val) { __result = val.Value; } } catch (Exception arg) { ManualLogSource? log = _log; if (log != null) { log.LogError((object)$"Could not apply the blue-brazier mapping for {__originalMethod.Name}: {arg}"); } } } } }