12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using KairoEngine.Core;
- namespace KairoEngine.Grids
- {
- [System.Serializable]
- public class PlaceableObjectRuleGroup
- {
- public ConditionType condition;
- public List<PlaceableObjectRule> rules = new List<PlaceableObjectRule>();
- public bool Evaluate(Grid<GridObject> grid, PlacedObjectType placedObjectType, int x, int y, PlacedObjectType.Dir dir)
- {
- List<bool> results = new List<bool>();
- for (int i = 0; i < rules.Count; i++)
- {
- results.Add(rules[i].Evaluate(grid, placedObjectType, x, y, dir));
- }
- if(condition == ConditionType.AND)
- {
- foreach (var value in results)
- {
- if(value == false) return false;
- }
- return true;
- }
- else
- {
- foreach (var value in results)
- {
- if(value == true) return true;
- }
- return false;
- }
- }
- }
- }
|