using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using CorgiLabs.Utility;

public class FloorRepairer : GrabbableObject
{
    [SerializeField] private SoundEffect m_RepairSfx;

    public override void OnLeave(IGrabber grabber)
    {
        base.OnLeave(grabber);

        Vector3Int pos = ServiceLocator.Get<Grid>().WorldToCell(transform.position);
        FloorBreaker breaker = FloorBreaker.Get(pos);

        if (breaker)
        {
            m_RepairSfx?.Play(transform.position);
            breaker.Repair(pos);
            gameObject.SetActive(false);
        }
    }
}
