Configuring and optimizing the generated orchestrator component
Initial Setup Process
Adding Orchestrator to GameObject
1Locate Your GameObject
Find the GameObject that contains your attribute system component (e.g., CharacterAttributes).
2Add Orchestrator Component
Select the GameObject
Click Add Component
Search for your generated orchestrator (e.g., "CharacterInfluence")
Add the component
3Configure References
Required Configuration:
• Attribute System: Assign your attribute component (CharacterAttributes)
• Formulas: Should auto-populate with generated formula assets
Auto-Detection: The orchestrator automatically finds and assigns formula assets from the generated folder.
Inspector Configuration
System Configuration Section
Attribute System: Reference to your ISimpleAttributeDataSource component
Formulas: List of FormulaAsset ScriptableObjects
The Formulas list shows all assigned formula assets:
Formula List Display:
StrengthDamage (Order: 0, Enabled)
LevelHealth (Order: 0, Enabled)
IntelligenceMana (Order: 1, Enabled)
MissingFormula (Missing asset reference)
Each formula shows:
• Execution order
• Enabled/disabled status
• Validation state
Performance Tuning
Update Mode Selection
Smart Mode (Recommended)
Best for: Real-time games, action RPGs
Automatic recalculation when attributes change
Zero overhead when values are stable
Immediate response to value changes
Interval Mode
Best for: High-frequency changes, performance-critical scenarios
Fixed-time recalculation intervals
Predictable performance cost
Batches multiple changes together
Manual Mode
Best for: Turn-based games, explicit control
Only recalculates when explicitly called
Maximum performance (no automatic updates)
Perfect for turn-based mechanics
Caching Configuration
Enable Caching: true
• Caches attribute references for faster lookup
• Reduces GetComponent calls during calculations
• Automatically refreshes when attribute system changes
• Small memory cost for significant performance gain
Recommended: Enable for systems with 5+ formulas
Performance Monitoring
Debug Mode Features:
• Calculation timing logs
• Formula execution order tracking
• Dependency resolution monitoring
• Performance bottleneck identification
Enable temporarily to profile your formula system performance.
Integration Patterns
Standard Integration
// Most common setup
GameObject: Player
├── CharacterAttributes (Base System)
│ ├── health, mana, strength, etc.
│ └── Implements ISimpleAttributeDataSource
└── CharacterInfluence (Pro System)
├── attributeSystem → CharacterAttributes
└── formulas → Auto-assigned formula assets
Multiple Character Types
// Different orchestrators for different entity types
PlayerCharacter:
├── PlayerAttributes + PlayerInfluence
EnemyCharacter:
├── EnemyAttributes + EnemyInfluence
NPCCharacter:
├── NPCAttributes + NPCInfluence
Each type can have specialized formula sets.
Shared Formula Systems
// Multiple GameObjects using same formula assets
GameManager:
├── GlobalInfluence (manages shared formulas)
└── References: List of all attribute systems
Characters reference global formulas for consistency.
Runtime Configuration
Dynamic Mode Switching
public class GameStateManager : MonoBehaviour
{
private CharacterInfluence orchestrator;
void Start()
{
orchestrator = GetComponent<CharacterInfluence>();
}
void EnterCombat()
{
// Switch to Smart mode for responsive combat
orchestrator.updateMode = UpdateMode.Smart;
orchestrator.recalculationMode = RecalculationMode.Auto;
}
void EnterTownPhase()
{
// Switch to Manual mode for non-critical periods
orchestrator.updateMode = UpdateMode.Manual;
orchestrator.recalculationMode = RecalculationMode.Manual;
}
}
Runtime Formula Management
public class DynamicFormulas : MonoBehaviour
{
private CharacterInfluence orchestrator;
void ApplyTemporaryEffect()
{
// Create temporary formula for buff/debuff
var tempFormula = ScriptableObject.CreateInstance<FormulaAsset>();
tempFormula.formulaName = "TempBuff";
tempFormula.targetAttribute = "Damage";
// ... configure formula ...
orchestrator.AddFormula(tempFormula);
// Remove after duration
StartCoroutine(RemoveFormulaAfter("TempBuff", 30f));
}
IEnumerator RemoveFormulaAfter(string formulaName, float duration)
{
yield return new WaitForSeconds(duration);
orchestrator.RemoveFormula(formulaName);
}
}
Advanced Configuration
Execution Order Management
Control formula calculation sequence for complex dependencies:
Execution Order Examples:
Order 0: Base stat calculations (STR → Damage, INT → Mana)
Order 1: Combined calculations (Physical + Magical → Total)
Order 2: Final modifiers (Difficulty scaling, global effects)
Lower numbers execute first, higher numbers execute later.
Validation Settings
Validation Configuration:
• Strict Mode: Halt execution on any validation error
• Warning Mode: Log warnings but continue execution
• Silent Mode: Ignore validation issues (not recommended)
Development: Use Strict Mode
Production: Use Warning Mode
Memory Management
Memory Optimization:
• Formula asset preloading
• Attribute reference caching
• Calculation result pooling
• Garbage collection minimization
Automatically handled by the orchestrator.
Debugging & Monitoring
Debug Mode Output
// Enable detailed logging
orchestrator.debugMode = true;
// Console output:
[Orchestrator] Recalculating all formulas...
[Formula] StrengthDamage: STR(25) → Damage +50
[Formula] LevelHealth: Level(10) → Health +200
[Validation] All formulas calculated successfully
[Performance] Total calculation time: 0.2ms
Performance Monitoring
// Monitor calculation frequency
void Update()
{
if (debugMode)
{
calculationsThisFrame++;
if (Time.frameCount % 60 == 0) // Log every second
{
Debug.Log($"Calculations per second: {calculationsThisFrame}");
calculationsThisFrame = 0;
}
}
}
Formula State Inspection
// Runtime inspection methods
Debug.Log(orchestrator.GetFormulaNames()); // List all formulas
Debug.Log(orchestrator.HasFormula("StrengthDamage")); // Check existence
Debug.Log(orchestrator.GetFormula("LevelHealth")); // Get formula asset
// Test individual formulas
var testValues = new Dictionary<string, float> {{"Strength", 30}};
float result = orchestrator.TestFormula("StrengthDamage", testValues);
Integration Best Practices
Component Order
Recommended Order:
Attribute System Component (CharacterAttributes)
Orchestrator Component (CharacterInfluence)
Other game logic components
Initialization Sequence
// Proper initialization in your game scripts
void Awake()
{
// Get components in correct order
attributes = GetComponent<CharacterAttributes>();
orchestrator = GetComponent<CharacterInfluence>();
}
void Start()
{
// Orchestrator is fully initialized here
// Safe to access calculated values
InitializeUI();
SetupEventListeners();
}
Event Handling
void SetupEventListeners()
{
// Listen for attribute changes
attributes.strength.OnBaseValueChanged += OnStrengthChanged;
attributes.level.OnBaseValueChanged += OnLevelChanged;
// Listen for total value changes (includes formula results)
attributes.health.OnValueChanged += UpdateHealthUI;
}
void OnStrengthChanged(SimpleRuntimeAttribute attr, float oldValue, float newValue)
{
// Formulas automatically recalculate in Smart mode
Debug.Log($"Strength changed: {oldValue} → {newValue}");
// health.formulaBonus will update automatically
}
Common Setup Issues
Reference Assignment Problems
Attribute System Not Assigned:
Drag your attribute component to the Attribute System field
Verify the component implements ISimpleAttributeDataSource
Check console for interface implementation errors
Missing Formula Assets:
Check that formula assets exist in the generated folder
// Custom events in your orchestrator
public class CharacterInfluence : MonoBehaviour
{
// Custom events for formula system
public UnityEvent OnSystemInitialized;
public UnityEvent<string> OnFormulaRecalculated;
public UnityEvent<float> OnMajorStatChange;
void NotifyMajorChange(string attributeName, float change)
{
if (Mathf.Abs(change) > significantChangeThreshold)
{
OnMajorStatChange?.Invoke(change);
}
}
}
Multi-System Coordination
// Coordinating multiple influence systems
public class SystemCoordinator : MonoBehaviour
{
[SerializeField] private CharacterInfluence playerInfluence;
[SerializeField] private EquipmentInfluence equipmentInfluence;
[SerializeField] private EnvironmentInfluence environmentInfluence;
void RecalculateAllSystems()
{
// Coordinate recalculation order
equipmentInfluence.RecalculateAll(); // Equipment first
environmentInfluence.RecalculateAll(); // Environment second
playerInfluence.RecalculateAll(); // Character last
}
}
Optimization Strategies
For Real-Time Games
Use Smart Mode: Event-driven updates for immediate response
Enable Caching: Reduces component lookup overhead
Minimize Formulas: Combine related calculations when possible
// Test performance with rapid changes
void TestPerformance()
{
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
for (int i = 0; i < 1000; i++)
{
attributes.strength.baseValue = Random.Range(10, 50);
// Formulas should recalculate automatically
}
stopwatch.Stop();
Debug.Log($"1000 calculations took: {stopwatch.ElapsedMilliseconds}ms");
}
Integration Test
// Verify integration with gameplay systems
void TestGameplayIntegration()
{
// Test damage calculation
float damage = attributes.strength.totalValue; // Should include formula bonus
// Test UI updates
healthBar.fillAmount = attributes.health.currentValue / attributes.health.totalValue;
// Test level up
attributes.level.baseValue += 1;
// Health should increase automatically via formula
}