using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NPCAbilityBinder : MonoBehaviour
{
    [SerializeField] private BaseAbility primaryAbility;
    [SerializeField] private BaseAbility coreAbility;

    private PhotonView user;
    private Taggable userTag;
    private Mana mana;

    private void Awake()
    {
        user = GetComponentInParent<PhotonView>();
        userTag = GetComponentInParent<Taggable>();
        mana = GetComponentInParent<Mana>();
    }

    private void Start()
    {
        if (!user.IsMine) this.enabled = false;
    }

    public void UsePrimaryAbility()
    {
        if (primaryAbility == null) return;

        if (mana.EnoughMana(primaryAbility.manaCost))
            primaryAbility.Execute(user, userTag);
    }

    public void UseCoreAbility(Vector3 point)
    {
        if (coreAbility == null) return;

        if (mana.EnoughMana(coreAbility.manaCost))
            coreAbility.Execute(user, userTag, point);
    }

    public bool ValidCoreAbility()
    {
        return coreAbility != null;
    }
}
