示例#1
0
        internal EcsBuilder(IServiceProvider services)
        {
            Services = services ?? throw new ArgumentNullException(nameof(services));

            _systemRegistry = services.GetRequiredService <ISystemRegistry>();
            _eventService   = services.GetRequiredService <IEventService>();
        }
 /// <summary>
 /// <inheritdoc />
 /// </summary>
 public void AddFromRegistry(ISystemRegistry registry)
 {
     if (registry == null)
     {
         throw new ArgumentNullException(nameof(registry));
     }
     foreach (ISystem system in registry)
     {
         Add(system.Info);
     }
 }
示例#3
0
        //TODO: replace with some sort of global components - or make the simulation or rather 'graph' or something an entity with the layout components on it

        public Simulation(SimulationConfiguration configuration,
                          IEntityRegistry entityRegistry,
                          IMatcherProvider matcherProvider,
                          ISystemRegistry systemRegistry,
                          // TODO: remove zenject dependency when implicit optional collection paramters is implemented
                          IEntityFactoryProvider entityFactoryProvider,
                          CommandQueue commandQueue)
            : base(configuration,
                   entityRegistry,
                   matcherProvider,
                   systemRegistry,
                   entityFactoryProvider,
                   commandQueue)
        {
        }
示例#4
0
        /// <inheritdoc />
        public void Initialize(IGameModeClient client)
        {
            client.UnhandledException += (sender, args) =>
            {
                CoreLog.Log(CoreLogLevel.Error, "Unhandled exception: " + args.Exception);
            };

            var services = new ServiceCollection();

            services.AddSingleton(client);
            services.AddSingleton(client.NativeLoader);
            Configure(services);

            _serviceProvider = services.BuildServiceProvider();
            _systemRegistry  = _serviceProvider.GetRequiredService <ISystemRegistry>();

            Configure();

            AddWrappedSystemTypes();
        }
示例#5
0
 /// <summary>
 /// Constructs an engine loader with the given parameters using the default admin
 /// </summary>
 /// <param name="targetLogicFrameLength">the frame length in seconds of logic updates which the engine will attempt to keep</param>
 /// <param name="targetMaxRenderFrameLength">the frame length in seconds of render updates which the engine will try to stay below</param>
 /// <param name="componentTypeRegistry">the component type registry to use to store component types</param>
 /// <param name="systemRegistry">the system registry to store systems</param>
 /// <param name="entityBuffer">the entity buffer to use to store entities</param>
 protected EngineLoader(IComponentTypeRegistry componentTypeRegistry,
                        ISystemRegistry systemRegistry, IEntityBuffer entityBuffer, float targetLogicFrameLength = 1f / 60f, float targetMaxRenderFrameLength = 1f / 30f)
 {
     Admin = new EntityAdmin(targetLogicFrameLength, targetMaxRenderFrameLength, componentTypeRegistry, systemRegistry, entityBuffer);
 }