mirror of
https://github.com/kwsch/PKHeX
synced 2024-09-20 22:32:00 +00:00
Minor tweaks
Make HP IV set use single array fetch, less memory required add some xmldoc
This commit is contained in:
parent
778aacb9cf
commit
2f078e6565
6 changed files with 43 additions and 27 deletions
|
@ -157,8 +157,10 @@ namespace PKHeX.Core
|
|||
ivs[2] = (ivs[2] & ~3) | (type & 3);
|
||||
return ivs;
|
||||
}
|
||||
|
||||
var bits = DefaultLowBits[type];
|
||||
for (int i = 0; i < 6; i++)
|
||||
ivs[i] = (ivs[i] & 0x1E) + DefaultLowBits[type, i];
|
||||
ivs[i] = (ivs[i] & 0x1E) + ((bits >> i) & 1);
|
||||
return ivs;
|
||||
}
|
||||
|
||||
|
@ -170,24 +172,24 @@ namespace PKHeX.Core
|
|||
/// These are just precomputed for fast modification.
|
||||
/// Individual Values (H/A/B/S/C/D)
|
||||
/// </remarks>
|
||||
public static readonly byte[,] DefaultLowBits =
|
||||
public static readonly byte[] DefaultLowBits =
|
||||
{
|
||||
{ 1, 1, 0, 0, 0, 0 }, // Fighting
|
||||
{ 0, 0, 0, 1, 0, 0 }, // Flying
|
||||
{ 1, 1, 0, 1, 0, 0 }, // Poison
|
||||
{ 1, 1, 1, 1, 0, 0 }, // Ground
|
||||
{ 1, 1, 0, 0, 1, 0 }, // Rock
|
||||
{ 1, 0, 0, 1, 1, 0 }, // Bug
|
||||
{ 1, 0, 1, 1, 1, 0 }, // Ghost
|
||||
{ 1, 1, 1, 1, 1, 0 }, // Steel
|
||||
{ 1, 0, 1, 0, 0, 1 }, // Fire
|
||||
{ 1, 0, 0, 1, 0, 1 }, // Water
|
||||
{ 1, 0, 1, 1, 0, 1 }, // Grass
|
||||
{ 1, 1, 1, 1, 0, 1 }, // Electric
|
||||
{ 1, 0, 1, 0, 1, 1 }, // Psychic
|
||||
{ 1, 0, 0, 1, 1, 1 }, // Ice
|
||||
{ 1, 0, 1, 1, 1, 1 }, // Dragon
|
||||
{ 1, 1, 1, 1, 1, 1 }, // Dark
|
||||
0b000011, // Fighting
|
||||
0b001000, // Flying
|
||||
0b001011, // Poison
|
||||
0b001111, // Ground
|
||||
0b010011, // Rock
|
||||
0b011001, // Bug
|
||||
0b011101, // Ghost
|
||||
0b011111, // Steel
|
||||
0b100101, // Fire
|
||||
0b101001, // Water
|
||||
0b101101, // Grass
|
||||
0b101111, // Electric
|
||||
0b110101, // Psychic
|
||||
0b111001, // Ice
|
||||
0b111101, // Dragon
|
||||
0b111111, // Dark
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace PKHeX.Core
|
|||
/// <remarks>Refer to <see cref="EggSource6"/> for inheritance ordering.</remarks>
|
||||
public static class MoveBreed6
|
||||
{
|
||||
private const int level = 1;
|
||||
|
||||
public static EggSource6[] Validate(int generation, int species, int form, GameVersion version, int[] moves, out bool valid)
|
||||
{
|
||||
var count = Array.IndexOf(moves, 0);
|
||||
|
@ -28,7 +30,7 @@ namespace PKHeX.Core
|
|||
var learnset = learn[index];
|
||||
var egg = MoveEgg.GetEggMoves(generation, species, form, version);
|
||||
|
||||
var value = new BreedInfo<EggSource6>(count, learnset, moves, 1);
|
||||
var value = new BreedInfo<EggSource6>(count, learnset, moves, level);
|
||||
if (moves[count - 1] is (int)Move.VoltTackle)
|
||||
value.Actual[--count] = VoltTackle;
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace PKHeX.Core
|
|||
public List<int> EggMovesLearned { get; } = new();
|
||||
public List<int> LevelUpEggMoves { get; } = new();
|
||||
public List<int> EventEggMoves { get; } = new();
|
||||
public List<int> IncenseMoves { get; } = new();
|
||||
|
||||
public readonly MoveParseSource Source;
|
||||
public readonly bool IsGen2Pkm;
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that exposes a <see cref="Version"/> to see which version the data originated in.
|
||||
/// </summary>
|
||||
public interface IVersion
|
||||
{
|
||||
/// <summary>
|
||||
/// The version the data originated in.
|
||||
/// </summary>
|
||||
GameVersion Version { get; }
|
||||
}
|
||||
|
||||
|
|
|
@ -491,13 +491,14 @@ namespace PKHeX.Core
|
|||
get => 15 * HPBitValType / 63;
|
||||
set
|
||||
{
|
||||
var dlb = HiddenPower.DefaultLowBits;
|
||||
IV_HP = (IV_HP & ~1) + dlb[value, 0];
|
||||
IV_ATK = (IV_ATK & ~1) + dlb[value, 1];
|
||||
IV_DEF = (IV_DEF & ~1) + dlb[value, 2];
|
||||
IV_SPE = (IV_SPE & ~1) + dlb[value, 3];
|
||||
IV_SPA = (IV_SPA & ~1) + dlb[value, 4];
|
||||
IV_SPD = (IV_SPD & ~1) + dlb[value, 5];
|
||||
var arr = HiddenPower.DefaultLowBits;
|
||||
var bits = (uint)value >= arr.Length ? 0 : arr[value];
|
||||
IV_HP = (IV_HP & ~1) + ((bits >> 0) & 1);
|
||||
IV_ATK = (IV_ATK & ~1) + ((bits >> 1) & 1);
|
||||
IV_DEF = (IV_DEF & ~1) + ((bits >> 2) & 1);
|
||||
IV_SPE = (IV_SPE & ~1) + ((bits >> 3) & 1);
|
||||
IV_SPA = (IV_SPA & ~1) + ((bits >> 4) & 1);
|
||||
IV_SPD = (IV_SPD & ~1) + ((bits >> 5) & 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that exposes a <see cref="Generation"/> to see which canonical generation the data originated in.
|
||||
/// </summary>
|
||||
public interface IGeneration
|
||||
{
|
||||
/// <summary>
|
||||
/// The canonical generation the data originated in.
|
||||
/// </summary>
|
||||
int Generation { get; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue