using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ValheimStaminaMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ValheimStaminaMod")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eac38915-81db-462a-ba70-9778430bc51d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ValheimCombatStamina;
[BepInPlugin("com.SeninNickin.SplitStamina", "Ayrik Stamina Modu", "1.7.0")]
[BepInProcess("valheim.exe")]
public class SplitStaminaMod : BaseUnityPlugin
{
[HarmonyPatch(typeof(Player), "UseStamina")]
public static class StaminaLogicPatch
{
private static bool Prefix(Player __instance, ref float v)
{
if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
{
return true;
}
bool flag = ((Humanoid)__instance).GetAttackDrawPercentage() > 0f;
bool flag2 = ((Character)__instance).InAttack();
if (flag2 || flag)
{
if (AttackStamina >= v)
{
AttackStamina -= v;
v = 0f;
}
else if (AttackStamina > 0f)
{
v -= AttackStamina;
AttackStamina = 0f;
}
}
else
{
float stamina = __instance.GetStamina();
if (stamina < 2f && AttackStamina > 5f)
{
((Character)__instance).AddStamina(v);
AttackStamina -= v * YedekDepoCezaCarpani;
if (AttackStamina < 0f)
{
AttackStamina = 0f;
}
}
}
return true;
}
}
public static float AttackStamina = 100f;
public static float MaxAttackStamina = 100f;
public static float AttackStaminaRegen = 12f;
public static float YedekDepoCezaCarpani = 3f;
private readonly Harmony _harmony = new Harmony("com.SeninNickin.SplitStamina");
private void Awake()
{
_harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"v1.8.0 Hibrit Sistem (Tasma Mantigi) Hazir!");
}
private void Update()
{
if (!((Object)(object)Player.m_localPlayer != (Object)null))
{
return;
}
float maxStamina = ((Character)Player.m_localPlayer).GetMaxStamina();
MaxAttackStamina = maxStamina * 0.8f;
bool flag = ((Humanoid)Player.m_localPlayer).GetAttackDrawPercentage() > 0f;
if (!((Character)Player.m_localPlayer).InAttack() && !flag)
{
if (AttackStamina < MaxAttackStamina)
{
AttackStamina += AttackStaminaRegen * Time.deltaTime;
}
if (AttackStamina > MaxAttackStamina)
{
AttackStamina = MaxAttackStamina;
}
}
}
private void OnGUI()
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Expected O, but got Unknown
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_0346: Unknown result type (might be due to invalid IL or missing references)
//IL_0361: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_037f: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Player.m_localPlayer == (Object)null || ((Character)Player.m_localPlayer).IsDead() || AttackStamina >= MaxAttackStamina - 0.5f)
{
return;
}
float num = 190f;
float num2 = 16f;
float num3 = (float)Screen.width / 2f - num / 2f;
float num4 = (float)Screen.height - 190f;
GUI.color = new Color(0f, 0f, 0f, 0.4f);
GUI.DrawTexture(new Rect(num3 - 3f, num4 - 3f, num + 6f, num2 + 6f), (Texture)(object)Texture2D.whiteTexture);
GUI.color = new Color(0.15f, 0.15f, 0.15f, 0.9f);
GUI.DrawTexture(new Rect(num3 - 1f, num4 - 1f, num + 2f, num2 + 2f), (Texture)(object)Texture2D.whiteTexture);
float num5 = Mathf.Clamp(AttackStamina, 0f, MaxAttackStamina);
float num6 = num5 / MaxAttackStamina;
float num7 = num * num6;
Color color = ((num5 < MaxAttackStamina * 0.2f) ? new Color(0.8f, 0.3f, 0.3f, 1f) : new Color(0.4f, 0.75f, 0.4f, 1f));
GUI.color = color;
GUI.DrawTexture(new Rect(num3, num4, num7, num2), (Texture)(object)Texture2D.whiteTexture);
GUI.color = new Color(1f, 1f, 1f, 0.15f);
GUI.DrawTexture(new Rect(num3, num4, num7, num2 / 2f), (Texture)(object)Texture2D.whiteTexture);
GUI.color = new Color(0f, 0f, 0f, 0.1f);
GUI.DrawTexture(new Rect(num3, num4 + num2 / 2f, num7, num2 / 2f), (Texture)(object)Texture2D.whiteTexture);
GUI.color = new Color(0f, 0f, 0f, 0.5f);
int num8 = 25;
int num9 = (int)(MaxAttackStamina / (float)num8);
float num10 = num / 2f - 20f;
float num11 = num / 2f + 20f;
for (int i = 1; i <= num9; i++)
{
float num12 = num / MaxAttackStamina * (float)(i * num8);
if (num12 < num7 && (num12 < num10 || num12 > num11))
{
GUI.DrawTexture(new Rect(num3 + num12, num4, 2f, num2), (Texture)(object)Texture2D.whiteTexture);
}
}
GUI.color = Color.white;
GUIStyle val = new GUIStyle();
val.alignment = (TextAnchor)4;
val.fontSize = 13;
val.fontStyle = (FontStyle)1;
val.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
string text = Mathf.Floor(Mathf.Max(0f, AttackStamina)).ToString();
GUI.contentColor = new Color(0f, 0f, 0f, 0.8f);
GUI.Label(new Rect(num3 + 1f, num4 + 1f, num, num2), text, val);
GUI.contentColor = Color.white;
GUI.Label(new Rect(num3, num4, num, num2), text, val);
}
}