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

namespace EscapeRoomEngine.Engine.Runtime.Requirements.Placement
{
    /// <summary>
    /// This requirement places a module in the same position as its first related module.
    /// Accepts an optional offset to the module.
    /// </summary>
    [CreateAssetMenu(menuName = "Requirements/Place With First Related Module")]
    public class PlaceWithFirstRelatedModule : PlacementRequirement
    {
        public Vector3Int offset;
        
        protected override List<Utilities.Placement> FilterCandidates(List<Utilities.Placement> candidates, Module module, Space space)
        {
            var placement = module.relatedModules[0].srPlacement;
            placement.position += offset;
            return new List<Utilities.Placement> { placement };
        }
    }
}