using System.Collections.Generic; using EscapeRoomEngine.Engine.Runtime.Modules; using UnityEngine; namespace EscapeRoomEngine.Engine.Runtime.Requirements { [CreateAssetMenu(menuName = "Requirements/Face Space Center")] public class FaceSpaceCenter : PlacementRequirement { protected override List FilterCandidates(List candidates, Module module, Space space) { float width = space.rrPlacement.size.x; float length = space.rrPlacement.size.y; candidates.RemoveAll(candidate => { var bottomLeft = candidate.BottomLeft; var center = new Vector2(bottomLeft.x, bottomLeft.z) + new Vector2(candidate.size.x / 2f, candidate.size.y / 2f); var xRel = center.x / width; var zRel = center.y / length; return candidate.orientation != (zRel > xRel ? zRel > 1 - xRel ? Orientation.South : Orientation.East : zRel > 1 - xRel ? Orientation.West : Orientation.North); }); return candidates; } } }