DodongosQuest.World.DiscoverTerrainAroundPlayer C# (CSharp) Method

DiscoverTerrainAroundPlayer() public method

public DiscoverTerrainAroundPlayer ( ) : void
return void
        public void DiscoverTerrainAroundPlayer()
        {
            foreach (ITerrain terrain in Tiles)
                terrain.IsVisibleToPlayer = false;

            List<Vector2> discoveredTiles = new List<Vector2>();
            for (int y = 0; y < WORLD_HEIGHT; y++)
            {
                for (int x = 0; x < WORLD_WIDTH; x++)
                {
                    List<Vector2> pathToCurrentPoint = GetWorldIndexPointsAlongLine(new Vector2(x, y), Player.WorldIndex);
                    if (pathToCurrentPoint.Count < Player.ViewDistance.Current)
                    {
                        bool currentPointIsVisible = true;
                        foreach (Vector2 pointAlongPath in pathToCurrentPoint)
                        {
                            if (Tiles[(int)pointAlongPath.X, (int)pointAlongPath.Y].ObstructsLineOfSight)
                            {
                                currentPointIsVisible = false;
                                break;
                            }
                            Door doorAtIndex = GetDoorAtIndex(pointAlongPath);
                            if(doorAtIndex != null)
                                if (doorAtIndex.IsOpen == false)
                                {
                                    currentPointIsVisible = false;
                                    break;
                                }
                        }
                        if (currentPointIsVisible)
                            discoveredTiles.Add(new Vector2(x, y));
                    }
                }
            }

            foreach (Vector2 index in discoveredTiles)
                DiscoverTerrainAndSetVisible(index);
        }