Files
OTG_6/Assets/_Scripts/Abilities/AbilityRuntime.cs
T

35 lines
900 B
C#
Raw Normal View History

2026-06-04 21:37:43 +03:00
using System;
using UnityEngine;
namespace OTG.Lab06.Abilities
{
[Serializable]
public sealed class AbilityRuntime
{
public AbilityRuntime(AbilityData data)
{
Data = data;
}
public AbilityData Data { get; }
public float CooldownRemaining { get; private set; }
public bool IsReady => CooldownRemaining <= 0f;
public float CooldownNormalized => Data == null || Data.cooldown <= 0f ? 0f : Mathf.Clamp01(CooldownRemaining / Data.cooldown);
public void Tick(float deltaTime)
{
if (CooldownRemaining <= 0f)
{
return;
}
CooldownRemaining = Mathf.Max(0f, CooldownRemaining - deltaTime);
}
public void StartCooldown()
{
CooldownRemaining = Data == null ? 0f : Mathf.Max(0f, Data.cooldown);
}
}
}