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 FeelingCozy v1.1.0
FeelingCozy.dll
Decompiled 3 weeks agousing 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 HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; 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: AssemblyVersion("0.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 FeelingCozy { [BepInPlugin("biznessman.feelingcozy", "FeelingCozy", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class FeelingCozyPlugin : BaseUnityPlugin { public const string PluginGuid = "biznessman.feelingcozy"; public const string PluginName = "FeelingCozy"; public const string PluginVersion = "1.1.0"; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<int> Mode; internal static ConfigEntry<int> MinComfort; private void Awake() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, new ConfigDescription("Turn the mod on or off.", (AcceptableValueBase)null, new object[1] { val })); Mode = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DegradationMode", 0, new ConfigDescription("How food behaves while you rest in your base:\n0 = Frozen: food timer and buffs stop completely.\n1 = Slow: food lasts twice as long.\n2 = Scaled: more comfort = slower decay (1/2 rate at 10 comfort, 1/3 at 15, 1/4 at 20+). Ignores MinimumComfort.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), new object[1] { val })); MinComfort = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MinimumComfort", 10, new ConfigDescription("Comfort level needed for modes 0 and 1 to apply. Not used in mode 2.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 25), new object[1] { val })); new Harmony("biznessman.feelingcozy").PatchAll(); } internal static float GetDecayRate(int comfort) { switch (Mode.Value) { case 0: if (comfort < MinComfort.Value) { return 1f; } return 0f; case 1: if (comfort < MinComfort.Value) { return 1f; } return 0.5f; case 2: if (comfort >= 20) { return 0.25f; } if (comfort >= 15) { return 1f / 3f; } if (comfort >= 10) { return 0.5f; } return 1f; default: return 1f; } } } internal class FoodState { public Food Food; public float Time; } internal class FreezeState { public float Rate; public List<FoodState> Foods; } [HarmonyPatch(typeof(Player), "UpdateFood")] internal static class UpdateFoodPatch { private static readonly FieldRef<Player, List<Food>> FoodsRef = AccessTools.FieldRefAccess<Player, List<Food>>("m_foods"); private static float GetRate(Player player) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!FeelingCozyPlugin.Enabled.Value) { return 1f; } if ((Object)(object)player != (Object)(object)Player.m_localPlayer) { return 1f; } if (!Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(((Component)player).transform.position, (Type)4, 0f))) { return 1f; } return FeelingCozyPlugin.GetDecayRate(player.GetComfortLevel()); } private static void Prefix(Player __instance, out FreezeState __state) { __state = null; float rate = GetRate(__instance); if (rate >= 1f) { return; } List<Food> list = FoodsRef.Invoke(__instance); __state = new FreezeState { Rate = rate, Foods = new List<FoodState>(list.Count) }; foreach (Food item in list) { __state.Foods.Add(new FoodState { Food = item, Time = item.m_time }); } } private static void Postfix(Player __instance, FreezeState __state) { if (__state == null) { return; } List<Food> list = FoodsRef.Invoke(__instance); foreach (FoodState food in __state.Foods) { bool flag = list.Contains(food.Food); float num = (flag ? (food.Time - food.Food.m_time) : 1f); float num2 = food.Time - num * __state.Rate; if (!(num2 <= 0f)) { food.Food.m_time = num2; if (!flag) { list.Add(food.Food); } } } } } }