using System;
using UnityEngine;
using Unity.Behavior;
using Unity.Properties;
using Condition = Unity.Behavior.Condition;
using Colosseum.Enemy;
namespace Colosseum.AI.BehaviorActions.Conditions
{
///
/// 체력이 지정된 비율 이하인지 확인합니다.
///
[Serializable, GeneratePropertyBag]
[Condition(name: "Is Health Below", story: "체력이 [HealthPercent]% 이하인가?", id: "7a4ce4b7-9344-4589-b744-11f5d846dcb2")]
[NodeDescription(name: "Is Health Below", story: "Check if health is below [HealthPercent] percent", category: "Combat")]
public partial class IsHealthBelowCondition : Condition
{
[SerializeReference]
public BlackboardVariable HealthPercent = new BlackboardVariable(50f);
public override bool IsTrue()
{
EnemyBase enemy = GameObject.GetComponent();
if (enemy == null)
{
return false;
}
float currentHealthPercent = (enemy.CurrentHealth / enemy.MaxHealth) * 100f;
return currentHealthPercent <= HealthPercent.Value;
}
}
}