using UnityEngine;

public class ObjectPlaceholder : DraggablePlaceholder
{
    public GameObject Prefab { get; set; }
    public override void Place()
    {
        Prefab.Create(transform.position);
    }
    public override bool CanBePlacedHere()
    {
        var objsOnPosition = LevelManager.Instance.GetAll<ILevelObject>(obj => obj.Position.IsContainedIn(transform.position));
        var positionContainsFarm = objsOnPosition.Exists(obj => obj.Name.ToLower().Contains("farm"));

        //either no object, or object is farm
        return objsOnPosition.Count == 0 || (objsOnPosition.Count == 1 && positionContainsFarm);
    }
}