private void FillcharacterBuffersWithWorldObjects(Screen screen, ConsoleCamera camera, GameSettings settings, NamelessGame game) { List <IEntity> characters = new List <IEntity>(); foreach (IEntity entity in RegisteredEntities) { Drawable drawable = entity.GetComponentOfType <Drawable>(); var character = entity.GetComponentOfType <Character>(); if (character != null) { characters.Add(entity); continue; } Position position = entity.GetComponentOfType <Position>(); LineToPlayer lineToPlayer = entity.GetComponentOfType <LineToPlayer>(); if (drawable.Visible) { Point screenPoint = camera.PointToScreen(position.Point.X, position.Point.Y); int x = screenPoint.X; int y = screenPoint.Y; if (x >= 0 && x < settings.GetWidth() && y >= 0 && y < settings.GetHeight()) { if (screen.ScreenBuffer[screenPoint.Y, screenPoint.X].isVisible) { screen.ScreenBuffer[screenPoint.Y, screenPoint.X].Char = drawable.Representation; screen.ScreenBuffer[screenPoint.Y, screenPoint.X].CharColor = drawable.CharColor; } else { screen.ScreenBuffer[screenPoint.Y, screenPoint.X].Char = ' '; screen.ScreenBuffer[screenPoint.Y, screenPoint.X].CharColor = new Color(); screen.ScreenBuffer[screenPoint.Y, screenPoint.X].BackGroundColor = new Color(); } } } if (lineToPlayer != null) { if (drawable.Visible) { Position playerPosition = game.PlayerEntity.GetComponentOfType <Position>(); List <Point> line = PointUtil.getLine(playerPosition.Point, position.Point); for (int i = 1; i < line.Count - 1; i++) { Point p = line[i]; Point screenPoint = camera.PointToScreen(p.X, p.Y); int x = screenPoint.X; int y = screenPoint.Y; if (x >= 0 && x < settings.GetWidth() && y >= 0 && y < settings.GetHeight()) { screen.ScreenBuffer[screenPoint.Y, screenPoint.X].Char = 'x'; screen.ScreenBuffer[screenPoint.Y, screenPoint.X].CharColor = drawable.CharColor; } } } } } foreach (IEntity entity in characters) { Drawable drawable = entity.GetComponentOfType <Drawable>(); if (drawable == null) { continue; } Position position = entity.GetComponentOfType <Position>(); if (drawable.Visible) { Point screenPoint = camera.PointToScreen(position.Point.X, position.Point.Y); int x = screenPoint.X; int y = screenPoint.Y; if (x >= 0 && x < settings.GetWidthZoomed() && y >= 0 && y < settings.GetHeightZoomed()) { if (screen.ScreenBuffer[screenPoint.Y, screenPoint.X].isVisible) { screen.ScreenBuffer[screenPoint.Y, screenPoint.X].Char = drawable.Representation; screen.ScreenBuffer[screenPoint.Y, screenPoint.X].CharColor = drawable.CharColor; } else { screen.ScreenBuffer[screenPoint.Y, screenPoint.X].Char = ' '; screen.ScreenBuffer[screenPoint.Y, screenPoint.X].CharColor = new Color(); screen.ScreenBuffer[screenPoint.Y, screenPoint.X].BackGroundColor = new Color(); } } } } }