47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using BehaviorDesigner.Runtime.Tasks;
|
|
using BlueWater.Npcs.Crews;
|
|
|
|
namespace BlueWater.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.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;
|
|
}
|
|
}
|
|
} |