68c4abace3
Replace the entire static, enum-based modifier pipeline with a composition-based, data-driven architecture using ScriptableObject polymorphism. New modifiers can now be created by assembling SO building blocks (Conditions + Effects + Behaviors) — no core code edits needed. New architecture: - Core/: TriggerType, ModifierPhase, ModifierContext, ICondition, IEffect - Definition/: ModifierDefinitionSO, ModifierBehaviorSO, ConditionSO, EffectSO, ModifierCatalogSO - Conditions/: DieValueCondition, CategoryCondition, MinScoreCondition, DiceCountCondition - Effects/: AddFlat, AddPerDie, Multiply, MultiplyPerDie, PostMultiply, AddCurrency, ConsumeCharge - Runtime/: ModifierInstance, ModifierRegistry (non-static service) - Pipeline/: async ModifierPipeline with phase ordering, tracing, anti-recursion - Editor/: ModifierDefinitionValidator with menu items - Events/: GameEventBus (non-static typed dispatcher) - DI/: GameLifetimeScope (VContainer composition root) Deleted old system: ModifierData, ModifierEffect, ModifierEnums, ModifierPipeline (static), ModifierRuntime, ModifierTarget, ShopCatalog, ModifierAssetCreator. Updated: ScoringSystem (VContainer + async), InventoryModel (delegates to ModifierRegistry), ShopModel (uses ModifierDefinitionSO), GameController (VContainer injection), SaveData (uses Runtime.ModifierSaveEntry), all views/controllers, and all test files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Text;
|
|
using YachtDice.Modifiers.Core;
|
|
|
|
namespace YachtDice.Modifiers.Pipeline
|
|
{
|
|
public class PipelineTrace
|
|
{
|
|
public TriggerType Trigger;
|
|
public readonly List<TraceEntry> Entries = new();
|
|
|
|
public struct TraceEntry
|
|
{
|
|
public string ModifierId;
|
|
public string BehaviorName;
|
|
public bool ConditionsPassed;
|
|
public string FailedCondition;
|
|
public string EffectApplied;
|
|
public ModifierPhase Phase;
|
|
}
|
|
|
|
public void AddConditionResult(string modifierId, string behaviorName, bool passed, string failedCondition = null)
|
|
{
|
|
Entries.Add(new TraceEntry
|
|
{
|
|
ModifierId = modifierId,
|
|
BehaviorName = behaviorName,
|
|
ConditionsPassed = passed,
|
|
FailedCondition = failedCondition,
|
|
});
|
|
}
|
|
|
|
public void AddEffectApplied(string modifierId, string effectName, ModifierPhase phase)
|
|
{
|
|
Entries.Add(new TraceEntry
|
|
{
|
|
ModifierId = modifierId,
|
|
EffectApplied = effectName,
|
|
Phase = phase,
|
|
ConditionsPassed = true,
|
|
});
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
var sb = new StringBuilder();
|
|
sb.AppendLine($"[ModifierPipeline] Trigger: {Trigger}");
|
|
for (int i = 0; i < Entries.Count; i++)
|
|
{
|
|
var e = Entries[i];
|
|
if (e.EffectApplied != null)
|
|
{
|
|
sb.AppendLine($" EFFECT [{e.Phase}] {e.ModifierId} -> {e.EffectApplied}");
|
|
}
|
|
else if (e.ConditionsPassed)
|
|
{
|
|
sb.AppendLine($" PASS {e.ModifierId} / {e.BehaviorName}");
|
|
}
|
|
else
|
|
{
|
|
sb.AppendLine($" FAIL {e.ModifierId} / {e.BehaviorName} (failed: {e.FailedCondition})");
|
|
}
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|