using System.Collections; using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector; using KairoEngine.Chunks; namespace KairoEngine.VoxelBuildingSystem { public enum RuleType { EmptyVoxels } [System.Serializable] public class VoxelBuildingRule { private string title { get { switch (rule) { case RuleType.EmptyVoxels: return $"Empty voxels"; default: return "?"; } } } [SerializeField, FoldoutGroup("@title")] private RuleType rule; public bool Evaluate(VoxelBuildingSystem buildingSystem, int templateIndex, Vector3Int position, int rotationIndex) { switch (rule) { case RuleType.EmptyVoxels: return EvaluateEmptyVoxels(buildingSystem, templateIndex, position, rotationIndex); default: return false; } } public bool EvaluateEmptyVoxels(VoxelBuildingSystem buildingSystem, int templateIndex, Vector3Int position, int rotationIndex) { List voxelPositions = buildingSystem.GetBuildingVoxelList(position, templateIndex, rotationIndex); for (int i = 0; i < voxelPositions.Count; i++) { VoxelBuildData block = buildingSystem.chunkSystem.GetBlock(voxelPositions[i]); if(block.buildingIndex != -1) { return false; } } return true; } } }