private void ConvertLightmap(Stream cacheStream, Dictionary <ResourceLocation, Stream> resourceStreams, IndexItem blamLightmapTag, int zoneSetIndex, BspFlags bspMask) { var blamCache = BlamCache; var blamLightmap = BlamCache.Deserializer.Deserialize <ScenarioLightmap>( new CacheSerializationContext(ref blamCache, blamLightmapTag)); if (blamCache.Version < CacheVersion.Halo3ODST) { var lightmapTag = CacheContext.AllocateTag <ScenarioLightmap>(blamLightmapTag.Name); var lightmap = blamLightmap; for (int i = 0, j = 0; i < blamLightmap.Lightmaps.Count; i++) { if (((BspFlags)(1u << i) & bspMask) == 0) { continue; } var blamLbsp = blamLightmap.Lightmaps[i]; var Lbsp = (ScenarioLightmapBspData)PortTag.ConvertData(cacheStream, resourceStreams, blamLbsp, blamLbsp, blamLightmapTag.Name); Lbsp.Airprobes = new List <ScenarioLightmap.Airprobe>(); Lbsp.Airprobes.AddRange(blamLightmap.Airprobes); Lbsp.BspIndex = (short)j++; var LbspTag = CacheContext.AllocateTag <ScenarioLightmapBspData>($"{blamLightmapTag.Name}_{i}_data"); CacheContext.Serialize(cacheStream, LbspTag, Lbsp); lightmap.LightmapDataReferences.Add(new ScenarioLightmap.LightmapDataReference() { LightmapData = LbspTag }); } lightmap.Airprobes.Clear(); CacheContext.Serialize(cacheStream, lightmapTag, lightmap); } else { var lightmapTag = CacheContext.AllocateTag <ScenarioLightmap>(blamLightmapTag.Name); var lightmap = blamLightmap; var newDataReferences = new List <ScenarioLightmap.LightmapDataReference>(); for (int i = 0, j = 0; i < blamLightmap.LightmapDataReferences.Count; i++) { if (((BspFlags)(1u << i) & bspMask) == 0) { continue; } var blamLbspTag = blamCache.GetIndexItemFromID(blamLightmap.LightmapDataReferences[i].LightmapData.Index); var blamLbsp = blamCache.Deserializer.Deserialize <ScenarioLightmapBspData>( new CacheSerializationContext(ref blamCache, blamLbspTag)); var Lbsp = (ScenarioLightmapBspData)PortTag.ConvertData(cacheStream, resourceStreams, blamLbsp, blamLbsp, blamLbspTag.Name); Lbsp.BspIndex = (short)j++; var LbspTag = CacheContext.AllocateTag <ScenarioLightmapBspData>(blamLbspTag.Name); CacheContext.Serialize(cacheStream, LbspTag, Lbsp); newDataReferences.Add(new ScenarioLightmap.LightmapDataReference() { LightmapData = LbspTag }); } lightmap.LightmapDataReferences = newDataReferences; CacheContext.Serialize(cacheStream, lightmapTag, lightmap); } }