using BehaviorDesigner.Runtime.Tasks; using BlueWater.Npcs.Crews; using BlueWater.Tycoons; namespace BlueWater.BehaviorTrees.Actions { [TaskCategory("Custom/Npc/Crew/ServerCrew")] public class Refind : Action { private ServerCrew _serverCrew; private ServingTable _emptyServingTable; public override void OnAwake() { _serverCrew = GetComponent(); } public override TaskStatus OnUpdate() { var tycoonManager = TycoonManager.Instance; var orderedCustomer = tycoonManager.CustomerController.FindCustomerMatchingItem(_serverCrew.CurrentPickupItem); if (orderedCustomer != null) { orderedCustomer.IsMatchedServer = true; _serverCrew.OrderedCustomer = orderedCustomer; _serverCrew.CrewInteraction = orderedCustomer; return TaskStatus.Success; } if (_emptyServingTable == null) { _emptyServingTable = tycoonManager.ServingTableController.FindEmptyServingTable(); _serverCrew.CrewInteraction = _emptyServingTable; return TaskStatus.Running; } _serverCrew.AIMovement.Move(_emptyServingTable.CenterTransform.position); if (!_serverCrew.CanInteractionPosition()) return TaskStatus.Running; _serverCrew.AIMovement.StopMove(); _serverCrew.CrewInteraction.InteractionCrew(_serverCrew); return TaskStatus.Success; } } }