/// <summary> /// Initializes a new instance of the <see cref="CrossGridVectorField"/> class. /// </summary> /// <param name="group">The group.</param> /// <param name="path">The path.</param> /// <param name="options">The options.</param> public CrossGridVectorField(TransientGroup <IUnitFacade> group, Path path, VectorFieldOptions options) { Ensure.ArgumentNotNull(group, "group"); this.group = group; _currentPath = path; var modelUnit = group.modelUnit; _unitProperties = modelUnit; var pathOptions = modelUnit.pathFinderOptions; // cache options locally _allowCornerCutting = pathOptions.allowCornerCutting; _allowDiagonals = !pathOptions.preventDiagonalMoves; _announceAllNodes = modelUnit.pathNavigationOptions.announceAllNodes; _obstacleStrengthFactor = options.obstacleStrengthFactor; _builtInContainment = options.builtInContainment; _updateInterval = options.updateInterval; _paddingIncrease = options.paddingIncrease; _maxExtraPadding = options.maxExtraPadding; _boundsPadding = options.boundsPadding; _boundsRecalculateThreshold = options.boundsRecalculateThreshold; _expectedGroupGrowthFactor = 1f + options.expectedGroupGrowthFactor; // pre-allocate lists _openSet = new SimpleQueue <Cell>(31); _tempWalkableNeighbours = new DynamicArray <Cell>(8); _extraTempWalkableNeighbours = new DynamicArray <Cell>(8); _groupBounds = new RectangleXZ(group.centerOfGravity, _boundsPadding, _boundsPadding); _grids = new List <IGrid>(4); }
/// <summary> /// Initializes a new instance of the <see cref="FullGridVectorField"/> class. /// </summary> /// <param name="group">The transient unit group.</param> /// <param name="path">The path.</param> /// <param name="options">The vector field options.</param> public FullGridVectorField(TransientGroup <IUnitFacade> group, Path path, VectorFieldOptions options) { Ensure.ArgumentNotNull(group, "group"); this.group = group; _currentPath = path; var modelUnit = group.modelUnit; _unitProperties = modelUnit; var pathOptions = modelUnit.pathFinderOptions; // cache options locally _obstacleStrengthFactor = options.obstacleStrengthFactor; _allowCornerCutting = pathOptions.allowCornerCutting; _allowDiagonals = !pathOptions.preventDiagonalMoves; _announceAllNodes = modelUnit.pathNavigationOptions.announceAllNodes; _builtInContainment = options.builtInContainment; _updateInterval = options.updateInterval; // pre-allocate lists _openSet = new SimpleQueue <Cell>(31); _tempWalkableNeighbours = new DynamicArray <Cell>(8); _extraTempWalkableNeighbours = new DynamicArray <Cell>(8); _grid = GridManager.instance.GetGrid(group.modelUnit.position); if (_grid != null) { _fastMarchedCells = new PlaneVector[_grid.sizeX, _grid.sizeZ]; _cellDirs = new VectorFieldCell[_grid.sizeX, _grid.sizeZ]; } }
/// <summary> /// Initializes a new instance of the <see cref="ProgressiveVectorField"/> class. /// </summary> /// <param name="group">The group.</param> /// <param name="path">The path.</param> /// <param name="options">The options.</param> public ProgressiveVectorField(TransientGroup<IUnitFacade> group, Path path, VectorFieldOptions options) { Ensure.ArgumentNotNull(group, "group"); this.group = group; _currentPath = path; var modelUnit = group.modelUnit; _unitProperties = modelUnit; var pathOptions = modelUnit.pathFinderOptions; // cache options locally _allowCornerCutting = pathOptions.allowCornerCutting; _allowDiagonals = !pathOptions.preventDiagonalMoves; _announceAllNodes = modelUnit.pathNavigationOptions.announceAllNodes; _obstacleStrengthFactor = options.obstacleStrengthFactor; _builtInContainment = options.builtInContainment; _updateInterval = options.updateInterval; _paddingIncrease = options.paddingIncrease; _maxExtraPadding = options.maxExtraPadding; _boundsPadding = options.boundsPadding; _boundsRecalculateThreshold = options.boundsRecalculateThreshold; _expectedGroupGrowthFactor = 1f + options.expectedGroupGrowthFactor; // pre-allocate lists memory _openSet = new SimpleQueue<Cell>(31); _tempWalkableNeighbours = new DynamicArray<Cell>(8); _extraTempWalkableNeighbours = new DynamicArray<Cell>(8); _groupBounds = new RectangleXZ(group.centerOfGravity, _boundsPadding, _boundsPadding); }
/// <summary> /// Initializes a new instance of the <see cref="FullGridVectorField"/> class. /// </summary> /// <param name="group">The transient unit group.</param> /// <param name="path">The path.</param> /// <param name="options">The vector field options.</param> public FullGridVectorField(TransientGroup<IUnitFacade> group, Path path, VectorFieldOptions options) { Ensure.ArgumentNotNull(group, "group"); this.group = group; _currentPath = path; var modelUnit = group.modelUnit; _unitProperties = modelUnit; var pathOptions = modelUnit.pathFinderOptions; // cache options locally _obstacleStrengthFactor = options.obstacleStrengthFactor; _allowCornerCutting = pathOptions.allowCornerCutting; _allowDiagonals = !pathOptions.preventDiagonalMoves; _announceAllNodes = modelUnit.pathNavigationOptions.announceAllNodes; _builtInContainment = options.builtInContainment; _updateInterval = options.updateInterval; // pre-allocate lists _openSet = new SimpleQueue<Cell>(31); _tempWalkableNeighbours = new DynamicArray<Cell>(8); _extraTempWalkableNeighbours = new DynamicArray<Cell>(8); _grid = GridManager.instance.GetGrid(group.modelUnit.position); if (_grid != null) { _fastMarchedCells = new PlaneVector[_grid.sizeX, _grid.sizeZ]; _cellDirs = new VectorFieldCell[_grid.sizeX, _grid.sizeZ]; } }
/// <summary> /// Initializes a new instance of the <see cref="FunnelVectorField"/> class. /// </summary> /// <param name="group">The group.</param> /// <param name="path">The path.</param> /// <param name="options">The options.</param> public FunnelVectorField(TransientGroup <IUnitFacade> group, Path path, VectorFieldOptions options) { Ensure.ArgumentNotNull(group, "group"); this.group = group; _currentPath = path; var modelUnit = group.modelUnit; _unitProperties = modelUnit; var pathOptions = modelUnit.pathFinderOptions; // cache options locally _funnelWidth = options.funnelWidth; _obstacleStrengthFactor = options.obstacleStrengthFactor; _allowCornerCutting = pathOptions.allowCornerCutting; _allowDiagonals = !pathOptions.preventDiagonalMoves; _announceAllNodes = modelUnit.pathNavigationOptions.announceAllNodes; _builtInContainment = options.builtInContainment; _updateInterval = options.updateInterval; // pre-allocate lists memory _openSet = new SimpleQueue <Cell>(31); _tempWalkableNeighbours = new DynamicArray <Cell>(8); _extraTempWalkableNeighbours = new DynamicArray <Cell>(8); _grid = GridManager.instance.GetGrid(group.modelUnit.position); if (_grid != null) { // we allocate half of the grid's size in order to have a bit more allocated memory than we expect to actually use int size = Mathf.CeilToInt((_grid.sizeX * _grid.sizeZ) / 2f); float minF = 9.99999944E-11f; _cellDirsSet = new Dictionary <Vector3, VectorFieldCell>(size, new Vector3EqualityComparer(minF)); _fastMarchedCellsSet = new Dictionary <Vector3, PlaneVector>(size, new Vector3EqualityComparer(minF)); } _funnelWidthSqr = _funnelWidth * _funnelWidth; }
/// <summary> /// Initializes a new instance of the <see cref="FunnelVectorField"/> class. /// </summary> /// <param name="group">The group.</param> /// <param name="path">The path.</param> /// <param name="options">The options.</param> public FunnelVectorField(TransientGroup<IUnitFacade> group, Path path, VectorFieldOptions options) { Ensure.ArgumentNotNull(group, "group"); this.group = group; _currentPath = path; var modelUnit = group.modelUnit; _unitProperties = modelUnit; var pathOptions = modelUnit.pathFinderOptions; // cache options locally _funnelWidth = options.funnelWidth; _obstacleStrengthFactor = options.obstacleStrengthFactor; _allowCornerCutting = pathOptions.allowCornerCutting; _allowDiagonals = !pathOptions.preventDiagonalMoves; _announceAllNodes = modelUnit.pathNavigationOptions.announceAllNodes; _builtInContainment = options.builtInContainment; _updateInterval = options.updateInterval; // pre-allocate lists memory _openSet = new SimpleQueue<Cell>(31); _tempWalkableNeighbours = new DynamicArray<Cell>(8); _extraTempWalkableNeighbours = new DynamicArray<Cell>(8); _grid = GridManager.instance.GetGrid(group.modelUnit.position); if (_grid != null) { // we allocate half of the grid's size in order to have a bit more allocated memory than we expect to actually use int size = Mathf.CeilToInt((_grid.sizeX * _grid.sizeZ) / 2f); float minF = 9.99999944E-11f; _cellDirsSet = new Dictionary<Vector3, VectorFieldCell>(size, new Vector3EqualityComparer(minF)); _fastMarchedCellsSet = new Dictionary<Vector3, PlaneVector>(size, new Vector3EqualityComparer(minF)); } _funnelWidthSqr = _funnelWidth * _funnelWidth; }