mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-15 08:47:14 +00:00
Remove unnecessary abstraction
less objects with only 1 property/field, less objects created = faster
This commit is contained in:
parent
55c7bf9858
commit
e83f313281
3 changed files with 10 additions and 22 deletions
|
@ -8,21 +8,21 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
public sealed class EvolutionLineage
|
||||
{
|
||||
public readonly List<EvolutionStage> Chain = new List<EvolutionStage>();
|
||||
public readonly List<List<EvolutionMethod>> Chain = new List<List<EvolutionMethod>>();
|
||||
|
||||
public void Insert(EvolutionMethod entry)
|
||||
{
|
||||
int matchChain = -1;
|
||||
for (int i = 0; i < Chain.Count; i++)
|
||||
{
|
||||
if (Chain[i].StageEntryMethods.Any(e => e.Species == entry.Species))
|
||||
if (Chain[i].Any(e => e.Species == entry.Species))
|
||||
matchChain = i;
|
||||
}
|
||||
|
||||
if (matchChain != -1)
|
||||
Chain[matchChain].StageEntryMethods.Add(entry);
|
||||
Chain[matchChain].Add(entry);
|
||||
else
|
||||
Chain.Insert(0, new EvolutionStage { StageEntryMethods = new List<EvolutionMethod> {entry}});
|
||||
Chain.Insert(0, new List<EvolutionMethod> {entry});
|
||||
}
|
||||
|
||||
public List<EvoCriteria> GetExplicitLineage(PKM pkm, int maxLevel, bool skipChecks, int maxSpeciesTree, int maxSpeciesOrigin, int minLevel)
|
||||
|
@ -33,7 +33,7 @@ namespace PKHeX.Core
|
|||
for (int i = Chain.Count - 1; i >= 0; i--) // reverse evolution!
|
||||
{
|
||||
bool oneValid = false;
|
||||
foreach (var evo in Chain[i].StageEntryMethods)
|
||||
foreach (var evo in Chain[i])
|
||||
{
|
||||
if (!evo.Valid(pkm, lvl, skipChecks))
|
||||
continue;
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Evolution Stage Entries
|
||||
/// </summary>
|
||||
public struct EvolutionStage
|
||||
{
|
||||
public List<EvolutionMethod> StageEntryMethods;
|
||||
}
|
||||
}
|
|
@ -180,15 +180,15 @@ namespace PKHeX.Core
|
|||
|
||||
// Ban Raichu Evolution on SM
|
||||
Lineage[Personal.GetFormeIndex(26, 0)]
|
||||
.Chain[1].StageEntryMethods[0]
|
||||
.Chain[1][0]
|
||||
.Banlist = EvolutionMethod.BanSM;
|
||||
// Ban Exeggutor Evolution on SM
|
||||
Lineage[Personal.GetFormeIndex(103, 0)]
|
||||
.Chain[0].StageEntryMethods[0]
|
||||
.Chain[0][0]
|
||||
.Banlist = EvolutionMethod.BanSM;
|
||||
// Ban Marowak Evolution on SM
|
||||
Lineage[Personal.GetFormeIndex(105, 0)]
|
||||
.Chain[0].StageEntryMethods[0]
|
||||
.Chain[0][0]
|
||||
.Banlist = EvolutionMethod.BanSM;
|
||||
}
|
||||
|
||||
|
@ -245,9 +245,9 @@ namespace PKHeX.Core
|
|||
{
|
||||
int index = Personal.GetFormeIndex(species, form);
|
||||
var node = Lineage[index];
|
||||
foreach (var z in node.Chain)
|
||||
foreach (var methods in node.Chain)
|
||||
{
|
||||
foreach (var prevo in z.StageEntryMethods)
|
||||
foreach (var prevo in methods)
|
||||
yield return prevo.Species;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue