List <IRenderable> GenerateRenderables() { var comparer = new RenderableComparer(this); var actors = world.ScreenMap.ActorsInBox(Viewport.TopLeft, Viewport.BottomRight) .Append(world.WorldActor) .ToList(); // Include player actor for the rendered player if (world.RenderPlayer != null) { actors.Add(world.RenderPlayer.PlayerActor); } var worldRenderables = actors.SelectMany(a => a.Render(this)); if (world.OrderGenerator != null) { worldRenderables = worldRenderables.Concat(world.OrderGenerator.Render(this, world)); } worldRenderables = worldRenderables.OrderBy(r => r, comparer); // Effects are drawn on top of all actors // HACK: Effects aren't interleaved with actors. var effectRenderables = world.Effects .SelectMany(e => e.Render(this)); if (world.OrderGenerator != null) { effectRenderables = effectRenderables.Concat(world.OrderGenerator.RenderAfterWorld(this, world)); } // Iterating via foreach() copies the structs, so enumerate by index var renderables = worldRenderables.Concat(effectRenderables).ToList(); Game.Renderer.WorldVoxelRenderer.BeginFrame(); for (var i = 0; i < renderables.Count; i++) { renderables[i].BeforeRender(this); } Game.Renderer.WorldVoxelRenderer.EndFrame(); return(renderables); }
List <IRenderable> GenerateRenderables() { var bounds = Game.viewport.WorldBounds(world); var comparer = new RenderableComparer(this); var tl = bounds.TopLeftAsCPos(); var br = bounds.BottomRightAsCPos(); var actors = world.FindActorsInBox(tl, br) .Append(world.WorldActor) .ToList(); // Include player actor for the rendered player if (world.RenderPlayer != null) { actors.Add(world.RenderPlayer.PlayerActor); } var worldRenderables = actors.SelectMany(a => a.Render(this)); if (world.OrderGenerator != null) { worldRenderables = worldRenderables.Concat(world.OrderGenerator.Render(this, world)); } worldRenderables = worldRenderables.OrderBy(r => r, comparer); // Effects are drawn on top of all actors // TODO: Allow effects to be interleaved with actors var effectRenderables = world.Effects .SelectMany(e => e.Render(this)); // Iterating via foreach() copies the structs, so enumerate by index var renderables = worldRenderables.Concat(effectRenderables).ToList(); Game.Renderer.WorldVoxelRenderer.BeginFrame(); for (var i = 0; i < renderables.Count; i++) { renderables[i].BeforeRender(this); } Game.Renderer.WorldVoxelRenderer.EndFrame(); return(renderables); }