/// <summary>Gets a Field-of-View for this board synchronously.</summary>
        public static IFov GetFieldOfView(this IFovBoard <IHex> @this, HexCoords origin, FovTargetMode targetMode, int heightOfMan, int hexesPerMile)
        {
            Traces.FieldOfView.Trace("GetFieldOfView");
            var fov = new ArrayFieldOfView(@this);

            if (@this.IsPassable(origin))
            {
                ShadowCasting.ComputeFieldOfView(origin, @this, targetMode, coords => fov[coords] = true, heightOfMan, hexesPerMile);
            }

            return(fov);
        }
Exemplo n.º 2
0
        /// <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);
        }