using System.Collections.Generic; using UnityEngine; using YachtDice.Modifiers.Core; using YachtDice.Modifiers.Runtime; namespace YachtDice.Modifiers.Definition { [CreateAssetMenu(fileName = "NewBehavior", menuName = "YachtDice/Modifiers/Behavior")] public class ModifierBehavior : ScriptableObject { [field: SerializeField] public TriggerType Trigger { get; private set; } [SerializeField] private List conditions = new(); [SerializeField] private List effects = new(); public IReadOnlyList Conditions => conditions; public IReadOnlyList Effects => effects; public bool EvaluateConditions(ModifierContext context, ModifierInstance instance) { foreach (var t in conditions) { if (t != null && !t.Evaluate(context, instance)) return false; } return true; } #if UNITY_EDITOR public static ModifierBehavior CreateForTest( TriggerType trigger, List conditions, List effects) { var so = CreateInstance(); so.Trigger = trigger; so.conditions = conditions ?? new List(); so.effects = effects ?? new List(); return so; } #endif } }