Beispiel #1
0
        private void Initialize(ICellMatrixConfiguration cfg)
        {
            _cellSize = cfg.cellSize;
            _origin   = cfg.origin;
            _start    = cfg.origin;
            _start.x -= this.columns * 0.5f * _cellSize;
            _start.z -= this.rows * 0.5f * _cellSize;

            _obstacleSensitivityRange   = cfg.obstacleSensitivityRange;
            _generateHeightMap          = cfg.generateHeightmap && (GameServices.heightStrategy.heightMode == HeightSamplingMode.HeightMap);
            _upperBoundary              = cfg.upperBoundary;
            _lowerBoundary              = cfg.lowerBoundary;
            _obstacleAndGroundDetection = cfg.obstacleAndGroundDetection;
            _obstacleAndGroundDetector  = cfg.obstacleAndGroundDetector;

            _granularity = GameServices.heightStrategy.sampleGranularity;

            if (_generateHeightMap)
            {
                _heightMapSizeX       = Mathf.RoundToInt(this.columns * this.cellSize / _granularity) + 1;
                _heightMapSizeZ       = Mathf.RoundToInt(this.rows * this.cellSize / _granularity) + 1;
                _heightLookupType     = cfg.heightLookupType;
                _heightLookupMaxDepth = cfg.heightLookupMaxDepth;
            }

            _bounds = cfg.bounds;

            _shortcutPortals = new List <PortalCell>();
        }
Beispiel #2
0
        /// <summary>
        /// Gets a builder for initializing the grid. This is a framework method, and should not be called.
        /// </summary>
        /// <returns>The builder configured for this grid.</returns>
        public GridBuilder GetBuilder()
        {
            //Resolve custom block detector if applicable
            if (this.obstacleAndGroundDetection == ColliderDetectionMode.Custom && _obstacleAndGroundDetector == null)
            {
                var fact = this.As <IBlockDetectorFactory>(true);
                if (fact == null)
                {
                    this.obstacleAndGroundDetection = ColliderDetectionMode.Mixed;
                }
                else
                {
                    _obstacleAndGroundDetector = fact.Create();
                    if (_obstacleAndGroundDetector == null)
                    {
                        this.obstacleAndGroundDetection = ColliderDetectionMode.Mixed;
                    }
                }
            }

            return(new GridBuilder
            {
                origin = this.origin,
                sizeX = this.sizeX,
                sizeZ = this.sizeZ,
                cellSize = this.cellSize,
                obstacleSensitivityRange = this.obstacleSensitivityRange,
                generateHeightmap = this.generateHeightmap,
                heightLookupType = this.heightLookupType,
                heightLookupMaxDepth = this.heightLookupMaxDepth,
                lowerBoundary = this.lowerBoundary,
                upperBoundary = this.upperBoundary,
                obstacleAndGroundDetection = this.obstacleAndGroundDetection,
                obstacleAndGroundDetector = _obstacleAndGroundDetector,
                subSectionsX = this.subSectionsX,
                subSectionsZ = this.subSectionsZ,
                subSectionsCellOverlap = this.subSectionsCellOverlap,
                bounds = this.bounds
            });
        }
        /// <summary>
        /// Gets a builder for initializing the grid. This is a framework method, and should not be called.
        /// </summary>
        /// <returns>The builder configured for this grid.</returns>
        public GridBuilder GetBuilder()
        {
            //Resolve custom block detector if applicable
            if (this.obstacleAndGroundDetection == ColliderDetectionMode.Custom && _obstacleAndGroundDetector == null)
            {
                var fact = this.As<IBlockDetectorFactory>(true);
                if (fact == null)
                {
                    this.obstacleAndGroundDetection = ColliderDetectionMode.Mixed;
                }
                else
                {
                    _obstacleAndGroundDetector = fact.Create();
                    if (_obstacleAndGroundDetector == null)
                    {
                        this.obstacleAndGroundDetection = ColliderDetectionMode.Mixed;
                    }
                }
            }

            return new GridBuilder
            {
                origin = this.origin,
                sizeX = this.sizeX,
                sizeZ = this.sizeZ,
                cellSize = this.cellSize,
                obstacleSensitivityRange = this.obstacleSensitivityRange,
                generateHeightmap = this.generateHeightmap,
                heightLookupType = this.heightLookupType,
                heightLookupMaxDepth = this.heightLookupMaxDepth,
                lowerBoundary = this.lowerBoundary,
                upperBoundary = this.upperBoundary,
                obstacleAndGroundDetection = this.obstacleAndGroundDetection,
                obstacleAndGroundDetector = _obstacleAndGroundDetector,
                subSectionsX = this.subSectionsX,
                subSectionsZ = this.subSectionsZ,
                subSectionsCellOverlap = this.subSectionsCellOverlap,
                bounds = this.bounds
            };
        }