47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Opsive.BehaviorDesigner.Runtime.Tasks;
|
|
using Opsive.BehaviorDesigner.Runtime.Tasks.Conditionals;
|
|
using Opsive.Shared.Utility;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters.AI
|
|
{
|
|
[Category("Cielonos")]
|
|
[Description("Checks if the automata has specified status effects.")]
|
|
public class CheckStatus : Conditional
|
|
{
|
|
private StatusSubmodule statusSm;
|
|
public List<StatusType> statusList;
|
|
|
|
public bool isAll = false;
|
|
public bool isAny = false;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
statusSm = gameObject.GetComponent<Automata>().statusSm;
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (isAll)
|
|
{
|
|
return statusList.Any(status => !statusSm.HasStatus(status)) ? TaskStatus.Failure : TaskStatus.Success;
|
|
}
|
|
|
|
if (isAny)
|
|
{
|
|
return statusList.Any(status => statusSm.HasStatus(status)) ? TaskStatus.Success : TaskStatus.Failure;
|
|
}
|
|
|
|
if (statusList.Count == 1)
|
|
{
|
|
StatusType status = statusList[0];
|
|
return statusSm.HasStatus(status) ? TaskStatus.Success : TaskStatus.Failure;
|
|
}
|
|
|
|
Debug.LogWarning("[CheckStatus] No valid condition specified.");
|
|
return TaskStatus.Failure;
|
|
}
|
|
}
|
|
} |