public string GetProductInfo(Product product)
    {
        switch (product.productType)
        {
        case Product.type_.storageJar:
            StorageJar jar = (StorageJar)product;
            return("Strain: " + jar.GetStrain().name);

        case Product.type_.glassBong:
        case Product.type_.acrylicBong:
            Bong bong = (Bong)product;
            return("Height: " + bong.height);

        case Product.type_.glassPipe:
        case Product.type_.acrylicPipe:
            Pipe pipe = (Pipe)product;
            return("Length: " + pipe.length);

        case Product.type_.rollingPaper:
            RollingPaper paper = (RollingPaper)product;
            return(paper.paperType.ToString());

        case Product.type_.edible:
            Edible edible = (Edible)product;
            return(edible.edibleType.ToString());

        case Product.type_.box:
            StorageBox box = (StorageBox)product;
            return("Products: " + box.products.Count);
        }
        return("ProductType");
    }
Esempio n. 2
0
    public void RemoveBud(PackagedBud toRemove, float weightToRemove)
    {
        List <PackagedBud> newList = new List <PackagedBud>();
        bool useNewList            = false;

        foreach (PackagedBud packagedBud in bud)
        {
            if (packagedBud.uniqueID == toRemove.uniqueID)
            {
                if (packagedBud.weight > weightToRemove)
                {
                    packagedBud.weight = packagedBud.weight - weightToRemove;
                }
                else if (packagedBud.weight <= weightToRemove)
                {
                    useNewList = true;
                }
            }
            else
            {
                newList.Add(packagedBud);
            }
        }
        if (useNewList)
        {
            bud = newList;
        }
        StorageBox storageBox = (StorageBox)product;

        storageBox.bud = bud;
    }
Esempio n. 3
0
 void cmdChatSkin(BasePlayer player, string command, string[] args)
 {
     if (args.Length == 1)
     {
         var option = args[0];
         if (option == "on" || !PlayersActivated.Contains(player.userID))
         {
             PlayersActivated.Add(player.userID);
             ItemSkinsCommand(player, true);
             SendReply(player, Messages["skinsOn"]);
         }
         else
         if (option == "off" || PlayersActivated.Contains(player.userID))
         {
             PlayersActivated.Remove(player.userID);
             ItemSkinsCommand(player, false);
             SendReply(player, Messages["skinsOff"]);
         }
         return;
     }
     if (!PlayersActivated.Contains(player.userID))
     {
         SendReply(player, Messages["skinsCurrentlyDisabled"]);
         return;
     }
     timer.Once(0.1f, () =>
     {
         StorageBox.Create(this, player, boxTitle, 18);
         var sb = StorageBox.AddComponent <SkinBox>(this, player);
         boxes.Add(sb, player);
         sb.Init(player);
         StorageBox.StartLooting(this, player);
     });
 }
Esempio n. 4
0
    public BoxStack CreateStackPlaceholder(int ignoreIndex)
    {
        GameObject newPlaceholderStack = new GameObject("Placeholder Stack");
        BoxStack   newStack            = newPlaceholderStack.AddComponent <BoxStack>();

        if (boxList.Count > 0)
        {
            newPlaceholderStack.transform.position = boxList[0].transform.position;
            for (int i = 0; i < boxList.Count; i++)
            {
                int        temp          = i;
                Box        currentBox    = boxList[temp];
                StorageBox parentProduct = (StorageBox)currentBox.product;
                boxList[i].product.PlayCloseAnimation();
                if (i != ignoreIndex)
                {
                    Box newBox = Instantiate(boxList[i]);
                    parentProduct.box = newBox.gameObject;
                    newBox.product    = parentProduct;
                    //newBoxObject.product.PlayCloseAnimation();
                    if (newBox.GetComponent <Placeholder>() == null)
                    {
                        newBox.gameObject.AddComponent <Placeholder>();
                    }
                    newStack.AddBox(newBox);
                }
            }
        }
        newStack.SortStack(newStack.transform.position, true, false);
        return(newStack);
    }
Esempio n. 5
0
    public void RemoveProduct(PackagedProduct toRemove)
    {
        List <PackagedProduct> newList = new List <PackagedProduct>();
        bool useNewList = false;

        foreach (PackagedProduct packagedProduct in products)
        {
            if (packagedProduct.uniqueID == toRemove.uniqueID)
            {
                if (packagedProduct.quantity > 1)
                {
                    packagedProduct.quantity--;
                }
                else if (packagedProduct.quantity <= 1)
                {
                    useNewList = true;
                }
            }
            else
            {
                newList.Add(packagedProduct);
            }
        }
        if (useNewList)
        {
            products = newList;
        }
        StorageBox storageBox = (StorageBox)product;

        storageBox.products = products;
    }
Esempio n. 6
0
        // get a box by number
        public static StorageBox GetBox(MyDVDsContext context, int boxnumber)
        {
            StorageBox box = context.StorageBoxes
                             .Where(p => p.BoxNumber == boxnumber)
                             .FirstOrDefault();

            return(box);
        }
Esempio n. 7
0
    public void AddProduct(PackagedProduct newPackagedProduct)
    {
        newPackagedProduct.parentBox = this;
        products.Add(newPackagedProduct);
        StorageBox storageBox = (StorageBox)product;

        storageBox.products = products;
    }
Esempio n. 8
0
 void OpenBox(BasePlayer player, uint cupboardId)
 {
     timer.Once(0.1f, () =>
     {
         StorageBox.Create(this, player, boxCaption, 18);
         var sb = StorageBox.AddComponent <CupboardBox>(this, player);
         boxes.Add(sb, player);
         sb.Init(player, cupboardId);
         StorageBox.StartLooting(this, player);
     });
 }
Esempio n. 9
0
 public StorageBox_s(StorageBox box) : base(Product.type_.box, box.uniqueID, box.objectID, box.subID, box.GetName(), box.productGO.transform.position, box.productGO.transform.eulerAngles)
 {
     foreach (Box.PackagedProduct product in box.products)
     {
         productsInBox.Add(product.MakeSerializable());
     }
     foreach (Box.PackagedBud bud in box.bud)
     {
         budInBox.Add(bud.MakeSerializable());
     }
 }
Esempio n. 10
0
        // get next available case # for adding a new case to the box object
        public static int GetNextCaseNumber(StorageBox box)
        {
            int nxtnumber = 1;

            if (box.Cases.Count() > 0)
            {
                nxtnumber  = box.Cases.Max(n => n.CaseNumber);
                nxtnumber += 1;
            }

            return(nxtnumber);
        }
Esempio n. 11
0
        public static dynamic AsCustomerView(this Appointment appt)
        {
            var staticStorageBox = StaticStorageBox.GetInstance();

            return(appt == null ? null : new
            {
                UserName = $"[{appt.UserId}] {(StorageBox.GetInstance().Users.Get(appt.UserId)?.UserName ?? "<unknown user>")}",
                Trademark = staticStorageBox.Trademarks.First(t => t.Id == appt.TrademarkId),
                CompanyName = staticStorageBox.Companies.First(c => c.Id == appt.CompanyId),
                Time = appt.Time
            });
        }
    static void Main(string[] args)
    {
        var box = new StorageBox();

        box.Addtobox(5);
        box.Addtobox(3);
        box.Addtobox(4);

        Console.WriteLine(box.WhatIsinBox());

        Console.Read();
    }
Esempio n. 13
0
    public void AddStartBox()
    {
        List <StoreObjectReference> boxModels = db.GetProducts(StoreObjectReference.productType.box);
        GameObject box       = Instantiate(boxModels[1].gameObject_);
        ProductGO  productGO = box.GetComponent <ProductGO>();

        productGO.objectID = boxModels[1].objectID;
        StorageBox storageBox = new StorageBox(boxModels[1], box);

        storageBox.uniqueID              = Dispensary.GetUniqueProductID();
        storageBox.objectID              = boxModels[1].objectID;
        productGO.product                = storageBox;
        productGO.canHighlight           = true;
        box.GetComponent <Box>().product = storageBox;
        List <Product> toAdd = new List <Product>();
        List <StoreObjectReference> bongs = db.GetProducts(StoreObjectReference.productType.glassBong);

        // Add bongs to box

        /*for (int i = 0; i < 4; i++)
         * {
         *  GameObject bongGO = Instantiate(bongs[0].gameObject_);
         *  bongGO.GetComponent<Glass>().height = 16f;
         *  ProductGO productGO_ = bongGO.GetComponent<ProductGO>();
         *  productGO_.objectID = bongs[0].objectID;
         *  Bong newBong = new Bong(bongGO);
         *  newBong.parentProduct = storageBox;
         *  newBong.objectID = bongs[0].objectID;
         *  productGO_.product = newBong;
         *  productGO_.canHighlight = false;
         *  bongGO.gameObject.SetActive(false);
         *  toAdd.Add(newBong);
         *  box.GetComponent<Box>().AddProduct(newBong);
         * }
         * storageBox.AddProducts(toAdd);*/
        Box parentBox = box.GetComponent <Box>();

        Box.PackagedProduct newPackagedProduct = new Box.PackagedProduct(parentBox, bongs[4], 8);
        parentBox.AddProduct(newPackagedProduct);

        Strain toUse = db.GetStrain("Trainwreck");

        // Temp add bud to starting box.  eventually will contain pipes, bowls, and rolling papers to start
        Box.PackagedBud newBud = new Box.PackagedBud(parentBox, toUse, 88);
        parentBox.AddBud(newBud);

        ShelfPosition boxPosition = dm.dispensary.Storage_cs[0].GetRandomStorageLocation(storageBox);

        box.transform.position = boxPosition.transform.position;
        box.transform.parent   = boxPosition.transform;
        boxPosition.shelf.parentShelf.AddProduct(storageBox);
    }
Esempio n. 14
0
        public override void RegisterElement()
        {
            DisplayerHeader("REGISTER MAGAZINE");

            Console.WriteLine(" - Enter collection of the new magazine");
            string magazineCollection = Console.ReadLine();

            Console.WriteLine(" - Enter edition number of the new magazine");
            string editionNumberTxt = Console.ReadLine();

            if (!int.TryParse(editionNumberTxt, out int editionNumber))
            {
                DisplayErrorText("Attribute edition number must a valid integer.");
                return;
            }

            Console.WriteLine(" - Enter release year of the new magazine ");
            string releaseYearTxt = Console.ReadLine();

            if (!DateTime.TryParse(releaseYearTxt, out DateTime releaseYear))
            {
                DisplayErrorText("Attribute release year of the storage box must a valid date.");
                return;
            }

            Console.WriteLine(" - Enter id of the storage box of the new magazine ");
            string storageboxIdTxt = Console.ReadLine();

            if (!int.TryParse(storageboxIdTxt, out int storageboxId))
            {
                DisplayErrorText("Attribute id of the storage box must a valid integer.");
                return;
            }

            StorageBox storageBox = (StorageBox)controllerStorageBox.SelectEntityById(storageboxId);

            Magazine magazine = new Magazine(0, magazineCollection, editionNumber, releaseYear, storageBox);
            string   response = mainController.CreateEntity(magazine);

            if (response != "OP_SUCCESS")
            {
                DisplayErrorText(response);
            }
            else
            {
                DisplaySuccessText("Register Operation Sucessful");
                Console.ReadLine();
                return;
            }
        }
Esempio n. 15
0
        public List <Case> GetCasesFromBox(StorageBox box)
        {
            List <Case> cases = new List <Case>();

            if (box.TotalCases > 0)
            {
                cases = box.Cases.ToList();
            }
            else
            {
                cases.Clear();
            }

            return(cases);
        }
Esempio n. 16
0
    public BoxStack_s MakeSerializable()
    {
        List <Product_s> serializableBoxList = new List <Product_s>();

        foreach (Box box in boxList)
        {
            List <Product_s> boxProducts     = new List <Product_s>();
            StorageBox       storageBox      = (StorageBox)box.product;
            Product_s        newStorageBox_s = storageBox.MakeSerializable();
            serializableBoxList.Add(newStorageBox_s);
        }
        BoxStack_s toReturn = new BoxStack_s(uniqueID, transform.position, transform.eulerAngles, serializableBoxList);

        return(toReturn);
    }
Esempio n. 17
0
        // ADD the next Case to a specific box
        public static Case AddNextCase(MyDVDsContext context, int boxnum)
        {
            StorageBox sb = new StorageBox();
            Case       ca = new Case();

            // get the box
            sb = GetBox(context, boxnum);

            // set next case number
            ca.CaseNumber = GetNextCaseNumber(sb);

            // set fields
            ca.CaseType  = sb.BoxType;
            ca.Notes     = "";
            ca.IsABoxset = false;
            ca.Title     = "";


            // set parent nav
            ca.StorageBoxId = sb.Id;
            sb.TotalCases++;
            ca.StorageBox = sb;

            // set lookup navs
            switch (ca.CaseType)
            {
            case "CD":
                ca.DVDIconId = CDCASEICON;
                break;

            case "DVD":
                ca.DVDIconId = DVDCASEICON;
                break;

            default:
                ca.DVDIconId = CDCASEICON;
                break;
            }

            ca.DVDIcon = GetDVDIcon(context, ca.DVDIconId);

            // add the new case to the box
            sb.Cases.Add(ca);
            context.SaveChanges();

            return(ca);
        }
Esempio n. 18
0
    public void AddBud(PackagedBud newBud)
    {
        int index = CheckAgainstList(newBud);

        if (!(index >= 0))
        {
            bud.Add(newBud);
        }
        else
        {
            bud[index].AddBud(newBud.weight);
        }
        currentWeight += Mathf.RoundToInt(newBud.weight);
        StorageBox storageBox = (StorageBox)product;

        storageBox.bud = bud;
    }
Esempio n. 19
0
        // ADD a new Box - no related records
        public static StorageBox AddABox(MyDVDsContext context, string boxtype)
        {
            StorageBox sb = new StorageBox();

            // get next box #
            sb.BoxNumber = GetNextBoxNumber(context);

            // init fields
            sb.BoxType = boxtype;
            sb.Notes   = "";

            // add it
            context.StorageBoxes.Add(sb);
            context.SaveChanges();

            return(sb);
        }
Esempio n. 20
0
    public Box CreateBox(int orderWeight)
    {
        StoreObjectReference currentBoxReference = GetBox(orderWeight);
        GameObject           newProductBox       = Instantiate(currentBoxReference.gameObject_);
        ProductGO            productGO           = newProductBox.GetComponent <ProductGO>();

        productGO.objectID = currentBoxReference.objectID;
        StorageBox storageBox = new StorageBox(currentBoxReference, newProductBox);

        storageBox.objectID    = currentBoxReference.objectID;
        storageBox.uniqueID    = Dispensary.GetUniqueProductID();
        productGO.product      = storageBox;
        productGO.canHighlight = true;
        newProductBox.GetComponent <Box>().product       = storageBox;
        newProductBox.GetComponent <Box>().currentWeight = 0;
        newProductBox.GetComponent <Box>().maxWeight     = currentBoxReference.boxWeight;
        return(newProductBox.GetComponent <Box>());
    }
Esempio n. 21
0
    public void AddProduct(StoreObjectReference newReference)
    {
        print("Adding reference");
        int checkValue = CheckAgainstList(newReference);

        if (checkValue == -1)
        {
            PackagedProduct newPackagedProduct = new PackagedProduct(this, newReference, 1);
            newPackagedProduct.uniqueID = Dispensary.GetUniqueProductID();
            products.Add(newPackagedProduct);
        }
        else if (checkValue >= 0)
        {
            products[checkValue].AddProduct();
        }
        currentWeight += product.boxWeight;
        StorageBox storageBox = (StorageBox)product;

        storageBox.products = products;
    }
Esempio n. 22
0
 public void FinishAddingBox(Box boxToMove)
 { // Sets the temp stack to be the main one
     if (tempIncreasedStack != null)
     {
         Destroy(tempIncreasedStack.gameObject);
     }
     displayingTempIncreasedStack = false;
     if (newBox != null)
     {
         StorageBox product      = (StorageBox)boxToMove.product;
         Box        reallyNewBox = Instantiate(newBox);
         product.box          = reallyNewBox.gameObject;
         reallyNewBox.product = product;
         ProductGO newProductGO    = reallyNewBox.GetComponent <ProductGO>();
         ProductGO toMoveProductGO = boxToMove.GetComponent <ProductGO>();
         newProductGO.objectID       = toMoveProductGO.objectID;
         reallyNewBox.parentBoxStack = this;
         AddBox(reallyNewBox);
     }
     Destroy(boxToMove.gameObject);
     SortStack(transform.position, true, false);
 }
Esempio n. 23
0
    public void Place(BoxStack newParentStack)
    {
        StorageBox thisStorageBox = (StorageBox)this;

        productGO.GetComponent <ProductGO>().enabled   = true;
        productGO.GetComponent <BoxCollider>().enabled = true;
        if (newParentStack != null)
        {
            newParentStack.FinishAddingBox(thisStorageBox.box.GetComponent <Box>());
        }
        else
        { // no stack
            try
            {
                BoxStack newStack = thisStorageBox.box.GetComponent <Box>().CreateBoxStack();
                thisStorageBox.GetDispensaryManager().dispensary.inventory.AddLooseBoxStack(newStack);
            }
            catch (System.NullReferenceException)
            {
                // Couldnt add to list
            }
        }
    }
Esempio n. 24
0
    public BoxStack CreateStackPlaceholder_IncreasedSize(Box newBox)
    {
        List <Box> tempBoxList = new List <Box>();

        foreach (Box box in boxList)
        {
            tempBoxList.Add(box);
        }
        tempBoxList.Add(newBox);
        tempBoxList.Sort(SortBoxes);
        GameObject newPlaceholderStack = new GameObject("Placeholder Stack");
        BoxStack   newStack            = newPlaceholderStack.AddComponent <BoxStack>();

        if (tempBoxList.Count > 0)
        {
            newPlaceholderStack.transform.position = tempBoxList[0].transform.position;
            for (int i = 0; i < tempBoxList.Count; i++)
            {
                int        temp          = i;
                Box        currentBox    = tempBoxList[temp];
                StorageBox parentProduct = (StorageBox)currentBox.product;
                Box        newBoxObject  = Instantiate(tempBoxList[i]);
                parentProduct.box    = newBoxObject.gameObject;
                newBoxObject.product = parentProduct;
                newBoxObject.gameObject.SetActive(true);
                //newBoxObject.product.PlayCloseAnimation();
                if (newBox.GetComponent <Placeholder>() == null)
                {
                    newBox.gameObject.AddComponent <Placeholder>();
                }
                newStack.AddBox(newBoxObject);
            }
        }
        newStack.SortStack(newStack.transform.position, true, false);
        Destroy(newBox.gameObject); // destory box that was originally sent
        return(newStack);
    }
Esempio n. 25
0
    public Box StartRemovingBox(ProductManager.CurrentProduct currentProduct, int productID)
    { // Displays a temp stack that doesnt include the box getting removed
        // Returns the box that got removed
        currentProduct.originalStack = this;
        Box toReturn    = null;
        int ignoreIndex = -1;
        int counter     = 0;

        foreach (Box box in boxList)
        {
            if (box.product.uniqueID == productID)
            {
                StoreObjectReference reference = box.product.productReference;
                toReturn = Instantiate(box);
                StorageBox newStorageBox = new StorageBox(reference, toReturn.gameObject);
                newStorageBox.uniqueID = currentProduct.currentProduct.uniqueID;
                toReturn.product       = newStorageBox;
                ignoreIndex            = counter;
            }
            counter++;
        }
        if (toReturn != null)
        {
            BoxCollider collider = toReturn.GetComponent <BoxCollider>();
            collider.enabled = false;
            toReturn.gameObject.SetActive(true);
            toReturn.product.PlayCloseAnimation();
            displayingTempReducedStack = true;
            tempReducedStack           = CreateStackPlaceholder(ignoreIndex);
            foreach (Box box in boxList)
            {
                box.gameObject.SetActive(false);
            }
        }
        return(toReturn);
    }
Esempio n. 26
0
 public ApptBL()
 {
     appts = StorageBox.GetInstance().Appointments;
 }
Esempio n. 27
0
        // get a box by number
        public StorageBox GetBox(int boxnumber)
        {
            StorageBox sb = DALServices.GetBox(context, boxnumber);

            return(sb);
        }
Esempio n. 28
0
 public CarWorkshopBL()
 {
     workshops = StorageBox.GetInstance().CarWorkshops;
 }
    public GameObject CreatePlaceholder(CurrentProduct needsPlaceholder)
    {
        Product product     = needsPlaceholder.currentProduct;
        Color   toUse       = Color.white;
        bool    assignColor = false;

        if (product != null)
        {
            GameObject toInstantiate = null;
            try
            {
                toInstantiate = product.productGO;
                if (toInstantiate == null)
                { // product go was null, throw exception
                    throw new System.NullReferenceException();
                }
            }
            catch (System.NullReferenceException)
            {
                if (product.productType == Product.type_.packagedBud)
                {
                    if (needsPlaceholder.currentContainer == null)
                    {
                        StoreObjectReference budPlaceholder = dm.database.GetProduct("Bud Placeholder");
                        toInstantiate = budPlaceholder.gameObject_;
                    }
                    else
                    {
                        toInstantiate = needsPlaceholder.currentContainer.gameObject_;
                    }
                }
                if (product.productType == Product.type_.packagedProduct)
                {
                    Box.PackagedProduct packagedProduct = (Box.PackagedProduct)product;
                    if (packagedProduct != null)
                    {
                        toInstantiate = packagedProduct.productReference.gameObject_;
                        toUse         = product.productReference.color.GetColor_PackagedProduct();
                        assignColor   = true;
                    }
                }
            }
            if (product.IsBox())
            {
                StorageBox storageBox = (StorageBox)product;
                Box        box        = storageBox.box.GetComponent <Box>();
                if (box.parentBoxStack != null)
                {
                    Box boxToMove = box.parentBoxStack.StartRemovingBox(needsPlaceholder, box.product.uniqueID);
                    if (boxToMove.GetComponent <Placeholder>() == null)
                    {
                        boxToMove.gameObject.AddComponent <Placeholder>();
                    }
                    storageBox.box    = boxToMove.gameObject;
                    boxToMove.product = storageBox;
                    return(boxToMove.gameObject);
                }
                else if (storageBox != null)
                {
                    Box         placeholderBox = Instantiate(storageBox.box.GetComponent <Box>());
                    BoxCollider collider       = placeholderBox.GetComponent <BoxCollider>();
                    collider.enabled = false;
                    StorageBox newStorageBox = new StorageBox(storageBox.productReference, placeholderBox.gameObject);
                    newStorageBox.uniqueID = storageBox.uniqueID;
                    placeholderBox.product = newStorageBox;
                    if (placeholderBox.GetComponent <Placeholder>() == null)
                    {
                        placeholderBox.gameObject.AddComponent <Placeholder>();
                    }
                    return(placeholderBox.gameObject);
                }
                else
                {
                    //print("Falling through");
                }
            }
            if (toInstantiate != null)
            {
                //print("Something exists to be instantiated");
                GameObject newPlaceholderGO = Instantiate(toInstantiate);
                //print("1");
                if (newPlaceholderGO.GetComponent <Placeholder>() == null)
                {
                    newPlaceholderGO.AddComponent <Placeholder>();
                }
                Placeholder newPlaceholder = newPlaceholderGO.GetComponent <Placeholder>();
                newPlaceholder.parentProduct      = needsPlaceholder;
                currentProduct.currentPlaceholder = newPlaceholder;
                if (product.productType == Product.type_.packagedBud)
                {
                    /*if (needsPlaceholder.currentContainer == null)
                     * {
                     *  newPlaceholder.NoContainerToggle();
                     * }
                     * else
                     * {
                     *  newPlaceholder.HasContainerToggle();
                     * }
                     */
                }

                // Apply product color
                if (assignColor)
                {
                    newPlaceholderGO = ApplyColor(newPlaceholderGO, toUse);
                }

                /*ProductGO productGO = currentProduct.GetComponent<ProductGO>();
                 * if (productGO != null)
                 * {
                 *  if (productGO.product != null)
                 *  {
                 *      if (productGO.product.productReference != null)
                 *      {
                 *          StoreObjectReference reference = productGO.product.productReference;
                 *          if (reference != null)
                 *          {
                 *              if (reference.color.colorIsAssigned)
                 *              {
                 *                  try
                 *                  {
                 *                      newPlaceholderGO = ApplyColor(newPlaceholderGO, reference.color.GetColor());
                 *                  }
                 *                  catch (System.ArgumentException)
                 *                  {
                 *                      print("Color was marked as being assigned, but wasnt there");
                 *                  }
                 *              }
                 *          }
                 *      }
                 *  }
                 * }*/

                return(newPlaceholderGO); // needsPlaceholder.currentPlaceholder = newPlaceholder.GetComponent<Placeholder>();
            }
            else
            {
                print("The object to instantiate is null: " + product.GetName());
                return(null);
            }
        }
        else
        {
            print("Returning null");
            return(null);
        }
    }
    IEnumerator MoveProduct()
    {
        while (true)
        {
            currentDisplayShelf = null;
            currentShelf        = null;
            bool movementConflict = false;
            if (currentProduct != null)
            {
                // Raise or lower shelf layer
                if (Input.GetKeyUp(dm.database.settings.GetRaiseShelfLayer()))
                {
                    SetCurrentShelfLayer(currentShelfLayer + 1);
                }
                if (Input.GetKeyUp(dm.database.settings.GetLowerShelfLayer()))
                {
                    SetCurrentShelfLayer(currentShelfLayer - 1);
                }

                // If moving a box
                bool productIsBox = currentProduct.currentProduct.IsBox();
                if (productIsBox)
                { // Moving box
                    print("Moving box");
                }
                if (currentProduct.newStack != null)
                {
                    currentProduct.newStack.CancelAddingBox();
                    currentProduct.newStack = null;
                    if (currentProduct.currentPlaceholder != null)
                    {
                        currentProduct.currentPlaceholder.gameObject.SetActive(true);
                    }
                }

                bool chooseContainerPanelOpen = uiM_v5.chooseContainerPanel.panelOpen;
                bool placingBudPanelOpen      = uiM_v5.packagedBudPlacementPanel.panelOpen;
                // Raycasting
                Ray          ray  = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit[] hits = Physics.RaycastAll(ray.origin, ray.direction);

                if (currentProduct.currentProduct.NeedsContainer())
                {
                    if (Input.GetKeyUp(dm.database.settings.GetOpenChooseContainerPanel().ToLower()))
                    {
                        if (chooseContainerPanelOpen)
                        {
                            uiM_v5.CloseChooseContainerPanel();
                        }
                        else
                        {
                            currentProduct.currentPlaceholder.indicator.OpenChooseContainerPanel(currentProduct);
                        }
                    }
                }
                if (chooseContainerPanelOpen || placingBudPanelOpen)
                {
                    // Dont carry on if either of these windows are open
                    yield return(null);
                }
                else if (currentProduct.currentPlaceholder != null)
                {
                    currentProduct.currentPlaceholder.GetComponent <BoxCollider>().enabled = false;
                    currentProduct.currentPlaceholder.HighlightOff();
                    bool hitShelf = false;
                    foreach (RaycastHit hit in hits)
                    {
                        if (hit.transform.tag == "DisplayShelf" || hit.transform.tag == "CheckoutCounter")
                        {
                            if (hit.transform.tag == "DisplayShelf")
                            {
                                SetCurrentDisplayShelf(hit.transform.gameObject.GetComponent <StoreObjectFunction_DisplayShelf>());
                            }
                            else if (hit.transform.tag == "CheckoutCounter")
                            {
                                StoreObjectFunction_DisplayShelf shelf = hit.transform.gameObject.GetComponent <StoreObjectFunction_DisplayShelf>();
                                if (shelf != null)
                                {
                                    SetCurrentDisplayShelf(shelf);
                                }
                                else
                                {
                                    hitShelf = false;
                                    break;
                                }
                            }
                        }
                        if (hit.transform.gameObject.layer == 21)
                        {
                            currentShelf = hit.transform.gameObject.GetComponent <Shelf>();
                            if (currentShelf.shelfLayer == GetCurrentShelfLayer())
                            {
                                hitShelf = true;
                                currentProduct.currentPlaceholder.transform.position = hit.point;
                            }
                            SetCurrentDisplayShelf(currentShelf.parentShelf);
                        }
                        if (hit.transform.gameObject.layer == 17)
                        {
                            //print("Hitting product");
                        }
                        if (hit.transform.tag == "StorageBox" && productIsBox)
                        {
                            Box        beingMoved           = currentProduct.currentPlaceholder.GetComponent <Box>();
                            StorageBox storageBoxBeingMoved = (StorageBox)beingMoved.product;
                            Box        hitBox = hit.transform.GetComponent <Box>();
                            if (hitBox != null)
                            {
                                BoxStack stack = hitBox.parentBoxStack;
                                if (stack != null)
                                {
                                    if (stack.boxList.Count <= 2)
                                    {
                                        currentProduct.newStack = stack;
                                        Box        toSend        = Instantiate(beingMoved);
                                        StorageBox newStorageBox = new StorageBox(storageBoxBeingMoved.productReference, toSend.gameObject);
                                        newStorageBox.uniqueID = storageBoxBeingMoved.uniqueID;
                                        toSend.product         = newStorageBox;
                                        currentProduct.newStack.StartAddingBox(toSend);
                                        beingMoved.gameObject.SetActive(false);
                                        // need to handle carrying across contents as well
                                    }
                                    else
                                    {
                                        // Stack is full
                                        stack.gameObject.GetComponent <Highlighter>().ConstantOnImmediate(Color.red);
                                    }
                                }
                                else
                                {
                                    print("Need to create a new stack");
                                }
                            }
                        }
                    }
                    if (!hitShelf && hits.Length > 0 && !productIsBox)
                    { // Find the nearest display shelf
                        try
                        {
                            currentDisplayShelf = GetClosestDisplayShelf(hits[0].point);
                            currentShelf        = currentDisplayShelf.GetShelf(GetCurrentShelfLayer(), hits[0].point);
                            Vector3 closestPoint = currentShelf.GetCollider().ClosestPoint(hits[0].point);
                            currentProduct.currentPlaceholder.transform.position = closestPoint;
                        }
                        catch (System.NullReferenceException)
                        {
                            // Failed to find a nearby shelf
                        }
                    }
                    else if (!hitShelf && hits.Length > 0 && productIsBox)
                    {
                        try
                        {
                            RaycastHit       toUse          = hits[0];
                            bool             outdoorHit     = false;
                            ComponentSubGrid closestSubGrid = dm.dispensary.GetClosestSubGrid(toUse.point);
                            ComponentGrid    grid           = closestSubGrid.parentGrid;
                            FloorTile        hitTile        = null;
                            foreach (RaycastHit hit in hits)
                            {
                                if (hit.transform.tag == "Floor")
                                {
                                    hitTile = hit.transform.GetComponent <FloorTile>();
                                }
                            }
                            if (hitTile != null)
                            {
                                outdoorHit = false;
                            }
                            else
                            {
                                outdoorHit = true;
                            }
                            ComponentNode nodeToSnapTo    = null;
                            GameObject    tempTileGO      = Instantiate(dm.database.GetFloorTile(10000).gameObject_);
                            BoxCollider   placeholderTile = tempTileGO.GetComponent <BoxCollider>();
                            if (hitTile != null)
                            {
                                outdoorHit   = false;
                                nodeToSnapTo = hitTile.node;
                            }
                            if (nodeToSnapTo == null)
                            {
                                nodeToSnapTo = GetClosestEdgeNode(grid, toUse, outdoorHit);
                            }
                            Vector3 snapPos = nodeToSnapTo.worldPosition;
                            Vector3 newPos  = new Vector3(snapPos.x, snapPos.y + placeholderTile.bounds.extents.y, snapPos.z);
                            if (!dm.actionManager.snapToGrid)
                            { // If not snapping to grid and didnt hit something outside
                                if (!outdoorHit)
                                {
                                    foreach (RaycastHit hit in hits)
                                    {
                                        if (hit.transform.tag == "Floor")
                                        {
                                            newPos = hit.point;
                                        }
                                    }
                                }
                            }
                            currentProduct.currentPlaceholder.transform.position = newPos;
                            Destroy(tempTileGO.gameObject);
                        }
                        catch (System.NullReferenceException)
                        {
                        }
                    }
                    if (currentDisplayShelf != null && currentShelf != null)
                    {
                        // Disable Colliders
                        currentDisplayShelf.GetComponent <BoxCollider>().enabled = false;
                        currentShelf.GetCollider().enabled = false;

                        // Perform collision check
                        BoxCollider productCollider = currentProduct.currentPlaceholder.GetComponent <BoxCollider>();
                        productCollider.enabled = true;
                        Vector3 size = productCollider.bounds.size; // /14
                        //Vector3 center = productCollider.bounds.center;
                        productCollider.enabled = false;
                        //size.x = Mathf.Abs(size.x);
                        //size.y = Mathf.Abs(size.y);
                        //size.z = Mathf.Abs(size.z);
                        //float oldY = size.y;
                        //size.y = size.z;
                        //size.z = oldY;
                        Vector3    center  = new Vector3(productCollider.transform.position.x, productCollider.transform.position.y + size.y / 2, productCollider.transform.position.z);
                        Collider[] results = Physics.OverlapBox(center, size / 2);

                        if (results.Length > 0)
                        {
                            //print(results.Length);
                            bool conflict = true;

                            /*foreach (Collider col in results)
                             * {
                             *  if (col.tag == "Shelf")
                             *  {
                             *      print("COnflict with shelf 1");
                             *      conflict = true;
                             *      break;
                             *  }
                             *  else if (col.gameObject.layer == 21)
                             *  { // Shelf layer
                             *      print("COnflict with shelf 2");
                             *      conflict = true;
                             *      break;
                             *  }
                             *  else if (col.gameObject.layer == 17)
                             *  { // Product layer
                             *      print("COnflict with product");
                             *      conflict = true;
                             *      break;
                             *  }
                             * }*/
                            if (conflict)
                            {
                                movementConflict = true;
                                currentProduct.currentPlaceholder.HighlightOn(Color.red);
                            }
                            results = null;
                        }

                        // Re-enable colliders
                        currentDisplayShelf.GetComponent <BoxCollider>().enabled = true;
                        currentShelf.GetCollider().enabled = true;
                    }
                    else
                    {
                        //print("Didnt check");
                    }
                    currentProduct.currentPlaceholder.GetComponent <BoxCollider>().enabled = true;
                }
                else
                {
                    print("Placeholder doesnt exist");
                }
                if (Input.GetMouseButtonUp(0) && !dm.PointerOverUI)
                { // Left Click
                    if (!movementConflict)
                    {
                        if (currentProduct.currentProduct.NeedsContainer())
                        {
                            if (currentProduct.currentContainer != null)
                            {
                                Box.PackagedBud packagedBud = currentProduct.GetPackagedBud();
                                if (packagedBud != null)
                                {
                                    currentProduct.currentPlaceholder.indicator.OpenPackagedBudPlacementPanel(currentProduct.currentContainer, packagedBud);
                                }
                            }
                            else
                            {
                                currentProduct.currentPlaceholder.indicator.OpenChooseContainerPanel(currentProduct);
                            }
                        }
                        else if (!productIsBox)
                        {
                            Box.PackagedProduct packagedProduct = null;
                            bool isPackagedProduct = false;
                            try
                            {
                                packagedProduct   = (Box.PackagedProduct)currentProduct.currentProduct;
                                isPackagedProduct = true;
                            }
                            catch (System.InvalidCastException)
                            { // Wasnt a packaged product
                                // Do nothing, allow to carry on
                                isPackagedProduct = false;
                            }
                            if (isPackagedProduct)
                            {
                                if (packagedProduct != null)
                                {
                                    packagedProduct.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentDisplayShelf);
                                    currentProduct.FinishMovement();

                                    // Try moving next packaged product
                                    StartCoroutine(StartMovingNextPackagedProduct());
                                    yield return(new WaitForSeconds(.0125f)); // Needs to last longer than the waitforseconds(.01f)

                                    packagedProduct.parentBox.RemoveProduct(packagedProduct);
                                    uiM_v5.leftBarMainSelectionsPanel.UpdateBoxScrollable();
                                    yield break;

                                    /*Product newProduct = null;
                                     * CurrentProduct oldProduct = currentProduct;
                                     * try
                                     * { // Use packaged product reference
                                     *  newProduct = CreateProduct(packagedProduct.packagedProductReference, packagedProduct.parentBox.transform.position);
                                     * }
                                     * catch (System.NullReferenceException)
                                     * { // Use product reference
                                     *  newProduct = CreateProduct(packagedProduct.productReference, packagedProduct.parentBox.transform.position);
                                     * }
                                     * if (newProduct != null)
                                     * {
                                     *  newProduct.productGO.gameObject.SetActive(false);
                                     *  newProduct.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentDisplayShelf);
                                     *  currentProduct.currentProduct.uniqueID = newProduct.uniqueID;
                                     *  currentProduct.FinishMovement();
                                     *
                                     *  // Try moving next packaged product
                                     *  StartCoroutine(StartMovingNextPackagedProduct());
                                     *  yield return new WaitForSeconds(.0125f); // Needs to last longer than the waitforseconds(.01f)
                                     *  packagedProduct.parentBox.RemoveProduct(packagedProduct);
                                     *  uiM_v5.leftBarMainSelectionsPanel.UpdateBoxScrollable();
                                     *  yield break;
                                     * }*/
                                }
                            }
                            else
                            { // Is not a packaged product0
                                currentProduct.currentProduct.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentDisplayShelf);

                                uiM_v5.leftBarMainSelectionsPanel.RemoveProduct(currentProduct.currentProduct, false);
                                if (moveMode == MoveMode.single)
                                {
                                    FinishedMovingSingleProduct();
                                }
                                else if (moveMode == MoveMode.multiple)
                                {
                                    FinishedMovingMultipleProducts();
                                }
                                yield break;
                            }
                        }
                        else if (productIsBox)
                        {
                            bool       newStackExists = false;
                            StorageBox beingMoved     = (StorageBox)currentProduct.currentProduct;
                            if (currentProduct.newStack != null)
                            {
                                newStackExists = true;
                            }
                            if (newStackExists)
                            {
                                beingMoved.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentProduct.newStack);
                            }
                            else if (currentDisplayShelf != null)
                            {
                                beingMoved.MoveProduct(Dispensary.JobType.StoreBudtender, currentProduct.currentPlaceholder.transform.position, currentDisplayShelf);
                            }
                        }
                    }
                    else
                    {
                        print("Cant move here: wont fit");
                    }
                }
            }
            yield return(null);
        }
    }