using System.Collections; using System.Collections.Generic; using UnityEngine; public class ClassResourceSpender : MonoBehaviour { protected RiftPlayer player; protected Taggable playerTag; protected ClassResource classResource; protected ClassAbilityPriorityManager abilityPriorityManager; protected AbilityCooldownTracker abilityCooldownTracker; protected virtual void Awake() { player = GetComponentInParent(); abilityPriorityManager = player.GetComponentInChildren(); abilityCooldownTracker = player.GetComponentInChildren(); playerTag = player.GetComponent(); classResource = player.GetComponent(); classResource.onResourceChanged.AddListener(OnClassResourceValueChanged); } public virtual void OnClassResourceValueChanged(float value) { BaseAbility autocastAbility = abilityPriorityManager.GetHighestPriorityAvailableAbility(); if (autocastAbility == null) { Debug.Log("No abilities available for current conditional state"); return; } autocastAbility.Execute(player.photonView, playerTag); if (autocastAbility.cooldown > 0) abilityCooldownTracker.StartAbilityCooldown(autocastAbility); } }