Files
YachtDice/Assets/Scripts/Modifiers/ModifierPipeline.cs
T
horooko bee20fd1f8 [Refactor] Add folder-based namespaces to all C# scripts
Wrap all 39 scripts and 6 test files in namespaces matching their folder
structure (e.g. Assets/Scripts/Dice/ → YachtDice.Dice). Add cross-namespace
using directives where types are referenced across modules. Set rootNamespace
in both .asmdef files (YachtDice, YachtDice.Tests).

Namespace mapping:
- YachtDice.Dice — Dice, DiceRoller
- YachtDice.Economy — CurrencyBank
- YachtDice.Game — GameManager, DiceManager, DebugGameInput
- YachtDice.Inventory — InventoryController/Model/SlotView/View
- YachtDice.Modifiers — ModifierData/Effect/Enums/Pipeline/Runtime/Target
- YachtDice.Persistence — SaveData, SaveSystem
- YachtDice.Scoring — CategoryScorer, ScoreResult, ScoringSystem, YachtCategory
- YachtDice.Shop — ShopCatalog/Controller/ItemView/Model/View
- YachtDice.UI — CategoryRowView, DicePanelView, GameController, GameInfoView, ScoreCardView
- YachtDice.Editor — ModifierAssetCreator
- YachtDice.Tests — all test files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:06:57 +07:00

68 lines
2.3 KiB
C#

using System.Collections.Generic;
using YachtDice.Scoring;
namespace YachtDice.Modifiers
{
public static class ModifierPipeline
{
// Application order (explicit):
// 1. Category-level additive (AddPerDieValue)
// 2. Category-level multiplicative (MultiplyPerDieValue)
// 3. Final-score additive (AddFlatToFinalScore)
// 4. Final-score multiplicative (MultiplyFinalScore)
public static void Apply(
IReadOnlyList<ModifierData> activeModifiers,
ref ScoreResult result,
ModifierScope currentScope)
{
if (activeModifiers == null) return;
// Pass 1: Category-level additive
for (int i = 0; i < activeModifiers.Count; i++)
{
var mod = activeModifiers[i];
if (!ShouldApply(mod, ref result, currentScope)) continue;
if (mod.IsCategoryLevel && mod.IsAdditive)
ModifierEffect.Apply(mod, ref result);
}
// Pass 2: Category-level multiplicative
for (int i = 0; i < activeModifiers.Count; i++)
{
var mod = activeModifiers[i];
if (!ShouldApply(mod, ref result, currentScope)) continue;
if (mod.IsCategoryLevel && mod.IsMultiplicative)
ModifierEffect.Apply(mod, ref result);
}
// Pass 3: Final-score additive
for (int i = 0; i < activeModifiers.Count; i++)
{
var mod = activeModifiers[i];
if (!ShouldApply(mod, ref result, currentScope)) continue;
if (mod.IsFinalScoreLevel && mod.IsAdditive)
ModifierEffect.Apply(mod, ref result);
}
// Pass 4: Final-score multiplicative
for (int i = 0; i < activeModifiers.Count; i++)
{
var mod = activeModifiers[i];
if (!ShouldApply(mod, ref result, currentScope)) continue;
if (mod.IsFinalScoreLevel && mod.IsMultiplicative)
ModifierEffect.Apply(mod, ref result);
}
}
private static bool ShouldApply(ModifierData mod, ref ScoreResult result, ModifierScope currentScope)
{
if (mod == null) return false;
if (mod.Scope != currentScope) return false;
if (mod.Target.HasCategoryFilter && mod.Target.TargetCategory != result.Category) return false;
return true;
}
}
}