public static void Prefix(SGBarracksAdvancementPanel __instance, Pilot ___curPilot, Pilot ___basePilot, List <SGBarracksSkillPip> ___gunPips, List <SGBarracksSkillPip> ___pilotPips, List <SGBarracksSkillPip> ___gutPips, List <SGBarracksSkillPip> ___tacPips, string type, int value) { if (___curPilot.StatCollection.GetValue <int>(type) > value) { var sim = UnityGameInstance.BattleTechGame.Simulation; if (sim == null) { return; } if (String.IsNullOrEmpty(___curPilot.GUID)) { return; } if (!ModState.PilotCurrentFreeXP.ContainsKey(___curPilot.GUID)) { ModState.PilotCurrentFreeXP.Add(___curPilot.GUID, ___curPilot.UnspentXP); Mod.Log.Info?.Write( $"CHEATDETECTION: {___curPilot.Description.Id}: Added key {___curPilot.GUID} to PilotCurrentXP with UnspentXP {___curPilot.UnspentXP} but should have been done already. At SGBarracksAdvancementPanel.OnValueClick, Pre."); } ModState.PilotCurrentFreeXP[___curPilot.GUID] = ___basePilot.UnspentXP; Mod.Log.Info?.Write( $"CHEATDETECTION: {___curPilot.Description.Id}: {___curPilot.GUID} Free XP state was {ModState.PilotCurrentFreeXP[___curPilot.GUID]} after changing to basePilot {___basePilot.UnspentXP} At SGBarracksAdvancementPanel.OnValueClick, Pre."); } }
public static void Prefix(SGBarracksAdvancementPanel __instance) { try { isBookish = false; isKlutz = false; if (__instance.curPilot == null) { return; } if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_bookish")) { isBookish = true; } if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_klutz")) { isKlutz = true; } if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_assassin")) { isAssassin = true; } } catch (Exception e) { Pre_Control.Helper.Logger.LogError(e); } }
public static void Postfix(SGBarracksAdvancementPanel __instance) { var sim = UnityGameInstance.BattleTechGame.Simulation; var currentPilots = new List <Pilot>(sim.PilotRoster); currentPilots.Add(sim.Commander); foreach (var pilot in currentPilots) { if (String.IsNullOrEmpty(pilot.GUID)) { return; } if (!ModState.PilotCurrentFreeXP.ContainsKey(pilot.GUID)) { ModState.PilotCurrentFreeXP.Add(pilot.GUID, pilot.UnspentXP); Mod.Log.Info?.Write( $"CHEATDETECTION: {pilot.Description.Id}: Added {pilot.GUID} key to PilotCurrentXP with UnspentXP {pilot.UnspentXP} on SGBarracksAdvancementPanel Close, post."); } else { ModState.PilotCurrentFreeXP[pilot.GUID] = pilot.UnspentXP; Mod.Log.Info?.Write( $"CHEATDETECTION: {pilot.Description.Id}: Set tracker {pilot.GUID} PilotCurrentXP with UnspentXP {pilot.UnspentXP} on SGBarracksAdvancementPanel Close, post."); } } }
public static void Prefix(SGBarracksAdvancementPanel __instance) { try { isIncreased = false; isDecreased = false; isBookish = false; isKlutz = false; isAssassin = false; OnValueClick = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_bookish")) { isBookish = true; } if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_klutz")) { isKlutz = true; } if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_assassin")) { isAssassin = true; } } catch (Exception e) { Logger.LogError(e); } }
static void Postfix(SGBarracksMWDetailPanel __instance, Pilot p, SGBarracksAdvancementPanel ___advancement, GameObject ___advancementSectionGO, SGBarracksDossierPanel ___dossier, SGBarracksServicePanel ___servicePanel, GameObject ___serviceSectionGO, HBSDOTweenButton ___customizeButton) { if (p == null) { return; } CrewDetails details = ModState.GetCrewDetails(p.pilotDef); GameObject skillsButton = __instance.gameObject.FindFirstChildNamed(ModConsts.GO_HBS_Barracks_Skill_Button); if (skillsButton == null) { Mod.Log.Debug?.Write("SkillsButton is null!"); } if (details.IsMechTechCrew || details.IsMedTechCrew || details.IsAerospaceCrew) { __instance.OnServiceSectionClicked(); skillsButton.SetActive(false); } else { skillsButton.SetActive(true); } }
public static void Postfix(SGBarracksMWDetailPanel __instance, Pilot p, SGBarracksAdvancementPanel ___advancement ) { var sim = UnityGameInstance.BattleTechGame.Simulation; var gunPips = Traverse.Create(___advancement).Field("gunPips").GetValue <List <SGBarracksSkillPip> >(); var pilotPips = Traverse.Create(___advancement).Field("pilotPips").GetValue <List <SGBarracksSkillPip> >(); var gutPips = Traverse.Create(___advancement).Field("gutPips").GetValue <List <SGBarracksSkillPip> >(); var tacPips = Traverse.Create(___advancement).Field("tacPips").GetValue <List <SGBarracksSkillPip> >(); var abilityDefs = p.pilotDef.AbilityDefs.Where(x => x.IsPrimaryAbility == true); //loop through abilities the pilot has, and place those ability icons/tooltips in the appropriate pip slot. foreach (AbilityDef ability in abilityDefs) { if (ability.ReqSkill == SkillType.Gunnery) { Traverse.Create(gunPips[ability.ReqSkillLevel - 1]).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = ability.AbilityIcon; Traverse.Create(gunPips[ability.ReqSkillLevel - 1]).Field("AbilityTooltip").GetValue <HBSTooltip>() .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(ability.Description)); } } foreach (AbilityDef ability in abilityDefs) { if (ability.ReqSkill == SkillType.Piloting) { Traverse.Create(pilotPips[ability.ReqSkillLevel - 1]).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = ability.AbilityIcon; Traverse.Create(pilotPips[ability.ReqSkillLevel - 1]).Field("AbilityTooltip").GetValue <HBSTooltip>() .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(ability.Description)); } } foreach (AbilityDef ability in abilityDefs) { if (ability.ReqSkill == SkillType.Guts) { Traverse.Create(gutPips[ability.ReqSkillLevel - 1]).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = ability.AbilityIcon; Traverse.Create(gutPips[ability.ReqSkillLevel - 1]).Field("AbilityTooltip").GetValue <HBSTooltip>() .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(ability.Description)); } } foreach (AbilityDef ability in abilityDefs) { if (ability.ReqSkill == SkillType.Tactics) { Traverse.Create(tacPips[ability.ReqSkillLevel - 1]).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = ability.AbilityIcon; Traverse.Create(tacPips[ability.ReqSkillLevel - 1]).Field("AbilityTooltip").GetValue <HBSTooltip>() .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(ability.Description)); } } }
// modified copy from assembly internal static void ForceResetCharacter(SGBarracksAdvancementPanel panel) { var sim = UnityGameInstance.BattleTechGame.Simulation; var traverse = Traverse.Create(panel); var orderedDictionary = traverse.Field("upgradedSkills").GetValue <OrderedDictionary>(); panel.SetPilot(traverse.Field("basePilot").GetValue <Pilot>(), true); foreach (var obj in orderedDictionary.Values) { var keyValuePair = (KeyValuePair <string, int>)obj; Trace($"Resetting {keyValuePair.Key} {keyValuePair.Value}"); // this is the only change - calling internal implementation SetTempPilotSkill(keyValuePair.Key, keyValuePair.Value, sim.GetLevelCost(keyValuePair.Value)); } var callback = traverse.Field("OnValueChangeCB").GetValue <UnityAction <Pilot> >(); callback?.Invoke(traverse.Field("curPilot").GetValue <Pilot>()); }
static void Postfix(SGBarracksMWDetailPanel __instance, Pilot ___curPilot, SGBarracksAdvancementPanel ___advancement, GameObject ___advancementSectionGO, SGBarracksDossierPanel ___dossier, SGBarracksServicePanel ___servicePanel, GameObject ___serviceSectionGO, HBSDOTweenButton ___customizeButton) { if (___curPilot == null) { return; } CrewDetails details = ModState.GetCrewDetails(___curPilot.pilotDef); if (details.IsMechTechCrew || details.IsMedTechCrew || details.IsAerospaceCrew) { ___advancementSectionGO.SetActive(false); } }
public static bool Prefix(SGBarracksAdvancementPanel __instance, List <SGBarracksSkillPip> pips, int originalSkill, int curSkill, int idx, bool needsXP, bool isLocked, Pilot ___curPilot) { var sim = UnityGameInstance.BattleTechGame.Simulation; SGBarracksSkillPip.PurchaseState purchaseState = SGBarracksSkillPip.PurchaseState.Unselected; if (originalSkill > idx) { purchaseState = SGBarracksSkillPip.PurchaseState.Purchased; } else if (curSkill > idx) { purchaseState = SGBarracksSkillPip.PurchaseState.Selected; } bool flag = false; if (isLocked && (idx + 1 == pips.Count || curSkill == idx + 1)) { flag = true; } if (pips[idx].Ability != null) { bool flag2 = sim.CanPilotTakeAbility(___curPilot.pilotDef, pips[idx].Ability, pips[idx].SecondTierAbility); bool flag3 = ___curPilot.pilotDef.abilityDefNames.Contains(pips[idx].Ability.Description.Id); //this is the pertinent change, which checks if pilot has ANY ability of the correct type and level, and sets it to be visible if true var type = pips[idx].Ability.ReqSkill; var abilityDefs = ___curPilot.pilotDef.AbilityDefs.Where(x => x.ReqSkill == type && x.ReqSkillLevel == idx + 1 && x.IsPrimaryAbility); bool flag4 = abilityDefs.Any(); pips[idx].Set(purchaseState, (curSkill == idx || curSkill == idx + 1) && !isLocked, curSkill == idx, needsXP, isLocked && flag); pips[idx].SetActiveAbilityVisible(flag2 || flag3 || flag4); } pips[idx].Set(purchaseState, (curSkill == idx || curSkill == idx + 1) && !isLocked, curSkill == idx, needsXP, isLocked && flag); return(false); }
internal static void ForceResetCharacter(SGBarracksAdvancementPanel panel) { var sim = UnityGameInstance.BattleTechGame.Simulation; var traverse = Traverse.Create(panel); var orderedDictionary = traverse.Field("upgradedSkills").GetValue <OrderedDictionary>(); var upgradedPrimarySkills = traverse.Field("upgradedPrimarySkills").GetValue <List <AbilityDef> >(); var upgradedAbilities = new List <AbilityDef>(); upgradedAbilities.AddRange(upgradedPrimarySkills); panel.SetPilot(traverse.Field("basePilot").GetValue <Pilot>(), true); foreach (var obj in orderedDictionary.Values) { var keyValuePair = (KeyValuePair <string, int>)obj; var abilityDef = upgradedAbilities.FindAll(x => x.ReqSkill.ToString() == keyValuePair.Key && x.ReqSkillLevel == keyValuePair.Value + 1); if (abilityDef.Count > 0) { Trace($"Resetting {keyValuePair.Key} {keyValuePair.Value}"); // this is the only change - calling internal implementation SetTempPilotSkill(keyValuePair.Key, keyValuePair.Value, sim.GetLevelCost(keyValuePair.Value), abilityDef[0]); } else { Trace($"Resetting {keyValuePair.Key} {keyValuePair.Value}"); // this is the only change - calling internal implementation SetTempPilotSkill(keyValuePair.Key, keyValuePair.Value, sim.GetLevelCost(keyValuePair.Value)); } } var callback = traverse.Field("OnValueChangeCB").GetValue <UnityAction <Pilot> >(); callback?.Invoke(traverse.Field("curPilot").GetValue <Pilot>()); }
public static bool Prefix( SGBarracksAdvancementPanel __instance, Pilot ___curPilot, List <SGBarracksSkillPip> ___gunPips, List <SGBarracksSkillPip> ___pilotPips, List <SGBarracksSkillPip> ___gutPips, List <SGBarracksSkillPip> ___tacPips, string type, int value) { try { ___curPilot.AddExperience(0, "", 100000); var sim = UnityGameInstance.BattleTechGame.Simulation; var pips = new Dictionary <string, List <SGBarracksSkillPip> > { { "Gunnery", ___gunPips }, { "Piloting", ___pilotPips }, { "Guts", ___gutPips }, { "Tactics", ___tacPips }, }; // removal of pip if (___curPilot.StatCollection.GetValue <int>(type) > value) { Trace($"Removing {type} {value}"); Trace(pips[type][value].Ability); Helpers.SetTempPilotSkill(type, value, -sim.GetLevelCost(value)); ___curPilot.pilotDef.abilityDefNames.Do(Trace); Log("\n"); Helpers.ForceResetCharacter(__instance); Traverse.Create(__instance).Method("ForceResetCharacter").GetValue(); return(false); } // add non-ability pip if (!Traverse.Create(pips[type][value]).Field("hasAbility").GetValue <bool>()) { Trace("Non-ability pip"); Helpers.SetTempPilotSkill(type, value, sim.GetLevelCost(value)); ___curPilot.pilotDef.abilityDefNames.Do(Trace); Trace("\n"); return(false); } // Ability pips // build complete list of defs from HBS and imported json // var abilityDefs = Helpers.ModAbilities // .Where(x => x.ReqSkillLevel == value + 1 && x.ReqSkill.ToString() == type).ToList(); var abilityDefs = new List <AbilityDef>(); var abilityDictionaries = sim.AbilityTree.Select(x => x.Value).ToList(); foreach (var abilityDictionary in abilityDictionaries) { abilityDefs.AddRange(abilityDictionary[value].Where(x => x.ReqSkill.ToString() == type)); } // don't create choice popups with 1 option if (abilityDefs.Count <= 1) { Trace($"Single ability for {type}|{value}, skipping"); Helpers.SetTempPilotSkill(type, value, sim.GetLevelCost(value)); return(false); } // prevents which were ability buttons before other primaries were selected from being abilities // not every ability button is visible all the time var curButton = Traverse.Create(pips[type][value]).Field("curButton").GetValue <HBSDOTweenToggle>(); var skillButton = Traverse.Create(pips[type][value]).Field("skillButton").GetValue <HBSDOTweenToggle>(); if (curButton != skillButton) { Trace(new string('=', 50)); Trace("curButton != skillButton"); Helpers.SetTempPilotSkill(type, value, sim.GetLevelCost(value)); return(false); } // dynamic buttons based on available abilities string abilityDescs = null; foreach (var abilityDef in abilityDefs) { string abilityID = abilityDef.Id + "Desc"; string abilityName = abilityDef.Description.Name; if (Mod.modSettings.usePopUpsForAbilityDesc == true) { abilityDescs += "[[DM.BaseDescriptionDefs[" + abilityID + "],<b>" + abilityName + "</b>]]" + "\n\n"; } else { abilityDescs += abilityDef.Description.Name + ": " + abilityDef.Description.Details + "\n\n"; } } var popup = GenericPopupBuilder .Create("Select an ability", abilityDescs) .AddFader(); popup.AlwaysOnTop = true; var pip = pips[type][value]; foreach (var abilityDef in abilityDefs) { popup.AddButton(abilityDef.Description.Name, () => { // have to change the Ability so SetPips later, SetActiveAbilityVisible works Traverse.Create(pip).Field("thisAbility").SetValue(abilityDef); Traverse.Create(pip).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = abilityDef.AbilityIcon; Traverse.Create(pip).Field("AbilityTooltip").GetValue <HBSTooltip>() .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(abilityDef.Description)); Helpers.SetTempPilotSkill(type, value, sim.GetLevelCost(value), abilityDef); }); } popup.Render(); } catch (Exception ex) { Log(ex); } return(false); }
public static void Prefix(SGBarracksAdvancementPanel __instance, List <SGBarracksSkillPip> pips, ref bool needsXP, int idx) { try { isBookish = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_bookish")) { isBookish = true; } isKlutz = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_klutz")) { isKlutz = true; } isAssassin = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_assassin")) { isAssassin = true; } var sim = UnityGameInstance.BattleTechGame.Simulation; if (__instance.curPilot == null) { return; } Pilot p = __instance.curPilot; isIncreased = false; isDecreased = false; if (isBookish || isKlutz || isAssassin) { if (pips == __instance.pilotPips) { if (isKlutz) { isIncreased = true; } else { isIncreased = false; } isDecreased = false; bool XPLevelCheck = p.UnspentXP < sim.GetLevelCost(idx); needsXP = XPLevelCheck && p.Piloting - 1 < idx; } if (pips == __instance.gunPips) { isIncreased = false; if (isAssassin) { isDecreased = true; } else { isDecreased = false; } bool XPLevelCheck = p.UnspentXP < sim.GetLevelCost(idx); needsXP = XPLevelCheck && p.Gunnery - 1 < idx; } if (pips == __instance.gutPips) { if (isBookish) { isIncreased = true; } else { isIncreased = false; } isDecreased = false; bool XPLevelCheck = p.UnspentXP < sim.GetLevelCost(idx); needsXP = XPLevelCheck && p.Guts - 1 < idx; } if (pips == __instance.tacPips) { isIncreased = false; if (isBookish) { isDecreased = true; } else { isDecreased = false; } bool XPLevelCheck = p.UnspentXP < sim.GetLevelCost(idx); needsXP = XPLevelCheck && p.Tactics - 1 < idx; } isIncreased = false; isDecreased = false; } } catch (Exception e) { Pre_Control.Helper.Logger.LogError(e); } }
public static void Prefix(SGBarracksAdvancementPanel __instance, string type, int skill, ref int expAmount) { var sim = UnityGameInstance.BattleTechGame.Simulation; try { isBookish = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_bookish")) { isBookish = true; } isKlutz = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_klutz")) { isKlutz = true; } isAssassin = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_assassin")) { isAssassin = true; } int twiddle = -1; if (OnValueClick) { twiddle = 1; } if (isBookish || isKlutz || isAssassin) { if (type == "Piloting") { if (isKlutz) { isIncreased = true; } else { isIncreased = false; } isDecreased = false; expAmount = twiddle * sim.GetLevelCost(skill); } if (type == "Gunnery") { isIncreased = false; if (isAssassin) { isDecreased = true; } else { isDecreased = false; } expAmount = twiddle * sim.GetLevelCost(skill); } if (type == "Guts") { if (isBookish) { isIncreased = true; } else { isIncreased = false; } isDecreased = false; expAmount = twiddle * sim.GetLevelCost(skill); } if (type == "Tactics") { isIncreased = false; if (isBookish) { isDecreased = true; } else { isDecreased = false; } expAmount = twiddle * sim.GetLevelCost(skill); } } } catch (Exception e) { Logger.LogError(e); } }
public static void Prefix(SGBarracksAdvancementPanel __instance, string type) { try { isBookish = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_bookish")) { isBookish = true; } isKlutz = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_klutz")) { isKlutz = true; } isAssassin = false; if (__instance.curPilot.pilotDef.PilotTags.Contains("pilot_assassin")) { isAssassin = true; } OnValueClick = true; if (isBookish || isKlutz || isAssassin) { if (type == "Piloting") { if (isKlutz) { isIncreased = true; } else { isIncreased = false; } isDecreased = false; } if (type == "Gunnery") { isIncreased = false; if (isAssassin) { isDecreased = true; } else { isDecreased = false; } } if (type == "Guts") { if (isBookish) { isIncreased = true; } else { isIncreased = false; } isDecreased = false; } if (type == "Tactics") { isIncreased = false; if (isBookish) { isDecreased = true; } else { isDecreased = false; } } } else { isIncreased = false; isDecreased = false; } } catch (Exception e) { Logger.LogError(e); } }
public static void Postfix(SGBarracksAdvancementPanel __instance) { saveSimState = __instance.simState; }
public static bool Prefix( SGBarracksAdvancementPanel __instance, Pilot ___curPilot, List <SGBarracksSkillPip> ___gunPips, List <SGBarracksSkillPip> ___pilotPips, List <SGBarracksSkillPip> ___gutPips, List <SGBarracksSkillPip> ___tacPips, string type, int value) { try { if (modSettings.debugXP == true) { ___curPilot.AddExperience(0, "", 100000); } var sim = UnityGameInstance.BattleTechGame.Simulation; var pips = new Dictionary <string, List <SGBarracksSkillPip> > { { "Gunnery", ___gunPips }, { "Piloting", ___pilotPips }, { "Guts", ___gutPips }, { "Tactics", ___tacPips }, }; // removal of pip if (___curPilot.StatCollection.GetValue <int>(type) > value) { Trace($"Removing {type} {value}"); Trace(pips[type][value].Ability); Helpers.SetTempPilotSkill(type, value, -sim.GetLevelCost(value)); ___curPilot.pilotDef.abilityDefNames.Do(Trace); Log("\n"); Helpers.ForceResetCharacter(__instance); // Traverse.Create(__instance).Method("ForceResetCharacter").GetValue(); return(false); } // add non-ability pip if (!Traverse.Create(pips[type][value]).Field("hasAbility").GetValue <bool>()) { Trace("Non-ability pip"); Helpers.SetTempPilotSkill(type, value, sim.GetLevelCost(value)); ___curPilot.pilotDef.abilityDefNames.Do(Trace); Trace("\n"); return(false); } // Ability pips // build complete list of defs from HBS and imported json // var abilityDefs = Helpers.ModAbilities // .Where(x => x.ReqSkillLevel == value + 1 && x.ReqSkill.ToString() == type).ToList(); var abilityDictionaries = sim.AbilityTree.Select(x => x.Value).ToList(); //List<AbilityDef> abilityDefs = sim.GetAbilityDefFromTree(type, value); //does same thing as below? var abilityDefs = new List <AbilityDef>(); foreach (var abilityDictionary in abilityDictionaries) { abilityDefs.AddRange(abilityDictionary[value].Where(x => x.ReqSkill.ToString() == type)); } // don't create choice popups with 1 option if (abilityDefs.Count <= 1) { Trace($"Single ability for {type}|{value}, skipping"); Helpers.SetTempPilotSkill(type, value, sim.GetLevelCost(value)); return(false); } // prevents which were ability buttons before other primaries were selected from being abilities // not every ability button is visible all the time var curButton = Traverse.Create(pips[type][value]).Field("curButton").GetValue <HBSDOTweenToggle>(); var skillButton = Traverse.Create(pips[type][value]).Field("skillButton").GetValue <HBSDOTweenToggle>(); if (curButton != skillButton) { Trace(new string('=', 50)); Trace("curButton != skillButton"); Helpers.SetTempPilotSkill(type, value, sim.GetLevelCost(value)); return(false); } // dynamic buttons based on available abilities //new code below// //new code below for ability requirements List <string> pilotAbilityDefNames = ___curPilot.pilotDef.abilityDefNames; var abilityFilter = modSettings.abilityReqs.Values.SelectMany(x => x).ToList(); List <AbilityDef> abilitiesWithReqs = abilityDefs.Where(ability => abilityFilter.Any(filter => filter.Equals(ability.Id))).ToList(); var abilityDefsForDesc = new List <AbilityDef>(); abilityDefsForDesc.AddRange(abilityDefs); foreach (var abilityWithReq in abilitiesWithReqs) { if (!pilotAbilityDefNames.Contains(modSettings.abilityReqs.FirstOrDefault(x => x.Value.Contains(abilityWithReq.Id)).Key)) { abilityDefs.Remove(abilityWithReq); } } //original code continues below// string abilityDescs = null; foreach (var abilityDefDesc in abilityDefsForDesc) { if (abilityDefs.Contains(abilityDefDesc)) { string abilityID = abilityDefDesc.Id + "Desc"; string abilityName = abilityDefDesc.Description.Name; if (modSettings.usePopUpsForAbilityDesc == true) { abilityDescs += "[[DM.BaseDescriptionDefs[" + abilityID + "],<b>" + abilityName + "</b>]]" + "\n\n"; } else { abilityDescs += "<color=#33f9ff>" + abilityDefDesc.Description.Name + ": </color>" + abilityDefDesc.Description.Details + "\n\n"; } } else { var dm = UnityGameInstance.BattleTechGame.DataManager; string abilityID = abilityDefDesc.Id + "Desc"; string abilityName = abilityDefDesc.Description.Name; var reqAbilityName = modSettings.abilityReqs.FirstOrDefault(x => x.Value.Contains(abilityDefDesc.Id)).Key; var allAbilities = new List <AbilityDef>(); allAbilities = sim.AbilityTree[type].SelectMany(x => x.Value).ToList(); // allAbilities.AddRange(Traverse.Create(dm).Field("abilityDefs").GetValue<List<AbilityDef>>()); var reqAbility = allAbilities.Find(x => x.Id == reqAbilityName); if (modSettings.usePopUpsForAbilityDesc == true) { //abilityDescs += "<color=#FF0000>(Requirements Unmet)</color> " + "[[DM.BaseDescriptionDefs[" + abilityID + "],<b>" + abilityName + "</b>]]" + "\n\n"; abilityDescs += "<color=#FF0000> Requires <u>" + reqAbility.Description.Name + "</u></color> " + "[[DM.BaseDescriptionDefs[" + abilityID + "],<b>" + abilityName + "</b>]]" + "\n\n"; } else { //abilityDescs += "<color=#FF0000>(Requirements Unmet)</color> " + "<color=#0000FF>" + abilityDefDesc.Description.Name + ": </color>" + abilityDefDesc.Description.Details + "\n\n"; abilityDescs += "<color=#FF0000> Requires <u>" + reqAbility.Description.Name + "</u></color> " + "<color=#33f9ff>" + abilityDefDesc.Description.Name + ": </color>" + abilityDefDesc.Description.Details + "\n\n"; } } } var popup = GenericPopupBuilder .Create("Select an ability", abilityDescs) .AddFader(); popup.AlwaysOnTop = true; var pip = pips[type][value]; foreach (var abilityDef in abilityDefs) { popup.AddButton(abilityDef.Description.Name, () => { // have to change the Ability so SetPips later, SetActiveAbilityVisible works Traverse.Create(pip).Field("thisAbility").SetValue(abilityDef); Traverse.Create(pip).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = abilityDef.AbilityIcon; Traverse.Create(pip).Field("AbilityTooltip").GetValue <HBSTooltip>() .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(abilityDef.Description)); Helpers.SetTempPilotSkill(type, value, sim.GetLevelCost(value), abilityDef); }); } popup.Render(); } catch (Exception ex) { Log(ex); } return(false); }