[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.Definition;
|
||||
|
||||
namespace YachtDice.Shop
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace YachtDice.Shop
|
||||
|
||||
private readonly List<ShopItemView> spawnedItems = new();
|
||||
|
||||
public event Action<ModifierData> OnBuyClicked;
|
||||
public event Action<ModifierDefinitionSO> OnBuyClicked;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -34,24 +34,24 @@ namespace YachtDice.Shop
|
||||
public void Hide() => gameObject.SetActive(false);
|
||||
public bool IsVisible => gameObject.activeSelf;
|
||||
|
||||
public void Populate(IReadOnlyList<ModifierData> catalog, ShopModel model)
|
||||
public void Populate(IReadOnlyList<ModifierDefinitionSO> catalog, ShopModel model)
|
||||
{
|
||||
ClearItems();
|
||||
|
||||
for (int i = 0; i < catalog.Count; i++)
|
||||
{
|
||||
var data = catalog[i];
|
||||
if (data == null) continue;
|
||||
var def = catalog[i];
|
||||
if (def == null) continue;
|
||||
|
||||
var item = Instantiate(itemPrefab, itemContainer);
|
||||
var state = model.GetItemState(data);
|
||||
item.Setup(data, state);
|
||||
var state = model.GetItemState(def);
|
||||
item.Setup(def, state);
|
||||
item.OnBuyClicked += HandleBuy;
|
||||
spawnedItems.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshStates(IReadOnlyList<ModifierData> catalog, ShopModel model)
|
||||
public void RefreshStates(IReadOnlyList<ModifierDefinitionSO> catalog, ShopModel model)
|
||||
{
|
||||
for (int i = 0; i < spawnedItems.Count && i < catalog.Count; i++)
|
||||
{
|
||||
@@ -76,6 +76,6 @@ namespace YachtDice.Shop
|
||||
spawnedItems.Clear();
|
||||
}
|
||||
|
||||
private void HandleBuy(ModifierData data) => OnBuyClicked?.Invoke(data);
|
||||
private void HandleBuy(ModifierDefinitionSO def) => OnBuyClicked?.Invoke(def);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user