Esempio n. 1
0
        public void IsOwningWorker_should_return_false_if_entity_doesnt_have_OwningWorker_component()
        {
            connectionHandler.CreateEntity(1, new EntityTemplate());
            receiveSystem.Update();

            Assert.IsFalse(PlayerLifecycleHelper.IsOwningWorker(new EntityId(1), worker.World));
        }
Esempio n. 2
0
        private GameObject CreateAndLinkGameObject <T>(long entityId) where T : MonoBehaviour
        {
            var template = new EntityTemplate();

            template.AddComponent(new Position.Snapshot(), "worker");
            connectionHandler.CreateEntity(entityId, template);
            receiveSystem.Update();

            var gameObject = new GameObject("TestGameObject");

            gameObject.AddComponent <T>();
            gameObject.GetComponent <T>().enabled = false;

            linker.LinkGameObjectToSpatialOSEntity(new EntityId(entityId), gameObject);
            requireLifecycleSystem.Update();

            return(gameObject);
        }
        public void Setup()
        {
            var connectionBuilder = new MockConnectionHandlerBuilder();

            connectionHandler = connectionBuilder.ConnectionHandler;

            workerInWorld = WorkerInWorld
                            .CreateWorkerInWorldAsync(connectionBuilder, "TestWorkerType", new LoggingDispatcher(), Vector3.zero)
                            .Result;

            var world = workerInWorld.World;

            receiveSystem          = world.GetExistingSystem <SpatialOSReceiveSystem>();
            requireLifecycleSystem = world.GetExistingSystem <RequireLifecycleSystem>();
            linker = new EntityGameObjectLinker(world);

            var template = new EntityTemplate();

            template.AddComponent(new Position.Snapshot(), "worker");
            connectionHandler.CreateEntity(EntityId, template);
            receiveSystem.Update();
        }
        public void Setup()
        {
            world             = new World("TestWorld");
            connectionHandler = new MockConnectionHandler();
            world.CreateManager <WorkerSystem>(connectionHandler, null,
                                               new LoggingDispatcher(), "TestWorkerType", Vector3.zero);
            receiveSystem = world.CreateManager <SpatialOSReceiveSystem>();
            world.GetOrCreateManager <ComponentUpdateSystem>();
            world.GetOrCreateManager <ComponentConstraintsCallbackSystem>();
            world.CreateManager <SubscriptionSystem>();
            world.CreateManager <CommandCallbackSystem>();
            world.CreateManager <ComponentCallbackSystem>();
            requireLifecycleSystem = world.CreateManager <RequireLifecycleSystem>();

            linker = new EntityGameObjectLinker(world);

            var template = new EntityTemplate();

            template.AddComponent(new Position.Snapshot(), "worker");
            connectionHandler.CreateEntity(EntityId, template);
            receiveSystem.Update();
        }
 private void Update()
 {
     receiveSystem.Update();
 }