public ArrayFieldOfView(IFovBoard<IHex> board) { _isOnboard = h => board.IsOnboard(h); _fovBacking = new BitArray[board.MapSizeHexes.Width]; for (var i = 0; i < board.MapSizeHexes.Width; i++) _fovBacking[i] = new BitArray(board.MapSizeHexes.Height); }
public ArrayFieldOfView(IFovBoard <IHex> board) { _isOnboard = h => board.IsOnboard(h); _fovBacking = new BitArray[board.MapSizeHexes.Width]; for (var i = 0; i < board.MapSizeHexes.Width; i++) { _fovBacking[i] = new BitArray(board.MapSizeHexes.Height); } }
/// <summary>TODO</summary> public static IFov GetFieldOfView(this IFovBoard <IHex> @this, HexCoords origin, FovTargetMode targetMode) { TraceFlags.FieldOfView.Trace("GetFieldOfView"); var fov = new ArrayFieldOfView(@this); if (@this.IsPassable(origin)) { Func <HexCoords, int> target; int observer; switch (targetMode) { case FovTargetMode.EqualHeights: observer = @this[origin].ElevationASL + 1; target = coords => @this[coords].ElevationASL + 1; break; case FovTargetMode.TargetHeightEqualZero: observer = @this[origin].HeightObserver; target = coords => @this[coords].ElevationASL; break; default: case FovTargetMode.TargetHeightEqualActual: observer = @this[origin].HeightObserver; target = coords => @this[coords].HeightTarget; break; } ShadowCasting.ShadowCasting.ComputeFieldOfView( origin, @this.FovRadius, observer, coords => @this.IsOnboard(coords), target, coords => @this[coords].HeightTerrain, coords => fov[coords] = true ); } return(fov); }