public override void ApplyToItem(ItemStats stats) { base.ApplyToItem(stats); var wStats = stats as WeaponStats; if (this.AttackSpeed != null) { wStats.AttackSpeed = (float)this.AttackSpeed; } if (this.Impact != null) { wStats.Impact = (float)this.Impact; } if (this.BaseDamage != null) { wStats.BaseDamage = SL_Damage.GetDamageList(this.BaseDamage); // fix for m_activeBaseDamage var weapon = wStats.GetComponent <Weapon>(); At.SetField(weapon, "m_activeBaseDamage", wStats.BaseDamage.Clone()); At.SetField(weapon, "m_baseDamage", wStats.BaseDamage.Clone()); } if (this.StamCost != null) { wStats.StamCost = (float)this.StamCost; } if (AutoGenerateAttackData || this.Attacks == null || this.Attacks.Length < 1) { // SL.Log("Generating AttackData automatically"); wStats.Attacks = GetScaledAttackData(wStats.GetComponent <Weapon>()); } else { wStats.Attacks = Attacks; } }
public override void ApplyToComponent <T>(T component) { var types = SL_Damage.GetDamageList(this.RequiredDamages); (component as DealtDamageCondition).DealtDamages = types.List.ToArray(); }
internal void Internal_ApplyTemplate() { SL.Log($"Applying Enchantment Recipe, ID: {this.EnchantmentID}, Name: {this.Name}"); var recipe = ScriptableObject.CreateInstance <EnchantmentRecipe>(); recipe.RecipeID = this.EnchantmentID; recipe.ResultID = this.EnchantmentID; if (ResourcesPrefabManager.Instance.GetItemPrefab(this.IncenseItemID) is Item incense) { var list = new List <EnchantmentRecipe.PillarData>(); foreach (var pillar in this.PillarDatas) { list.Add(new EnchantmentRecipe.PillarData { Direction = (UICardinalPoint_v2.CardinalPoint)pillar.Direction, IsFar = pillar.IsFar, CompatibleIngredients = new EnchantmentRecipe.IngredientData[] { new EnchantmentRecipe.IngredientData { Type = EnchantmentRecipe.IngredientData.IngredientType.Specific, SpecificIngredient = incense } } }); } recipe.PillarDatas = list.ToArray(); } recipe.CompatibleEquipments = new EnchantmentRecipe.EquipmentData { EquipmentTag = new TagSourceSelector(CustomTags.GetTag(this.CompatibleEquipment.RequiredTag)), }; if (this.CompatibleEquipment.Equipments != null) { var equipList = new List <EnchantmentRecipe.IngredientData>(); foreach (var ingData in this.CompatibleEquipment.Equipments) { var data = new EnchantmentRecipe.IngredientData(); if (ingData.SelectorType == IngredientTypes.Tag) { data.Type = EnchantmentRecipe.IngredientData.IngredientType.Generic; data.IngredientTag = new TagSourceSelector(CustomTags.GetTag(ingData.SelectorValue)); } else if (ingData.SelectorType == IngredientTypes.SpecificItem) { data.Type = EnchantmentRecipe.IngredientData.IngredientType.Specific; data.SpecificIngredient = ResourcesPrefabManager.Instance.GetItemPrefab(ingData.SelectorValue); } equipList.Add(data); } recipe.CompatibleEquipments.CompatibleEquipments = equipList.ToArray(); } else { recipe.CompatibleEquipments.CompatibleEquipments = new EnchantmentRecipe.IngredientData[0]; } recipe.TimeOfDay = this.TimeOfDay ?? new Vector2[0]; recipe.Region = this.Areas ?? new AreaManager.AreaEnum[0]; recipe.Temperature = this.Temperature ?? new TemperatureSteps[0]; recipe.WindAltarActivated = this.WindAltarActivated; if (!string.IsNullOrEmpty(this.QuestEventUID)) { recipe.QuestEvent = new QuestEventReference() { m_eventUID = QuestEventUID, UID = QuestEventUID }; } if (this.WeatherConditions != null) { var list = new List <EnchantmentRecipe.WeaterCondition>(); foreach (var condition in this.WeatherConditions) { list.Add(new EnchantmentRecipe.WeaterCondition { Invert = condition.Invert, Weather = (EnchantmentRecipe.WeaterType)condition.WeatherType }); } recipe.Weather = list.ToArray(); } else { recipe.Weather = new EnchantmentRecipe.WeaterCondition[0]; } recipe.TableIsInBuilding = this.IsEnchantingGuildRecipe; // ========== Create actual Enchantment effects prefab ========== var enchantmentObject = new GameObject(this.EnchantmentID + "_" + this.Name); GameObject.DontDestroyOnLoad(enchantmentObject); var enchantment = enchantmentObject.AddComponent <Enchantment>(); At.SetField <EffectPreset>(enchantment, "m_StatusEffectID", this.EnchantmentID); SetLocalization(this, out enchantment.CustomDescLocKey); enchantment.EnchantTime = this.EnchantTime; if (this.Effects != null) { SL_EffectTransform.ApplyTransformList(enchantment.transform, this.Effects?.ToArray(), EditBehaviours.Override); } if (this.AddedDamages != null) { var list = new List <Enchantment.AdditionalDamage>(); foreach (var dmg in this.AddedDamages) { list.Add(new Enchantment.AdditionalDamage { BonusDamageType = dmg.AddedDamageType, ConversionRatio = dmg.ConversionRatio, SourceDamageType = dmg.SourceDamageType }); } enchantment.AdditionalDamages = list.ToArray(); } if (this.StatModifications != null) { var list = new Enchantment.StatModificationList(); foreach (var mod in this.StatModifications) { list.Add(new Enchantment.StatModification { Name = mod.Stat, Type = mod.Type, Value = mod.Value }); } enchantment.StatModifications = list; } if (this.FlatDamageAdded != null) { enchantment.DamageBonus = SL_Damage.GetDamageList(this.FlatDamageAdded); } if (this.DamageModifierBonus != null) { enchantment.DamageModifier = SL_Damage.GetDamageList(this.DamageModifierBonus); } if (this.DamageResistanceBonus != null) { enchantment.ElementalResistances = SL_Damage.GetDamageList(this.DamageResistanceBonus); } enchantment.HealthAbsorbRatio = this.HealthAbsorbRatio; enchantment.StaminaAbsorbRatio = this.StaminaAbsorbRatio; enchantment.ManaAbsorbRatio = this.ManaAbsorbRatio; enchantment.Indestructible = this.Indestructible; enchantment.TrackDamageRatio = this.TrackDamageRatio; enchantment.GlobalStatusResistance = this.GlobalStatusResistance; // =========== SET DICTIONARY REFS ============ // Recipe dict if (References.ENCHANTMENT_RECIPES.ContainsKey(this.EnchantmentID)) { References.ENCHANTMENT_RECIPES[this.EnchantmentID] = recipe; } else { References.ENCHANTMENT_RECIPES.Add(this.EnchantmentID, recipe); } // Enchantment dict if (References.ENCHANTMENT_PREFABS.ContainsKey(this.EnchantmentID)) { References.ENCHANTMENT_PREFABS[this.EnchantmentID] = enchantment; } else { References.ENCHANTMENT_PREFABS.Add(this.EnchantmentID, enchantment); } }