using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("MeditationPlus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MeditationPlus")]
[assembly: AssemblyTitle("MeditationPlus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Meditation;
[BepInPlugin("com.github.system233.meditation", "MeditationPlus", "1.0.0")]
public class MeditationPlus : BaseUnityPlugin
{
public static ConfigEntry<bool> EnableBurntSitRegen;
public static ConfigEntry<bool> EnableCurrentSitRegen;
public static ConfigEntry<float> BurntStaminaRegen;
public static ConfigEntry<float> BurntHealthRegen;
public static ConfigEntry<float> BurntManaRegen;
public static ConfigEntry<float> CurrentStaminaRegen;
public static ConfigEntry<float> CurrentHealthRegen;
public static ConfigEntry<float> CurrentManaRegen;
public static ConfigEntry<bool> EnableSitting;
private static ManualLogSource logger;
private static readonly Harmony harmony = new Harmony("com.github.system233.meditation");
private void Awake()
{
EnableBurntSitRegen = ((BaseUnityPlugin)this).Config.Bind<bool>("Burnt Stat Regen", "EnableBurntSitRegen", true, "Enable or disable the regeneration of burnt stats while sitting");
EnableCurrentSitRegen = ((BaseUnityPlugin)this).Config.Bind<bool>("Current Stat Regen", "EnableCurrentSitRegen", true, "Enable or disable the regeneration of current(non-burnt) stats while sitting");
BurntStaminaRegen = ((BaseUnityPlugin)this).Config.Bind<float>("Burnt Stat Regen", "BurntStaminaRegen", 0.5f, "How quickly burnt stamina will regen while siting. Default: 0.5f");
BurntHealthRegen = ((BaseUnityPlugin)this).Config.Bind<float>("Burnt Stat Regen", "BurntHealthRegen", 0.5f, "How quickly burnt health will regen while siting. Default: 0.5f");
BurntManaRegen = ((BaseUnityPlugin)this).Config.Bind<float>("Burnt Stat Regen", "BurntManaRegen", 0.5f, "How quickly burnt Mana will regen while siting. Default: 0.5f");
CurrentStaminaRegen = ((BaseUnityPlugin)this).Config.Bind<float>("Current Stat Regen", "CurrentStaminaRegen", 1f, "How quickly stamina will regen while siting. Default: 1.0f");
CurrentHealthRegen = ((BaseUnityPlugin)this).Config.Bind<float>("Current Stat Regen", "CurrentHealthRegen", 1f, "How quickly health will regen while siting. Default: 1.0f");
CurrentManaRegen = ((BaseUnityPlugin)this).Config.Bind<float>("Current Stat Regen", "CurrentManaRegen", 1f, "How quickly mana will regen while siting. Default: 1.0f");
EnableSitting = ((BaseUnityPlugin)this).Config.Bind<bool>("Sitting", "EnableSitting", true, "Ability to toggle sitting from this mod if you prefer another mods implimentation. Default: true");
logger = Logger.CreateLogSource("MeditationPlus");
harmony.PatchAll();
logger.LogInfo((object)"loaded");
}
public static void LogInfo(params object[] args)
{
ManualLogSource val = logger;
if (val != null)
{
val.LogDebug((object)string.Join(",", args));
}
}
}
[HarmonyPatch(typeof(PlayerCharacterStats), "OnUpdateStats")]
internal class Patch_PlayerCharacterStats_OnUpdateStats
{
private static bool Prefix(PlayerCharacterStats __instance)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
if ((int)((CharacterStats)__instance).m_character.CurrentSpellCast == 41)
{
if (MeditationPlus.EnableBurntSitRegen.Value)
{
((CharacterStats)__instance).m_burntStamina = Mathf.Clamp(((CharacterStats)__instance).m_burntStamina - MeditationPlus.BurntStaminaRegen.Value, 0f, ((CharacterStats)__instance).MaxStamina);
((CharacterStats)__instance).m_burntHealth = Mathf.Clamp(((CharacterStats)__instance).m_burntHealth - MeditationPlus.BurntHealthRegen.Value, 0f, ((CharacterStats)__instance).MaxHealth);
((CharacterStats)__instance).m_burntMana = Mathf.Clamp(((CharacterStats)__instance).m_burntMana - MeditationPlus.BurntManaRegen.Value, 0f, ((CharacterStats)__instance).MaxMana);
}
if (MeditationPlus.EnableCurrentSitRegen.Value)
{
((CharacterStats)__instance).m_stamina = Mathf.Clamp(((CharacterStats)__instance).m_stamina + MeditationPlus.CurrentStaminaRegen.Value, 0f, ((CharacterStats)__instance).ActiveMaxStamina);
((CharacterStats)__instance).m_health = Mathf.Clamp(((CharacterStats)__instance).m_health + MeditationPlus.CurrentHealthRegen.Value, 0f, ((CharacterStats)__instance).ActiveMaxHealth);
((CharacterStats)__instance).m_mana = Mathf.Clamp(((CharacterStats)__instance).m_mana + MeditationPlus.CurrentManaRegen.Value, 0f, ((CharacterStats)__instance).ActiveMaxMana);
}
}
return true;
}
}
[HarmonyPatch(typeof(ControlsInput), "Sheathe")]
internal class Patch_ControlsInput_Sheathe
{
private static void Postfix(ref bool __result, object[] __args)
{
int key = (int)__args[0];
RewiredInputs val = ControlsInput.m_playerInputManager[key];
string gameplayActionName = ControlsInput.GetGameplayActionName((GameplayActions)9);
__result = val.GetButtonUpQuick(gameplayActionName, 0.5f);
}
}
[HarmonyPatch(typeof(LocalCharacterControl), "UpdateInteraction")]
internal class Patch_LocalCharacterControl_UpdateInteraction
{
private static void Postfix(LocalCharacterControl __instance)
{
if (!MeditationPlus.EnableSitting.Value || ((CharacterControl)__instance).InputLocked || ((CharacterControl)__instance).Character.CharacterUI.ChatPanel.IsChatFocused)
{
return;
}
int playerID = ((CharacterControl)__instance).Character.OwnerPlayerSys.PlayerID;
if (!ControlsInput.QuickSlotToggle1(playerID) && !ControlsInput.QuickSlotToggle1(playerID))
{
RewiredInputs obj = ControlsInput.m_playerInputManager[playerID];
string gameplayActionName = ControlsInput.GetGameplayActionName((GameplayActions)9);
if (obj.m_rewiredPlayer.GetButtonLongPress(gameplayActionName))
{
((CharacterControl)__instance).Character.CastSpell((SpellCastType)41, ((Component)((CharacterControl)__instance).Character).gameObject, (SpellCastModifier)0, 1, -1f);
}
}
}
}