A downloadable tool

"A modular stamina framework designed for action gating and scalable RPG combat systems."

Overview

This system implements an integer stamina resource that governs player actions such as heavy attacks and charged abilities. It includes delayed regeneration, fractional buffering for smooth regen behavior, and safe clamping to avoid overflow.

The goal was to create a modular, reusable resource system that could support multiple gameplay actions without duplicating logic across classes.

Key Points

• Integer stamina with float-based regeneration buffering
• Regeneration delay after resource consumption
• Centralized SpendStamina() validation method
• Clamp-to-max safety
• Action gating (validate → consume → execute)
• Designed for inheritance (Character → PlayerCharacter → Elf)


Architecture Overview

Character (base class)
→ staminaNow / staminaMax
→ regenDelay logic
→ SpendStamina(float amount)
→ Regen tick (Update)

PlayerCharacter : Character
→ movement + common player logic

Elf : PlayerCharacter
→ charged attack → validate stamina → SpendStamina() → execute action


Execution Pattern – Resource Gated Action

VALIDATE → CONSUME → EXECUTE

“Camera/input cleanup omitted for clarity.”

View full implementation → Elf.cs

https://github.com/VelardLugossian/gameplay-systems-portfolio/blob/main/src/Elf.cs

-----------------------------------------------------------

Core Resource Logic (Base Character)

SPEND → START DELAY → REGEN (buffered) → CLAMP

"Stamina is stored as an integer, while regeneration is continuous (float/sec).

To preserve smooth regeneration without losing precision, a fractional buffer accumulates over time and converts to whole stamina points."

View full implementation → Character.cs

https://github.com/VelardLugossian/gameplay-systems-portfolio/blob/main/src/Character.cs


*      *      *

Go back →Gameplay Systems Portfolio – Velard (Main)

https://velard.itch.io/portfolio-gameplay