public void StopDining()
    {
        diningTable.ResetSeat(diningSeat);
        diningSeat  = null;
        diningTable = null;
        dining      = false;
        anim.SetBool("Sitting", false);

        if (owedAmount > 0)
        {
            AddAssetToInventory(C.c.data.bill);
            ReadyToCheckOut();
        }
        else
        {
            GoHome();
        }
    }
    public IEnumerator AILoop()
    {
        yield return(null);

        while (true)
        {
            if (inventory[0].amount > 0 && !readyToCheckout && !goingHome)
            {
                if (Random.value < .01f)
                {
                    ReadyToCheckOut();
                    yield return(null);
                }
            }

            if (!walkingToDestination)
            {
                if (readyToCheckout)
                {
                    timeSpentWaiting += loopDelay;
                    if (Random.value < .01f)
                    {
                        UpdateInWaitingLine();
                    }
                    if (C.c.currentShop.npcCheckoutLine.Count > 0 && C.c.currentShop.npcCheckoutLine[0] == this)
                    {
                        if (C.c.currentShop.register.assetBeingSoldModel.childCount == 0)
                        {
                            var inst = Instantiate(inventory[0].asset.modelPrefab, C.c.currentShop.register.assetBeingSoldModel);
                            var rb   = inst.GetComponent <Rigidbody>(); if (rb)
                            {
                                rb.isKinematic = true;
                            }
                            inst.transform.localPosition = Vector3.zero + Vector3.up * inventory[0].asset.modelYOffset;
                            var coll = inst.AddComponent <SphereCollider>();
                            coll.radius               *= 1.5f;
                            inst.transform.name        = "AssetBeingSoldModel";
                            inst.transform.localScale *= inventory[0].asset.miniModelScaleMultiplier;
                        }
                    }
                }

                else   //At Shop
                {
                    if (dining)
                    {
                        if (diningSeat.ordered == null)
                        {
                            yield return(new WaitForSeconds(Random.Range(3f, 10f)));

                            if (C.c.currentShop.foodMenu.Count > 0)
                            {
                                diningSeat.ordered      = C.c.currentShop.foodMenu[Random.Range(0, C.c.currentShop.foodMenu.Count)];
                                diningSeat.orderedModel = Instantiate(diningSeat.ordered.modelPrefab, diningSeat.seatTrans).transform;
                                diningSeat.orderedModel.localPosition = new Vector3(0, 2.5f, 0);
                                diningSeat.orderedModel.eulerAngles   = new Vector3(30, 0, 30);
                                diningSeat.orderedModel.localScale   *= diningSeat.ordered.invModelScaleMultiplier * .5f;
                            }
                            else
                            {
                                timeSpentWaiting += 10f;
                            }
                        }
                        else
                        {
                            if (!diningSeat.hasBeenServed)
                            {
                                if (!C.c.currentShop.foodMenu.Contains(diningSeat.ordered))
                                {
                                    diningSeat.ordered = null; Destroy(diningSeat.orderedModel.gameObject);
                                }
                                timeSpentWaiting += loopDelay;
                            }
                        }
                        if (diningSeat.finishedEating)
                        {
                            yield return(new WaitForSeconds(Random.Range(3f, 8f)));

                            StopDining();
                        }
                        else if (diningSeat.hasBeenServed)
                        {
                            yield return(new WaitForSeconds(Random.Range(5f, 10f)));

                            diningSeat.finishedEating = true;
                            Destroy(diningSeat.orderedModel.gameObject);
                            diningSeat.plateNull.GetChild(0).gameObject.SetActive(false);
                            diningSeat.plateNull.GetChild(1).gameObject.SetActive(true);
                            if (!diningSeat.ordered.liquid)
                            {
                                diningSeat.dirty = true;
                            }
                        }
                        if (timeSpentWaiting > 5 * 60)
                        {
                            StopDining();
                        }
                    }
                    else if (interestedInAsset)
                    {
                        if (!C.c.currentShop.assetsSelling.Contains(interestedInAsset))
                        {
                            interestedInAsset = null;
                        }                                                                                             //cancel if taken not selling anymore
                        else
                        {
                            if (Random.value < .15f)   //get item
                            {
                                AddAssetToInventory(interestedInAsset.data);
                                C.c.currentShop.assetsSelling.Remove(interestedInAsset);
                                Destroy(interestedInAsset.gameObject);
                                interestedInAsset = null;
                            }
                            else if (Random.value < .15f)
                            {
                                interestedInAsset = null;                           //lose interest in item
                            }
                        }
                    }
                    else
                    {
                        if (atShop)
                        {
                            if (Random.value < .06f && C.c.currentShop.assetsSelling.Count > 0)
                            {
                                interestedInAsset = C.c.currentShop.assetsSelling[Random.Range(0, C.c.currentShop.assetsSelling.Count)];
                                agent.SetDestination(interestedInAsset.transform.position);
                                walkingToDestination = true;
                            }
                            if (Random.value < .06f)
                            {
                                if (C.c.currentShop.availableDiningSeats.Count > 0 && C.c.currentShop.foodMenu.Count > 0)
                                {
                                    dining     = true;
                                    diningSeat = C.c.currentShop.availableDiningSeats[Random.Range(0, C.c.currentShop.availableDiningSeats.Count - 1)];
                                    C.c.currentShop.availableDiningSeats.Remove(diningSeat);
                                    agent.SetDestination(diningSeat.seatTrans.position);
                                    walkingToDestination = true;
                                }
                            }
                        }
                        else
                        {
                            goingToShop = true;
                            agent.SetDestination(C.c.currentShop.transform.position + new Vector3(Random.Range(-C.c.currentShop.boxCastSize.x * .5f, C.c.currentShop.boxCastSize.x * .5f), 0,
                                                                                                  Random.Range(-C.c.currentShop.boxCastSize.z * .5f, C.c.currentShop.boxCastSize.z * .5f)));
                            walkingToDestination = true;
                        }
                    }
                    //go home without anything

                    /*if (atShop) {
                     *  if (inventory[0].amount == 0) {
                     *      if (Random.value < .0025f) {
                     *          GoHome();
                     *      }
                     *  }
                     * }*/
                }
            }

            yield return(new WaitForSeconds(loopDelay));
        }
    }