2019-06-17 00:56:36 +00:00
|
|
|
using System;
|
2019-06-15 00:03:56 +00:00
|
|
|
using System.Collections.Generic;
|
2019-06-17 00:56:36 +00:00
|
|
|
using System.Reflection;
|
|
|
|
using System.Linq;
|
2019-06-24 19:14:37 +00:00
|
|
|
using Encompass.Exceptions;
|
2019-10-24 20:13:43 +00:00
|
|
|
using MoonTools.Core.Graph;
|
|
|
|
using MoonTools.Core.Graph.Extensions;
|
2019-06-15 00:03:56 +00:00
|
|
|
|
2019-06-16 01:05:56 +00:00
|
|
|
namespace Encompass
|
|
|
|
{
|
2019-10-24 19:48:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// WorldBuilder is used to construct a World from Engines, Renderers, and an initial state of Entities, Components, and Messages.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// WorldBuilder enforces certain rules about Engine structure. It is forbidden to have messages create cycles between Engines,
|
|
|
|
/// and no Component may be written by more than one Engine.
|
|
|
|
/// The WorldBuilder uses Engines and their Message read/emit information to determine a valid ordering of the Engines, which is given to the World.
|
|
|
|
/// </remarks>
|
2019-06-16 01:05:56 +00:00
|
|
|
public class WorldBuilder
|
|
|
|
{
|
2019-06-20 17:46:15 +00:00
|
|
|
private readonly List<Engine> engines = new List<Engine>();
|
2019-10-24 20:13:43 +00:00
|
|
|
private readonly DirectedGraph<Engine, Unit> engineGraph = GraphBuilder.DirectedGraph<Engine>();
|
2019-12-06 00:00:00 +00:00
|
|
|
private readonly ComponentStore startingComponentStoreForComponentManager = new ComponentStore();
|
2019-12-06 06:32:09 +00:00
|
|
|
private readonly ComponentStore startingComponentStoreForComponentUpdateManager = new ComponentStore();
|
2019-06-15 00:51:06 +00:00
|
|
|
|
2019-06-20 17:46:15 +00:00
|
|
|
private readonly ComponentManager componentManager;
|
|
|
|
private readonly EntityManager entityManager;
|
|
|
|
private readonly MessageManager messageManager;
|
2019-12-06 06:32:09 +00:00
|
|
|
private readonly ComponentUpdateManager componentUpdateManager;
|
2019-11-21 21:53:33 +00:00
|
|
|
private readonly TimeManager timeManager;
|
2019-06-20 17:46:15 +00:00
|
|
|
private readonly DrawLayerManager drawLayerManager;
|
|
|
|
private readonly RenderManager renderManager;
|
2019-06-15 00:03:56 +00:00
|
|
|
|
2019-07-16 18:17:07 +00:00
|
|
|
private readonly Dictionary<Type, HashSet<Engine>> typeToReaders = new Dictionary<Type, HashSet<Engine>>();
|
2019-06-17 00:56:36 +00:00
|
|
|
|
2019-07-18 21:02:57 +00:00
|
|
|
private readonly HashSet<Engine> senders = new HashSet<Engine>();
|
|
|
|
|
|
|
|
private readonly HashSet<Type> registeredComponentTypes = new HashSet<Type>();
|
|
|
|
|
2019-06-16 01:05:56 +00:00
|
|
|
public WorldBuilder()
|
|
|
|
{
|
2019-06-20 00:40:01 +00:00
|
|
|
drawLayerManager = new DrawLayerManager();
|
2019-11-21 22:22:10 +00:00
|
|
|
timeManager = new TimeManager();
|
2019-12-06 06:32:09 +00:00
|
|
|
componentUpdateManager = new ComponentUpdateManager();
|
|
|
|
componentManager = new ComponentManager(drawLayerManager, componentUpdateManager);
|
2019-12-05 22:59:55 +00:00
|
|
|
messageManager = new MessageManager(timeManager);
|
2019-12-05 04:50:08 +00:00
|
|
|
entityManager = new EntityManager(componentManager);
|
2019-12-06 06:32:09 +00:00
|
|
|
renderManager = new RenderManager(drawLayerManager);
|
2019-06-15 00:03:56 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 19:48:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Creates and returns a new empty Entity.
|
|
|
|
/// </summary>
|
2019-06-16 01:05:56 +00:00
|
|
|
public Entity CreateEntity()
|
|
|
|
{
|
2019-06-19 21:14:44 +00:00
|
|
|
return entityManager.CreateEntity();
|
2019-06-15 00:03:56 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 19:48:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Specifies that the given Message should be sent immediately on the first World Update.
|
|
|
|
/// </summary>
|
2019-07-19 04:07:26 +00:00
|
|
|
public void SendMessage<TMessage>(TMessage message) where TMessage : struct, IMessage
|
2019-06-29 05:07:48 +00:00
|
|
|
{
|
|
|
|
messageManager.AddMessage(message);
|
|
|
|
}
|
|
|
|
|
2019-10-24 19:48:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Specifies that the given Message should be sent after the specified number of seconds after the first World Update.
|
|
|
|
/// </summary>
|
2019-11-26 03:37:03 +00:00
|
|
|
public void SendMessage<TMessage>(TMessage message, double time) where TMessage : struct, IMessage
|
2019-08-20 02:05:18 +00:00
|
|
|
{
|
|
|
|
messageManager.AddMessageDelayed(message, time);
|
|
|
|
}
|
|
|
|
|
2019-10-24 19:48:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Sets Component data for the specified Component Type on the specified Entity.
|
|
|
|
/// </summary>
|
2019-12-05 22:59:55 +00:00
|
|
|
public void SetComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
2019-07-17 18:24:21 +00:00
|
|
|
{
|
2019-12-06 00:00:00 +00:00
|
|
|
startingComponentStoreForComponentManager.Set(entity, component);
|
2019-12-06 06:32:09 +00:00
|
|
|
startingComponentStoreForComponentUpdateManager.Set(entity, component);
|
|
|
|
|
|
|
|
RegisterComponent(typeof(TComponent));
|
2019-12-05 22:59:55 +00:00
|
|
|
|
2019-11-21 03:16:44 +00:00
|
|
|
if (component is IDrawableComponent drawableComponent)
|
|
|
|
{
|
2019-12-05 22:59:55 +00:00
|
|
|
componentManager.RegisterDrawableComponent(entity, component, drawableComponent.Layer);
|
2019-11-21 03:16:44 +00:00
|
|
|
}
|
2019-07-17 18:24:21 +00:00
|
|
|
}
|
|
|
|
|
2019-07-18 21:02:57 +00:00
|
|
|
internal void RegisterComponent(Type componentType)
|
|
|
|
{
|
|
|
|
registeredComponentTypes.Add(componentType);
|
|
|
|
}
|
|
|
|
|
2019-10-24 19:48:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Adds the specified Engine to the World.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="engine">An instance of an Engine.</param>
|
2019-06-24 19:26:19 +00:00
|
|
|
public Engine AddEngine<TEngine>(TEngine engine) where TEngine : Engine
|
2019-06-16 01:05:56 +00:00
|
|
|
{
|
2019-06-24 19:14:37 +00:00
|
|
|
engine.AssignEntityManager(entityManager);
|
|
|
|
engine.AssignComponentManager(componentManager);
|
|
|
|
engine.AssignMessageManager(messageManager);
|
2019-12-06 06:32:09 +00:00
|
|
|
engine.AssignComponentUpdateManager(componentUpdateManager);
|
2019-11-21 21:53:33 +00:00
|
|
|
engine.AssignTimeManager(timeManager);
|
2019-06-15 00:51:06 +00:00
|
|
|
|
|
|
|
engines.Add(engine);
|
2019-10-24 20:13:43 +00:00
|
|
|
engineGraph.AddNode(engine);
|
2019-06-17 00:56:36 +00:00
|
|
|
|
2019-07-19 19:47:17 +00:00
|
|
|
var messageReceiveTypes = engine.receiveTypes;
|
2019-07-19 01:20:38 +00:00
|
|
|
var messageSendTypes = engine.sendTypes;
|
2019-06-17 00:56:36 +00:00
|
|
|
|
2019-07-29 02:17:00 +00:00
|
|
|
foreach (var messageType in messageReceiveTypes.Union(messageSendTypes))
|
|
|
|
{
|
|
|
|
messageManager.RegisterMessageType(messageType);
|
|
|
|
}
|
|
|
|
|
2019-12-06 03:55:17 +00:00
|
|
|
foreach (var writePendingType in engine.writePendingTypes.Intersect(engine.readPendingTypes))
|
2019-07-18 21:02:57 +00:00
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
throw new EngineSelfCycleException("Engine {0} both writes and reads pending Component {1}", engine.GetType().Name, writePendingType.Name);
|
|
|
|
}
|
2019-07-19 23:15:48 +00:00
|
|
|
|
2019-12-06 03:55:17 +00:00
|
|
|
foreach (var messageType in messageReceiveTypes.Intersect(messageSendTypes))
|
|
|
|
{
|
2019-07-19 23:15:48 +00:00
|
|
|
throw new EngineSelfCycleException("Engine {0} both receives and sends Message {1}", engine.GetType().Name, messageType.Name);
|
2019-07-18 21:02:57 +00:00
|
|
|
}
|
2019-06-17 00:56:36 +00:00
|
|
|
|
2019-12-06 03:55:17 +00:00
|
|
|
if (messageSendTypes.Count > 0 || engine.writePendingTypes.Count > 0)
|
2019-07-18 21:02:57 +00:00
|
|
|
{
|
|
|
|
senders.Add(engine);
|
|
|
|
}
|
|
|
|
|
2019-12-06 08:36:54 +00:00
|
|
|
foreach (var componentType in engine.readTypes.Union(engine.writeTypes).Union(engine.readPendingTypes))
|
2019-07-18 21:02:57 +00:00
|
|
|
{
|
2019-12-06 07:16:47 +00:00
|
|
|
RegisterComponent(componentType);
|
2019-12-06 03:55:17 +00:00
|
|
|
}
|
2019-06-17 00:56:36 +00:00
|
|
|
|
2019-12-06 07:16:47 +00:00
|
|
|
foreach (var receiveType in engine.receiveTypes.Union(engine.readPendingTypes))
|
2019-12-06 03:55:17 +00:00
|
|
|
{
|
2019-07-19 19:47:17 +00:00
|
|
|
if (!typeToReaders.ContainsKey(receiveType))
|
2019-06-17 00:56:36 +00:00
|
|
|
{
|
2019-07-19 19:47:17 +00:00
|
|
|
typeToReaders.Add(receiveType, new HashSet<Engine>());
|
2019-06-29 05:57:18 +00:00
|
|
|
}
|
2019-06-17 00:56:36 +00:00
|
|
|
|
2019-07-19 19:47:17 +00:00
|
|
|
typeToReaders[receiveType].Add(engine);
|
|
|
|
}
|
|
|
|
|
2019-06-15 00:51:06 +00:00
|
|
|
return engine;
|
|
|
|
}
|
|
|
|
|
2019-10-24 19:48:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Adds the specified OrderedRenderer to the World.
|
|
|
|
/// </summary>
|
2019-11-21 03:16:44 +00:00
|
|
|
public OrderedRenderer<TComponent> AddOrderedRenderer<TComponent>(OrderedRenderer<TComponent> renderer) where TComponent : struct, IComponent, IDrawableComponent
|
2019-06-19 21:14:44 +00:00
|
|
|
{
|
|
|
|
renderer.AssignEntityManager(entityManager);
|
|
|
|
renderer.AssignComponentManager(componentManager);
|
2019-08-01 22:06:19 +00:00
|
|
|
renderManager.RegisterOrderedRenderer<TComponent>(renderer.InternalRender);
|
2019-06-20 05:38:56 +00:00
|
|
|
return renderer;
|
|
|
|
}
|
|
|
|
|
2019-10-24 19:48:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Adds the specified GeneralRenderer to the World at the specified layer.
|
|
|
|
/// Higher layer numbers draw on top of lower layer numbers.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="renderer">An instance of a GeneralRenderer.</param>
|
|
|
|
/// <param name="layer">The layer at which the GeneralRenderer should render. Higher numbers draw over lower numbers.</param>
|
2019-06-24 23:49:26 +00:00
|
|
|
public TRenderer AddGeneralRenderer<TRenderer>(TRenderer renderer, int layer) where TRenderer : GeneralRenderer
|
2019-06-20 05:38:56 +00:00
|
|
|
{
|
|
|
|
renderer.AssignEntityManager(entityManager);
|
|
|
|
renderer.AssignComponentManager(componentManager);
|
|
|
|
|
|
|
|
renderManager.RegisterGeneralRendererWithLayer(renderer, layer);
|
2019-06-19 21:14:44 +00:00
|
|
|
|
|
|
|
return renderer;
|
|
|
|
}
|
|
|
|
|
2019-07-18 21:02:57 +00:00
|
|
|
private void BuildEngineGraph()
|
|
|
|
{
|
|
|
|
foreach (var senderEngine in senders)
|
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
foreach (var messageType in senderEngine.sendTypes.Union(senderEngine.writePendingTypes))
|
2019-07-18 21:02:57 +00:00
|
|
|
{
|
|
|
|
if (typeToReaders.ContainsKey(messageType))
|
|
|
|
{
|
|
|
|
foreach (var readerEngine in typeToReaders[messageType])
|
|
|
|
{
|
2019-07-19 04:07:26 +00:00
|
|
|
if (senderEngine != readerEngine)
|
|
|
|
{
|
2019-11-13 21:05:31 +00:00
|
|
|
if (!engineGraph.Exists(senderEngine, readerEngine))
|
|
|
|
{
|
|
|
|
engineGraph.AddEdge(senderEngine, readerEngine);
|
|
|
|
}
|
2019-07-19 04:07:26 +00:00
|
|
|
}
|
2019-07-18 21:02:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-24 19:48:36 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Builds the World out of the state specified on the WorldBuilder.
|
|
|
|
/// Validates and constructs an ordering of the given Engines.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>An instance of World.</returns>
|
2019-06-16 01:05:56 +00:00
|
|
|
public World Build()
|
|
|
|
{
|
2019-07-18 21:02:57 +00:00
|
|
|
BuildEngineGraph();
|
|
|
|
|
2019-06-17 00:56:36 +00:00
|
|
|
if (engineGraph.Cyclic())
|
|
|
|
{
|
|
|
|
var cycles = engineGraph.SimpleCycles();
|
|
|
|
var errorString = "Cycle(s) found in Engines: ";
|
2019-07-19 23:15:48 +00:00
|
|
|
foreach (var cycle in cycles)
|
2019-06-17 00:56:36 +00:00
|
|
|
{
|
2019-07-19 23:15:48 +00:00
|
|
|
var reversed = cycle.Reverse();
|
2019-06-17 00:56:36 +00:00
|
|
|
errorString += "\n" +
|
2019-07-19 23:15:48 +00:00
|
|
|
string.Join(" -> ", reversed.Select((engine) => engine.GetType().Name)) +
|
2019-06-17 00:56:36 +00:00
|
|
|
" -> " +
|
2019-07-19 23:15:48 +00:00
|
|
|
reversed.First().GetType().Name;
|
2019-06-17 00:56:36 +00:00
|
|
|
}
|
|
|
|
throw new EngineCycleException(errorString);
|
|
|
|
}
|
|
|
|
|
2019-08-21 02:25:59 +00:00
|
|
|
var writtenComponentTypesWithoutPriority = new HashSet<Type>();
|
|
|
|
var writtenComponentTypesWithPriority = new HashSet<Type>();
|
|
|
|
var duplicateWritesWithoutPriority = new List<Type>();
|
2019-08-22 00:54:43 +00:00
|
|
|
var duplicateWritesWithSamePriority = new List<Type>();
|
|
|
|
var writePriorities = new Dictionary<Type, HashSet<int>>();
|
2019-08-21 02:25:59 +00:00
|
|
|
var writeMessageToEngines = new Dictionary<Type, List<Engine>>();
|
2019-06-17 00:56:36 +00:00
|
|
|
|
|
|
|
foreach (var engine in engines)
|
|
|
|
{
|
2019-11-21 21:53:33 +00:00
|
|
|
if (engine.GetType().GetCustomAttribute<IgnoresTimeDilation>() != null)
|
|
|
|
{
|
|
|
|
engine.usesTimeDilation = false;
|
|
|
|
}
|
|
|
|
|
2019-09-26 20:26:48 +00:00
|
|
|
var defaultWritePriorityAttribute = engine.GetType().GetCustomAttribute<DefaultWritePriority>(false);
|
|
|
|
|
2019-12-06 03:55:17 +00:00
|
|
|
foreach (var writeType in engine.writeTypes)
|
2019-06-17 00:56:36 +00:00
|
|
|
{
|
2019-09-26 20:26:48 +00:00
|
|
|
int? priority = null;
|
2019-12-06 03:55:17 +00:00
|
|
|
if (engine.writePriorities.ContainsKey(writeType))
|
2019-06-17 00:56:36 +00:00
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
priority = engine.writePriorities[writeType];
|
2019-09-26 20:26:48 +00:00
|
|
|
}
|
|
|
|
else if (defaultWritePriorityAttribute != null)
|
|
|
|
{
|
|
|
|
priority = defaultWritePriorityAttribute.writePriority;
|
|
|
|
}
|
2019-08-22 00:54:43 +00:00
|
|
|
|
2019-09-26 20:26:48 +00:00
|
|
|
if (priority.HasValue)
|
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
writtenComponentTypesWithPriority.Add(writeType);
|
2019-08-22 00:54:43 +00:00
|
|
|
|
2019-12-06 03:55:17 +00:00
|
|
|
if (!writePriorities.ContainsKey(writeType))
|
2019-08-22 00:54:43 +00:00
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
writePriorities[writeType] = new HashSet<int>();
|
2019-08-22 00:54:43 +00:00
|
|
|
}
|
|
|
|
|
2019-12-06 03:55:17 +00:00
|
|
|
if (writePriorities[writeType].Contains(priority.Value))
|
2019-08-22 00:54:43 +00:00
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
duplicateWritesWithSamePriority.Add(writeType);
|
2019-08-22 00:54:43 +00:00
|
|
|
}
|
2019-12-06 03:55:17 +00:00
|
|
|
else if (writtenComponentTypesWithoutPriority.Contains(writeType))
|
2019-08-21 02:25:59 +00:00
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
duplicateWritesWithoutPriority.Add(writeType);
|
2019-08-21 02:25:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
writePriorities[writeType].Add(priority.Value);
|
2019-08-21 02:25:59 +00:00
|
|
|
}
|
2019-07-19 23:15:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
if (writtenComponentTypesWithoutPriority.Contains(writeType) || writtenComponentTypesWithPriority.Contains(writeType))
|
2019-08-22 00:54:43 +00:00
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
duplicateWritesWithoutPriority.Add(writeType);
|
2019-08-22 00:54:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
writtenComponentTypesWithoutPriority.Add(writeType);
|
2019-08-22 00:54:43 +00:00
|
|
|
}
|
2019-07-19 23:15:48 +00:00
|
|
|
}
|
2019-07-19 01:20:38 +00:00
|
|
|
|
2019-12-06 03:55:17 +00:00
|
|
|
if (!writeMessageToEngines.ContainsKey(writeType))
|
2019-07-19 23:15:48 +00:00
|
|
|
{
|
2019-12-06 03:55:17 +00:00
|
|
|
writeMessageToEngines[writeType] = new List<Engine>();
|
2019-06-17 00:56:36 +00:00
|
|
|
}
|
2019-07-19 23:15:48 +00:00
|
|
|
|
2019-12-06 03:55:17 +00:00
|
|
|
writeMessageToEngines[writeType].Add(engine);
|
2019-06-17 00:56:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-21 02:25:59 +00:00
|
|
|
if (duplicateWritesWithoutPriority.Count > 0)
|
2019-06-17 00:56:36 +00:00
|
|
|
{
|
2019-08-21 02:25:59 +00:00
|
|
|
var errorString = "Multiple Engines write the same Component without declaring priority: ";
|
|
|
|
foreach (var componentType in duplicateWritesWithoutPriority)
|
2019-06-17 00:56:36 +00:00
|
|
|
{
|
|
|
|
errorString += "\n" +
|
2019-08-21 02:25:59 +00:00
|
|
|
componentType.Name + " written by: " +
|
|
|
|
string.Join(", ", writeMessageToEngines[componentType].Select((engine) => engine.GetType().Name));
|
2019-06-17 00:56:36 +00:00
|
|
|
}
|
2019-09-26 20:26:48 +00:00
|
|
|
errorString += "\nTo resolve the conflict, add priority arguments to the Writes declarations or use a DefaultWritePriority attribute.";
|
2019-06-17 00:56:36 +00:00
|
|
|
|
2019-08-21 02:25:59 +00:00
|
|
|
throw new EngineWriteConflictException(errorString);
|
2019-06-17 00:56:36 +00:00
|
|
|
}
|
|
|
|
|
2019-08-22 00:54:43 +00:00
|
|
|
if (duplicateWritesWithSamePriority.Count > 0)
|
2019-06-17 00:56:36 +00:00
|
|
|
{
|
2019-08-22 00:54:43 +00:00
|
|
|
var errorString = "Multiple Engines write the same Component with the same priority: ";
|
|
|
|
foreach (var componentType in duplicateWritesWithSamePriority)
|
2019-06-17 00:56:36 +00:00
|
|
|
{
|
|
|
|
errorString += "\n" +
|
2019-08-22 00:54:43 +00:00
|
|
|
componentType.Name + " written by: " +
|
|
|
|
string.Join(", ", writeMessageToEngines[componentType].Select(engine => engine.GetType().Name));
|
2019-06-17 00:56:36 +00:00
|
|
|
}
|
2019-09-26 20:26:48 +00:00
|
|
|
errorString += "\nTo resolve the conflict, add priority arguments to the Writes declarations or use a DefaultWritePriority attribute.";
|
2019-06-17 00:56:36 +00:00
|
|
|
|
2019-08-22 00:54:43 +00:00
|
|
|
throw new EngineWriteConflictException(errorString);
|
2019-06-17 00:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var engineOrder = new List<Engine>();
|
2019-12-06 07:16:47 +00:00
|
|
|
|
|
|
|
foreach (var registeredComponentType in registeredComponentTypes)
|
|
|
|
{
|
|
|
|
var emitterEngine = (Engine)Activator.CreateInstance(typeof(ComponentEmitter<>).MakeGenericType(registeredComponentType));
|
|
|
|
AddEngine(emitterEngine);
|
|
|
|
engineOrder.Add(emitterEngine);
|
|
|
|
}
|
|
|
|
|
2019-06-17 00:56:36 +00:00
|
|
|
foreach (var engine in engineGraph.TopologicalSort())
|
|
|
|
{
|
|
|
|
engineOrder.Add(engine);
|
|
|
|
}
|
|
|
|
|
2019-06-15 00:51:06 +00:00
|
|
|
var world = new World(
|
2019-06-17 00:56:36 +00:00
|
|
|
engineOrder,
|
2019-06-19 21:14:44 +00:00
|
|
|
entityManager,
|
|
|
|
componentManager,
|
|
|
|
messageManager,
|
2019-12-06 06:32:09 +00:00
|
|
|
componentUpdateManager,
|
2019-11-21 21:53:33 +00:00
|
|
|
timeManager,
|
2019-06-19 21:14:44 +00:00
|
|
|
renderManager
|
2019-06-15 00:51:06 +00:00
|
|
|
);
|
2019-06-15 00:03:56 +00:00
|
|
|
|
2019-12-06 06:32:09 +00:00
|
|
|
componentUpdateManager.SetStartingComponentStore(startingComponentStoreForComponentUpdateManager);
|
2019-12-06 00:00:00 +00:00
|
|
|
componentManager.SetComponentStore(startingComponentStoreForComponentManager);
|
2019-07-18 01:53:31 +00:00
|
|
|
|
2019-06-15 00:03:56 +00:00
|
|
|
return world;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|