private void SpawnWave()
 {
     Entities.ForEach((Entity SPEntity, ref EnemySpawnTag Tag, ref LocalToWorld transform) =>
     {
         DynamicBuffer <EnemySpawnData> Buffer = EntityManager.GetBuffer <EnemySpawnData>(SPEntity);
         for (int cnt = 0; cnt < Buffer.Length; cnt++)
         {
             if (!SpawnControl.CanSpawn)
             {
                 return;
             }
             if (Buffer[cnt].spawnData.Spawn)
             {
                 Object.Instantiate(EnemyDatabase.GetEnemy(Buffer[cnt].spawnData.SpawnID).GO, transform.Position, transform.Rotation);
                 EnemySpawnData tempData = Buffer[cnt];
                 tempData.spawnData.SpawnCount--;
                 if (tempData.spawnData.SpawnCount == 0)
                 {
                     tempData.spawnData.Spawn = false;
                 }
                 Buffer[cnt] = tempData;
                 SpawnControl.CountinScene++;
             }
         }
     });
 }
        public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
        {
            var EnemyBuffer2 = chunk.GetBufferAccessor(chunkEnemyBuffer);

            for (int cnt = 0; cnt < EnemyBuffer2.Length; cnt++)
            {
                DynamicBuffer <EnemySpawnData> EnemyBuffer = EnemyBuffer2[cnt];
                for (int i = 0; i < EnemyBuffer.Length; i++)
                {
                    if (count[0] >= SpawnCount)
                    {
                        return;
                    }
                    if (EnemyBuffer[i].spawnData.SpawnID == SpawnID)
                    {
                        EnemySpawnData temp = EnemyBuffer[i];
                        temp.spawnData.SpawnCount++;
                        temp.spawnData.Spawn = true;
                        EnemyBuffer[i]       = temp;
                        count[0]++;
                    }
                }
            }
        }