[Fix] Name & add meta
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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
|
||||
{
|
||||
[SerializeField] private TriggerType trigger;
|
||||
[SerializeField] private List<Condition> conditions = new();
|
||||
[SerializeField] private List<Effect> effects = new();
|
||||
|
||||
public TriggerType Trigger => trigger;
|
||||
public IReadOnlyList<Condition> Conditions => conditions;
|
||||
public IReadOnlyList<Effect> Effects => effects;
|
||||
|
||||
public bool EvaluateConditions(ModifierContext context, ModifierInstance instance)
|
||||
{
|
||||
for (int i = 0; i < conditions.Count; i++)
|
||||
{
|
||||
if (conditions[i] != null && !conditions[i].Evaluate(context, instance))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static ModifierBehavior CreateForTest(
|
||||
TriggerType trigger,
|
||||
List<Condition> conditions,
|
||||
List<Effect> effects)
|
||||
{
|
||||
var so = CreateInstance<ModifierBehavior>();
|
||||
so.trigger = trigger;
|
||||
so.conditions = conditions ?? new List<Condition>();
|
||||
so.effects = effects ?? new List<Effect>();
|
||||
return so;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user