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>(); }
/// <summary> /// Creates a cell matrix based on the given configuration and stored data. /// </summary> /// <param name="cfg">The configuration.</param> /// <param name="data">The data.</param> /// <returns>The matrix</returns> public static CellMatrix Create(ICellMatrixConfiguration cfg, CellMatrixData data) { var matrix = new CellMatrix(cfg); var iter = matrix.Populate(data); while (iter.MoveNext()) { /* NOOP, we just iterate over all */ } return(matrix); }
internal static CellMatrix CreateForEditor(ICellMatrixConfiguration cfg, CellMatrixData data) { var matrix = new CellMatrix(cfg); if (data == null) { matrix._heightLookup = matrix.CreateHeightLookup(0); } else { matrix.InitHeightMapForEditor(data); } return(matrix); }
/// <summary> /// Initializes a new instance of the <see cref="CellMatrix"/> class. /// </summary> /// <param name="cfg">The configuration.</param> protected CellMatrix(ICellMatrixConfiguration cfg) : base(cfg.sizeX, cfg.sizeZ) { Initialize(cfg); if (GameServices.heightStrategy.heightMode == HeightSamplingMode.NoHeightSampling) { _cellFactory = FlatCell.factory; _heightSettingsProvider = new FlatCellHeightSettingsProvider(this); } else if (GameServices.heightStrategy.useGlobalHeightNavigationSettings) { _cellFactory = StandardCell.factory; _heightSettingsProvider = new StandardCellHeightSettingsProvider(this); } else { _cellFactory = RichCell.factory; _heightSettingsProvider = new RichCellHeightSettingsProvider(this); } }
internal MatrixIncrementalInitializer(ICellMatrixConfiguration cfg) { _matrix = new CellMatrix(cfg); _iter = _matrix.Populate(); }
internal static MatrixIncrementalInitializer CreateIncrementally(ICellMatrixConfiguration cfg, CellMatrixData data) { return(new MatrixIncrementalInitializer(cfg, data)); }
/// <summary> /// Initializes a new instance of the <see cref="CellMatrix"/> class. /// </summary> /// <param name="cfg">The configuration.</param> protected CellMatrix(ICellMatrixConfiguration cfg) : base(cfg.sizeX, cfg.sizeZ) { Initialize(cfg); }