예제 #1
0
            public MatrixBounds Prepare(CellMatrix matrix, bool block)
            {
                MatrixBounds combinedCoverage;

                //The bounds used last check
                _oldBounds.Mirror(_actualBounds);

                if (!block)
                {
                    //Only unblock is required, so the affected area is the most recent coverage
                    combinedCoverage = _cellCoverage;
                    _actualBounds.Reset();
                    _cellCoverage = MatrixBounds.nullBounds;

                    return(combinedCoverage);
                }

                var velocity = _parent.GetVelocity();

                var obstacleSensitivityRange = _parent.useGridObstacleSensitivity ? matrix.obstacleSensitivityRange : _parent.customSensitivity;

                PrepareHull(velocity, obstacleSensitivityRange);

                //Get the axis-aligned bounding box
                var bounds = _actualBounds.CalculateBounds();

                //Get the new coverage, combine it with the old for coverage of both those to unblock and block
                var newCoverage = matrix.GetMatrixBounds(bounds, matrix.cellSize / 2f, true);

                combinedCoverage = MatrixBounds.Combine(_cellCoverage, newCoverage);
                _cellCoverage    = newCoverage;

                return(combinedCoverage);
            }