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(); } 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; } } }