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>
45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
using YachtDice.Modifiers.Core;
|
|
using YachtDice.Modifiers.Definition;
|
|
using YachtDice.Modifiers.Runtime;
|
|
|
|
namespace YachtDice.Modifiers.Effects
|
|
{
|
|
[CreateAssetMenu(fileName = "MultiplyPerDieEffect", menuName = "YachtDice/Modifiers/Effects/Multiply Per Die")]
|
|
public class MultiplyPerDieEffect : EffectSO
|
|
{
|
|
[Tooltip("Multiplier to apply per matching die.")]
|
|
[SerializeField] private float multiplierPerDie = 1f;
|
|
|
|
[Tooltip("Die face value to match (1-6). 0 = any/all dice.")]
|
|
[SerializeField, Range(0, 6)] private int targetDieValue;
|
|
|
|
public override UniTask Apply(ModifierContext context, ModifierInstance instance)
|
|
{
|
|
if (context.DiceValues == null) return UniTask.CompletedTask;
|
|
|
|
for (int i = 0; i < context.DiceValues.Length; i++)
|
|
{
|
|
if (targetDieValue == 0 || context.DiceValues[i] == targetDieValue)
|
|
context.Multiplier *= multiplierPerDie;
|
|
}
|
|
|
|
return UniTask.CompletedTask;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
public static MultiplyPerDieEffect CreateForTest(float multiplierPerDie, int targetDieValue = 0,
|
|
ModifierPhase phase = ModifierPhase.Multiplicative, int priority = 0)
|
|
{
|
|
var so = CreateInstance<MultiplyPerDieEffect>();
|
|
so.multiplierPerDie = multiplierPerDie;
|
|
so.targetDieValue = targetDieValue;
|
|
so.SetPhaseForTest(phase);
|
|
so.SetPriorityForTest(priority);
|
|
return so;
|
|
}
|
|
#endif
|
|
}
|
|
}
|