//TODO: This is a bit of a logic abomination with lots of repeat code public List <Ability_Activated> GetModifiedActivatedAbilities() { List <Ability_Activated> moddedMap = new List <Ability_Activated>(); // Get golem mods List <Ability> golemAbilities = GetAbilities_Golem(); List <Ability_Modifier> golemMods = new List <Ability_Modifier>(); for (int i = 0; i < golemAbilities.Count; i++) { Ability_Modifier mod = golemAbilities[i] as Ability_Modifier; if (mod != null && mod.extent == ModExtent.Golem) { golemMods.Add(mod); } } // Each compartment for (int c = 0; c < map.Count; c++) { // Get compartment mods List <Ability> compartmentAbilities = GetAbilities_Compartment(c); List <Ability_Modifier> compartmentMods = new List <Ability_Modifier>(); for (int i = 0; i < compartmentAbilities.Count; i++) { Ability_Modifier mod = compartmentAbilities[i] as Ability_Modifier; if (mod != null && mod.extent == ModExtent.Compartment) { compartmentMods.Add(mod); } } // Each gear for (int g = 0; g < map[c].Count; g++) { // Get gear mods List <Ability> gearAbilities = GetAbilities_Gear(c, g); List <Ability_Modifier> gearMods = new List <Ability_Modifier>(); for (int i = 0; i < gearAbilities.Count; i++) { Ability_Modifier mod = gearAbilities[i] as Ability_Modifier; if (mod != null && mod.extent == ModExtent.Gear) { gearMods.Add(mod); } } // Get, modify, and add to returnVal the activated abilities // Uses the various Mods lists to know what can be applied to it for (int i = 0; i < gearAbilities.Count; i++) { Ability_Activated activated = gearAbilities[i] as Ability_Activated; if (activated == null) { continue; } List <Ability_Modifier> mods = new List <Ability_Modifier>(); AddMatchingMods(activated, mods, golemMods); AddMatchingMods(activated, mods, compartmentMods); AddMatchingMods(activated, mods, gearMods); moddedMap.Add(activated.GetModified(mods)); } } } return(moddedMap); }
// Searches modsFrom for any overlapping moddingAbilityTypes with the activated ability // Adds found mods to modsTo public void AddMatchingMods(Ability_Activated activated, List <Ability_Modifier> modsTo, List <Ability_Modifier> modsFrom) { modsTo.AddRange(modsFrom.FindAll(m => activated.HasMatchingModTypes(m))); }