SadRogueSharp.Consoles.MapConsole.UpdatePlayerView C# (CSharp) Method

UpdatePlayerView() private method

private UpdatePlayerView ( ) : void
return void
        private void UpdatePlayerView()
        {
            // Find out what the player can see
            map.ComputeFov(player.Position.X, player.Position.Y, 20, true);

            // Mark all render points as visible or not
            for (int i = 0; i < this.textSurface.Cells.Length; i++)
            {
                var point = SadConsole.Consoles.TextSurface.GetPointFromIndex(i, Width);
                var currentCell = map.GetCell(point.X, point.Y);

                if (currentCell.IsInFov)
                {
                    if (this[i].Effect != null)
                    {
                        explored.Clear(this[i]);
                        this[i].Effect = null;
                    }

                    this[i].IsVisible = true;
                    map.SetCellProperties(point.X, point.Y, currentCell.IsTransparent, currentCell.IsWalkable, true);
                }
                else if (currentCell.IsExplored)
                {
                    this[i].IsVisible = true;
                    this[i].Effect = explored;
                    explored.Apply(this[i]);
                }
                else
                {
                    this[i].IsVisible = false;
                }
            }

            // Calculate the view area and sync it with our player location
            textSurface.RenderArea = new Microsoft.Xna.Framework.Rectangle(player.Position.X - 15, player.Position.Y - 15, 30, 30);
            player.RenderOffset = this.Position - textSurface.RenderArea.Location;

            // Check for entities.
            foreach (var entity in entities)
            {
                if (entity != player)
                {
                    entity.IsVisible = map.IsInFov(entity.Position.X, entity.Position.Y);

                    // Entity is in our view, but it may not be within the viewport.
                    if (entity.IsVisible)
                    {
                        entity.RenderOffset = this.Position - textSurface.RenderArea.Location;

                        // If the entity is not in our view area we don't want to show it.
                        if (!textSurface.RenderArea.Contains(entity.Position))
                            entity.IsVisible = false;
                    }

                }
            }
        }