public void Run() { for (int i = 0; i < _players.EntitiesCount; i++) { var playerPosition = _players.Components1[i].Position; var item = _items.GetSecondComponent(x => x.Position == playerPosition); if (item == null) { continue; } item.GameObject.SetActive(false); int playerEntity = _players.Entities[i]; switch (item.ItemType) { case ItemTypes.Food: CreateFoodComponent(playerEntity); break; case ItemTypes.Energizer: CreateEnergizerComponent(playerEntity); break; default: throw new ArgumentOutOfRangeException(); } item.GameObject = null; _ecsWorld.RemoveEntity(item.ItemEntity); } }