using System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace NoSleepManaBurn; [BepInPlugin("com.spencer4792.nosleepmanaburn", "NoSleepManaBurn", "1.0.4")] public class NoSleepManaBurnPlugin : BaseUnityPlugin { public const string GUID = "com.spencer4792.nosleepmanaburn"; public const string NAME = "NoSleepManaBurn"; public const string VERSION = "1.0.4"; internal static ManualLogSource Log; internal static ConfigEntry BurnMultiplier; internal void Awake() { Log = ((BaseUnityPlugin)this).Logger; try { Init(); } catch (Exception ex) { Log.LogError((object)("Startup failed: " + ex)); } } [MethodImpl(MethodImplOptions.NoInlining)] private void Init() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) BurnMultiplier = ((BaseUnityPlugin)this).Config.Bind("General", "ManaBurnMultiplier", 0f, "Scales the mana burnt by sleeping. 0 = sleeping burns no mana (default), 0.5 = half of vanilla, 1 = vanilla behavior. Applies after tents, skills and camping events have already reduced the vanilla amount. Range 0-1."); new Harmony("com.spencer4792.nosleepmanaburn").PatchAll(typeof(SleepManaBurnScaler)); Log.LogMessage((object)"NoSleepManaBurn 1.0.4 ready."); } } [HarmonyPatch(typeof(CharacterResting), "GetPostRestBurntManaRatio")] internal static class SleepManaBurnScaler { [HarmonyPostfix] private static void Postfix(ref float __result) { try { float num = NoSleepManaBurnPlugin.BurnMultiplier.Value; if (num < 0f) { num = 0f; } else if (num > 1f) { num = 1f; } __result *= num; } catch (Exception ex) { NoSleepManaBurnPlugin.Log.LogError((object)("Postfix: " + ex)); } } }