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 Everlit v1.1.1
plugins/Everlit/Everlit.dll
Decompiled 15 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: AssemblyCompany("Everlit")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("(c) 2026 Cody Keats")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+e0c7f207b593a6951d867b3fb21625257d55dd4d")] [assembly: AssemblyProduct("Everlit")] [assembly: AssemblyTitle("Everlit")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.0")] [module: UnverifiableCode] namespace Everlit { internal static class Keeper { private enum Kind { Campfire, Bonfire, Hearth, Torch, Brazier, Candle, HotTub, Oven, Refinery, Furnace, FrostKiln, FrostFoundry, Shield, Other } private enum Via { Fireplace, Smelter, CookingStation, ShieldGenerator } private sealed class FireType { public string Name; public Kind Kind; public float MaxFuel; public Via Via; public float Normal; public bool CoverOff; public bool CanTurnOff; } private struct Ward { public Vector3 Pos; public float Radius; public bool On; } [HarmonyPatch(typeof(ZDO), "Deserialize")] private static class Arrived { private static void Postfix(ZDO __instance) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (types != null) { int prefab = __instance.GetPrefab(); if (types.ContainsKey(prefab)) { arrived.Add(__instance.m_uid); } else if (warded && wardTypes.ContainsKey(prefab)) { wardArrived.Add(__instance.m_uid); } } } } [HarmonyPatch(typeof(ZDOMan), "HandleDestroyedZDO")] private static class Destroyed { private static void Prefix(ZDOID uid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (wards.Remove(uid) && wardsKnown) { WardChanged(); } } } private static readonly int HasFields = StringExtensionMethods.GetStableHashCode("HasFields"); private static readonly int HasFieldsFireplace = StringExtensionMethods.GetStableHashCode("HasFieldsFireplace"); private static readonly int InfiniteFuel = StringExtensionMethods.GetStableHashCode("Fireplace.m_infiniteFuel"); private static readonly int HasFieldsSmelter = StringExtensionMethods.GetStableHashCode("HasFieldsSmelter"); private static readonly int SmelterMaxFuel = StringExtensionMethods.GetStableHashCode("Smelter.m_maxFuel"); private static readonly int HasFieldsCooking = StringExtensionMethods.GetStableHashCode("HasFieldsCookingStation"); private static readonly int CookingSecPerFuel = StringExtensionMethods.GetStableHashCode("CookingStation.m_secPerFuel"); private static readonly int HasFieldsShield = StringExtensionMethods.GetStableHashCode("HasFieldsShieldGenerator"); private static readonly int ShieldFuelPerDamage = StringExtensionMethods.GetStableHashCode("ShieldGenerator.m_fuelPerDamage"); private static readonly int CoverCheck = StringExtensionMethods.GetStableHashCode("Fireplace.m_disableCoverCheck"); private static readonly int TurnOff = StringExtensionMethods.GetStableHashCode("Fireplace.m_canTurnOff"); private const int FOREVER = int.MaxValue; private const float OVEN_FUEL = 0.99f; private static readonly int Mark = StringExtensionMethods.GetStableHashCode("everlit"); private const int ROUND_BUDGET = 2000; private const double ROUND_MS = 1.0; private const int ROUND_CHANGES = 25; private const float REPORT_MINUTES = 10f; private const float WARD_DELAY = 5f; private static Dictionary<int, FireType> types; private static HashSet<int> wanted; private static readonly HashSet<ZDOID> arrived = new HashSet<ZDOID>(); private static readonly List<ZDOID> work = new List<ZDOID>(); private static readonly Dictionary<ZDOID, float> fuelSeen = new Dictionary<ZDOID, float>(); private static readonly HashSet<ZDOID> stillBurning = new HashSet<ZDOID>(); private static readonly HashSet<ZDOID> known = new HashSet<ZDOID>(); private static readonly List<ZDOID> roundList = new List<ZDOID>(); private static float nextRound; private static float nextReport; private static bool running; private static bool wholeWorld; private static bool forceWorld; private static bool firstRound = true; private static int liveLit; private static int sector; private static int index; private static int slowestFrame; private static int gcs; private static bool slowestGc; private static bool again; private static int rLit; private static int rUnlit; private static int rKept; private static int rWorld; private static int rBurning; private static int rSwitched; private static readonly Dictionary<Kind, int> rKinds = new Dictionary<Kind, int>(); private static readonly Stopwatch clock = new Stopwatch(); private static double roundMs; private static double slowestMs; private static int roundFrames; private static Dictionary<int, float> wardTypes; private static readonly Dictionary<ZDOID, Ward> wards = new Dictionary<ZDOID, Ward>(); private static readonly HashSet<ZDOID> wardArrived = new HashSet<ZDOID>(); private static bool warded; private static bool wardsKnown; private static bool wardRound; private static float wardRoundAt; private static bool Active { get { if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer() && ZDOMan.instance != null) { return (Object)(object)ZNetScene.instance != (Object)null; } return false; } } public static void SettingsChanged() { wanted = null; if (!running) { nextRound = 0f; } else { again = true; } } public static void Update() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) if (!Active || (types == null && !Load())) { return; } if (wanted == null) { Want(); } clock.Restart(); gcs = GC.CollectionCount(0); if (wardArrived.Count > 0) { work.Clear(); work.AddRange(wardArrived); wardArrived.Clear(); foreach (ZDOID item in work) { ZDO zDO = ZDOMan.instance.GetZDO(item); if (zDO != null && wardTypes.TryGetValue(zDO.GetPrefab(), out var value)) { NoteWard(zDO, value); } } } if (wardRound && !running && Time.time >= wardRoundAt) { wardRound = false; nextRound = 0f; } if (arrived.Count > 0) { work.Clear(); work.AddRange(arrived); arrived.Clear(); foreach (ZDOID item2 in work) { if (Look(ZDOMan.instance.GetZDO(item2), live: true)) { liveLit++; } } } if (Time.time >= nextReport) { Report(); } if (!running && Time.time >= nextRound) { StartRound(); } if (running) { Round(); } } private static bool Load() { if (ZNetScene.instance.m_prefabs == null || ZNetScene.instance.m_prefabs.Count == 0) { return false; } types = new Dictionary<int, FireType>(); wardTypes = new Dictionary<int, float>(); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if (!Object.op_Implicit((Object)(object)prefab)) { continue; } PrivateArea component = prefab.GetComponent<PrivateArea>(); if ((Object)(object)component != (Object)null) { wardTypes[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = component.m_radius; continue; } ShieldGenerator component2 = prefab.GetComponent<ShieldGenerator>(); if ((Object)(object)component2 != (Object)null) { if (component2.m_fuelPerDamage > 0f && component2.m_fuelItems.Count > 0) { types[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = new FireType { Name = ((Object)prefab).name, Kind = Kind.Shield, Normal = component2.m_fuelPerDamage, Via = Via.ShieldGenerator }; } continue; } Smelter component3 = prefab.GetComponent<Smelter>(); if ((Object)(object)component3 != (Object)null) { if (component3.m_maxFuel > 0 && !((Object)(object)component3.m_fuelItem == (Object)null)) { string name = ((Object)((Component)component3.m_fuelItem).gameObject).name; Kind? kind = ((component3.m_maxOre == 0 && component3.m_conversion.Count == 0) ? new Kind?(Kind.HotTub) : ((name == "Coal") ? new Kind?(Kind.Furnace) : ((name == "Sap") ? new Kind?(Kind.Refinery) : ((((Object)prefab).name == "piece_FrostKiln") ? new Kind?(Kind.FrostKiln) : ((Kind?)null))))); if (kind.HasValue) { types[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = new FireType { Name = ((Object)prefab).name, Kind = kind.Value, Normal = component3.m_maxFuel, Via = Via.Smelter }; } } continue; } CookingStation component4 = prefab.GetComponent<CookingStation>(); if ((Object)(object)component4 != (Object)null) { if (component4.m_useFuel && !((Object)(object)component4.m_fuelItem == (Object)null) && component4.m_secPerFuel > 0) { Kind? kind2 = ((((Object)((Component)component4.m_fuelItem).gameObject).name == "Wood") ? new Kind?(Kind.Oven) : ((((Object)prefab).name == "piece_FrostFoundry") ? new Kind?(Kind.FrostFoundry) : ((Kind?)null))); if (kind2.HasValue) { types[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = new FireType { Name = ((Object)prefab).name, Kind = kind2.Value, Normal = component4.m_secPerFuel, Via = Via.CookingStation }; } } } else { Fireplace component5 = prefab.GetComponent<Fireplace>(); if (!((Object)(object)component5 == (Object)null) && !component5.m_infiniteFuel && !(component5.m_secPerFuel <= 0f) && !((Object)(object)component5.m_fuelItem == (Object)null)) { types[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = new FireType { Name = ((Object)prefab).name, Kind = KindOf(((Object)prefab).name), MaxFuel = component5.m_maxFuel, CoverOff = component5.m_disableCoverCheck, CanTurnOff = component5.m_canTurnOff }; } } } ZLog.Log((object)($"Everlit: {types.Count} kinds of fire and furnace: " + string.Join(", ", from t in types.Values orderby t.Kind select $"{t.Name} ({t.Kind})") + $"; {wardTypes.Count} kinds of ward")); Stopwatch stopwatch = Stopwatch.StartNew(); Warm(); ZLog.Log((object)$"Everlit: ready in {stopwatch.Elapsed.TotalMilliseconds:F1} ms; the world walk starts in a minute"); nextRound = Time.time + 60f; return true; } private static Kind KindOf(string name) { string text = name.ToLowerInvariant(); switch (text) { case "fire_pit": case "fire_pit_iron": return Kind.Campfire; case "bonfire": return Kind.Bonfire; case "hearth": return Kind.Hearth; default: if (text.Contains("torch") || text.Contains("jackoturnip") || text.Contains("lantern")) { return Kind.Torch; } if (text.Contains("brazier")) { return Kind.Brazier; } if (text.Contains("candle")) { return Kind.Candle; } return Kind.Other; } } private static void Want() { warded = Plugin.Enabled.Value && Plugin.WardedOnly.Value; if (!warded) { wards.Clear(); wardArrived.Clear(); wardsKnown = (wardRound = false); } HashSet<string> hashSet = new HashSet<string>(from s in Plugin.ExcludeFires.Value.Split(new char[1] { ',' }) select s.Trim().ToLowerInvariant() into s where s.Length > 0 select s); wanted = new HashSet<int>(); if (!Plugin.Enabled.Value) { return; } foreach (KeyValuePair<int, FireType> type in types) { if (!hashSet.Contains(type.Value.Name.ToLowerInvariant()) && type.Value.Kind switch { Kind.Campfire => Plugin.Campfires.Value, Kind.Bonfire => Plugin.Bonfires.Value, Kind.Hearth => Plugin.Hearths.Value, Kind.Torch => Plugin.Torches.Value, Kind.Brazier => Plugin.Braziers.Value, Kind.Candle => Plugin.Candles.Value, Kind.HotTub => Plugin.HotTubs.Value, Kind.Oven => Plugin.Ovens.Value, Kind.Refinery => Plugin.EitrRefinery.Value, Kind.FrostKiln => Plugin.FrostKiln.Value, Kind.FrostFoundry => Plugin.FrostFoundry.Value, Kind.Furnace => Plugin.Furnaces.Value, Kind.Shield => Plugin.ShieldGenerators.Value, _ => Plugin.OtherFires.Value, }) { wanted.Add(type.Key); } } } public static bool IsLit(ZDO zdo) { if (zdo.GetInt(Mark, 0) == 1) { if (!zdo.GetBool(InfiniteFuel, false) && zdo.GetInt(SmelterMaxFuel, -1) != 0 && zdo.GetInt(CookingSecPerFuel, 0) != int.MaxValue) { return zdo.GetFloat(ShieldFuelPerDamage, -1f) == 0f; } return true; } return false; } private static bool Look(ZDO zdo, bool live) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) if (zdo == null || !zdo.IsValid()) { return false; } int prefab = zdo.GetPrefab(); if (!types.TryGetValue(prefab, out var value)) { if (warded && wardTypes.TryGetValue(prefab, out var value2)) { NoteWard(zdo, value2); } return false; } known.Add(zdo.m_uid); if (warded && !wardsKnown) { return false; } bool flag = zdo.GetLong(ZDOVars.s_creator, 0L) != 0; bool flag2 = wanted.Contains(prefab) && (flag || !Plugin.PlayerBuiltOnly.Value) && (!warded || InWard(zdo.GetPosition())); bool flag3 = zdo.GetInt(Mark, 0) == 1; if (flag2 && !IsLit(zdo)) { zdo.Set(HasFields, true); zdo.Set(Mark, 1, false); if (value.Via == Via.Smelter) { zdo.Set(HasFieldsSmelter, true); zdo.Set(SmelterMaxFuel, 0, false); } else if (value.Via == Via.CookingStation) { zdo.Set(HasFieldsCooking, true); zdo.Set(CookingSecPerFuel, int.MaxValue, false); if (zdo.GetFloat(ZDOVars.s_fuel, 0f) < 0.99f) { zdo.Set(ZDOVars.s_fuel, 0.99f); } } else if (value.Via == Via.ShieldGenerator) { zdo.Set(HasFieldsShield, true); zdo.Set(ShieldFuelPerDamage, 0f); } else { zdo.Set(HasFieldsFireplace, true); zdo.Set(InfiniteFuel, true); zdo.Set(ZDOVars.s_fuel, value.MaxFuel); } Switches(zdo, value, lit: true); Win(zdo); rLit++; rKinds[value.Kind] = ((!rKinds.TryGetValue(value.Kind, out var value3)) ? 1 : (value3 + 1)); if (Plugin.LogEachFire.Value) { ZLog.Log((object)("Everlit: lit " + value.Name + " at " + Where(zdo) + (live ? " (just built)" : ""))); } return true; } if (!flag2 && flag3) { if (value.Via == Via.Smelter) { zdo.Set(SmelterMaxFuel, (int)value.Normal, false); } else if (value.Via == Via.CookingStation) { zdo.Set(CookingSecPerFuel, (int)value.Normal, false); } else if (value.Via == Via.ShieldGenerator) { zdo.Set(ShieldFuelPerDamage, value.Normal); } else { zdo.Set(InfiniteFuel, false); } Switches(zdo, value, lit: false); zdo.RemoveInt(Mark); Win(zdo); rUnlit++; if (Plugin.LogEachFire.Value) { ZLog.Log((object)("Everlit: put " + value.Name + " at " + Where(zdo) + " back to normal")); } return true; } if (flag2 && Switches(zdo, value, lit: true)) { Win(zdo); rSwitched++; return true; } if (flag2) { rKept++; rKinds[value.Kind] = ((!rKinds.TryGetValue(value.Kind, out var value4)) ? 1 : (value4 + 1)); float num = zdo.GetFloat(ZDOVars.s_fuel, 0f); if (fuelSeen.TryGetValue(zdo.m_uid, out var value5) && num < value5 - 0.0001f) { rBurning++; stillBurning.Add(zdo.m_uid); } fuelSeen[zdo.m_uid] = num; } else if (!flag) { rWorld++; } return false; } private static bool Switches(ZDO zdo, FireType type, bool lit) { if (type.Via != Via.Fireplace) { return false; } bool result = false; bool flag = (lit && Plugin.NoSmokeChoke.Value) || type.CoverOff; if (zdo.GetBool(CoverCheck, type.CoverOff) != flag) { zdo.Set(CoverCheck, flag); result = true; } bool flag2 = (lit && Plugin.PlayersCanTurnOff.Value) || type.CanTurnOff; if (zdo.GetBool(TurnOff, type.CanTurnOff) != flag2) { zdo.Set(TurnOff, flag2); if (!flag2 && zdo.GetInt(ZDOVars.s_state, 1) != 1) { zdo.Set(ZDOVars.s_state, 1, false); } result = true; } return result; } private static void NoteWard(ZDO zdo, float radius) { //IL_001b: 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) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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 (zdo.GetLong(ZDOVars.s_creator, 0L) == 0L) { return; } Ward value = new Ward { Pos = zdo.GetPosition(), Radius = radius, On = zdo.GetBool(ZDOVars.s_enabled, false) }; if (!wards.TryGetValue(zdo.m_uid, out var value2) || value2.On != value.On || !(value2.Pos == value.Pos)) { wards[zdo.m_uid] = value; if (wardsKnown) { WardChanged(); } } } private static void WardChanged() { wardRound = true; wardRoundAt = Time.time + 5f; } private static bool InWard(Vector3 p) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) foreach (Ward value in wards.Values) { if (value.On && Utils.DistanceXZ(value.Pos, p) < value.Radius) { return true; } } return false; } private static void Win(ZDO zdo) { zdo.DataRevision += 4; } private static void StartRound() { running = true; wholeWorld = firstRound || forceWorld || (warded && !wardsKnown); forceWorld = false; sector = 0; index = 0; roundList.Clear(); if (!wholeWorld) { roundList.AddRange(known); } rLit = (rUnlit = (rKept = (rWorld = (rBurning = (rSwitched = 0))))); rKinds.Clear(); roundMs = (slowestMs = 0.0); roundFrames = (slowestFrame = 0); slowestGc = false; } private static void Round() { //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = 0; int num3 = 0; bool flag; if (wholeWorld) { List<ZDO>[] objectsBySector = ZDOMan.instance.m_objectsBySector; while (sector < objectsBySector.Length && num < 2000 && num2 < 25 && ((++num3 & 7) != 0 || !(clock.Elapsed.TotalMilliseconds > 1.0))) { List<ZDO> list = objectsBySector[sector]; if (list == null || index >= list.Count) { sector++; index = 0; continue; } if (Look(list[index++], live: false)) { num2++; } num++; } flag = sector >= objectsBySector.Length; } else { while (index < roundList.Count && num < 2000 && num2 < 25 && ((++num3 & 7) != 0 || !(clock.Elapsed.TotalMilliseconds > 1.0))) { ZDOID val = roundList[index++]; ZDO zDO = ZDOMan.instance.GetZDO(val); if (zDO == null) { known.Remove(val); fuelSeen.Remove(val); continue; } if (Look(zDO, live: false)) { num2++; } num++; } flag = index >= roundList.Count; } double totalMilliseconds = clock.Elapsed.TotalMilliseconds; roundMs += totalMilliseconds; roundFrames++; if (totalMilliseconds > slowestMs) { slowestMs = totalMilliseconds; slowestFrame = roundFrames; slowestGc = GC.CollectionCount(0) != gcs; } if (!flag) { return; } running = false; nextRound = (again ? 0f : float.MaxValue); again = false; if (warded && !wardsKnown && wholeWorld) { wardsKnown = true; nextRound = 0f; ZLog.Log((object)$"Everlit: WardedOnly: {wards.Count} wards found, {wards.Values.Count((Ward w) => w.On)} switched on; walk took {roundMs:F1} ms over {roundFrames} frames"); return; } if (firstRound || rLit > 0 || rUnlit > 0 || rBurning > 0 || rSwitched > 0) { string text = ((rKinds.Count == 0) ? "" : (" (" + string.Join(", ", from k in rKinds orderby k.Key select $"{k.Value} {KindName(k.Key)}") + ")")); ZLog.Log((object)($"Everlit: {rKept + rLit} fires kept lit{text}; {rLit} newly lit, {rUnlit} put back to normal, " + ((rSwitched > 0) ? $"{rSwitched} lit fires' switches changed, " : "") + ((rBurning > 0) ? $"{rBurning} still using fuel in a player's game (until it next loads there), " : "") + string.Format("{0} of the world's own left alone; {1} took {2:F1} ms over {3} frames, slowest frame {4:F2} ms (#{5}{6})", rWorld, wholeWorld ? "whole world" : "known fires", roundMs, roundFrames, slowestMs, slowestFrame, slowestGc ? ", a garbage collection ran in it" : ""))); } firstRound = false; } private static void Report() { nextReport = Time.time + 600f; if (liveLit > 0 || stillBurning.Count > 0) { ZLog.Log((object)($"Everlit: last {10f:F0} min: {liveLit} fires lit as they were built" + ((stillBurning.Count > 0) ? $", {stillBurning.Count} lit fires still used fuel in a player's game (they stop once it next loads there)" : ""))); } liveLit = 0; stillBurning.Clear(); } private static void Warm() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) try { MethodInfo[] methods = typeof(Keeper).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!methodInfo.IsAbstract && !methodInfo.ContainsGenericParameters) { RuntimeHelpers.PrepareMethod(methodInfo.MethodHandle); } } methods = typeof(ZDO).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo2 in methods) { if ((methodInfo2.Name.StartsWith("Get") || methodInfo2.Name.StartsWith("Set") || methodInfo2.Name == "IsValid") && !methodInfo2.ContainsGenericParameters) { RuntimeHelpers.PrepareMethod(methodInfo2.MethodHandle); } } ZDOID val = default(ZDOID); ((ZDOID)(ref val))..ctor(1L, 1u); HashSet<ZDOID> hashSet = new HashSet<ZDOID> { val }; hashSet.Contains(val); hashSet.Remove(val); Dictionary<ZDOID, float> dictionary = new Dictionary<ZDOID, float>(); ZDOID key = val; dictionary[key] = 1f; dictionary.TryGetValue(val, out var _); dictionary.Remove(val); Dictionary<Kind, int> dictionary2 = new Dictionary<Kind, int>(); dictionary2[Kind.Torch] = 1; dictionary2.TryGetValue(Kind.Torch, out var _); List<ZDOID> list = new List<ZDOID>(); list.Add(val); list.AddRange(hashSet); Look(null, live: false); } catch { } } private static string KindName(Kind k) { return k switch { Kind.HotTub => "hot tub", Kind.Refinery => "eitr refinery", Kind.FrostKiln => "frost kiln", Kind.FrostFoundry => "frost foundry", Kind.Shield => "shield generator", _ => k.ToString().ToLowerInvariant(), }; } private static string Where(ZDO zdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Vector3 position = zdo.GetPosition(); return $"{position.x:F0}, {position.z:F0}"; } } [BepInPlugin("com.cocopuff2u.everlit", "Everlit", "1.1.1")] public class Plugin : BaseUnityPlugin { public const string GUID = "com.cocopuff2u.everlit"; public const string NAME = "Everlit"; public const string VERSION = "1.1.1"; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> PlayerBuiltOnly; internal static ConfigEntry<bool> WardedOnly; internal static ConfigEntry<bool> Campfires; internal static ConfigEntry<bool> Bonfires; internal static ConfigEntry<bool> Hearths; internal static ConfigEntry<bool> Torches; internal static ConfigEntry<bool> Braziers; internal static ConfigEntry<bool> Candles; internal static ConfigEntry<bool> OtherFires; internal static ConfigEntry<bool> HotTubs; internal static ConfigEntry<bool> Ovens; internal static ConfigEntry<bool> EitrRefinery; internal static ConfigEntry<bool> Furnaces; internal static ConfigEntry<bool> FrostKiln; internal static ConfigEntry<bool> FrostFoundry; internal static ConfigEntry<bool> ShieldGenerators; internal static ConfigEntry<bool> NoSmokeChoke; internal static ConfigEntry<bool> PlayersCanTurnOff; internal static ConfigEntry<string> ExcludeFires; internal static ConfigEntry<bool> LogEachFire; private FileSystemWatcher watcher; private volatile bool changed; private float reloadAt; private void Awake() { //IL_02a9: Unknown result type (might be due to invalid IL or missing references) Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Keep fires lit. Turning this off puts every fire Everlit lit back to normal (burning fuel) on the next round; do that and let a round run before removing the mod, or those fires stay lit for good"); PlayerBuiltOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayerBuiltOnly", true, "Only fires a player built. Off: the world's own fire pits too (abandoned camps, villages), which then light up and stay lit"); WardedOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "WardedOnly", false, "Only fires and stations inside a player's ward that's switched on. Ones outside stay normal; building, switching or tearing down a ward changes the fires around it a few seconds later"); Campfires = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Campfires", true, "Campfires and the iron fire pit"); Bonfires = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Bonfires", true, "Bonfires"); Hearths = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Hearths", true, "Hearths"); Torches = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Torches", true, "Standing and wall torches, jack-o-turnips and lanterns"); Braziers = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Braziers", true, "Standing and hanging braziers"); Candles = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Candles", true, "Resin candles"); OtherFires = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "OtherFires", true, "Any other fire that burns fuel, including ones added by other mods"); HotTubs = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "HotTubs", true, "Hot tubs stay hot without wood. Wood already in one stays there, and can't be added while this is on"); Ovens = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Ovens", true, "Stone ovens never run out of wood. An empty one is given just under one piece (tearing it down drops none)"); Furnaces = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "Furnaces", false, "Smelters and blast furnaces (and any modded furnace that burns coal) smelt without coal. Coal already in one stays there, and can't be added while this is on"); EitrRefinery = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "EitrRefinery", true, "The eitr refinery refines without sap. Sap already in one stays there, and can't be added while this is on"); FrostKiln = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "FrostKiln", false, "The frost kiln runs without ice. It takes nothing else in, so it makes frozen fuel out of nothing: a piece every 30 s while a player is near it, and up to an hour's worth at once when someone comes back"); FrostFoundry = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "FrostFoundry", false, "The frost foundry never runs out of frozen fuel. An empty one is given just under one piece (tearing it down drops none)"); ShieldGenerators = ((BaseUnityPlugin)this).Config.Bind<bool>("Fires", "ShieldGenerators", false, "Shield generators use up no fuel when their shield is hit, so the shield never breaks. It still needs fuel put in once to switch on, and its size still goes by how much is in it"); NoSmokeChoke = ((BaseUnityPlugin)this).Config.Bind<bool>("Lit fires", "NoSmokeChoke", false, "Lit fires don't go out when their smoke can't get away (indoors, under a roof), with something solid right above them, or partly buried. The smoke still fills the room and still hurts"); PlayersCanTurnOff = ((BaseUnityPlugin)this).Config.Bind<bool>("Lit fires", "PlayersCanTurnOff", false, "Players can turn lit fires off and on again by using them (no on-screen prompt: the game shows none on a fire that never runs out). The game's own rule for such fires: rain, or strong wind with little cover, turns one off, and it stays off until someone lights it again"); ExcludeFires = ((BaseUnityPlugin)this).Config.Bind<string>("Fires", "ExcludeFires", "", "Fires to leave alone, by prefab name, comma separated (e.g. \"piece_walltorch, bonfire\"). Wins over the switches above"); LogEachFire = ((BaseUnityPlugin)this).Config.Bind<bool>("Log", "LogEachFire", false, "A log line for every fire lit or put back to normal: what it is and where"); new Harmony("com.cocopuff2u.everlit").PatchAll(Assembly.GetExecutingAssembly()); WatchConfig(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Everlit 1.1.1 loaded"); } private void Update() { ReloadIfChanged(); Keeper.Update(); } private void WatchConfig() { try { watcher = new FileSystemWatcher(Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath), Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath)); watcher.Changed += delegate { changed = true; }; watcher.Created += delegate { changed = true; }; watcher.Renamed += delegate { changed = true; }; watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite; watcher.EnableRaisingEvents = true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Settings won't reload by themselves: " + ex.Message)); } } private void ReloadIfChanged() { if (changed) { changed = false; reloadAt = Time.time + 1f; } if (reloadAt == 0f || Time.time < reloadAt) { return; } reloadAt = 0f; try { bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; try { ((BaseUnityPlugin)this).Config.Reload(); } finally { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet; } Keeper.SettingsChanged(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Settings reloaded"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Settings not reloaded: " + ex.Message)); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }