using UnityEngine; /// <summary> /// Customer Get Product Primitive Task /// </summary> public class GetProduct : PrimitiveTask { private SectionHandler productSection; private int amount; // ================== CONSTRUCTOR ================== public GetProduct(SectionHandler productSection, int amount) { this.productSection = productSection; this.amount = amount; } // ================== TASK ACTION ================== public override void Execute(HTNPlanner planner) { Customer customer = planner.Agent as Customer; if (customer != null) { int id = productSection.Product.ID; if (productSection != null) { productSection.RemoveQuantity(amount); // removes the item amount from the shelf customer.Basket.AddItem(id, amount); //Adds the item to the basket customer.wishList.Remove(id); // Removes the item from the wish list } else { Debug.LogError("No Section is Null!"); } } else { Debug.LogError("The Agent is not a Customer!"); } } }