public void should_stop_system_when_added_to_handler() { var mockSystem = Substitute.For <IManualSystem>(); var systemHandler = new ManualSystemHandler(); systemHandler.DestroySystem(mockSystem); mockSystem.Received(1).StopSystem(); }
public void should_correctly_handle_systems() { var teardownSystemHandler = new ManualSystemHandler(); var fakeMatchingSystem = Substitute.For <IManualSystem>(); var fakeNonMatchingSystem1 = Substitute.For <IReactToEntitySystem>(); var fakeNonMatchingSystem2 = Substitute.For <IGroupSystem>(); Assert.True(teardownSystemHandler.CanHandleSystem(fakeMatchingSystem)); Assert.False(teardownSystemHandler.CanHandleSystem(fakeNonMatchingSystem1)); Assert.False(teardownSystemHandler.CanHandleSystem(fakeNonMatchingSystem2)); }
public void should_start_system_when_added_to_handler() { var mockObservableGroup = Substitute.For <IObservableGroup>(); var mockCollectionManager = Substitute.For <IEntityCollectionManager>(); mockCollectionManager.CreateObservableGroup(Arg.Any <IGroup>()).Returns(mockObservableGroup); var mockSystem = Substitute.For <IManualSystem>(); var systemHandler = new ManualSystemHandler(mockCollectionManager); systemHandler.SetupSystem(mockSystem); mockSystem.Received(1).StartSystem(Arg.Is(mockObservableGroup)); }
private SystemExecutor CreateExecutor() { var messageBroker = new EventSystem(new MessageBroker()); var identityGenerator = new SequentialIdentityGenerator(); var poolManager = new PoolManager(identityGenerator, messageBroker); var reactsToEntityHandler = new ReactToEntitySystemHandler(poolManager); var reactsToGroupHandler = new ReactToGroupSystemHandler(poolManager); var reactsToDataHandler = new ReactToDataSystemHandler(poolManager); var manualSystemHandler = new ManualSystemHandler(poolManager); var setupHandler = new SetupSystemHandler(poolManager); return(new SystemExecutor(poolManager, messageBroker, reactsToEntityHandler, reactsToGroupHandler, setupHandler, reactsToDataHandler, manualSystemHandler)); }
public void should_stop_system_when_added_to_handler() { var mockObservableGroup = Substitute.For <IObservableGroup>(); var observableGroupManager = Substitute.For <IObservableGroupManager>(); observableGroupManager.GetObservableGroup(Arg.Any <IGroup>()).Returns(mockObservableGroup); var mockSystem = Substitute.For <IManualSystem>(); var systemHandler = new ManualSystemHandler(observableGroupManager); systemHandler.DestroySystem(mockSystem); mockSystem.Received(1).StopSystem(Arg.Is(mockObservableGroup)); }
private SystemExecutor CreateExecutor() { var messageBroker = new EventSystem(new MessageBroker()); var entityFactory = new DefaultEntityFactory(messageBroker); var poolFactory = new DefaultPoolFactory(entityFactory, messageBroker); var groupAccessorFactory = new DefaultGroupAccessorFactory(messageBroker); var poolManager = new PoolManager(messageBroker, poolFactory, groupAccessorFactory); var reactsToEntityHandler = new ReactToEntitySystemHandler(poolManager); var reactsToGroupHandler = new ReactToGroupSystemHandler(poolManager); var reactsToDataHandler = new ReactToDataSystemHandler(poolManager); var manualSystemHandler = new ManualSystemHandler(poolManager); var setupHandler = new SetupSystemHandler(poolManager); return(new SystemExecutor(poolManager, messageBroker, reactsToEntityHandler, reactsToGroupHandler, setupHandler, reactsToDataHandler, manualSystemHandler)); }
private SystemExecutor CreateExecutor(IEntityCollectionManager entityCollectionManager) { 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 conventionalSystems = new List <IConventionalSystemHandler> { setupHandler, reactsToEntityHandler, reactsToGroupHandler, reactsToDataHandler, manualSystemHandler }; return(new SystemExecutor(conventionalSystems)); }
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); }
private SystemExecutor CreateExecutor(IObservableGroupManager observableGroupManager) { var threadHandler = new DefaultThreadHandler(); var reactsToEntityHandler = new ReactToEntitySystemHandler(observableGroupManager); var reactsToGroupHandler = new ReactToGroupSystemHandler(observableGroupManager, threadHandler); var reactsToDataHandler = new ReactToDataSystemHandler(observableGroupManager); var manualSystemHandler = new ManualSystemHandler(observableGroupManager); var setupHandler = new SetupSystemHandler(observableGroupManager); var teardownHandler = new TeardownSystemHandler(observableGroupManager); var conventionalSystems = new List <IConventionalSystemHandler> { setupHandler, reactsToEntityHandler, reactsToGroupHandler, reactsToDataHandler, manualSystemHandler, teardownHandler }; return(new SystemExecutor(conventionalSystems)); }
protected ReactorApplication() { var messageBroker = new MessageBroker(); EventSystem = new EventSystem(messageBroker); SystemExecutor = new SystemExecutor(EventSystem); var entityFactory = new DefaultEntityFactory(); var entityIndexPool = new EntityIndexPool(); var poolFactory = new DefaultPoolFactory(entityFactory, EventSystem, entityIndexPool, SystemExecutor); var groupAccessorFactory = new DefaultGroupAccessorFactory(EventSystem); PoolManager = new PoolManager(EventSystem, poolFactory, groupAccessorFactory); var entitySytemHandler = new EntityReactionSystemHandler(PoolManager); var groupSystemHandler = new GroupReactionSystemHandler(PoolManager); var setupSystemHandler = new SetupSystemHandler(PoolManager); var interactSystemHandler = new InteractReactionSystemHandler(PoolManager); var manualSystemHandler = new ManualSystemHandler(PoolManager); var systemHandlerManager = new SystemHandlerManager(entitySytemHandler, groupSystemHandler, setupSystemHandler, interactSystemHandler, manualSystemHandler); CoreManager = new CoreManager(PoolManager, systemHandlerManager, SystemExecutor); }