Пример #1
0
        private void MergeCharacter(Stream cacheStream, Dictionary <ResourceLocation, Stream> resourceStreams, CachedTagInstance edTag, CacheFile.IndexItem h3Tag)
        {
            var edDef = CacheContext.Deserialize <Character>(cacheStream, edTag);

            var h3Def = BlamCache.Deserializer.Deserialize <Character>(
                new CacheSerializationContext(ref BlamCache, h3Tag));

            var merged = false;

            if (edDef.WeaponsProperties.Count == h3Def.WeaponsProperties.Count)
            {
                for (var i = 0; i < edDef.WeaponsProperties.Count; i++)
                {
                    if (edDef.WeaponsProperties[i].Weapon != null || h3Def.WeaponsProperties[i].Weapon == null)
                    {
                        continue;
                    }

                    edDef.WeaponsProperties[i].Weapon = ConvertTag(cacheStream, resourceStreams,
                                                                   BlamCache.GetIndexItemFromID(h3Def.WeaponsProperties[i].Weapon.Index));

                    merged = true;
                }
            }

            if (edDef.VehicleProperties.Count == h3Def.VehicleProperties.Count)
            {
                for (var i = 0; i < edDef.VehicleProperties.Count; i++)
                {
                    if (edDef.VehicleProperties[i].Unit != null || h3Def.VehicleProperties[i].Unit == null)
                    {
                        continue;
                    }

                    edDef.VehicleProperties[i].Unit = ConvertTag(cacheStream, resourceStreams,
                                                                 BlamCache.GetIndexItemFromID(h3Def.VehicleProperties[i].Unit.Index));

                    merged = true;
                }
            }

            if (edDef.EquipmentProperties.Count == h3Def.EquipmentProperties.Count)
            {
                for (var i = 0; i < edDef.EquipmentProperties.Count; i++)
                {
                    if (edDef.EquipmentProperties[i].Equipment != null || h3Def.EquipmentProperties[i].Equipment == null)
                    {
                        continue;
                    }

                    edDef.EquipmentProperties[i].Equipment = ConvertTag(cacheStream, resourceStreams,
                                                                        BlamCache.GetIndexItemFromID(h3Def.EquipmentProperties[i].Equipment.Index));

                    merged = true;
                }
            }

            if (merged)
            {
                CacheContext.Serialize(cacheStream, edTag, edDef);
            }
        }
Пример #2
0
        private void MergeMultiplayerEvent(Stream cacheStream, Dictionary <ResourceLocation, Stream> resourceStreams, MultiplayerGlobals.RuntimeBlock.EventBlock edEvent, MultiplayerGlobals.RuntimeBlock.EventBlock h3Event)
        {
            if (h3Event.EnglishSound != null)
            {
                edEvent.EnglishSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.EnglishSound.Index));
            }

            if (h3Event.JapaneseSound != null)
            {
                edEvent.JapaneseSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.JapaneseSound.Index));
            }

            if (h3Event.GermanSound != null)
            {
                edEvent.GermanSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.GermanSound.Index));
            }

            if (h3Event.FrenchSound != null)
            {
                edEvent.FrenchSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.FrenchSound.Index));
            }

            if (h3Event.SpanishSound != null)
            {
                edEvent.SpanishSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.SpanishSound.Index));
            }

            if (h3Event.LatinAmericanSpanishSound != null)
            {
                edEvent.LatinAmericanSpanishSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.LatinAmericanSpanishSound.Index));
            }

            if (h3Event.ItalianSound != null)
            {
                edEvent.ItalianSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.ItalianSound.Index));
            }

            if (h3Event.KoreanSound != null)
            {
                edEvent.KoreanSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.KoreanSound.Index));
            }

            if (h3Event.ChineseTraditionalSound != null)
            {
                edEvent.ChineseTraditionalSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.ChineseTraditionalSound.Index));
            }

            if (h3Event.ChineseSimplifiedSound != null)
            {
                edEvent.ChineseSimplifiedSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.ChineseSimplifiedSound.Index));
            }

            if (h3Event.PortugueseSound != null)
            {
                edEvent.PortugueseSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.PortugueseSound.Index));
            }

            if (h3Event.PolishSound != null)
            {
                edEvent.PolishSound = ConvertTag(cacheStream, resourceStreams, BlamCache.GetIndexItemFromID(h3Event.PolishSound.Index));
            }
        }