Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [System.Serializable]
- public class Condition
- {
- [SerializeField]
- Disjunction[] and;
- public bool Check(IEnumerable<IPredicateEvaluator> evaluators)
- {
- foreach (Disjunction dis in and)
- {
- if (!dis.Check(evaluators))
- {
- return false;
- }
- }
- return true;
- }
- [System.Serializable]
- public class Disjunction
- {
- [SerializeField]
- Predicate[] or;
- public bool Check(IEnumerable<IPredicateEvaluator> evaluators)
- {
- foreach (Predicate pred in or)
- {
- if (pred.Check(evaluators))
- {
- return true;
- }
- }
- return false;
- }
- }
- [System.Serializable]
- public class Predicate
- {
- [SerializeField] EPredicate predicate;
- [SerializeField] string[] parameters;
- [SerializeField] bool negate = false;
- public bool Check(IEnumerable<IPredicateEvaluator> evaluators)
- {
- foreach (var evaluator in evaluators)
- {
- bool? result = evaluator.Evaluate(predicate, parameters);
- if (result == null) continue;
- if (result == negate) return false;
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment