CapersProject/Assets/02.Scripts/BehaviorTree/Npc/Crew/Conditional/OnMission.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2024-10-14 11:13:08 +00:00
using BehaviorDesigner.Runtime.Tasks;
using BlueWater.Npcs.Crews;
namespace BlueWater.BehaviorTrees.Actions
{
2024-10-15 18:01:16 +00:00
[TaskCategory("Custom/Npc/Crew")]
public class OnMission : Conditional
2024-10-14 11:13:08 +00:00
{
2024-10-15 18:01:16 +00:00
private Crew _crew;
2024-10-14 11:13:08 +00:00
public override void OnAwake()
{
2024-10-15 18:01:16 +00:00
_crew = GetComponent<Crew>();
2024-10-14 11:13:08 +00:00
}
public override void OnStart()
{
2024-11-07 12:20:24 +00:00
if (_crew.CrewInteraction != null && _crew.CrewInteraction.CenterTransform)
2024-10-14 11:13:08 +00:00
{
2024-10-15 18:01:16 +00:00
_crew.AIMovement.Move(_crew.CrewInteraction.CenterTransform.position);
2024-10-14 11:13:08 +00:00
}
}
public override TaskStatus OnUpdate()
{
2024-10-27 09:44:22 +00:00
if (_crew.CrewInteraction == null || !_crew.CrewInteraction.CanInteractionCrew(_crew))
2024-10-14 11:13:08 +00:00
{
2024-10-15 18:01:16 +00:00
_crew.AIMovement.StopMove();
_crew.ResetMission();
2024-10-14 11:13:08 +00:00
return TaskStatus.Failure;
}
2024-10-15 18:01:16 +00:00
if (!_crew.CanInteractionPosition()) return TaskStatus.Running;
2024-10-14 11:13:08 +00:00
2024-10-15 18:01:16 +00:00
_crew.AIMovement.StopMove();
2024-10-22 12:41:31 +00:00
if (_crew.CrewInteraction != null)
{
_crew.CrewInteraction.InteractionCrew(_crew);
return TaskStatus.Success;
}
2024-10-14 11:13:08 +00:00
2024-10-22 12:41:31 +00:00
_crew.ResetMission();
return TaskStatus.Failure;
2024-10-14 11:13:08 +00:00
}
}
}