public void Setup(IDependencyContainer container) { container.Bind <IMessageBroker, MessageBroker>(); container.Bind <IEventSystem, EventSystem>(); container.Bind <IIdPool, IdPool>(); container.Bind <IEntityFactory, DefaultEntityFactory>(); container.Bind <IEntityCollectionFactory, DefaultEntityCollectionFactory>(); container.Bind <IObservableGroupFactory, DefaultObservableObservableGroupFactory>(); container.Bind <IEntityCollectionManager, EntityCollectionManager>(); container.Bind <IConventionalSystemHandler, ReactToEntitySystemHandler>(); container.Bind <IConventionalSystemHandler, ReactToGroupSystemHandler>(); container.Bind <IConventionalSystemHandler, ReactToDataSystemHandler>(); container.Bind <IConventionalSystemHandler, ManualSystemHandler>(); container.Bind <IConventionalSystemHandler, SetupSystemHandler>(); container.Bind <IConventionalSystemHandler, TeardownSystemHandler>(); container.Bind <ISystemExecutor, SystemExecutor>(); var componentTypeAssigner = new DefaultComponentTypeAssigner(); var allComponents = componentTypeAssigner.GenerateComponentLookups(); var componentLookup = new ComponentTypeLookup(allComponents); container.Bind <IComponentTypeAssigner>(new BindingConfiguration { BindInstance = componentTypeAssigner }); container.Bind <IComponentTypeLookup>(new BindingConfiguration { BindInstance = componentLookup }); container.Bind <IComponentDatabase, ComponentDatabase>(); container.Bind <IComponentRepository, ComponentRepository>(); }
public void GlobalSetup() { var componentTypeAssigner = new DefaultComponentTypeAssigner(); var allComponents = componentTypeAssigner.GenerateComponentLookups(); var componentLookup = new ComponentTypeLookup(allComponents); _availableComponents = allComponents.Keys .Select(x => Activator.CreateInstance(x) as IComponent) .ToArray(); var componentDatabase = new ComponentDatabase(componentLookup); var componentRepository = new ComponentRepository(componentLookup, componentDatabase); var entityFactory = new DefaultEntityFactory(new IdPool(), componentRepository); var poolFactory = new DefaultEntityCollectionFactory(entityFactory); var observableGroupFactory = new DefaultObservableObservableGroupFactory(); _entityCollectionManager = new EntityCollectionManager(poolFactory, observableGroupFactory, componentLookup); _availableComponents = _groupFactory.GetComponentTypes .Select(x => Activator.CreateInstance(x) as IComponent) .ToArray(); _testGroups = _groupFactory.CreateTestGroups().ToArray(); foreach (var group in _testGroups) { _entityCollectionManager.GetObservableGroup(group); } _defaultEntityCollection = _entityCollectionManager.GetCollection(); }
public void Setup(IDependencyContainer container) { container.Bind <IMessageBroker, MessageBroker>(); container.Bind <IEventSystem, EventSystem>(); container.Bind <IIdPool, IdPool>(); container.Bind <IThreadHandler, DefaultThreadHandler>(); container.Bind <IEntityFactory, DefaultEntityFactory>(); container.Bind <IEntityCollectionFactory, DefaultEntityCollectionFactory>(); container.Bind <IObservableGroupFactory, DefaultObservableObservableGroupFactory>(); container.Bind <IEntityCollectionManager, EntityCollectionManager>(); container.Bind <IObservableGroupManager>(x => x.ToMethod(y => y.Resolve <IEntityCollectionManager>())); container.Bind <IConventionalSystemHandler, ManualSystemHandler>(); container.Bind <ISystemExecutor, SystemExecutor>(); var componentTypeAssigner = new DefaultComponentTypeAssigner(); var allComponents = componentTypeAssigner.GenerateComponentLookups(); var componentLookup = new ComponentTypeLookup(allComponents); container.Bind <IComponentTypeAssigner>(new BindingConfiguration { ToInstance = componentTypeAssigner }); container.Bind <IComponentTypeLookup>(new BindingConfiguration { ToInstance = componentLookup }); container.Bind <IComponentDatabase, ComponentDatabase>(); }
public void GlobalSetup() { var componentTypeAssigner = new DefaultComponentTypeAssigner(); var allComponents = componentTypeAssigner.GenerateComponentLookups(); var componentLookup = new ComponentTypeLookup(allComponents); _availableComponents = allComponents.Keys .Select(x => Activator.CreateInstance(x) as IComponent) .ToArray(); var componentDatabase = new ComponentDatabase(componentLookup); _componentRepository = new ComponentRepository(componentLookup, componentDatabase); }
protected EcsRxApplication() { // For sending events around EventSystem = new EventSystem(new MessageBroker()); // For mapping component types to underlying indexes var componentTypeAssigner = new DefaultComponentTypeAssigner(); var allComponents = componentTypeAssigner.GenerateComponentLookups(); var componentLookup = new ComponentTypeLookup(allComponents); // For interacting with the component databases var componentDatabase = new ComponentDatabase(componentLookup); var componentRepository = new ComponentRepository(componentLookup, componentDatabase); // For creating entities, collections, observable groups and managing Ids var entityFactory = new DefaultEntityFactory(new IdPool(), componentRepository); var entityCollectionFactory = new DefaultEntityCollectionFactory(entityFactory); var observableGroupFactory = new DefaultObservableObservableGroupFactory(); EntityCollectionManager = new EntityCollectionManager(entityCollectionFactory, observableGroupFactory, componentLookup); // All system handlers for the system types you want to support var reactsToEntityHandler = new ReactToEntitySystemHandler(EntityCollectionManager); var reactsToGroupHandler = new ReactToGroupSystemHandler(EntityCollectionManager); var reactsToDataHandler = new ReactToDataSystemHandler(EntityCollectionManager); var manualSystemHandler = new ManualSystemHandler(EntityCollectionManager); var setupHandler = new SetupSystemHandler(EntityCollectionManager); var teardownHandler = new TeardownSystemHandler(EntityCollectionManager); var conventionalSystems = new List <IConventionalSystemHandler> { setupHandler, teardownHandler, reactsToEntityHandler, reactsToGroupHandler, reactsToDataHandler, manualSystemHandler }; // The main executor which manages how systems are given information SystemExecutor = new SystemExecutor(conventionalSystems); }