예제 #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));
        }
        private void CreateEntity()
        {
            var template = new EntityTemplate();

            template.AddComponent(new Position.Snapshot(), "worker");
            template.AddComponent(new DependentDataComponent.Snapshot(), "worker");
            connectionHandler.CreateEntity(EntityId, template);
        }
예제 #3
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();
        }
예제 #5
0
        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();
        }