Complete reference for all Simple Attribute Forge classes, methods, and interfaces.
SimpleRuntimeAttribute
The core runtime attribute class managing values, events, and regeneration.
Properties - Core Values
// Three-Tier Value System
public float baseValue { get; set; } // Persistent value (saved with character)
public float formulaBonus { get; set; } // Calculated by Ultimate's Influence System
public float modifierBonus { get; set; } // Temporary effects (buffs/debuffs)
public float totalValue { get; } // CALCULATED: base + formula + modifier
// For Vitals only
public float currentValue { get; set; } // Actual HP/MP within max bounds
Properties - Identity (Read Only)
public string attributeName { get; } // Display name
public string code { get; } // Short abbreviation for UI (HP, STR)
public string enumName { get; } // Type-safe identifier
public string description { get; } // Purpose description
public SimpleBehaviorType behaviorType { get; } // Basic/Vital/Resource/Percentage
public bool forceInteger { get; } // Round to whole numbers
public float minValue { get; } // Minimum boundary
public float maxValue { get; } // Maximum boundary
Properties - Modifiable at Runtime
// Visual
public Sprite icon { get; set; } // UI icon (for status effects)
// Regeneration (Vitals only)
public bool canRegenerate { get; set; } // Enable auto-recovery
public float regenerationRate { get; set; } // Recovery per second
public float regenerationDelay { get; set; } // Cooldown before regen starts
public bool IsRegenerating { get; } // Current regen state
Core Methods
// Value Modification (CRITICAL DISTINCTION)
void ModifyValue(float amount) // Gameplay changes - FIRES regeneration
void SetValue(float value) // Admin/loading - NO regeneration
// Quick Actions
void FillToMax() // Set to maximum value
void EmptyToMin() // Set to minimum value
// Value Access
float GetCurrentValue() // Current display value
float GetMaxValue() // Maximum possible value
int GetIntValue() // Integer version
float GetFloatValue() // Exact float value
string GetDisplayValue() // Formatted string
// State Queries
float GetPercentage() // 0.0 to 1.0 percentage
bool IsAtMax() // At maximum value
bool IsAtMin() // At minimum value
bool IsEmpty() // Convenience for IsAtMin()
bool IsFull() // Convenience for IsAtMax()
float GetMissingValue() // Deficit from maximum
// UI Optimization
bool IsDirty { get; } // Value changed since last update
void ClearDirtyFlag() // Clear after UI update
// Validation
void ValidateAndFixConfiguration() // Auto-fix invalid values
bool ValidateConfiguration(out string error) // Detailed validation
Events
// Value Events
System.Action OnValueChanged // Any value change
System.Action OnMaxValueChanged // Max value changed
System.Action<SimpleRuntimeAttribute, float, float> OnBaseValueChanged // For formulas
// Boundary Events
System.Action OnReachedZero // Hit minimum/zero
System.Action OnReachedMax // Hit maximum
// Regeneration Events (Used by coroutine system)
System.Action<bool> OnRegenerationStateChanged
System.Action<SimpleRuntimeAttribute> OnShouldStartRegeneration
System.Action<SimpleRuntimeAttribute> OnShouldStopRegeneration
Critical: Always use totalValue for gameplay logic (damage calculations, etc.). Use baseValue only for save/load and formula inputs.
ISimpleAttributeDataSource Interface
Required interface for all generated attribute containers.
Generated components provide aggregate events for all attributes.
// Component-level events (on generated component)
public event System.Action<string, float> OnAnyAttributeChanged;
public event System.Action<string> OnAnyAttributeDepleted;
public event System.Action<string> OnAnyAttributeMaxed;
// Usage example
void Start()
{
var attributes = GetComponent<CharacterAttributes>();
attributes.OnAnyAttributeChanged += OnAttributeChanged;
attributes.OnAnyAttributeDepleted += OnAttributeDepleted;
}
void OnAttributeChanged(string attributeName, float newValue)
{
Debug.Log($"{attributeName} changed to {newValue}");
UpdateUI(attributeName, newValue);
}
void OnAttributeDepleted(string attributeName)
{
if (attributeName == "Health")
{
HandleDeath();
}
}
Extension Methods
Convenience methods for working with attribute systems.
// MonoBehaviour extensions
public static class SimpleAttributeSystemExtensions
{
// Find attribute system on GameObject
public static MonoBehaviour FindAttributeSystem(this GameObject gameObject);
// Get runtime attribute (works with old and new systems)
public static SimpleRuntimeAttribute GetRuntimeAttribute(
this MonoBehaviour component, string attributeName);
// Get all runtime attributes
public static Dictionary<string, SimpleRuntimeAttribute> GetAllRuntimeAttributes(
this MonoBehaviour component);
// Check if component is attribute system
public static bool IsAttributeSystem(this MonoBehaviour component);
// Convenience value access
public static float GetAttributeValue(
this MonoBehaviour component, string attributeName, float defaultValue = 0f);
// Set attribute value
public static bool SetAttributeValue(
this MonoBehaviour component, string attributeName, float value);
}
// Usage examples
var health = gameObject.GetRuntimeAttribute("Health");
float healthValue = gameObject.GetAttributeValue("Health", 100f);
bool success = gameObject.SetAttributeValue("Health", 50f);
Regeneration System API
Automatic coroutine-based regeneration for Vital attributes.
Configuration
// Enable/configure regeneration
health.canRegenerate = true;
health.regenerationRate = 5f; // 5 HP per second
health.regenerationDelay = 3f; // 3 second delay after damage
// Check regeneration state
bool isRegenerating = health.IsRegenerating;
Generated Component Methods
// Context menu methods (for testing)
[ContextMenu("Debug Active Regeneration")]
private void DebugActiveRegeneration() // Shows active regen coroutines
[ContextMenu("Log All Attributes")]
public void LogAllAttributes() // Detailed attribute state
// Runtime testing
public void SetAttributeValue() // Uses inspector test values
Key Insight: Regeneration is completely automatic. Use ModifyValue() for gameplay damage and the system handles regeneration automatically.
Usage Patterns
Reading Values for Gameplay
// CORRECT - Use totalValue for gameplay
float damage = strength.totalValue * weaponDamage;
float defense = armor.totalValue;
bool canCast = mana.currentValue >= spellCost;
// WRONG - Don't use baseValue for gameplay
float damage = strength.baseValue * weaponDamage; // Missing bonuses!
Modifying Values
// Gameplay changes (triggers regeneration)
health.ModifyValue(-damage); // Take damage
mana.ModifyValue(-spellCost); // Cast spell
strength.baseValue += 2; // Permanent upgrade
// Administrative changes (no regeneration)
health.SetValue(100f); // Load save data
health.FillToMax(); // Admin heal
Working with Formulas (Ultimate Only)
// Formulas automatically manage formulaBonus (requires Ultimate's Influence System)
// DO NOT modify formulaBonus manually
// Let the Influence System handle it
var orchestrator = GetComponent<InfluenceSystem>();
orchestrator.RecalculateAll();
// Modify base values, formulas update automatically
strength.baseValue += 5; // Formulas using STR will recalculate