encompass-cs/encompass-cs/World.cs

51 lines
1.4 KiB
C#

using System.Collections.Generic;
namespace Encompass
{
public class World
{
private readonly List<Engine> enginesInOrder;
private readonly EntityManager entityManager;
private readonly ComponentManager componentManager;
private readonly MessageManager messageManager;
private readonly RenderManager renderManager;
internal World(
List<Engine> enginesInOrder,
EntityManager entityManager,
ComponentManager componentManager,
MessageManager messageManager,
RenderManager renderManager
)
{
this.enginesInOrder = enginesInOrder;
this.entityManager = entityManager;
this.componentManager = componentManager;
this.messageManager = messageManager;
this.renderManager = renderManager;
}
public void Update(double dt)
{
foreach (var engine in enginesInOrder)
{
engine.Update(dt);
}
messageManager.ClearMessages();
entityManager.DestroyMarkedEntities();
componentManager.PerformComponentUpdates();
componentManager.RemoveMarkedComponents();
entityManager.CheckEntitiesWithAddedComponents();
entityManager.CheckEntitiesWithRemovedComponents();
}
public void Draw()
{
renderManager.Draw();
}
}
}