using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class DeleteButton : PlacementButton
{
    [SerializeField]
    private GameObject _prefab;
    protected override DraggablePlaceholder Place()
    {
        var instance = Instantiate(_prefab);

        //strip the object
        foreach (var r_body in instance.transform.GetAllComponents<Rigidbody2D>())
            Destroy(r_body);
        foreach (var coll in instance.transform.GetAllComponents<Collider2D>())
            Destroy(coll);
        foreach (var script in instance.transform.GetAllComponents<MonoBehaviour>())
            Destroy(script);

        var placeholder = instance.AddComponent<DeleteShovel>();

        //assign outline material to all renderers of the placeholder
        foreach (var rend in instance.transform.GetAllComponents<SpriteRenderer>())
        {
            var color = rend.color;
            color.a = 0.6f;
            rend.color = color;

            rend.material = OutlineMaterial;
            placeholder.OutlineRenderers.Add(rend);
        }

        return placeholder;
    }
}
