GetNearSwapPosition(...) in GameSequence

                Never    
C#
       
    public bool GetNearSwapPosition(DroppableBlock block, out Vector2Int[] gridPositions)
    {
        gridPositions = new Vector2Int[block.CurrentGridPositions.Length];

        var swapPoint = Vector2.positiveInfinity;

        var haveSwap = false;

        foreach (var point in _swapPositions)
        {
            if (!point.Value)
                continue;

            Vector3[] worldPositions;

            if (!GetWorldPosition(new Vector2Int[] { point.Key }, out worldPositions))
                continue;

            if (Vector2.Distance(swapPoint, block.Position) < Vector2.Distance(worldPositions[0], block.Position))
                continue;

            var haveSpace = true;

            for (int i = 0; i < worldPositions.Length; i++)
            {
                var overlap = Physics2D.OverlapBoxAll(worldPositions[i], Vector2.one * 0.5f * LevelScaleFactor, 0f, GameConfig.BlockLayer);

                var checkedPos = true;

                foreach (var collider in overlap)
                {
                    if (!block.Colliders.Contains(collider))
                    {
                        checkedPos = false;
                        break;
                    }
                }

                if (!checkedPos)
                {
                    haveSpace = false;
                    break;
                }
            }

            if (!haveSpace)
                continue;
        }

        return haveSwap;
    }

Raw Text