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>
83 lines
2.9 KiB
C#
83 lines
2.9 KiB
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using YachtDice.Modifiers.Runtime;
|
|
|
|
namespace YachtDice.Inventory
|
|
{
|
|
public class InventorySlotView : MonoBehaviour
|
|
{
|
|
[SerializeField] private Image iconImage;
|
|
[SerializeField] private TMP_Text nameText;
|
|
[SerializeField] private TMP_Text descriptionText;
|
|
[SerializeField] private TMP_Text usesText;
|
|
[SerializeField] private Button activateButton;
|
|
[SerializeField] private Button deactivateButton;
|
|
[SerializeField] private Button sellButton;
|
|
[SerializeField] private TMP_Text sellPriceText;
|
|
[SerializeField] private Image background;
|
|
|
|
[Header("Colors")]
|
|
[SerializeField] private Color activeColor = new(0.7f, 1f, 0.7f);
|
|
[SerializeField] private Color inactiveColor = Color.white;
|
|
|
|
private ModifierInstance instance;
|
|
|
|
public event Action<ModifierInstance> OnActivateClicked;
|
|
public event Action<ModifierInstance> OnDeactivateClicked;
|
|
public event Action<ModifierInstance> OnSellClicked;
|
|
|
|
private void Awake()
|
|
{
|
|
if (activateButton != null)
|
|
activateButton.onClick.AddListener(() => OnActivateClicked?.Invoke(instance));
|
|
if (deactivateButton != null)
|
|
deactivateButton.onClick.AddListener(() => OnDeactivateClicked?.Invoke(instance));
|
|
if (sellButton != null)
|
|
sellButton.onClick.AddListener(() => OnSellClicked?.Invoke(instance));
|
|
}
|
|
|
|
public void Setup(ModifierInstance modifierInstance, bool canActivateMore)
|
|
{
|
|
instance = modifierInstance;
|
|
var def = instance.Definition;
|
|
|
|
if (def == null) return;
|
|
|
|
if (nameText != null) nameText.text = def.DisplayName;
|
|
if (descriptionText != null) descriptionText.text = def.Description;
|
|
if (iconImage != null && def.Icon != null) iconImage.sprite = def.Icon;
|
|
|
|
if (usesText != null)
|
|
{
|
|
if (def.HasLimitedUses)
|
|
{
|
|
usesText.gameObject.SetActive(true);
|
|
usesText.text = $"{instance.RemainingUses}/{def.MaxUses}";
|
|
}
|
|
else
|
|
{
|
|
usesText.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
if (sellPriceText != null) sellPriceText.text = def.SellPrice.ToString();
|
|
|
|
bool isActive = instance.IsActive;
|
|
|
|
if (activateButton != null)
|
|
{
|
|
activateButton.gameObject.SetActive(!isActive);
|
|
activateButton.interactable = canActivateMore;
|
|
}
|
|
|
|
if (deactivateButton != null)
|
|
deactivateButton.gameObject.SetActive(isActive);
|
|
|
|
if (background != null)
|
|
background.color = isActive ? activeColor : inactiveColor;
|
|
}
|
|
}
|
|
}
|