2024-04-28 13:55:19 +00:00
|
|
|
|
using ColdMint.scripts.character;
|
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.behaviorTree.ai;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>The node that controls the rotor when the AI is facing the wall</para>
|
|
|
|
|
/// <para>当AI面向墙壁时,控制转头的节点</para>
|
|
|
|
|
/// </summary>
|
2024-05-08 10:22:04 +00:00
|
|
|
|
public class AiRotorNode : BehaviorTreeNodeTemplate
|
2024-04-28 13:55:19 +00:00
|
|
|
|
{
|
2024-05-08 10:22:04 +00:00
|
|
|
|
public AiCharacter? Character { get; set; }
|
2024-04-28 13:55:19 +00:00
|
|
|
|
|
|
|
|
|
public override int Execute(bool isPhysicsProcess, double delta)
|
|
|
|
|
{
|
|
|
|
|
if (Character == null)
|
|
|
|
|
{
|
|
|
|
|
return Config.BehaviorTreeResult.Failure;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-08 10:22:04 +00:00
|
|
|
|
var notFacingTheWall = Character.WallDetection?.GetCollider() == null;
|
2024-04-28 13:55:19 +00:00
|
|
|
|
if (notFacingTheWall)
|
|
|
|
|
{
|
|
|
|
|
return Config.BehaviorTreeResult.Failure;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Character.Rotor();
|
|
|
|
|
return Config.BehaviorTreeResult.Success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|