using System.Linq;
using UnityEditor;
using UnityEngine;

public class CharacterInfo : MonoBehaviour
{
    public MaskProperties maskProperties;

    public bool isDead = false; 

    public void AttachMask(MaskProperties mask)
    {
        var head = GetComponentsInChildren<Transform>().FirstOrDefault(t => t.name == "Head");
        var newMask = Instantiate(mask, head);
        newMask.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
        newMask.transform.localScale = Vector3.one * 1.2f;
        if (mask.coverHair)
        {
            var hairModel = GetComponentsInChildren<Transform>().FirstOrDefault(t => t.name.Contains("HAIR"));
            if (hairModel != null)
                hairModel.gameObject.SetActive(false);
            var hatModel = GetComponentsInChildren<Transform>().FirstOrDefault(t => t.name.Contains("HAT"));
            if (hatModel != null)
                hatModel.gameObject.SetActive(false);
        }
        maskProperties = newMask;
    }
}
