using System; using System.Collections.Generic; using Encompass; using Kav; using KavTest.Components; using Microsoft.Xna.Framework.Graphics; namespace KavTest.Renderers { public class SceneRenderer : GeneralRenderer { private GraphicsDevice GraphicsDevice { get; } private IEnumerable Models { get { foreach (var entity in ReadEntitiesAsEnumerable()) { var transformComponent = GetComponent(entity); var modelComponent = GetComponent(entity); modelComponent.Model.ApplyTransform(transformComponent.Transform); yield return modelComponent.Model; } } } private IEnumerable PointLights { get { foreach (var entity in ReadEntitiesAsEnumerable()) { var transformComponent = GetComponent(entity); var pointLightComponent = GetComponent(entity); yield return new PointLight( transformComponent.Transform.Translation, pointLightComponent.Color, pointLightComponent.Intensity ); } } } public SceneRenderer(GraphicsDevice graphicsDevice) { GraphicsDevice = graphicsDevice; } public override void Render() { if (SomeComponent()) { var cameraComponent = ReadComponent(); Kav.Renderer.Render( GraphicsDevice, cameraComponent.Camera, Models, PointLights ); } } } }