public override TaskStatus OnUpdate() { if (vendor == null) { return(TaskStatus.Failure); } var collections = InventoryManager.GetLootToCollections(); for (int i = 0; i < collections.Length; ++i) { var items = collections[i].items; for (int j = items.Length - 1; j > -1; --j) { if (items[j].item == null) { continue; } vendor.SellItemToVendorNow(items[j].item, items[j].item.currentStackSize); } } return(TaskStatus.Success); }