private void Update()
        {
            if (gameManager.GameForcePause && !gameManager.IsTutorialEnabled)
            {
                return;
            }

            var ray         = Camera.main.ScreenPointToRay(Input.mousePosition);
            var rotateInput = Input.GetButtonUp("RotatePrefab");

            if (rotateInput)
            {
                transform.Rotate(0.0f, 90f, 0.0f);
                var tmp = tableLength;
                tableLength = tableWidth;
                tableWidth  = tmp;
            }

            if (Physics.Raycast(ray, out hit))
            {
                tmp = hit.collider;
                if (hit.collider.gameObject.CompareTag("Ground"))
                {
                    pos    = hit.point;
                    pos.y += 1;
                    var cell = grid.getCellPosition(pos);
                    pos.x = cell.x;
                    pos.z = cell.z;

                    transform.position = pos;

                    // var hitColliders =
                    //     Physics.OverlapBox(transform.position, new Vector3(1f, 0.5f, 2f), transform.rotation);
                    // foreach (var hitCollider in hitColliders)
                    //     if (!hitCollider.transform.IsChildOf(transform))
                    //         if (!hitCollider.gameObject.CompareTag("Ground"))
                    //         {
                    //             setColor(true);
                    //             return;
                    //         }

                    if (!checkPosition())
                    {
                        setColor(true);
                        notificationSystem.CreateNotification("Too close to another object", 0.5f);
                        return;
                    }

                    setColor(false);
                }
            }


            if (Input.GetMouseButtonDown(0))
            {
                var transform1 = transform;

                if (!checkPosition())
                {
                    return;
                }

                updateGrid();


                // var hitColliders =
                //     Physics.OverlapBox(transform1.position, new Vector3(1f, 0.5f, 2f), transform1.rotation);
                // foreach (var hitCollider in hitColliders)
                //     if (!hitCollider.transform.IsChildOf(transform))
                //         if (!hitCollider.gameObject.CompareTag("Ground"))
                //             return;

                Instantiate(prefab, transform1.position - new Vector3(0f, 0.5f, 0f), transform1.rotation);
                resourcesManager.Seats += seats;
                graph.UpdateGraph();
                notificationSystem.CreateNotification("Table placed");
                Destroy(gameObject);
                gameManager.GamePause = false;
            }
        }
        private void Update()
        {
            if (gameManager.GameForcePause && !gameManager.IsTutorialEnabled)
            {
                return;
            }

            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.gameObject.CompareTag("BorderWall"))
                {
                    if (nextAnchor == hit.collider.gameObject)
                    {
                        delay += Time.unscaledDeltaTime;
                    }
                    else
                    {
                        nextAnchor = hit.collider.gameObject;
                        delay      = 0f;
                    }

                    if (delay >= 0.5f)
                    {
                        placeable          = true;
                        wallAnchor         = nextAnchor;
                        transform.position = hit.collider.transform.position;
                        transform.rotation = hit.collider.transform.rotation;
                    }
                }
            }

            var hitColliders = Physics.OverlapBox(CalculateCentroid(), new Vector3(1.5f, 2f, 1.5f), transform.rotation);

            if (hitColliders.Length != 0)
            {
                placeable = false;
            }

            if (placeable)
            {
                setColor(true);
            }
            else
            {
                setColor(false);
            }

            if (Input.GetMouseButtonDown(0) && placeable)
            {
                var o = Instantiate(prefab, transform.position, transform.rotation);
                gameObject.SetActive(false);

                foreach (var item in o.GetComponentsInChildren <Transform>())
                {
                    if (item.CompareTag("BorderWall"))
                    {
                        if (CheckForOtherRoom(1f, item.gameObject))
                        {
                            Destroy(o);
                            gameObject.SetActive(true);
                            return;
                        }
                    }
                }

                foreach (var item in o.GetComponentsInChildren <Transform>())
                {
                    if (item.CompareTag("BorderWall"))
                    {
                        // if (transform.eulerAngles.y != 0 && transform.eulerAngles.y != -180 && transform.eulerAngles.y != 180)
                        // {
                        //     item.GetComponent<GridSetter>().Pivot = true;
                        // }
                        if (item.position.x < tavernLimit)
                        {
                            item.gameObject.tag = "Wall";
                        }

                        DestroyObjectAtLocation(0.5f, item.gameObject);
                    }
                }

                gameObject.SetActive(true);
                placementManager.InitAllNodes();
                notificationSystem.CreateNotification("New room build");
                Destroy(wallAnchor);
                Destroy(gameObject);
                gameManager.GamePause = false;
            }
        }