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

namespace EscapeRoomEngine.Engine.Runtime.Requirements
{
    /// <summary>
    /// This requirement guarantees that a module is placed in the same space as its related module.
    /// </summary>
    [CreateAssetMenu(menuName = "Requirements/Related Module")]
    class RelatedModule : PreconditionRequirement
    {
        [InfoBox("A related module that must be added to the same space successfully before this module is added.")]
        [Required]
        public ModuleDescription relatedModule;
        
        protected override List<bool> FilterCandidates(List<bool> candidates, Module module, Space space)
        {
            var newModule = Module.CreateModuleByType(space, relatedModule);
            module.relatedModules.Add(newModule);
            
            return new List<bool> { space.StageModuleWithRequirements(newModule) };
        }
    }
}