コード例 #1
0
        public void Subscribe_to_worker_id_should_always_be_available()
        {
            var workerIdSubscription = SubscriptionSystem.Subscribe <WorkerId>(entityId);

            Assert.True(workerIdSubscription.HasValue);
            Assert.AreEqual("TestWorker", workerIdSubscription.Value);
        }
コード例 #2
0
        public void Subscribe_to_world_should_always_be_available()
        {
            var worldSubscription = SubscriptionSystem.Subscribe <World>(entityId);

            Assert.IsTrue(worldSubscription.HasValue);
            Assert.AreEqual(World, worldSubscription.Value);
        }
コード例 #3
0
        public void Subscribe_to_entity_id_should_always_be_available()
        {
            var entitySubscription = SubscriptionSystem.Subscribe <EntityId>(entityId);

            Assert.True(entitySubscription.HasValue);
            Assert.AreEqual(entityId, entitySubscription.Value);
        }
コード例 #4
0
        public void Subscribe_to_log_dispatcher_should_always_be_available()
        {
            var logSubscription = SubscriptionSystem.Subscribe <ILogDispatcher>(entityId);

            Assert.IsTrue(logSubscription.HasValue);
            Assert.AreEqual(LogDispatcher, logSubscription.Value);
        }
コード例 #5
0
        public void Subscribe_to_LinkedGameObjectMap_should_be_available_if_GameObjectCreation_systems_are_added()
        {
            GameObjectCreationHelper.EnableStandardGameObjectCreation(World, new MockGameObjectCreator());

            var goMapSubscription = SubscriptionSystem.Subscribe <LinkedGameObjectMap>(entityId);

            Assert.IsTrue(goMapSubscription.HasValue);
            Assert.IsNotNull(goMapSubscription.Value);
        }
コード例 #6
0
        public void AggregateSubscription_should_not_be_available_if_not_all_constraints_satisfied()
        {
            var handler = new AvailabilityHandler();
            var aggSub  = SubscriptionSystem.Subscribe(entityId, typeof(Entity), typeof(World));

            aggSub.SetAvailabilityHandler(handler);

            Assert.IsFalse(handler.IsAvailable);
            Assert.Throws <InvalidOperationException>(() => aggSub.GetValue <Entity>());
        }
コード例 #7
0
        public void Subscribe_to_ecs_entity_should_be_available_if_the_entity_exists()
        {
            var entity = World.EntityManager.CreateEntity();

            Worker.EntityIdToEntity.Add(entityId, entity);

            var ecsEntitySubscription = SubscriptionSystem.Subscribe <Entity>(entityId);

            Assert.IsTrue(ecsEntitySubscription.HasValue);
            Assert.AreEqual(entity, ecsEntitySubscription.Value);
        }
コード例 #8
0
        public void AggregateSubscription_should_be_available_if_all_constraints_satisfied()
        {
            var handler = new AvailabilityHandler();
            var aggSub  = SubscriptionSystem.Subscribe(entityId, typeof(EntityId), typeof(World));

            aggSub.SetAvailabilityHandler(handler);

            Assert.IsTrue(handler.IsAvailable);
            Assert.AreEqual(entityId, aggSub.GetValue <EntityId>());
            Assert.AreEqual(World, aggSub.GetValue <World>());
        }
コード例 #9
0
 public Subscription SubscribeToData(string dataName, Action <System.Object> callback)
 {
     if (dataSubscriptions[dataName] == null)
     {
         Messenger <object>           messenger  = new Messenger <object>();
         SubscriptionService <object> subService = messenger.SubscriptionService();
         dataSubscriptions[dataName] = new SubscriptionSystem <object>(messenger, subService);
         return(subService.Subscribe(callback));
     }
     return(dataSubscriptions[dataName].subscriptionService.Subscribe(callback));
 }
コード例 #10
0
        public void Subscribe_to_world_commands_should_be_available_if_the_entity_exists()
        {
            var entity = World.EntityManager.CreateEntity();

            Worker.EntityIdToEntity.Add(entityId, entity);

            var worldCommandSub = SubscriptionSystem.Subscribe <WorldCommandSender>(entityId);

            Assert.IsTrue(worldCommandSub.HasValue);
            Assert.IsNotNull(worldCommandSub.Value);
            Assert.IsTrue(worldCommandSub.Value.IsValid);
        }
コード例 #11
0
        public void Setup()
        {
            // This is the minimal set required for subscriptions to work.
            // TODO: Look into untangling these!
            World  = new World("test-world");
            Worker = World.CreateManager <WorkerSystem>(new MockConnectionHandler(), null, new TestLogDispatcher(), "TestWorkerType", Vector3.zero);
            World.CreateManager <SpatialOSReceiveSystem>();
            World.GetOrCreateManager <ComponentConstraintsCallbackSystem>();
            SubscriptionSystem = World.CreateManager <SubscriptionSystem>();

            LogDispatcher = Worker.LogDispatcher;
        }
コード例 #12
0
        public void Setup()
        {
            // This is the minimal set required for subscriptions to work.

            var mockConnectionBuilder = new MockConnectionHandlerBuilder();

            WorkerInWorld = WorkerInWorld.CreateWorkerInWorldAsync(mockConnectionBuilder, "TestWorkerType",
                                                                   new TestLogDispatcher(), Vector3.zero).Result;

            World              = WorkerInWorld.World;
            Worker             = World.GetExistingSystem <WorkerSystem>();
            SubscriptionSystem = World.GetExistingSystem <SubscriptionSystem>();
            LogDispatcher      = Worker.LogDispatcher;
        }
コード例 #13
0
        public void Subscribe_to_world_commands_should_not_be_available_if_the_entity_does_not_exist()
        {
            var worldCommandSub = SubscriptionSystem.Subscribe <WorldCommandSender>(entityId);

            Assert.IsFalse(worldCommandSub.HasValue);
        }
コード例 #14
0
        public void Subscribe_to_ecs_entity_should_not_be_available_if_the_entity_does_not_exist()
        {
            var ecsEntitySubscription = SubscriptionSystem.Subscribe <Entity>(entityId);

            Assert.IsFalse(ecsEntitySubscription.HasValue);
        }
コード例 #15
0
        public void Subscribe_to_LinkedGameObjectMap_should_not_be_available_if_GameObjectCreation_systems_are_not_present()
        {
            var goMapSubscription = SubscriptionSystem.Subscribe <LinkedGameObjectMap>(entityId);

            Assert.IsFalse(goMapSubscription.HasValue);
        }