Engines/FlatRedBallXNA/FlatRedBall/AI/LineOfSight/VisibilityGrid.cs
/// <summary>
/// Adds an IViewer to this grid.
/// </summary>
/// <param name="viewerToAdd">The viewer to add.</param>
Adds an IViewer to this grid.
Adds an IViewer to this grid .
public void AddViewer(IViewer viewerToAdd)
        {
            int localGridDimension = MathFunctions.RoundToInt(viewerToAdd.WorldViewRadius / mGridSpacing) * 2 + 1;
            VisibilityGrid localVisibilityGrid = new VisibilityGrid(0, 0, mGridSpacing,
                localGridDimension, localGridDimension);
            ViewerInformation viewerInformation = new ViewerInformation();
            viewerInformation.LocalVisibilityGrid = localVisibilityGrid;
            if (mFogFactor > 0)
            {
                localVisibilityGrid.FogColor = FogColor;
                localVisibilityGrid.FogShade = FogShade;
                localVisibilityGrid.FogResolution = FogResolution;
            }
            int xIndex;
            int yIndex;
            mViewers.Add(viewerToAdd, viewerInformation);
            WorldToIndex(viewerToAdd.X, viewerToAdd.Y, out xIndex, out yIndex);
            int radiusAsInt = MathFunctions.RoundToInt(viewerToAdd.WorldViewRadius / mGridSpacing);
            if (xIndex >= radiusAsInt && yIndex >= radiusAsInt &&
                xIndex + radiusAsInt < mNumberOfXTiles && yIndex + radiusAsInt < mNumberOfYTiles)
            {
                UpdateViewersLocalVisibilityGrid(viewerToAdd, viewerInformation);
            }
            UpdateRevealedFromViewers();
        }
public void AddViewer ( IViewer viewerToAdd ) { int localGridDimension = MathFunctions . RoundToInt ( viewerToAdd . WorldViewRadius / mGridSpacing ) * 2 + 1 ; VisibilityGrid localVisibilityGrid = new VisibilityGrid ( 0 , 0 , mGridSpacing , localGridDimension , localGridDimension ) ; ViewerInformation viewerInformation = new ViewerInformation ( ) ; viewerInformation . LocalVisibilityGrid = localVisibilityGrid ; if ( mFogFactor > 0 ) { localVisibilityGrid . FogColor = FogColor ; localVisibilityGrid . FogShade = FogShade ; localVisibilityGrid . FogResolution = FogResolution ; } int xIndex ; int yIndex ; mViewers . Add ( viewerToAdd , viewerInformation ) ; WorldToIndex ( viewerToAdd . X , viewerToAdd . Y , out xIndex , out yIndex ) ; int radiusAsInt = MathFunctions . RoundToInt ( viewerToAdd . WorldViewRadius / mGridSpacing ) ; if ( xIndex >= radiusAsInt && yIndex >= radiusAsInt && xIndex + radiusAsInt < mNumberOfXTiles && yIndex + radiusAsInt < mNumberOfYTiles ) { UpdateViewersLocalVisibilityGrid ( viewerToAdd , viewerInformation ) ; } UpdateRevealedFromViewers ( ) ; }
Adds an IViewer to this grid.
Adds an IViewer to this grid .
viewerToAdd
IViewer
The viewer to add.
The viewer to add .