PKHeX/PKHeX.Core/Legality/Evolutions/EvolutionHistory.cs
Kurt 6d4cd60461 More fixes/improvements
Improve cctor times for Breeding; direct calls for splitbreed checks; inlined binary searches via generated IL instead of hashset
Fix permitting alpha ribbon on non-alphas in Gen8/8a/8b, disallow Gen8a/8b ribbons for Gen7 Alolan Raichu
Improve some IL generation of EvoChain logic
Add xmldoc for new evotree additions
2023-07-08 12:46:46 -07:00

67 lines
2.2 KiB
C#

using System;
namespace PKHeX.Core;
/// <summary>
/// Stores the possible evolution bounds for a parsed entity with respect to its origins and game traversal.
/// </summary>
public sealed class EvolutionHistory
{
private static readonly EvoCriteria[] NONE = Array.Empty<EvoCriteria>();
public EvoCriteria[] Gen1 = NONE;
public EvoCriteria[] Gen2 = NONE;
public EvoCriteria[] Gen3 = NONE;
public EvoCriteria[] Gen4 = NONE;
public EvoCriteria[] Gen5 = NONE;
public EvoCriteria[] Gen6 = NONE;
public EvoCriteria[] Gen7 = NONE;
public EvoCriteria[] Gen8 = NONE;
public EvoCriteria[] Gen9 = NONE;
public EvoCriteria[] Gen7b = NONE;
public EvoCriteria[] Gen8a = NONE;
public EvoCriteria[] Gen8b = NONE;
public bool HasVisitedGen1 => Gen1.Length != 0;
public bool HasVisitedGen2 => Gen2.Length != 0;
public bool HasVisitedGen3 => Gen3.Length != 0;
public bool HasVisitedGen4 => Gen4.Length != 0;
public bool HasVisitedGen5 => Gen5.Length != 0;
public bool HasVisitedGen6 => Gen6.Length != 0;
public bool HasVisitedGen7 => Gen7.Length != 0;
public bool HasVisitedSWSH => Gen8.Length != 0;
public bool HasVisitedGen9 => Gen9.Length != 0;
public bool HasVisitedLGPE => Gen7b.Length != 0;
public bool HasVisitedPLA => Gen8a.Length != 0;
public bool HasVisitedBDSP => Gen8b.Length != 0;
public ReadOnlySpan<EvoCriteria> Get(EntityContext context) => context switch
{
EntityContext.Gen1 => Gen1,
EntityContext.Gen2 => Gen2,
EntityContext.Gen3 => Gen3,
EntityContext.Gen4 => Gen4,
EntityContext.Gen5 => Gen5,
EntityContext.Gen6 => Gen6,
EntityContext.Gen7 => Gen7,
EntityContext.Gen8 => Gen8,
EntityContext.Gen9 => Gen9,
EntityContext.Gen7b => Gen7b,
EntityContext.Gen8a => Gen8a,
EntityContext.Gen8b => Gen8b,
_ => throw new ArgumentOutOfRangeException(nameof(context), context, null),
};
public static bool HasVisited(in ReadOnlySpan<EvoCriteria> evos, ushort species)
{
foreach (ref readonly var evo in evos)
{
if (evo.Species == species)
return true;
}
return false;
}
}