Beispiel #1
0
        protected override void HandleWorkerConnectionEstablished()
        {
            PlayerLifecycleHelper.AddClientSystems(Worker.World, false);

            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World,
                                                                      new AdvancedEntityPipeline(Worker), entityRepresentationMapping);
        }
Beispiel #2
0
 public static void AddGameLogicSystems(World world)
 {
     AddLifecycleSystems(world);
     TransformSynchronizationHelper.AddServerSystems(world);
     PlayerLifecycleHelper.AddServerSystems(world);
     GameObjectCreationHelper.EnableStandardGameObjectCreation(world);
 }
        protected override void HandleWorkerConnectionEstablished()
        {
            PlayerLifecycleHelper.AddClientSystems(Worker.World);
            var gameObjectCreator = new GameObjectCreatorFromTransform(WorkerType, transform.position);

            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, gameObjectCreator, entityRepresentationMapping);
        }
 protected override void HandleWorkerConnectionEstablished()
 {
     PlayerLifecycleHelper.AddClientSystems(Worker.World);
     TransformSynchronizationHelper.AddClientSystems(Worker.World);
     GameObjectRepresentationHelper.AddSystems(Worker.World);
     GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World);
 }
Beispiel #5
0
        protected override void HandleWorkerConnectionEstablished()
        {
            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, new SyncTransObjectCreation(Worker), entityRepresentationMapping);
            WorkerUtils.AddClientSystems(Worker.World, false);

            this.ConnectionState = ConnectionState.ConnectionEstablished;
        }
    protected override void HandleWorkerConnectionEstablished()
    {
        Debug.Log("Handling client worker connection established");

        PlayerLifecycleHelper.AddClientSystems(Worker.World);
        GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, entityRepresentationMapping);
    }
 protected override void HandleWorkerConnectionEstablished()
 {
     Worker.World.GetOrCreateManager <MetricSendSystem>();
     PlayerLifecycleHelper.AddServerSystems(Worker.World);
     GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World);
     TransformSynchronizationHelper.AddServerSystems(Worker.World);
 }
Beispiel #8
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);
        }
Beispiel #9
0
        public static void AddStrategyLogicSystems(World world, EntityRepresentationMapping entityRepresentationMapping)
        {
            TransformSynchronizationHelper.AddServerSystems(world);
            PlayerLifecycleHelper.AddServerSystems(world);
            GameObjectCreationHelper.EnableStandardGameObjectCreation(world, entityRepresentationMapping);

            world.GetOrCreateSystem <ProcessLaunchCommandSystem>();
            world.GetOrCreateSystem <MetricSendSystem>();
            //world.GetOrCreateSystem<ArmyCloudUpdateSystem>();
        }
Beispiel #10
0
    protected override void HandleWorkerConnectionEstablished()
    {
        Debug.Log("Server connection established");
        var world = Worker.World;

        PlayerLifecycleHelper.AddServerSystems(world);
        GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, entityRepresentationMapping);

        // Add server systems
    }
        protected override void HandleWorkerConnectionEstablished()
        {
            PlayerLifecycleHelper.AddClientSystems(Worker.World);
            TransformSynchronizationHelper.AddClientSystems(Worker.World);

            IEntityGameObjectCreator fallbackCreator = new GameObjectCreatorFromMetadata(Worker.WorkerType, Worker.Origin, Worker.LogDispatcher);
            IEntityGameObjectCreator customCreator   = new PlayerGameObjectCreator(fallbackCreator, Worker.World, Worker.WorkerType);

            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, customCreator);
        }
        protected override void HandleWorkerConnectionEstablished()
        {
            PlayerLifecycleHelper.AddClientSystems(Worker.World, false);

            var fallback = new GameObjectCreatorFromMetadata(Worker.WorkerType,
                                                             Worker.Origin, Worker.LogDispatcher);

            GameObjectCreationHelper.EnableStandardGameObjectCreation(
                Worker.World,
                new AdvancedEntityPipeline(Worker, AuthPlayer, NonAuthPlayer, fallback));
        }
Beispiel #13
0
 protected override MockWorld.Options GetOptions()
 {
     return(new MockWorld.Options
     {
         AdditionalSystems = world =>
         {
             var testGameObjectCreator = new TestGameObjectCreator(WorkerType);
             GameObjectCreationHelper.EnableStandardGameObjectCreation(world, testGameObjectCreator);
         }
     });
 }
        protected override void HandleWorkerConnectionEstablished()
        {
            Worker.World.GetOrCreateSystem <MetricSendSystem>();
            PlayerLifecycleHelper.AddServerSystems(Worker.World);
            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World);

            if (level != null)
            {
                levelInstance = Instantiate(level, transform.position, transform.rotation);
            }
        }
Beispiel #15
0
        protected override void HandleWorkerConnectionEstablished()
        {
            PlayerLifecycleHelper.AddClientSystems(Worker.World);
            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, entityRepresentationMapping);

            if (level == null)
            {
                return;
            }

            levelInstance = Instantiate(level, transform.position, transform.rotation);
        }
Beispiel #16
0
        private void ConfigurePlayerLifeCycle(Unity.Entities.World world)
        {
            PlayerLifecycleHelper.AddClientSystems(world);
            world.GetOrCreateManager <HandlePlayerHeartbeatRequestSystem>();

            var fallback = new GameObjectCreatorFromMetadata(Worker.WorkerId, Worker.Origin, Worker.LogDispatcher);

            GameObjectCreationHelper.EnableStandardGameObjectCreation(
                world,
                new AdvancedEntityCreationPipeline(
                    Worker, EntityUtils.PlayerEntityType, AuthPlayer, NonAuthPlayer, fallback),
                gameObject);
        }
Beispiel #17
0
 public static void AddGameLogicSystems(World world)
 {
     AddLifecycleSystems(world);
     TransformSynchronizationHelper.AddServerSystems(world);
     PlayerLifecycleHelper.AddServerSystems(world);
     GameObjectCreationHelper.EnableStandardGameObjectCreation(world);
     world.GetOrCreateManager <CubeMovementSystem>();
     world.GetOrCreateManager <TriggerColorChangeSystem>();
     world.GetOrCreateManager <ProcessLaunchCommandSystem>();
     world.GetOrCreateManager <ProcessRechargeSystem>();
     world.GetOrCreateManager <MetricSendSystem>();
     world.GetOrCreateManager <ProcessScoresSystem>();
     world.GetOrCreateManager <CollisionProcessSystem>();
 }
        protected override void HandleWorkerConnectionEstablished()
        {
            var world = Worker.World;

            PlayerLifecycleHelper.AddClientSystems(world, autoRequestPlayerCreation: false);
            PlayerLifecycleConfig.MaxPlayerCreationRetries = 0;

            var entityPipeline = new AdvancedEntityPipeline(Worker, GetAuthPlayerPrefabPath(), GetNonAuthPlayerPrefabPath());

            entityPipeline.OnRemovedAuthoritativePlayer += RemovingAuthoritativePlayer;

            // Set the Worker gameObject to the ClientWorker so it can access PlayerCreater reader/writers
            GameObjectCreationHelper.EnableStandardGameObjectCreation(world, entityPipeline, gameObject);
        }
Beispiel #19
0
        public void Setup()
        {
            world         = new World("TestWorld");
            entityManager = world.GetOrCreateManager <EntityManager>();
            worker        = world.CreateManager <WorkerSystem>(null, new LoggingDispatcher(), "TestWorker", Vector3.zero);
            world.CreateManager <EntityGameObjectLinkerSystem>();

            gameObjectDispatcherSystem = world.GetOrCreateManager <GameObjectDispatcherSystem>();

            workerGameObject = new GameObject();
            workerGameObject.AddComponent <MonoBehaviourOnWorker>();
            GameObjectCreationHelper.EnableStandardGameObjectCreation(world, workerGameObject: workerGameObject);
            workerLinkerSystem = world.GetExistingManager <WorkerEntityGameObjectLinkerSystem>();
        }
Beispiel #20
0
 public static void AddClientSystems(World world)
 {
     AddLifecycleSystems(world);
     TransformSynchronizationHelper.AddClientSystems(world);
     PlayerLifecycleHelper.AddClientSystems(world);
     GameObjectCreationHelper.EnableStandardGameObjectCreation(world);
     world.GetOrCreateSystem <ProcessColorChangeSystem>();
     world.GetOrCreateSystem <LocalPlayerInputSync>();
     world.GetOrCreateSystem <MoveLocalPlayerSystem>();
     world.GetOrCreateSystem <InitCameraSystem>();
     world.GetOrCreateSystem <FollowCameraSystem>();
     world.GetOrCreateSystem <UpdateUISystem>();
     world.GetOrCreateSystem <PlayerCommandsSystem>();
     world.GetOrCreateSystem <MetricSendSystem>();
 }
        protected override void HandleWorkerConnectionEstablished()
        {
            PlayerLifecycleHelper.AddClientSystems(Worker.World);
            PlayerLifecycleConfig.MaxPlayerCreationRetries = 0;

            entityPipeline = new AdvancedEntityPipeline(Worker, GetAuthPlayerPrefabPath(), GetNonAuthPlayerPrefabPath());
            entityPipeline.OnRemovedAuthoritativePlayer += RemovingAuthoritativePlayer;

            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, entityPipeline, gameObject);

            if (level != null)
            {
                levelInstance = Instantiate(level, transform.position, transform.rotation);
            }
        }
        protected override void HandleWorkerConnectionEstablished()
        {
            PlayerLifecycleHelper.AddClientSystems(Worker.World);

            // 改变状态
            ClientManager.Instance.StateMachine.TriggerTransition(ConnectionFSMStateEnum.StateEnum.CONNECTED);

            // 创建实体的预制件
            var fallbackCreator = new GameObjectCreatorFromMetadata(Worker.WorkerType, Worker.Origin, Worker.LogDispatcher);
            var customCreator   = new EntityGameObjectCreator(fallbackCreator, Worker.World, Worker.WorkerType);

            Debug.Log("HandleWorkerConnectionEstablished!");

            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, customCreator);
        }
Beispiel #23
0
        protected override void HandleWorkerConnectionEstablished()
        {
            Worker.World.GetOrCreateSystem <MetricSendSystem>();
            PlayerLifecycleHelper.AddClientSystems(Worker.World);
            var gameObjectCreator = new GameObjectCreatorFromTransform(WorkerType, transform.position);

            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, gameObjectCreator, entityRepresentationMapping);
            TransformSynchronizationHelper.AddClientSystems(Worker.World);

            // if no level make one....
            if (level == null)
            {
                return;
            }
            levelInstance = Instantiate(level, transform.position, transform.rotation);
        }
Beispiel #24
0
        protected override void HandleWorkerConnectionEstablished()
        {
            var world = Worker.World;

            PlayerLifecycleHelper.AddServerSystems(world);
            GameObjectCreationHelper.EnableStandardGameObjectCreation(world, entityRepresentationMapping);

            // Shooting
            world.GetOrCreateSystem <ServerShootingSystem>();

            // Metrics
            world.GetOrCreateSystem <MetricSendSystem>();

            // Health
            world.GetOrCreateSystem <ServerHealthModifierSystem>();
            world.GetOrCreateSystem <HealthRegenSystem>();
        }
        protected override void HandleWorkerConnectionEstablished()
        {
            var world = Worker.World;

            PlayerLifecycleHelper.AddClientSystems(world, autoRequestPlayerCreation: false);
            PlayerLifecycleConfig.MaxPlayerCreationRetries = 0;

            var fallback = new GameObjectCreatorFromMetadata(Worker.WorkerType, Worker.Origin, Worker.LogDispatcher);

            // Set the Worker gameObject to the ClientWorker so it can access PlayerCreater reader/writers
            GameObjectCreationHelper.EnableStandardGameObjectCreation(
                world,
                new AdvancedEntityPipeline(Worker, AuthPlayer, NonAuthPlayer, fallback),
                gameObject);

            base.HandleWorkerConnectionEstablished();
        }
        protected override void HandleWorkerConnectionEstablished()
        {
            Worker.World.GetOrCreateSystem <TankMovementSystem>();
            PlayerLifecycleHelper.AddClientSystems(Worker.World);

            var fallbackCreator = new GameObjectCreatorFromMetadata(Worker.WorkerType, Worker.Origin, Worker.LogDispatcher);
            var customCreator   = new CustomGameObjectCreator(fallbackCreator, Worker.World, Worker.WorkerType, Worker.Origin, Worker.LogDispatcher);

            GameObjectCreationHelper.EnableStandardGameObjectCreation(Worker.World, customCreator);
            TransformSynchronizationHelper.AddClientSystems(Worker.World);

            if (level == null)
            {
                return;
            }
            levelInstance = Instantiate(level, transform.position, transform.rotation);
        }
Beispiel #27
0
        protected override MockWorld.Options GetOptions()
        {
            return(new MockWorld.Options
            {
                AdditionalSystems = world =>
                {
                    var testGameObjectCreator = new TestGameObjectCreator(WorkerType);
                    var dummyDatabase = ScriptableObject.CreateInstance <EntityRepresentationMapping>();
                    dummyDatabase.EntityRepresentationResolvers = new List <IEntityRepresentationResolver>
                    {
                        new SimpleEntityResolver("TestObject", new GameObject())
                    };

                    GameObjectCreationHelper.EnableStandardGameObjectCreation(world, testGameObjectCreator, dummyDatabase);
                }
            });
        }
        protected override void HandleWorkerConnectionEstablished()
        {
            var world = Worker.World;

            // Only take the Heartbeat from the PlayerLifecycleConfig Client Systems.
            world.GetOrCreateManager <HandlePlayerHeartbeatRequestSystem>();

            var fallback = new GameObjectCreatorFromMetadata(Worker.WorkerType, Worker.Origin, Worker.LogDispatcher);

            // Set the Worker gameObject to the ClientWorker so it can access PlayerCreater reader/writers
            GameObjectCreationHelper.EnableStandardGameObjectCreation(
                world,
                new AdvancedEntityPipeline(Worker, AuthPlayer, NonAuthPlayer, fallback),
                gameObject);

            base.HandleWorkerConnectionEstablished();
        }
 public static void AddClientSystems(World world, UnityEngine.GameObject gameObject, bool autoRequestPlayerCreation = true)
 {
     TransformSynchronizationHelper.AddClientSystems(world);
     PlayerLifecycleHelper.AddClientSystems(world, autoRequestPlayerCreation);
     GameObjectCreationHelper.EnableStandardGameObjectCreation(world, gameObject);
     world.GetOrCreateSystem <ProcessColorChangeSystem>();
     world.GetOrCreateSystem <AdvancedPlayerInputSync>();
     world.GetOrCreateSystem <MoveAdvancedUnitSystem>();
     world.GetOrCreateSystem <InitCameraSystem>();
     world.GetOrCreateSystem <FollowCameraSystem>();
     world.GetOrCreateSystem <InitUISystem>();
     world.GetOrCreateSystem <UpdateUISystem>();
     world.GetOrCreateSystem <PlayerCommandsSystem>();
     world.GetOrCreateSystem <MetricSendSystem>();
     world.GetOrCreateSystem <BulletMovementSystem>();
     world.GetOrCreateSystem <FieldQueryClientSystem>();
 }
Beispiel #30
0
        public void Subscribe_to_LinkedGameObjectMap_should_be_available_if_GameObjectCreation_systems_are_added()
        {
            World
            .Step((world) =>
            {
                GameObjectCreationHelper.EnableStandardGameObjectCreation(world.Worker.World, new MockGameObjectCreator());
                var subscriptionSystem = world.GetSystem <SubscriptionSystem>();
                var goMapSubscription  = subscriptionSystem.Subscribe <LinkedGameObjectMap>(entityId);

                return(goMapSubscription);
            })
            .Step((world, goMapSubscription) =>
            {
                Assert.IsTrue(goMapSubscription.HasValue);
                Assert.IsNotNull(goMapSubscription.Value);
            });
        }