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); }
public void Subscribe_to_world_should_always_be_available() { var worldSubscription = SubscriptionSystem.Subscribe <World>(entityId); Assert.IsTrue(worldSubscription.HasValue); Assert.AreEqual(World, worldSubscription.Value); }
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); }
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); }
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); }
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>()); }
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); }
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>()); }
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)); }
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); }
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; }
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; }
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); }
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); }
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); }