using System.Collections.Generic;
using EscapeRoomEngine.Engine.Runtime.Modules;
using UnityEngine;

namespace EscapeRoomEngine.Engine.Runtime.Requirements.Placement
{
    /// <summary>
    /// This requirement guarantees that the back side of the module is placed on the bottom row of the space.
    /// </summary>
    [CreateAssetMenu(menuName = "Requirements/Place On Bottom Row")]
    public class PlaceOnBottomRow : PlacementRequirement
    {
        protected override List<Utilities.Placement> FilterCandidates(List<Utilities.Placement> candidates, Module module, Space space)
        {
            candidates.RemoveAll(candidate =>
            {
                var (left, right) = candidate.BackCorners;
                return !(left.z == 0 && right.z == 0);
            });

            return candidates;
        }
    }
}