Engines/FlatRedBallXNA/FlatRedBall/AI/LineOfSight/VisibilityGrid.cs
/// <summary>
/// Checks if any viewers have changed since last Update, and if so it updates the grid.
/// </summary>
/// <returns>Whether anything has changed.</returns>
Checks if any viewers have changed since last Update, and if so it updates the grid.
Checks if any viewers have changed since last Update and if so it updates the grid .
public bool Activity()
        {
            bool hasAnythingChanged = false;
            int xIndex;
            int yIndex;
            foreach (KeyValuePair<IViewer, ViewerInformation> kvp in this.mViewers)
            {
                IViewer viewer = kvp.Key;
                ViewerInformation information = kvp.Value;
                WorldToIndex(viewer.X, viewer.Y, out xIndex, out yIndex);
                int radiusAsInt = MathFunctions.RoundToInt(viewer.WorldViewRadius / mGridSpacing);
                if (xIndex != information.LastX || yIndex != information.LastY)
                {
                    hasAnythingChanged = true;
                    information.LastX = xIndex;
                    information.LastY = yIndex;
                    if (xIndex >= radiusAsInt && yIndex >= radiusAsInt &&
                        xIndex + radiusAsInt < mNumberOfXTiles && yIndex + radiusAsInt < mNumberOfYTiles)
                    {
                        UpdateViewersLocalVisibilityGrid(viewer, information);
                    }
                }
            }
            if (hasAnythingChanged)
            {
                UpdateRevealedFromViewers();
            }
            return hasAnythingChanged;
        }
public bool Activity ( ) { bool hasAnythingChanged = false ; int xIndex ; int yIndex ; foreach ( KeyValuePair < IViewer , ViewerInformation > kvp in this . mViewers ) { IViewer viewer = kvp . Key ; ViewerInformation information = kvp . Value ; WorldToIndex ( viewer . X , viewer . Y , out xIndex , out yIndex ) ; int radiusAsInt = MathFunctions . RoundToInt ( viewer . WorldViewRadius / mGridSpacing ) ; if ( xIndex != information . LastX || yIndex != information . LastY ) { hasAnythingChanged = true ; information . LastX = xIndex ; information . LastY = yIndex ; if ( xIndex >= radiusAsInt && yIndex >= radiusAsInt && xIndex + radiusAsInt < mNumberOfXTiles && yIndex + radiusAsInt < mNumberOfYTiles ) { UpdateViewersLocalVisibilityGrid ( viewer , information ) ; } } } if ( hasAnythingChanged ) { UpdateRevealedFromViewers ( ) ; } return hasAnythingChanged ; }
Checks if any viewers have changed since last Update, and if so it updates the grid.
Checks if any viewers have changed since last Update and if so it updates the grid .
Whether anything has changed.
Whether anything has changed .