View Format: Multi-Page Single Page
All Docs Documentation Version: Base (Free) Influence System Modifier System

API Reference

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.

public interface ISimpleAttributeDataSource { // Runtime attribute access SimpleRuntimeAttribute GetRuntimeAttribute(string attributeName); SimpleRuntimeAttribute GetRuntimeAttribute(System.Enum attributeEnum); Dictionary<string, SimpleRuntimeAttribute> GetAllRuntimeAttributes(); // Definition access SimpleAttributeValue[] GetAttributeDefinitions(); string[] GetAttributeNames(); SimpleAttributeValue? GetAttributeByName(string name); int AttributeCount { get; } bool HasAttribute(string name); System.Type GetAttributeEnumType(); }

Generated Component Methods

// Generated convenience methods public SimpleRuntimeAttribute GetAttribute(string attributeName); public bool ModifyAttribute(string attributeName, float amount); public bool SetAttribute(string attributeName, float value); // Type-safe enum access public Dictionary<YourAttributeEnum, SimpleRuntimeAttribute> GetAllAttributesByEnum(); public SimpleRuntimeAttribute GetAttributeByEnum<T>(T enumValue) where T : System.Enum; // Performance helpers public List<SimpleRuntimeAttribute> GetAllAttributeInstances(); Dictionary<string, SimpleRuntimeAttribute> GetAllAttributes(); // Cached lookup

Behavior Types

Each attribute has a behavior type that determines its features and limitations.

Basic

Simple numeric values like STR, INT, DEX. No current/max separation, no regeneration.

// Basic attribute usage float damage = strength.totalValue * 2f; strength.baseValue += 5; // Permanent upgrade

Vital

Has current and max values with regeneration support. Examples: Health, Mana, Stamina.

// Vital attribute usage health.ModifyValue(-30f); // Take damage float healthPercent = health.GetPercentage(); uiText.text = $"{health.currentValue}/{health.totalValue}";

Resource

Currency or countable items. Forced integer values, no regeneration. Examples: Gold, Experience.

// Resource attribute usage gold.ModifyValue(100f); // Add gold int totalGold = gold.GetIntValue();

Percentage

Values representing rates or chances. Typically 0-100 range. Examples: Critical Chance, Block Rate.

// Percentage attribute usage float critChance = criticalChance.totalValue; if (Random.Range(0f, 100f) < critChance) { // Critical hit! }

Component-Level Events

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

UI Display Patterns

// Vital attributes (HP/MP) if (attr.behaviorType == SimpleBehaviorType.Vital) { healthText.text = $"{attr.currentValue:F0}/{attr.totalValue:F0}"; healthBar.fillAmount = attr.GetPercentage(); } else { // Basic/Resource/Percentage attributes statText.text = attr.GetDisplayValue(); } // Show bonus breakdown if (attr.formulaBonus != 0 || attr.modifierBonus != 0) { tooltipText = $"{attr.baseValue:F1}"; if (attr.formulaBonus != 0) tooltipText += $" +{attr.formulaBonus:F1} (formulas)"; if (attr.modifierBonus != 0) tooltipText += $" +{attr.modifierBonus:F1} (effects)"; tooltipText += $" = {attr.totalValue:F1}"; }