[Refactor] Replace enum-driven modifier system with data-driven SO composition
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>
This commit is contained in:
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using YachtDice.Modifiers;
|
||||
using YachtDice.Modifiers.Runtime;
|
||||
|
||||
namespace YachtDice.Inventory
|
||||
{
|
||||
@@ -16,9 +16,9 @@ namespace YachtDice.Inventory
|
||||
|
||||
private readonly List<InventorySlotView> spawnedSlots = new();
|
||||
|
||||
public event Action<ModifierRuntime> OnActivateClicked;
|
||||
public event Action<ModifierRuntime> OnDeactivateClicked;
|
||||
public event Action<ModifierRuntime> OnSellClicked;
|
||||
public event Action<ModifierInstance> OnActivateClicked;
|
||||
public event Action<ModifierInstance> OnDeactivateClicked;
|
||||
public event Action<ModifierInstance> OnSellClicked;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -36,7 +36,7 @@ namespace YachtDice.Inventory
|
||||
public void Hide() => gameObject.SetActive(false);
|
||||
public bool IsVisible => gameObject.activeSelf;
|
||||
|
||||
public void Refresh(IReadOnlyList<ModifierRuntime> owned, int maxSlots)
|
||||
public void Refresh(IReadOnlyList<ModifierInstance> owned, int maxSlots)
|
||||
{
|
||||
ClearSlots();
|
||||
|
||||
@@ -44,11 +44,11 @@ namespace YachtDice.Inventory
|
||||
|
||||
for (int i = 0; i < owned.Count; i++)
|
||||
{
|
||||
var runtime = owned[i];
|
||||
if (runtime.IsActive) activeCount++;
|
||||
var inst = owned[i];
|
||||
if (inst.IsActive) activeCount++;
|
||||
|
||||
var slot = Instantiate(slotPrefab, slotContainer);
|
||||
slot.Setup(runtime, activeCount <= maxSlots);
|
||||
slot.Setup(inst, activeCount <= maxSlots);
|
||||
slot.OnActivateClicked += HandleActivate;
|
||||
slot.OnDeactivateClicked += HandleDeactivate;
|
||||
slot.OnSellClicked += HandleSell;
|
||||
@@ -71,8 +71,8 @@ namespace YachtDice.Inventory
|
||||
spawnedSlots.Clear();
|
||||
}
|
||||
|
||||
private void HandleActivate(ModifierRuntime runtime) => OnActivateClicked?.Invoke(runtime);
|
||||
private void HandleDeactivate(ModifierRuntime runtime) => OnDeactivateClicked?.Invoke(runtime);
|
||||
private void HandleSell(ModifierRuntime runtime) => OnSellClicked?.Invoke(runtime);
|
||||
private void HandleActivate(ModifierInstance inst) => OnActivateClicked?.Invoke(inst);
|
||||
private void HandleDeactivate(ModifierInstance inst) => OnDeactivateClicked?.Invoke(inst);
|
||||
private void HandleSell(ModifierInstance inst) => OnSellClicked?.Invoke(inst);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user