using System.Collections.Generic; namespace Encompass { /// /// The World is a collection of Engines, Renderers, Entities, Components, and Messages that compose the simulation. /// public class World { private readonly List enginesInOrder; private readonly EntityManager entityManager; private readonly ComponentManager componentManager; private readonly MessageManager messageManager; private readonly ComponentMessageManager componentMessageManager; private readonly RenderManager renderManager; internal World( List enginesInOrder, EntityManager entityManager, ComponentManager componentManager, MessageManager messageManager, ComponentMessageManager componentMessageManager, RenderManager renderManager ) { this.enginesInOrder = enginesInOrder; this.entityManager = entityManager; this.componentManager = componentManager; this.messageManager = messageManager; this.componentMessageManager = componentMessageManager; this.renderManager = renderManager; } /// /// Drives the simulation. Should be called from your game engine's update loop. /// /// The time in seconds that has passed since the previous frame. public void Update(double dt) { messageManager.ProcessDelayedMessages(dt); foreach (var engine in enginesInOrder) { engine.Update(dt); } messageManager.ClearMessages(); componentMessageManager.ClearMessages(); entityManager.DestroyMarkedEntities(); componentManager.RemoveMarkedComponents(); componentManager.WriteComponents(); } /// /// Causes the Renderers to draw. /// public void Draw() { renderManager.Draw(); } } }