コード例 #1
0
        public void Serialize(EnchantmentRecipe recipe, Enchantment enchantment)
        {
            Name     = enchantment.Name;
            RecipeID = recipe.RecipeID;

            TimeOfDay          = recipe.TimeOfDay;
            Temperatures       = recipe.Temperature;
            WindAltarActivated = recipe.WindAltarActivated;
            Regions            = recipe.Region;

            if (recipe.QuestEvent?.Event != null)
            {
                var qEvt = recipe.QuestEvent.Event;
                QuestEvent = qEvt.EventName + " (" + qEvt.Description + ")";
            }

            CompatibleEquipment = new EquipmentData();

            if (recipe.CompatibleEquipments.EquipmentTag != null && recipe.CompatibleEquipments.EquipmentTag.Tag != Tag.None)
            {
                CompatibleEquipment.EquipmentTag = recipe.CompatibleEquipments.EquipmentTag.Tag.TagName;
            }

            if (recipe.CompatibleEquipments.CompatibleEquipments != null)
            {
                var list = new List <IngredientData>();
                foreach (var equip in recipe.CompatibleEquipments.CompatibleEquipments)
                {
                    var data = new IngredientData
                    {
                        Type = equip.Type
                    };
                    if (equip.Type == EnchantmentRecipe.IngredientData.IngredientType.Generic)
                    {
                        data.IngredientTag = equip.IngredientTag.Tag.TagName;
                    }
                    else
                    {
                        data.SpecificItemID = equip.SpecificIngredient.ItemID;
                    }
                    list.Add(data);
                }
                CompatibleEquipment.CompatibleEquipments = list.ToArray();
            }

            if (recipe.PillarDatas != null)
            {
                var list = new List <PillarData>();

                foreach (var pillarData in recipe.PillarDatas)
                {
                    var pillar = new PillarData
                    {
                        Direction = pillarData.Direction,
                        IsFar     = pillarData.IsFar,
                    };
                    var ingList = new List <IngredientData>();
                    foreach (var ingredient in pillarData.CompatibleIngredients)
                    {
                        var ing = new IngredientData
                        {
                            Type = ingredient.Type,
                        };

                        if (ingredient.Type == EnchantmentRecipe.IngredientData.IngredientType.Generic)
                        {
                            ing.IngredientTag = ingredient.IngredientTag.Tag.TagName;
                        }
                        else
                        {
                            ing.SpecificItemID = ingredient.SpecificIngredient.ItemID;
                        }

                        ingList.Add(ing);
                    }
                    pillar.CompatibleIngredients = ingList.ToArray();

                    list.Add(pillar);
                }

                PillarDatas = list.ToArray();
            }

            if (recipe.Weather != null)
            {
                var weatherList = new List <WeatherCondition>();
                foreach (var weather in recipe.Weather)
                {
                    weatherList.Add(new WeatherCondition
                    {
                        Invert      = weather.Invert,
                        WeatherType = weather.Weather
                    });
                }
                Weather = weatherList.ToArray();
            }

            Result = DM_Enchantment.ParseEnchantment(enchantment);
        }
コード例 #2
0
        public static DM_Enchantment ParseEnchantment(Enchantment enchantment)
        {
            var template = new DM_Enchantment
            {
                Name        = enchantment.Name,
                Description = enchantment.Description,

                HealthAbsorbRatio  = enchantment.HealthAbsorbRatio,
                ManaAbsorbRatio    = enchantment.ManaAbsorbRatio,
                StaminaAbsorbRatio = enchantment.StaminaAbsorbRatio,

                GlobalStatusResistance = enchantment.GlobalStatusResistance,

                Indescructible   = enchantment.Indestructible,
                TrackDamageRatio = enchantment.TrackDamageRatio,
            };

            if (enchantment.Effects != null)
            {
                template.Effects = new List <DM_Effect>();
                foreach (var effect in enchantment.Effects)
                {
                    var effectTemplate = DM_Effect.ParseEffect(effect);

                    if (effectTemplate != null)
                    {
                        template.Effects.Add(effectTemplate);
                    }
                }
            }

            if (enchantment.AdditionalDamages != null)
            {
                template.AdditionalDamages = new List <AdditionalDamage>();
                foreach (var addDmg in enchantment.AdditionalDamages)
                {
                    template.AdditionalDamages.Add(new AdditionalDamage
                    {
                        BonusDamageType  = addDmg.BonusDamageType,
                        ConversionRatio  = addDmg.ConversionRatio,
                        SourceDamageType = addDmg.SourceDamageType
                    });
                }
            }

            if (enchantment.StatModifications != null)
            {
                template.StatModifications = new List <StatModification>();
                foreach (var statMod in enchantment.StatModifications)
                {
                    template.StatModifications.Add(new StatModification
                    {
                        Name  = statMod.Name,
                        Type  = statMod.Type,
                        Value = statMod.Value
                    });
                }
            }

            if (enchantment.DamageBonus != null)
            {
                template.DamageBonus = new List <Damages>();
                foreach (var dmgBonus in enchantment.DamageBonus.List)
                {
                    var dmg = Damages.ParseDamageType(dmgBonus);
                    template.DamageBonus.Add(dmg);
                }
            }

            if (enchantment.DamageModifier != null)
            {
                template.DamageModifier = new List <Damages>();
                foreach (var dmgBonus in enchantment.DamageModifier.List)
                {
                    var dmg = Damages.ParseDamageType(dmgBonus);
                    template.DamageModifier.Add(dmg);
                }
            }

            if (enchantment.ElementalResistances != null)
            {
                template.ElementalResistances = new List <Damages>();
                foreach (var dmgBonus in enchantment.ElementalResistances.List)
                {
                    var dmg = Damages.ParseDamageType(dmgBonus);
                    template.ElementalResistances.Add(dmg);
                }
            }

            return(template);
        }