CapersProject/Assets/02.Scripts/BlueWater/BehaviorTree/Npc/Crew/Conditional/OnMission.cs
2025-02-10 11:13:46 +09:00

47 lines
1.3 KiB
C#

using BehaviorDesigner.Runtime.Tasks;
using DDD.Npcs.Crews;
namespace DDD.BehaviorTrees.Actions
{
[TaskCategory("Custom/Npc/Crew")]
public class OnMission : Conditional
{
private Crew _crew;
public override void OnAwake()
{
_crew = GetComponent<Crew>();
}
public override void OnStart()
{
if (_crew.CrewInteraction != null && _crew.CrewInteraction.CenterTransform)
{
_crew.AIMovement.Move(_crew.CrewInteraction.CenterTransform.position);
}
}
public override TaskStatus OnUpdate()
{
if (_crew.CrewInteraction == null || !_crew.CrewInteraction.CanInteractionCrew(_crew))
{
_crew.AIMovement.StopMove();
_crew.ResetMission();
return TaskStatus.Failure;
}
if (!_crew.CanInteractionPosition()) return TaskStatus.Running;
_crew.AIMovement.StopMove();
if (_crew.CrewInteraction != null)
{
_crew.CrewInteraction.InteractionCrew(_crew);
return TaskStatus.Success;
}
_crew.ResetMission();
return TaskStatus.Failure;
}
}
}