Please disclose if your mod was created primarily 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 InstantComfort v0.0.1
InstantComfort.dll
Decompiled 6 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("InstantComfort")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InstantComfort")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6613e5c7-f491-46ab-9870-f1743bbc530f")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace InstantComfort; [BepInPlugin("mtsukn.InstantComfort", "InstantComfort", "0.0.1")] public class Main : BaseUnityPlugin { private const string pluginGUID = "mtsukn.InstantComfort"; private const string pluginName = "InstantComfort"; private const string pluginVersion = "0.0.1"; private readonly Harmony HarmonyInstance = new Harmony("mtsukn.InstantComfort"); public static ManualLogSource logger = Logger.CreateLogSource("InstantComfort"); public static ConfigEntry<float> restTimeCampfire { get; private set; } public static ConfigEntry<float> restTimeShelter { get; private set; } public static ConfigEntry<bool> ignoreAlerted { get; private set; } public void Awake() { restTimeCampfire = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Rest time (campfire)", 6.7f, "Seconds that Resting takes to apply Rested while sitting at a campfire (vanilla=20)"); restTimeShelter = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Rest time (shelter)", 0f, "Seconds that Resting takes to apply Rested while under shelter (vanilla=20)"); ignoreAlerted = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Ignore alerted", true, "Enables resting while alerted by enemies"); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); } public static float getRestTime() { if (Player.m_localPlayer.InShelter()) { return restTimeShelter.Value; } return restTimeCampfire.Value; } public static bool getSensed() { if (ignoreAlerted.Value) { return false; } return Player.m_localPlayer.IsSensed(); } } public class InstantComfort : BaseUnityPlugin { [HarmonyPatch(typeof(Player))] [HarmonyPatch("UpdateEnvStatusEffects")] public static class Player_UpdateEnvStatusEffects_Patch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Call && list[i].operand.ToString() == "Boolean IsSensed()") { list.Insert(i + 2, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Main), "getSensed", (Type[])null, (Type[])null))); list.Insert(i + 3, new CodeInstruction(OpCodes.Stloc_S, (object)7)); break; } } return list.AsEnumerable(); } } [HarmonyPatch(typeof(SE_Cozy))] [HarmonyPatch("UpdateStatusEffect")] public static class SE_Cozy_StatusEffects_Patch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldarg_0 && list[i + 1].opcode == OpCodes.Ldfld && list[i + 1].operand.ToString() == "System.Single m_delay") { list[i + 1] = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Main), "getRestTime", (Type[])null, (Type[])null)); list.RemoveAt(i); break; } } return list.AsEnumerable(); } } public void Awake() { } }