コード例 #1
0
    protected override void OnUpdate()
    {
        var requestArray = SpawnGroup.GetComponentDataArray <CharacterSpawnRequest>();

        if (requestArray.Length == 0)
        {
            return;
        }

        var requestEntityArray = SpawnGroup.GetEntityArray();

        // Copy requests as spawning will invalidate Group
        var spawnRequests = new CharacterSpawnRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            spawnRequests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(requestEntityArray[i]);
        }

        for (var i = 0; i < spawnRequests.Length; i++)
        {
            var request     = spawnRequests[i];
            var playerState = EntityManager.GetComponentObject <PlayerState>(request.playerEntity);
            var character   = SpawnCharacter(m_world, playerState, request.position, request.rotation, request.characterType, m_ResourceManager);
            playerState.controlledEntity = character.gameObject.GetComponent <GameObjectEntity>().Entity;
        }
    }
コード例 #2
0
    //[Inject] EndFrameBarrier endFrameBarrier;
    protected override void OnUpdate()
    {
        //EntityCommandBuffer commandBuffer = endFrameBarrier.CreateCommandBuffer();


        for (int i = 0; i < ballsGroup.Length; i++)
        {
            float dist = math.distance(playerGroup.playerPos[0].Value, ballsGroup.ballPos[i].Value);

            //!= 0 is required as this system actually checks distances even before I set them apart in the first frame
            // in another system.
            if (dist < 1 & dist != 0)
            {
                //this is to make things float up and down
                //var newPos = ballsGroup.ballPos[i];
                //newPos.Value = new float3(newPos.Value.x, 3 - dist, newPos.Value.z);
                //ballsGroup.ballPos[i] = newPos;


                // this baby is working perfect. But I understand I can also destroy them no problem so why send another component
                PostUpdateCommands.AddComponent <Die>(ballsGroup.entityArray[i], new Die());
                PostUpdateCommands.DestroyEntity(ballsGroup.entityArray[i]);

                // null check just to be sure at the first frame
                if (scoreText != null)
                {
                    score++;
                    scoreText.text = score.ToString();
                }
                //commandBuffer.AddComponent<Die>(ballsGroup.entityArray[i], new Die());
            }
        }
    }
コード例 #3
0
    protected override void OnUpdate()
    {
        var requestArray = DespawnGroup.GetComponentDataArray <CharacterDespawnRequest>();

        if (requestArray.Length == 0)
        {
            return;
        }

        Profiler.BeginSample("HandleCharacterDespawnRequests");

        var requestEntityArray = DespawnGroup.GetEntityArray();

        for (var i = 0; i < requestArray.Length; i++)
        {
            var request = requestArray[i];

            var character = EntityManager
                            .GetComponentObject <Character>(request.characterEntity);
            GameDebug.Assert(character != null, "Character despawn requst entity is not a character");

            GameDebug.Log("Despawning character:" + character.name + " tick:" + m_world.worldTime.tick);

            m_world.RequestDespawn(character.gameObject, PostUpdateCommands);



            m_world.RequestDespawn(PostUpdateCommands, character.behaviourController);
            m_world.RequestDespawn(PostUpdateCommands, character.item);

            PostUpdateCommands.DestroyEntity(requestEntityArray[i]);
        }

        Profiler.EndSample();
    }
コード例 #4
0
        protected override void OnUpdate()
        {
            if (this._playerGroup.Length <= 0)
            {
                return;
            }

            var playerPos  = this._playerGroup.Position[0].Value;
            var playerLife = this._playerGroup.Life[0];

            var   bulletDamage = this._playerGroup.PlayerSettings[0].LifeSettingsInstance.DamageAmount;
            float pRadius      = this._playerGroup.Collision[0].Radius;

            for (int i = 0; i < this._enemyBulletGroup.Length; ++i)
            {
                var   bulletPos = this._enemyBulletGroup.Position[i].Value;
                float bRadius   = this._enemyBulletGroup.Collision[i].Radius;

                if (math.pow((playerPos.x - bulletPos.x), 2) + math.pow((playerPos.z - bulletPos.z), 2) <= math.pow((pRadius + bRadius), 2))
                {
                    PostUpdateCommands.DestroyEntity(this._enemyBulletGroup.Entities[i]);

                    playerLife.Value -= bulletDamage;
                    if (playerLife.Value <= 0)
                    {
                        playerLife.Value = 0;
                        PostUpdateCommands.DestroyEntity(this._playerGroup.Entities[0]);
                        break;
                    }
                }
            }

            this._playerGroup.Life[0] = playerLife;
        }
コード例 #5
0
    protected override void OnUpdate()
    {
        for (int i = 0; i < sourceBlocks.Length; i++)
        {
            for (int j = 0; j < targetBlocks.Length; j++)
            {
                Vector3 offect = targetBlocks.postions[j].Value - sourceBlocks.postions[i].Value;
                //平方
                float sqrLen = offect.sqrMagnitude;
                //就是删除方块组中有和总方块组一样的
                if (sqrLen == 0)
                {
                    //同时寻找砖块上是否有草 有了也删除 就是草的位置y-1如果等于现在位置就删除
                    for (int k = 0; k < surfacePlants.Length; k++)
                    {
                        float3 pos = new float3(surfacePlants.postions[k].Value.x, surfacePlants.postions[k].Value.y + Vector3.down.y, surfacePlants.postions[k].Value.z);
                        offect = targetBlocks.postions[j].Value - pos;
                        sqrLen = offect.sqrMagnitude;

                        if (sqrLen == 0)
                        {
                            PostUpdateCommands.DestroyEntity(surfacePlants.entity[k]);
                        }
                    }

                    //删除 删除方块组和总方块组的该entity
                    PostUpdateCommands.DestroyEntity(sourceBlocks.entity[i]);
                    PostUpdateCommands.DestroyEntity(targetBlocks.entity[j]);
                }
            }
        }
    }
コード例 #6
0
    protected override void OnUpdate()
    {
        Entities.WithNone <SendRpcCommandRequestComponent>().ForEach((Entity reqEnt, ref GoInGameRequest req, ref ReceiveRpcCommandRequestComponent reqSrc) =>
        {
            PostUpdateCommands.AddComponent <NetworkStreamInGame>(reqSrc.SourceConnection);
            UnityEngine.Debug.Log(String.Format("Server setting connection {0} to in game", EntityManager.GetComponentData <NetworkIdComponent>(reqSrc.SourceConnection).Value));
#if true
            var ghostCollection = GetSingleton <GhostPrefabCollectionComponent>();
            var ghostId         = NetCubeGhostSerializerCollection.FindGhostType <CubeSnapshotData>();
            var prefab          = EntityManager.GetBuffer <GhostPrefabBuffer>(ghostCollection.serverPrefabs)[ghostId].Value;
            var player          = EntityManager.Instantiate(prefab);
            EntityManager.SetComponentData(player, new MovableCubeComponent {
                PlayerId = EntityManager.GetComponentData <NetworkIdComponent>(reqSrc.SourceConnection).Value
            });

            PostUpdateCommands.AddBuffer <CubeInput>(player);
            PostUpdateCommands.SetComponent(reqSrc.SourceConnection, new CommandTargetComponent {
                targetEntity = player
            });
#endif


            PostUpdateCommands.DestroyEntity(reqEnt);
        });
    }
コード例 #7
0
    protected override void OnUpdate()
    {
        float dt           = Time.deltaTime;
        var   requestArray = RequestGroup.GetComponentDataArray <SkillSpawnRequest>();

        if (requestArray.Length == 0)
        {
            return;
        }

        var requestEntityArray = RequestGroup.GetEntityArray();

        // Copy requests as spawning will invalidate Group
        var requests = new SkillSpawnRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            requests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(requestEntityArray[i]);
        }

        for (var i = 0; i < requests.Length; i++)
        {
            //如果不是主角参与的战斗,不在视野里的战斗协议需要过滤,在视野里的话就根据场景的人数每人分配一个时间间隔,人越多就间隔越大,间隔内收到的战斗协议也要过滤掉
            if (IsIgnore())
            {
                continue;
            }
        }
    }
コード例 #8
0
 private void ClearAll()
 {
     for (int i = 0; i < mCubeGroup.Length; i++)
     {
         PostUpdateCommands.DestroyEntity(mCubeGroup.Entities[i]);
     }
 }
コード例 #9
0
        protected override void OnUpdate()
        {
            var cameraSector = EntityManager.GetComponentData <Sector>(camera.main);

            // Remove anything outside ObjectsUnloadDistance radius
            CameraSystem.AddRemoveGrid(
                cameraSector.value,
                WorldChunkConstants.ObjectsUnloadDistance,
                ref objectsFilter.sectors,
                (int2 sector) => { },
                (int index, int2 sector) =>
            {
                PostUpdateCommands.DestroyEntity(objectsFilter.entities[index]);
            }
                );

            // Add any missing sector inside ObjectsVisibleDistance radius
            CameraSystem.AddRemoveGrid(
                cameraSector.value,
                WorldChunkConstants.ObjectsVisibleDistance,
                ref objectsFilter.sectors,
                (int2 sector) =>
            {
                PostUpdateCommands.CreateEntity(archetype);
                PostUpdateCommands.SetComponent(new Sector(sector));

                PostUpdateCommands.CreateEntity();
                PostUpdateCommands.AddComponent(new WorldSectorVegetationCreateEvent()
                {
                    sector = sector
                });
            },
                (int index, int2 sector) => { }
                );
        }
コード例 #10
0
 protected override void OnUpdate()
 {
     for (int i = 0; i < group.Length; i++)
     {
         PostUpdateCommands.DestroyEntity(group.entity[i]);
     }
 }
コード例 #11
0
    protected override void OnUpdate()
    {
        Entities.ForEach((Entity e,
                          ref PlayerComponent playerComponent,
                          ref StatsComponent statsComponent) =>
        {
            if (statsComponent.health <= 0)
            {
                Debug.Log("Player killed");
                Audio.PlayDeathSound();
                Entities.ForEach((Entity e1) =>
                {
                    PostUpdateCommands.DestroyEntity(e1);
                });

                Application.LoadLevel(3);
            }
        });
        Entities.ForEach((Entity e,
                          ref StatsComponent statsComponent) =>
        {
            if (statsComponent.health <= 0)
            {
                Debug.Log("Enemy killed");
                Audio.PlayDeathSound();
                PostUpdateCommands.DestroyEntity(e);
            }
        });
    }
コード例 #12
0
    protected override void OnUpdate()
    {
        var gameUi = SurvivalShooterBootstrap.Settings.GameUi;

        Entities.ForEach((Entity entity, ref HealthUpdatedEvent hp) =>
        {
            PostUpdateCommands.DestroyEntity(entity);

            gameUi.OnPlayerTookDamage(hp.Health);

            var health = hp.Health;
            Entities.WithAll <PlayerData>().ForEach((AudioSource audio, Animator animator) =>
            {
                if (health <= 0)
                {
                    var playerDeathClip = SurvivalShooterBootstrap.Settings.PlayerDeathClip;
                    audio.clip          = playerDeathClip;

                    animator.SetTrigger(DieHash);
                }

                audio.Play();
            });
        });
    }
コード例 #13
0
 protected override void OnUpdate()
 {
     Entities.ForEach((Entity entity, ref MuzzleFlashComponent muzzleFlash) => {
         TurretInstantiator.onShotFired(muzzleFlash.effectId, muzzleFlash.position, muzzleFlash.rotation);
         PostUpdateCommands.DestroyEntity(entity);
     });
 }
コード例 #14
0
    protected override void OnUpdate()
    {
        Entities.ForEach((Entity entity, ref Health health, ref Translation pos) =>
        {
            if (health.Value <= 0)
            {
                PostUpdateCommands.DestroyEntity(entity);

                if (EntityManager.HasComponent <Player>(entity))
                {
                    Boot.Instance.OnPlayerDeath();
                }
//                if (EntityManager.HasComponent(entity, typeof(Player)))
//                {
////                    Settings.PlayerDied();
//                }
//
//                else if (EntityManager.HasComponent(entity, typeof(Enemy)))
//                {
//                    PostUpdateCommands.DestroyEntity(entity);
////                    BulletImpactPool.PlayBulletImpact(pos.Value);
//                }
            }
        });
    }
コード例 #15
0
ファイル: Game.cs プロジェクト: Ecstasyzzz/multiplayer
    protected override void OnUpdate()
    {
        Entities.WithNone <SendRpcCommandRequestComponent>().ForEach((Entity reqEnt, ref GoInGameRequest req, ref ReceiveRpcCommandRequestComponent reqSrc) =>
        {
            PostUpdateCommands.AddComponent <NetworkStreamInGame>(reqSrc.SourceConnection);
            UnityEngine.Debug.Log(String.Format("Server setting connection {0} to in game", EntityManager.GetComponentData <NetworkIdComponent>(reqSrc.SourceConnection).Value));
#if true
            var ghostCollection = GetSingleton <GhostPrefabCollectionComponent>();
            var prefab          = Entity.Null;
            var serverPrefabs   = EntityManager.GetBuffer <GhostPrefabBuffer>(ghostCollection.serverPrefabs);
            for (int ghostId = 0; ghostId < serverPrefabs.Length; ++ghostId)
            {
                if (EntityManager.HasComponent <MovableCubeComponent>(serverPrefabs[ghostId].Value))
                {
                    prefab = serverPrefabs[ghostId].Value;
                }
            }
            var player = EntityManager.Instantiate(prefab);
            EntityManager.SetComponentData(player, new GhostOwnerComponent {
                NetworkId = EntityManager.GetComponentData <NetworkIdComponent>(reqSrc.SourceConnection).Value
            });

            PostUpdateCommands.AddBuffer <CubeInput>(player);
            PostUpdateCommands.SetComponent(reqSrc.SourceConnection, new CommandTargetComponent {
                targetEntity = player
            });
#endif


            PostUpdateCommands.DestroyEntity(reqEnt);
        });
    }
コード例 #16
0
    protected override void OnUpdate()
    {
        float dt           = Time.deltaTime;
        var   requestArray = RequestGroup.GetComponentDataArray <SkillSpawnRequest>();

        if (requestArray.Length == 0)
        {
            return;
        }

        var requestEntityArray = RequestGroup.GetEntityArray();

        // Copy requests as spawning will invalidate Group
        var requests = new SkillSpawnRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            requests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(requestEntityArray[i]);
        }

        for (var i = 0; i < requests.Length; i++)
        {
        }
    }
コード例 #17
0
    protected override void OnUpdate()
    {
        // Copy requests as spawning will invalidate Group
        var requests = new ProjectileRequest[Group.requests.Length];

        for (var i = 0; i < Group.requests.Length; i++)
        {
            requests[i] = Group.requests[i];
            PostUpdateCommands.DestroyEntity(Group.entities[i]);
        }

        // Handle requests
        foreach (var request in requests)
        {
            var projectileEntity = m_settings.projectileFactory.Create(EntityManager);

            var projectileData = EntityManager.GetComponentData <ProjectileData>(projectileEntity);

            projectileData.Initialize(request);
            projectileData.LoadSettings(m_resourceSystem);

            PostUpdateCommands.SetComponent(projectileEntity, projectileData);
            PostUpdateCommands.AddComponent(projectileEntity, new ServerEntity());
        }
    }
コード例 #18
0
    protected override void OnUpdate()
    {
        // Debug.Log("on OnUpdate role looks system");
        var requestArray = SpawnGroup.ToComponentDataArray <RoleLooksSpawnRequest>(Allocator.TempJob);

        if (requestArray.Length == 0)
        {
            requestArray.Dispose();
            return;
        }

        var requestEntityArray = SpawnGroup.ToEntityArray(Allocator.TempJob);

        // Copy requests as spawning will invalidate Group
        var spawnRequests = new RoleLooksSpawnRequest[requestArray.Length];

        for (var i = 0; i < requestArray.Length; i++)
        {
            spawnRequests[i] = requestArray[i];
            PostUpdateCommands.DestroyEntity(requestEntityArray[i]);
        }

        for (var i = 0; i < spawnRequests.Length; i++)
        {
            var request = spawnRequests[i];
            // var playerState = EntityManager.GetComponentObject<RoleState>(request.ownerEntity);
            var looksInfo = EntityManager.GetComponentData <LooksInfo>(request.ownerEntity);
            int career    = request.career;
            int body      = request.body;
            int hair      = request.hair;
            // Debug.Log("body : "+body+" hair:"+hair);
            string bodyPath = ResPath.GetRoleBodyResPath(career, body);
            string hairPath = ResPath.GetRoleHairResPath(career, hair);
            // Debug.Log("SpawnRoleLooks bodyPath : "+bodyPath);
            XLuaFramework.ResourceManager.GetInstance().LoadAsset <GameObject>(bodyPath, delegate(UnityEngine.Object[] objs) {
                if (objs != null && objs.Length > 0)
                {
                    GameObject bodyObj        = objs[0] as GameObject;
                    GameObjectEntity bodyOE   = m_world.Spawn <GameObjectEntity>(bodyObj);
                    var parentTrans           = EntityManager.GetComponentObject <Transform>(request.ownerEntity);
                    parentTrans.localPosition = request.position;
                    bodyOE.transform.SetParent(parentTrans);
                    bodyOE.transform.localPosition = Vector3.zero;
                    bodyOE.transform.localRotation = Quaternion.identity;
                    LoadHair(hairPath, bodyOE.transform.Find("head"));
                    // Debug.Log("load ok role model");
                    looksInfo.CurState    = LooksInfo.State.Loaded;
                    looksInfo.LooksEntity = bodyOE.Entity;
                    EntityManager.SetComponentData <LooksInfo>(request.ownerEntity, looksInfo);
                }
                else
                {
                    Debug.LogError("cannot fine file " + bodyPath);
                }
            });
        }
        requestEntityArray.Dispose();
        requestArray.Dispose();
    }
コード例 #19
0
        protected override void OnUpdate()
        {
            Entities.ForEach((Entity entity, ref WaveComponent wave) =>
            {
                if (!CurWave(wave))
                {
                    return;
                }
                if (Control == null)
                {
                    Control = SpawnController.Instance;
                }
                if (Control.MaxCountInScene != wave.MaxEnemyAtOnce)
                {
                    Control.MaxCountInScene = wave.MaxEnemyAtOnce;
                }

                if (!wave.AllEnemiesDispatched)
                {
                    DynamicBuffer <WaveBufferComponent> WaveBuffer = EntityManager.GetBuffer <WaveBufferComponent>(entity);
                    foreach (WaveBufferComponent waveEnemy in WaveBuffer)
                    {
                        int count = waveEnemy.EnemySpecForWave.SpawnCount;
                        while (count != 0)
                        {
                            NativeArray <int> dispatched = new NativeArray <int>(1, Allocator.TempJob);


                            var testing = new DispatchSpawnsToSpawnPointsEnemy()
                            {
                                SpawnCount       = count,
                                SpawnID          = waveEnemy.EnemySpecForWave.spawnID,
                                count            = dispatched,
                                chunkEnemyBuffer = GetArchetypeChunkBufferType <EnemySpawnData>(),
                                C1 = GetArchetypeChunkComponentType <EnemySpawnTag>()
                            };

                            JobHandle handle = testing.Schedule(m_Group);
                            handle.Complete();

                            count -= testing.count[0];
                            wave.EnemiesDispatched += dispatched[0];
                            dispatched.Dispose();
                        }
                    }
                    wave.AllEnemiesDispatched = true;
                }
                WaveComponent currentwave = wave;
                Entities.ForEach((ref Destroytag tag, ref EnemyTag Enemy) => {
                    currentwave.EnemiesDefeated++;
                });
                wave = currentwave;
                if (WaveDefeat(wave))
                {
                    PostUpdateCommands.DestroyEntity(entity);
                    wavecnt++;
                }
            });
        }
コード例 #20
0
 void MakeOneMatch(NativeArray <CellInfo> cells, int startIndex, int end)
 {
     while (startIndex < end)
     {
         m_MatchCount++;
         PostUpdateCommands.DestroyEntity(cells[startIndex++].Entity);
     }
 }
コード例 #21
0
 protected override void OnUpdate()
 {
     Entities.WithAll <CoinTag, CollectedTag>().ForEach((Entity entity) =>
     {
         PostUpdateCommands.DestroyEntity(entity);
         PlayerSettings.IncreaseCoin();
     });
 }
コード例 #22
0
 protected override void OnUpdate()
 {
     for (int i = 0; i < group.Length; i++)
     {
         AttackRangeManager.GetInstance().DestroyAttackRange();
         PostUpdateCommands.DestroyEntity(group.entity[i]);
     }
 }
コード例 #23
0
 void RemoveComponentOnDestroyEntity <T>(Entity entity) where T : struct, IComponentData
 {
     if (EntityManager.HasComponent <NetworkComponentState <T> >(entity))
     {
         PostUpdateCommands.RemoveComponent <NetworkComponentState <T> >(entity);
         PostUpdateCommands.DestroyEntity(EntityManager.GetComponentData <NetworkComponentState <T> >(entity).dataEntity);
     }
 }
コード例 #24
0
 protected override void OnUpdate()
 {
     for (int i = 0; i < m_Data.Length; i++)
     {
         PostUpdateCommands.DestroyEntity(m_Data.Entities[i]);
         PostUpdateCommands.DestroyEntity(m_Data.Destroy[i].Entity);
     }
 }
コード例 #25
0
 protected override void OnUpdate()
 {
     Entities.WithAll <BallStateUpdateComp>().ForEach((Entity entity, ref BallStateUpdateComp ballStateUpdateComp) =>
     {
         UpdateBall(ballStateUpdateComp);
         PostUpdateCommands.DestroyEntity(entity);
     });
 }
コード例 #26
0
 protected override void OnUpdate()
 {
     Entities.ForEach((Entity entity, ref SimpleRpcCommand cmd, ref ReceiveRpcCommandRequestComponent req) =>
     {
         PostUpdateCommands.DestroyEntity(entity);
         ++ReceivedCount;
     });
 }
コード例 #27
0
 protected override void OnUpdate()
 {
     Entities.ForEach((Entity entity, ref PlayerStateUpdateComp playerStateUpdateComp) =>
     {
         UpdatePlayers(playerStateUpdateComp);
         PostUpdateCommands.DestroyEntity(entity);
     });
 }
コード例 #28
0
 protected override void OnUpdate()
 {
     Entities.ForEach((
                          Entity event_entity,
                          ref GameEvent ev) => {
         PostUpdateCommands.DestroyEntity(event_entity);
     });
 }
コード例 #29
0
ファイル: LoopSystem.cs プロジェクト: hasarden/pgd-jam
        protected override void OnUpdate()
        {
            var restart = GetSingleton <RestartEventComponent>();

            if (!restart.Triggered)
            {
                return;
            }

            var offset = GetSingleton <EnvironmentOffsetComponent>();

            offset.Offset           = 0;
            offset.AdditionalOffset = 0.0f;
            SetSingleton(offset);

            var loading = GetSingleton <LoadingStateComponent>();

            loading.Duration = 0.0f;
            SetSingleton(loading);

            var obstacles = GetSingleton <ObstacleSpawnState>();

            obstacles.LastObstacleOffset = 0;
            SetSingleton(obstacles);

            var difficulty = GetSingleton <DifficultyStateComponent>();

            difficulty.Reset = true;
            SetSingleton(difficulty);

            Entities
            .WithAll <EnvironmentBlockComponent>()
            .ForEach(entity => PostUpdateCommands.DestroyEntity(entity));

            Entities
            .WithAll <ObstacleComponent>()
            .ForEach(entity => PostUpdateCommands.DestroyEntity(entity));

            Entities
            .ForEach((Entity entity, ref JumpStateComponent jumpState) =>
            {
                PostUpdateCommands.RemoveComponent(entity, ComponentType.ReadWrite <JumpStateComponent>());
            });

            Entities.ForEach((ref PlayerOrientationComponent orientation) => { orientation.Grounded = true; });

            Entities
            .WithAll <TagPlayer>()
            .ForEach((ref Translation translation, ref Rotation rotation, ref NonUniformScale scale) =>
            {
                translation.Value = float3.zero;
                rotation.Value    = quaternion.identity;
                scale.Value       = new float3(1.0f, 1.0f, 1.0f);
            });

            restart.Triggered = false;
            SetSingleton(restart);
        }
コード例 #30
0
ファイル: Game.cs プロジェクト: WuYPing/NetCode-FPS
        protected override void OnUpdate()
        {
            Entities.WithNone <SendRpcCommandRequestComponent>().ForEach((Entity reqEnt, ref GoInGameRequest req,
                                                                          ref ReceiveRpcCommandRequestComponent reqSrc) =>
            {
                Debug.Log($"[{nameof(EnableNetFPS)}] RPC->GoInGame:" + req.value);
                PostUpdateCommands.DestroyEntity(reqEnt);

                PostUpdateCommands.AddComponent <NetworkStreamInGame>(reqSrc.SourceConnection);

                var collection = GetSingleton <GhostPrefabCollectionComponent>();
                var buffer     = EntityManager.GetBuffer <GhostPrefabBuffer>(collection.ServerPrefabs);

                if (!buffer.FindOwner(out GhostPrefabBuffer ownerGhostPrefab))
                {
                    Debug.LogError($"无法找到Owner预制体!!!");
                    return;
                }

                if (!initScene)
                {
                    Entity ball = Entity.Null;
                    for (int i = 0; i < buffer.Length; i++)
                    {
                        if (EntityManager.HasComponent <SphereTagComponent>(buffer[i].Value))
                        {
                            ball = buffer[i].Value;
                        }
                    }

                    Entity d1 = Entity.Null;
                    for (int i = 0; i < buffer.Length; i++)
                    {
                        if (EntityManager.HasComponent <D1Tag>(buffer[i].Value))
                        {
                            d1 = buffer[i].Value;
                        }
                    }

                    EntityManager.Instantiate(ball);
                    EntityManager.Instantiate(d1);
                    initScene = true;
                }

                Entity entity = EntityManager.Instantiate(ownerGhostPrefab.Value);

                // 组件
                var networkId = EntityManager.GetComponentData <NetworkIdComponent>(reqSrc.SourceConnection).Value;
                EntityManager.AddBuffer <InputCommand>(entity);
                EntityManager.AddComponent <PlayerControlledState>(entity);
                EntityManager.AddComponentData(entity, new GhostOwnerComponent {
                    Value = networkId
                });
                EntityManager.AddComponentData(reqSrc.SourceConnection, new CommandTargetComponent {
                    Target = entity
                });
            });
        }