// Copyright (c) Strange Loop Games. All rights reserved.
// See LICENSE file in the project root for full license information.

namespace Eco.Mods.TechTree
{
    using System.Linq;
    using Eco.Gameplay.Skills;
    using Eco.Gameplay.Components;
    using Eco.Gameplay.Players;

    public partial class ParallelProcessingTalent : Talent
    {
        public override bool HasActiveRequirements { get { return true; } }
        public override bool Active(object obj, User user = null)
        {
            var cc = obj as CraftingComponent;
            if (cc != null)
                if (cc.Parent.HasComponent<RoomRequirementsComponent>() && cc.Parent.GetComponent<RoomRequirementsComponent>().RoomStats != null && cc.Parent.GetComponent<RoomRequirementsComponent>().RoomStats.ContainedWorldObjects.Where(x => x.GetType() == cc.Parent.GetType()).Count() < 2)
                    return false;
            return true;
        }
    }
}
