private static bool CanBuild()
    {
        // Check if nodes are occupied
        int gx = Instance.rotation % 2 == 0 ? placingBuilding.gridWidth : placingBuilding.gridHeight;
        int gy = Instance.rotation % 2 == 1 ? placingBuilding.gridWidth : placingBuilding.gridHeight;

        for (int dx = 0; dx < gx; dx++)
        {
            for (int dy = 0; dy < gy; dy++)
            {
                if (!Grid.ValidNode(Instance.hoverGridX + dx, Instance.hoverGridY + dy))
                {
                    continue;
                }
                Node myNode = Grid.GetNode(Instance.hoverGridX + dx, Instance.hoverGridY + dy);
                if (Grid.Occupied(Instance.hoverGridX + dx, Instance.hoverGridY + dy) || (placingBuilding.inWater != myNode.IsWater()))
                {
                    return(false);
                }
                if (Instance.cave && !placingBuilding.stayInRangeOfParent && !GameManager.InRange(Grid.ToWorld(Instance.hoverGridX + dx, Instance.hoverGridY + dy), Instance.cave.transform.position, Instance.cave.BuildRange))
                {
                    return(false);
                }
            }
        }

        if (placingBuilding.stayInRangeOfParent)
        {
            BuildingScript parent = UIManager.Instance.GetSelectedBuilding();
            if (Instance.movingBuilding)
            {
                parent = BuildingScript.Identify(Instance.movingBuilding.ParentBuildingNr);
            }
            if (!GameManager.InRange(Instance.hoverBuilding.position, parent.transform.position, parent.BuildRange))
            {
                return(false);
            }
        }
        return(true);
    }