Traveller/scripts/behaviorTree/ai/AIWallDetectionNode.cs
2024-04-28 21:55:19 +08:00

31 lines
845 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>
public class AIRotorNode : BehaviorTreeNodeTemplate
{
public AICharacter Character { get; set; }
public override int Execute(bool isPhysicsProcess, double delta)
{
if (Character == null)
{
return Config.BehaviorTreeResult.Failure;
}
var notFacingTheWall = Character.WallDetection.GetCollider() == null;
if (notFacingTheWall)
{
return Config.BehaviorTreeResult.Failure;
}
else
{
Character.Rotor();
return Config.BehaviorTreeResult.Success;
}
}
}