Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Warmth v1.0.2
Warmth.dll
Decompiled 9 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Warmth")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Warmth")] [assembly: AssemblyTitle("Warmth")] [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 Warmth { [BepInPlugin("yourname.valheim.warmth", "Warmth", "3.6.0")] public class WarmthPlugin : BaseUnityPlugin { public const string PluginGUID = "yourname.valheim.warmth"; public const string PluginName = "Warmth"; public const string PluginVersion = "3.6.0"; internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "yourname.valheim.warmth"); Log.LogInfo((object)"Warmth v3.6.0 loaded."); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScene_Awake_Patch { private const float TargetRadiusMultiplier = 0.5f; private static readonly string[] TargetFireSources = new string[15] { "piece_walltorch", "piece_groundtorch", "piece_groundtorch_blue", "piece_groundtorch_green", "piece_groundtorch_mist", "piece_groundtorch_wood", "CastleKit_groundtorch", "CastleKit_groundtorch_blue", "CastleKit_groundtorch_green", "CastleKit_groundtorch_unlit", "CastleKit_metal_groundtorch_unlit", "forge", "TrophySurtling", "piece_dvergr_lantern", "piece_dvergr_lantern_pole" }; private static void Postfix(ZNetScene __instance) { //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) WarmthPlugin.Log.LogInfo((object)$"[Warmth] ZNetScene.Awake fired with {__instance.m_prefabs.Count} prefabs registered."); List<GameObject> source = __instance.m_prefabs.Where((GameObject p) => (Object)(object)p != (Object)null && (Object)(object)p.GetComponent<Fireplace>() != (Object)null).ToList(); GameObject val = ((IEnumerable<GameObject>)source).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => ((Object)p).name.ToLowerInvariant().Contains("campfire"))) ?? source.FirstOrDefault(); if ((Object)(object)val == (Object)null) { WarmthPlugin.Log.LogWarning((object)"[Warmth] Could not find any Fireplace-component prefab to use as a template."); return; } WarmthPlugin.Log.LogInfo((object)("[Warmth] Using '" + ((Object)val).name + "' as the Heat area template.")); EffectArea val2 = ((IEnumerable<EffectArea>)val.GetComponentsInChildren<EffectArea>(true)).FirstOrDefault((Func<EffectArea, bool>)((EffectArea a) => (a.m_type & 1) > 0)); if ((Object)(object)val2 == (Object)null) { WarmthPlugin.Log.LogWarning((object)("[Warmth] '" + ((Object)val).name + "' has no Heat EffectArea to copy.")); return; } HashSet<string> matched = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (GameObject prefab in __instance.m_prefabs) { if ((Object)(object)prefab == (Object)null || (Object)(object)prefab == (Object)(object)val || !TargetFireSources.Any((string k) => string.Equals(k, ((Object)prefab).name, StringComparison.OrdinalIgnoreCase))) { continue; } matched.Add(((Object)prefab).name); if (prefab.GetComponentsInChildren<EffectArea>(true).Any((EffectArea a) => (a.m_type & 1) > 0)) { WarmthPlugin.Log.LogInfo((object)("[Warmth] '" + ((Object)prefab).name + "' already has a Heat area — skipped.")); continue; } GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject); val3.transform.SetParent(prefab.transform, false); ((Object)val3).name = "Warmth_HeatArea"; val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = ((Component)val2).transform.localScale; Collider component = val3.GetComponent<Collider>(); SphereCollider val4 = (SphereCollider)(object)((component is SphereCollider) ? component : null); if (val4 != null) { val4.radius *= 0.5f; } else { CapsuleCollider val5 = (CapsuleCollider)(object)((component is CapsuleCollider) ? component : null); if (val5 != null) { val5.radius *= 0.5f; } else { WarmthPlugin.Log.LogWarning((object)("[Warmth] '" + ((Object)prefab).name + "' clone has an unrecognized collider type (" + ((object)component)?.GetType().Name + ") — radius not scaled.")); } } WarmthPlugin.Log.LogInfo((object)("[Warmth] Cloned Heat area onto '" + ((Object)prefab).name + "'.")); } List<string> list = TargetFireSources.Where((string k) => !matched.Contains(k)).ToList(); if (list.Count > 0) { WarmthPlugin.Log.LogWarning((object)("[Warmth] These configured names were never found in ZNetScene: " + string.Join(", ", list))); } } } }