1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using KairoEngine.Chunks;
- namespace KairoEngine.VoxelBuildingSystem
- {
- [System.Serializable]
- public class VoxelBuildingRuleset
- {
- public ConditionType condition;
- public List<VoxelBuildingRule> rules = new List<VoxelBuildingRule>();
- public bool Evaluate(VoxelBuildingSystem buildingSystem, int templateIndex, Vector3Int position, int rotationIndex)
- {
- List<bool> results = new List<bool>();
- for (int i = 0; i < rules.Count; i++)
- {
- results.Add(rules[i].Evaluate(buildingSystem, templateIndex, position, rotationIndex));
- }
- 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;
- }
- }
-
- }
- public enum ConditionType
- {
- AND,
- OR
- }
- }
|