123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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<Vector3Int> 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;
- }
- }
- }
|