using UnityEngine; /// <summary> /// Customer payment Compund Task /// </summary> public class Payment : CompoundTask { // ================== CONSTRUCTOR ================== public Payment(HTNPlanner planner) { //Casting Customer customer = planner.Agent as Customer; //Get Exit Area Position from the worldstate Vector3 exitPos = planner.WorldState.Get<Transform>("ExitArea").position; //Checks if the cast is not successful if (customer == null) { Debug.Log("Casting failed!"); return; } //Gets the payment first position Vector3 paymentArePos = planner.WorldState.Get<PaymentArea>("PaymentArea").FirstQueuePosition.position; //Handles in Case if the Queue is Empty Method payment = new Method("Join and Pay if Possible") //Add Preconditions to the method .AddPrecondition(new IsWishListEmpty("Is Wish List Empty")) //Add Subtasks of the method .AddSubTask(new JoinPaymentQueue() .AddPostCondition(new IsCostumerInTheQueue())) .AddSubTask(new WaitInTheQueueUntilFirst() //Coroutine Task .AddPostCondition(new IsFirstInTheQueue())) .AddSubTask(new ProceedPayment(customer.Basket.CurrentValue)) .AddSubTask(new LeaveTheQueue()) .AddSubTask(new GoToLocation(exitPos) .AddPostCondition(new HasReachedDestination(exitPos)) //Adding Postcondition to the Subtask .Build("Payment")); //Adding Methods AddMethod(payment); } }