Ejemplo n.º 1
0
        public SystemExecutor(IPoolManager poolManager, IEventSystem eventSystem,
                              IReactToEntitySystemHandler reactToEntitySystemHandler, IReactToGroupSystemHandler reactToGroupSystemHandler,
                              ISetupSystemHandler setupSystemHandler, IReactToDataSystemHandler reactToDataSystemHandler,
                              IManualSystemHandler manualSystemHandler)
        {
            PoolManager = poolManager;
            EventSystem = eventSystem;
            ReactToEntitySystemHandler = reactToEntitySystemHandler;
            ReactToGroupSystemHandler  = reactToGroupSystemHandler;
            SetupSystemHandler         = setupSystemHandler;
            ReactToDataSystemHandler   = reactToDataSystemHandler;
            ManualSystemHandler        = manualSystemHandler;

            var addEntitySubscription       = EventSystem.Receive <EntityAddedEvent>().Subscribe(OnEntityAddedToPool);
            var removeEntitySubscription    = EventSystem.Receive <EntityRemovedEvent>().Subscribe(OnEntityRemovedFromPool);
            var addComponentSubscription    = EventSystem.Receive <ComponentAddedEvent>().Subscribe(OnEntityComponentAdded);
            var removeComponentSubscription = EventSystem.Receive <ComponentRemovedEvent>().Subscribe(OnEntityComponentRemoved);

            _systems             = new List <ISystem>();
            _systemSubscriptions = new Dictionary <ISystem, IList <SubscriptionToken> >();
            _eventSubscriptions  = new List <IDisposable>
            {
                addEntitySubscription, removeEntitySubscription, addComponentSubscription, removeComponentSubscription
            };
        }
Ejemplo n.º 2
0
        public SystemExecutor(IPoolManager poolManager, IMessageBroker messageBroker,
                              IReactToEntitySystemHandler reactToEntitySystemHandler, IReactToGroupSystemHandler reactToGroupSystemHandler,
                              ISetupSystemHandler setupSystemHandler, IReactToDataSystemHandler reactToDataSystemHandler)
        {
            PoolManager   = poolManager;
            MessageBroker = messageBroker;
            ReactToEntitySystemHandler = reactToEntitySystemHandler;
            ReactToGroupSystemHandler  = reactToGroupSystemHandler;
            SetupSystemHandler         = setupSystemHandler;
            ReactToDataSystemHandler   = reactToDataSystemHandler;

            MessageBroker.Receive <EntityAddedEvent>().Subscribe(OnEntityAddedToPool);
            MessageBroker.Receive <EntityRemovedEvent>().Subscribe(OnEntityRemovedFromPool);
            MessageBroker.Receive <ComponentAddedEvent>().Subscribe(OnEntityComponentAdded);
            MessageBroker.Receive <ComponentRemovedEvent>().Subscribe(OnEntityComponentRemoved);

            _systems             = new List <ISystem>();
            _systemSubscriptions = new Dictionary <ISystem, IList <SubscriptionToken> >();
        }