using System.Collections.Generic; using EscapeRoomEngine.Engine.Runtime.Modules; using UnityEngine; namespace EscapeRoomEngine.Engine.Runtime.Requirements.Placement { /// /// This requirement guarantees that the back side of the module is placed at the edge of the space. /// [CreateAssetMenu(menuName = "Requirements/Place Along Space Edges")] public class PlaceAlongSpaceEdges : PlacementRequirement { protected override List FilterCandidates(List candidates, Module module, Space space) { var sizeMinusOne = space.rrPlacement.size - Vector2Int.one; candidates.RemoveAll(candidate => { var (left, right) = candidate.BackCorners; return !(left.x == 0 && right.x == 0 || left.z == 0 && right.z == 0 || left.x == sizeMinusOne.x && right.x == sizeMinusOne.x || left.z == sizeMinusOne.y && right.z == sizeMinusOne.y); }); return candidates; } } }