public static void SetLocalization(SL_EnchantmentRecipe recipe, out string descKey) { var dict = References.GENERAL_LOCALIZATION; var nameKey = $"Enchantment_{recipe.EnchantmentID}"; descKey = $"DESC_{nameKey}"; if (dict.ContainsKey(nameKey)) { dict[nameKey] = recipe.Name; } else { dict.Add(nameKey, recipe.Name); } if (dict.ContainsKey(descKey)) { dict[descKey] = recipe.Description; } else { dict.Add(descKey, recipe.Description); } }
// ======== Serializing Enchantment into a Template ========= public static SL_EnchantmentRecipe SerializeEnchantment(EnchantmentRecipe recipe) { var enchantment = ResourcesPrefabManager.Instance.GetEnchantmentPrefab(recipe.ResultID); var template = new SL_EnchantmentRecipe { Name = enchantment.Name, Description = enchantment.Description, EnchantmentID = recipe.RecipeID, IncenseItemID = recipe.PillarDatas?[0]?.CompatibleIngredients?[0].SpecificIngredient?.ItemID ?? -1, TimeOfDay = recipe.TimeOfDay, Areas = recipe.Region, Temperature = recipe.Temperature, WindAltarActivated = recipe.WindAltarActivated, IsEnchantingGuildRecipe = recipe.TableIsInBuilding, EnchantTime = enchantment.EnchantTime, HealthAbsorbRatio = enchantment.HealthAbsorbRatio, StaminaAbsorbRatio = enchantment.StaminaAbsorbRatio, ManaAbsorbRatio = enchantment.ManaAbsorbRatio, Indestructible = enchantment.Indestructible, TrackDamageRatio = enchantment.TrackDamageRatio }; if (recipe.PillarDatas != null) { var pillarList = new List <PillarData>(); foreach (var pillarData in recipe.PillarDatas) { var data = new PillarData { Direction = (Directions)pillarData.Direction, IsFar = pillarData.IsFar, }; pillarList.Add(data); } template.PillarDatas = pillarList.ToArray(); } var compatibleEquipment = new EquipmentData { RequiredTag = recipe.CompatibleEquipments.EquipmentTag.Tag.TagName }; if (recipe.CompatibleEquipments.CompatibleEquipments != null) { var equipList = new List <IngredientData>(); foreach (var equipData in recipe.CompatibleEquipments.CompatibleEquipments) { var data = new IngredientData { SelectorType = (IngredientTypes)equipData.Type }; if (data.SelectorType == IngredientTypes.SpecificItem) { data.SelectorValue = equipData.SpecificIngredient?.ItemID.ToString(); } else { data.SelectorValue = equipData.IngredientTag.Tag.TagName; } equipList.Add(data); } compatibleEquipment.Equipments = equipList.ToArray(); } template.CompatibleEquipment = compatibleEquipment; // Parse the actual Enchantment effects if (enchantment.transform.childCount > 0) { var effects = new List <SL_EffectTransform>(); foreach (Transform child in enchantment.transform) { var effectsChild = SL_EffectTransform.ParseTransform(child); if (effectsChild.HasContent) { effects.Add(effectsChild); } } template.Effects = effects.ToArray(); } if (enchantment.AdditionalDamages != null) { var list = new List <AdditionalDamage>(); foreach (var addedDmg in enchantment.AdditionalDamages) { list.Add(new AdditionalDamage { AddedDamageType = addedDmg.BonusDamageType, ConversionRatio = addedDmg.ConversionRatio, SourceDamageType = addedDmg.SourceDamageType }); } template.AddedDamages = list.ToArray(); } if (enchantment.StatModifications != null) { var list = new List <StatModification>(); foreach (var statMod in enchantment.StatModifications) { list.Add(new StatModification { Stat = statMod.Name, Type = statMod.Type, Value = statMod.Value }); } template.StatModifications = list.ToArray(); } if (enchantment.DamageBonus != null) { template.FlatDamageAdded = SL_Damage.ParseDamageList(enchantment.DamageBonus).ToArray(); } if (enchantment.DamageModifier != null) { template.DamageModifierBonus = SL_Damage.ParseDamageList(enchantment.DamageModifier).ToArray(); } if (enchantment.ElementalResistances != null) { template.DamageResistanceBonus = SL_Damage.ParseDamageList(enchantment.ElementalResistances).ToArray(); } template.GlobalStatusResistance = enchantment.GlobalStatusResistance; return(template); }