void SetChannelTextureIndices(int[] block2TextureSet, TextureBundle[] bundles, Func <TextureBundle, TextureSet> getTexSet, Action <int[]> setTextureSet2ArrayIndex) { var indices = new List <TextureSet>(); foreach (var i in block2TextureSet) { while (i >= indices.Count) { indices.Add(default(TextureSet)); } indices[i] = getTexSet(bundles[i]); } setTextureSet2ArrayIndex(TextureSet.ToIntArray(indices)); }