static void CreateMetamagicRods(BlueprintFeature feature, ModMetamagic modMetamagic, String friendlyName, BlueprintComponent logic) { // Create a metamagic rod by cloning an existing one. var rodIds = existingRodIds[Metamagic.Empower]; var rodCosts = metamagicRodCosts[modMetamagic.OriginalCost() - 1]; var library = Main.library; var names = new string[] { "Lesser", "Normal", "Greater" }; var displayPrefix = new string[] { "Lesser ", "", "Greater " }; var maxLevel = new string[] { "3rd", "6th", "9th " }; for (int i = 0; i < 3; i++) { var displayName = displayPrefix[i] + friendlyName.Replace(" Spell", " Metamagic Rod"); var description = $"The wielder can cast up to three spells per day that are affected as though the spells were augmented with the {friendlyName} feat.\n" + $"{displayPrefix[i]} rods can be used with spells of {maxLevel[i]} level or lower.\n" + $"{friendlyName}: {feature.Description}"; // We need to clone 3 things: // - the item // - the activatable ability // - the buff var existingRod = library.Get <BlueprintItemEquipmentUsable>(rodIds[i]); var existingAbility = existingRod.ActivatableAbility; var existingBuff = existingAbility.Buff; var newRod = library.CopyAndAdd(existingRod, $"MetamagicRod{names[i]}{modMetamagic}", feature.AssetGuid, existingRod.AssetGuid); var newAbility = library.CopyAndAdd(existingAbility, $"{newRod.name}ToggleAbility", feature.AssetGuid, existingAbility.AssetGuid); var newBuff = library.CopyAndAdd(existingBuff, $"{newRod.name}Buff", feature.AssetGuid, existingBuff.AssetGuid); newRod.ActivatableAbility = newAbility; newAbility.Buff = newBuff; if (logic != null) { newAbility.AddComponent(logic); } Helpers.SetField(newRod, "m_Cost", rodCosts[i]); Helpers.SetField(newRod, "m_DisplayNameText", Helpers.CreateString(newRod.name + ".Name", displayName)); Helpers.SetField(newRod, "m_DescriptionText", Helpers.CreateString(newRod.name + ".Description", description)); newAbility.SetNameDescriptionIcon(displayName, description, newAbility.Icon); newBuff.SetNameDescriptionIcon(displayName, description, newBuff.Icon); newBuff.SetComponents(newBuff.ComponentsArray.Select(c => { var mechanics = c as MetamagicRodMechanics; if (mechanics == null) { return(c); } var newMechanics = UnityEngine.Object.Instantiate(mechanics); newMechanics.Metamagic = (Metamagic)modMetamagic; newMechanics.RodAbility = newAbility; return(newMechanics); })); newRods.PutIfAbsent(GetMetamagicRodKey(i, modMetamagic.OriginalCost()), () => new List <BlueprintItemEquipmentUsable>()).Add(newRod); } }
static BlueprintFeature CreateElementalMetamagicFeat(ModMetamagic metamagic, DamageEnergyType energyType, String assetId, String iconAssetId) { var friendlyName = $"Elemental Spell — {energyType}"; var shortName = energyType.ToString().ToLower(); var description = $"You can manipulate the elemental nature of your spells. You may replace a spell’s normal damage with {shortName} damage.\nLevel Increase: +1"; return(CreateMetamagicFeat(metamagic, assetId, friendlyName, description, iconAssetId, Helpers.Create <ElementalMetamagic>(e => e.EnergyType = energyType))); }
static BlueprintFeature CreateElementalMetamagicFeat(ModMetamagic metamagic, DamageEnergyType energyType, String assetId, String iconAssetId) { var friendlyName = string.Format(Main.lc.GetTranslate("Metamagic.ftElementalSubName"), energyType); var shortName = energyType.ToString().ToLower(); var description = string.Format(Main.lc.GetTranslate("Metamagic.ftElementalSubDesc"), shortName); return(CreateMetamagicFeat(metamagic, assetId, friendlyName, description, iconAssetId, Helpers.Create <ElementalMetamagic>(e => e.EnergyType = energyType))); }
static BlueprintFeature CreateElementalMetamagicFeat(ModMetamagic metamagic, DamageEnergyType energyType, String assetId, Sprite icon) { var displayName = energyType.ToString().ToLower() == "magic" ? RES.NewMetamagicNamesElementalForcePrefix_info : LocalizedTexts.Instance.DamageEnergy.GetText(energyType); var friendlyName = string.Format(RES.MetamagicFeatElementalSpellName_info, displayName); var description = string.Format(RES.MetamagicFeatElementalSpellDescription_info, displayName); return(CreateMetamagicFeat(metamagic, assetId, friendlyName, description, icon, Helpers.Create <ElementalMetamagic>(e => e.EnergyType = energyType))); }
static BlueprintFeature CreateMetamagicFeat(ModMetamagic metamagic, String assetId, String friendlyName, String description, String iconAssetId, BlueprintComponent logic = null, params BlueprintComponent[] extra) { var components = new List <BlueprintComponent> { Helpers.Create <AddMetamagicFeat>(m => m.Metamagic = (Metamagic)metamagic), Helpers.Create <RecommendationRequiresSpellbook>() }; if (logic != null) { components.Add(logic); } components.AddRange(extra); var feat = Helpers.Create <BlueprintFeature>(); feat.name = metamagic.ToString() + "SpellFeat"; feat.Groups = new FeatureGroup[] { FeatureGroup.WizardFeat, FeatureGroup.Feat }; feat.SetComponents(components); friendlyName = friendlyName ?? (metamagic.ToString() + " Spell"); feat.SetNameDescriptionIcon($"Metamagic ({friendlyName})", description, Helpers.GetIcon(iconAssetId)); Main.library.AddAsset(feat, assetId); CreateMetamagicRods(feat, metamagic, friendlyName, logic); return(feat); }
static void CreateMetamagicRods(BlueprintFeature feature, ModMetamagic modMetamagic, String friendlyName, BlueprintComponent logic) { // For loacalization var ModMetamagicNames = new Dictionary <ModMetamagic, string> { { ModMetamagic.Dazing, RES.NewMetamagicNamesDazing_info }, // {ModMetamagic.Elemental, RES.NewMetamagicNamesElemental_info.Trim()}, { ModMetamagic.ElementalAcid, LocalizedTexts.Instance.DamageEnergy.GetText(DamageEnergyType.Acid) + RES.NewMetamagicNamesElemental_info }, { ModMetamagic.ElementalCold, LocalizedTexts.Instance.DamageEnergy.GetText(DamageEnergyType.Cold) + RES.NewMetamagicNamesElemental_info }, { ModMetamagic.ElementalElectricity, LocalizedTexts.Instance.DamageEnergy.GetText(DamageEnergyType.Electricity) + RES.NewMetamagicNamesElemental_info }, { ModMetamagic.ElementalFire, LocalizedTexts.Instance.DamageEnergy.GetText(DamageEnergyType.Fire) + RES.NewMetamagicNamesElemental_info }, { ModMetamagic.ElementalForce, RES.NewMetamagicNamesElementalForcePrefix_info + RES.NewMetamagicNamesElemental_info }, { ModMetamagic.Intensified, RES.NewMetamagicNamesIntensified_info }, { ModMetamagic.Persistent, RES.NewMetamagicNamesPersistent_info }, { ModMetamagic.Rime, RES.NewMetamagicNamesRime_info }, { ModMetamagic.Selective, RES.NewMetamagicNamesSelectvie_info }, { ModMetamagic.Toppling, RES.NewMetamagicNamesToppling_info } }; // Create a metamagic rod by cloning an existing one. var rodIds = existingRodIds[Metamagic.Empower]; var rodCosts = metamagicRodCosts[modMetamagic.OriginalCost() - 1]; var library = Main.library; var names = new string[] { "Lesser", "Normal", "Greater" }; var displayPrefix = new string[] { RES.MetamagicRodDisplayPrefixString_Lesser, RES.MetamagicRodDisplayPrefixString_Normal, RES.MetamagicRodDisplayPrefixString_Greater }; var maxLevel = new string[] { RES.MetamagicRodSpellMaxLevel_3rd, RES.MetamagicRodSpellMaxLevel_6th, RES.MetamagicRodSpellMaxLevel_9th }; for (int i = 0; i < 3; i++) { var displayName = i == 1 ? ModMetamagicNames[modMetamagic] + RES.MetamagicRodName_info : displayPrefix[i] + ModMetamagicNames[modMetamagic] + RES.MetamagicRodName_info; var description = string.Format(RES.MetamagicRodDescription_info, feature.Name, displayPrefix[i], maxLevel[i], friendlyName, feature.Description); // We need to clone 3 things: // - the item // - the activatable ability // - the buff var existingRod = library.Get <BlueprintItemEquipmentUsable>(rodIds[i]); var existingAbility = existingRod.ActivatableAbility; var existingBuff = existingAbility.Buff; var newRod = library.CopyAndAdd(existingRod, $"MetamagicRod{names[i]}{modMetamagic}", feature.AssetGuid, existingRod.AssetGuid); var newAbility = library.CopyAndAdd(existingAbility, $"{newRod.name}ToggleAbility", feature.AssetGuid, existingAbility.AssetGuid); var newBuff = library.CopyAndAdd(existingBuff, $"{newRod.name}Buff", feature.AssetGuid, existingBuff.AssetGuid); newRod.ActivatableAbility = newAbility; newAbility.Buff = newBuff; if (logic != null) { newAbility.AddComponent(logic); } Helpers.SetField(newRod, "m_Cost", rodCosts[i]); Helpers.SetField(newRod, "m_DisplayNameText", Helpers.CreateString(newRod.name + ".Name", displayName)); Helpers.SetField(newRod, "m_DescriptionText", Helpers.CreateString(newRod.name + ".Description", description)); newAbility.SetNameDescriptionIcon(displayName, description, newAbility.Icon); newBuff.SetNameDescriptionIcon(displayName, description, newBuff.Icon); newBuff.SetComponents(newBuff.ComponentsArray.Select(c => { var mechanics = c as MetamagicRodMechanics; if (mechanics == null) { return(c); } var newMechanics = UnityEngine.Object.Instantiate(mechanics); newMechanics.Metamagic = (Metamagic)modMetamagic; newMechanics.RodAbility = newAbility; return(newMechanics); })); newRods.PutIfAbsent(GetMetamagicRodKey(i, modMetamagic.OriginalCost()), () => new List <BlueprintItemEquipmentUsable>()).Add(newRod); } }
static void CreateMetamagicRods(BlueprintFeature feature, ModMetamagic modMetamagic, String friendlyName, BlueprintComponent logic) { Dictionary <ModMetamagic, string> AdjMetamagic = new Dictionary <ModMetamagic, string> { { ModMetamagic.Dazing, Main.lc.GetTranslate("Metamagic.stAdjDazing") }, { ModMetamagic.ElementalAcid, Main.lc.GetTranslate("Metamagic.stAdjElementalAcid") }, { ModMetamagic.ElementalCold, Main.lc.GetTranslate("Metamagic.stAdjElementalCold") }, { ModMetamagic.ElementalElectricity, Main.lc.GetTranslate("Metamagic.stAdjElementalElectric") }, { ModMetamagic.ElementalFire, Main.lc.GetTranslate("Metamagic.stAdjElementalFire") }, { ModMetamagic.Intensified, Main.lc.GetTranslate("Metamagic.stAdjIntensified") }, { ModMetamagic.Persistent, Main.lc.GetTranslate("Metamagic.stAdjPersistent") }, { ModMetamagic.Rime, Main.lc.GetTranslate("Metamagic.stAdjRime") }, { ModMetamagic.Selective, Main.lc.GetTranslate("Metamagic.stAdjSelective") }, { ModMetamagic.Toppling, Main.lc.GetTranslate("Metamagic.stAdjToppling") } }; // Create a metamagic rod by cloning an existing one. var rodIds = existingRodIds[Metamagic.Empower]; var rodCosts = metamagicRodCosts[modMetamagic.DefaultCost() - 1]; var library = Main.library; var names = new string[] { "Lesser", "Normal", "Greater" }; var displayPrefix = new string[] { Main.lc.GetTranslate("Metamagic.stLesser") + " ", Main.lc.GetTranslate("Metamagic.stNormal") + " ", Main.lc.GetTranslate("Metamagic.stGreater") + " " }; var maxLevel = new string[] { Main.lc.GetTranslate("Metamagic.st3rd"), Main.lc.GetTranslate("Metamagic.st6th"), Main.lc.GetTranslate("Metamagic.st9th") }; for (int i = 0; i < 3; i++) { var displayName = displayPrefix[i] + AdjMetamagic[modMetamagic] + Main.lc.GetTranslate("Metamagic.stMetamagicRodSuffix"); var description = string.Format(Main.lc.GetTranslate("Metamagic.ieMetamagicRodDesc"), friendlyName, displayPrefix[i], maxLevel[i], feature.Description); // We need to clone 3 things: // - the item // - the activatable ability // - the buff var existingRod = library.Get <BlueprintItemEquipmentUsable>(rodIds[i]); var existingAbility = existingRod.ActivatableAbility; var existingBuff = existingAbility.Buff; var newRod = library.CopyAndAdd(existingRod, $"MetamagicRod{names[i]}{modMetamagic}", feature.AssetGuid, existingRod.AssetGuid); var newAbility = library.CopyAndAdd(existingAbility, $"{newRod.name}ToggleAbility", feature.AssetGuid, existingAbility.AssetGuid); var newBuff = library.CopyAndAdd(existingBuff, $"{newRod.name}Buff", feature.AssetGuid, existingBuff.AssetGuid); newRod.ActivatableAbility = newAbility; newAbility.Buff = newBuff; if (logic != null) { newAbility.AddComponent(logic); } Helpers.SetField(newRod, "m_Cost", rodCosts[i]); Helpers.SetField(newRod, "m_DisplayNameText", Helpers.CreateString(newRod.name + ".Name", displayName)); Helpers.SetField(newRod, "m_DescriptionText", Helpers.CreateString(newRod.name + ".Description", description)); newAbility.SetNameDescriptionIcon(displayName, description, newAbility.Icon); newBuff.SetNameDescriptionIcon(displayName, description, newBuff.Icon); newBuff.SetComponents(newBuff.ComponentsArray.Select(c => { var mechanics = c as MetamagicRodMechanics; if (mechanics == null) { return(c); } var newMechanics = UnityEngine.Object.Instantiate(mechanics); newMechanics.Metamagic = (Metamagic)modMetamagic; newMechanics.RodAbility = newAbility; return(newMechanics); })); newRods.PutIfAbsent(GetMetamagicRodKey(i, modMetamagic.DefaultCost()), () => new List <BlueprintItemEquipmentUsable>()).Add(newRod); } }