66 lines
2.1 KiB
C#
66 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Opsive.BehaviorDesigner.Runtime.Tasks;
|
|
using Opsive.GraphDesigner.Runtime;
|
|
using Opsive.GraphDesigner.Runtime.Variables;
|
|
using Opsive.Shared.Utility;
|
|
using SLSUtilities.FunctionalAnimation;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters.AI
|
|
{
|
|
[Description("检测一个功能动画的状态")]
|
|
[NodeIcon("Assets/Sprites/Icon/Quest01.png")]
|
|
[Category("Cielonos")]
|
|
public class CheckFuncAnim : AutomataConditionalBase
|
|
{
|
|
[Tooltip("是否选择其他功能动画子模块,默认子模块为全身动作子模块。")]
|
|
public bool isOtherFuncAnimSm = false;
|
|
[Tooltip("如果未满足条件,是否继续等待直到满足条件。")]
|
|
public bool willWaitForSuccess = false;
|
|
|
|
private AnimationSubcontrollerBase animationSc => self.animationSc;
|
|
private FunctionalAnimationSubmodule funcAnimSm;
|
|
private RuntimeFuncAnim funcAnim;
|
|
|
|
public bool checkCurrentPlaying = false;
|
|
public List<string> currentPlayingFuncAnimNames = new List<string>();
|
|
public TaskStatus ifMatch = TaskStatus.Success;
|
|
public TaskStatus ifNotMatch = TaskStatus.Failure;
|
|
public TaskStatus ifNull = TaskStatus.Failure;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
base.OnAwake();
|
|
funcAnimSm = isOtherFuncAnimSm ? null : animationSc.fullBodyFuncAnimSm;
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (funcAnimSm == null)
|
|
{
|
|
throw new Exception("没有指定功能动画子模块");
|
|
}
|
|
|
|
funcAnim = funcAnimSm.currentRuntimeFuncAnim;
|
|
if (funcAnim == null)
|
|
{
|
|
return ifNull;
|
|
}
|
|
|
|
if (checkCurrentPlaying)
|
|
{
|
|
if (currentPlayingFuncAnimNames.Contains(funcAnim.animationName))
|
|
{
|
|
return ifMatch;
|
|
}
|
|
else
|
|
{
|
|
return ifNotMatch;
|
|
}
|
|
}
|
|
|
|
return TaskStatus.Failure;
|
|
}
|
|
}
|
|
} |