mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-22 20:13:06 +00:00
Change some field types, reduce memory usage
This commit is contained in:
parent
2991f62052
commit
50828fa1bb
9 changed files with 34 additions and 30 deletions
|
@ -6,7 +6,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Intermediary Representation of Dream World Data
|
||||
/// </summary>
|
||||
internal record DreamWorldEntry(int Species, int Level, int Move1 = 0, int Move2 = 0, int Move3 = 0, int Form = 0, int Gender = -1)
|
||||
internal record DreamWorldEntry(int Species, int Level, ushort Move1 = 0, ushort Move2 = 0, ushort Move3 = 0, byte Form = 0, sbyte Gender = -1)
|
||||
{
|
||||
private int EntryCount => Move1 == 0 ? 1 : Move2 == 0 ? 1 : Move3 == 0 ? 2 : 3;
|
||||
|
||||
|
|
|
@ -21,22 +21,24 @@ namespace PKHeX.Core
|
|||
public virtual int Location { get; init; }
|
||||
public AbilityPermission Ability { get; init; }
|
||||
public Shiny Shiny { get; init; } = Shiny.Random;
|
||||
public int Gender { get; init; } = -1;
|
||||
public int EggLocation { get; init; }
|
||||
public Nature Nature { get; init; } = Nature.Random;
|
||||
public sbyte Gender { get; init; } = -1;
|
||||
|
||||
public ushort HeldItem { get; init; }
|
||||
public bool Gift { get; init; }
|
||||
public int Ball { get; init; } = 4; // Only checked when is Gift
|
||||
public bool Fateful { get; init; }
|
||||
|
||||
public byte EggCycles { get; init; }
|
||||
public byte FlawlessIVCount { get; init; }
|
||||
public byte Ball { get; init; } = 4; // Only checked when is Gift
|
||||
|
||||
public int EggLocation { get; init; }
|
||||
|
||||
public Ball FixedBall => Gift ? (Ball)Ball : Core.Ball.None;
|
||||
|
||||
public IReadOnlyList<int> Moves { get; init; } = Array.Empty<int>();
|
||||
public IReadOnlyList<int> IVs { get; init; } = Array.Empty<int>();
|
||||
public int FlawlessIVCount { get; init; }
|
||||
|
||||
public int HeldItem { get; init; }
|
||||
public int EggCycles { get; init; }
|
||||
|
||||
public bool Fateful { get; init; }
|
||||
public bool EggEncounter => EggLocation > 0;
|
||||
|
||||
private const string _name = "Static Encounter";
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{
|
||||
public override int Generation => 4;
|
||||
|
||||
public EncounterStatic4Pokewalker(int species, int gender, int level) : base(GameVersion.HGSS)
|
||||
public EncounterStatic4Pokewalker(int species, sbyte gender, int level) : base(GameVersion.HGSS)
|
||||
{
|
||||
Species = species;
|
||||
Gender = gender;
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace PKHeX.Core
|
|||
Fateful = mew,
|
||||
Location = Locations.Transfer1,
|
||||
Level = metLevel,
|
||||
FlawlessIVCount = mew ? 5 : 3,
|
||||
FlawlessIVCount = mew ? (byte)5 : (byte)3,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace PKHeX.Core
|
|||
Fateful = fateful,
|
||||
Location = Locations.Transfer2,
|
||||
Level = metLevel,
|
||||
FlawlessIVCount = fateful ? 5 : 3,
|
||||
FlawlessIVCount = fateful ? (byte)5 : (byte)3,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public sealed record EncounterStatic8a(GameVersion Version) : EncounterStatic(Ve
|
|||
return new OverworldParam8a
|
||||
{
|
||||
IsAlpha = IsAlpha,
|
||||
FlawlessIVs = (byte)FlawlessIVCount,
|
||||
FlawlessIVs = FlawlessIVCount,
|
||||
Shiny = Shiny,
|
||||
RollCount = 1, // Everything is shiny locked anyways
|
||||
GenderRatio = gender,
|
||||
|
|
|
@ -17,42 +17,44 @@ namespace PKHeX.Core
|
|||
public int Level { get; init; }
|
||||
public virtual int LevelMin => Level;
|
||||
public int LevelMax => 100;
|
||||
public IReadOnlyList<int> Moves { get; init; } = Array.Empty<int>();
|
||||
public abstract int Generation { get; }
|
||||
|
||||
public int CurrentLevel { get; init; } = -1;
|
||||
public abstract int Location { get; }
|
||||
|
||||
public AbilityPermission Ability { get; init; }
|
||||
public int Gender { get; init; } = -1;
|
||||
public Nature Nature { get; init; } = Nature.Random;
|
||||
public Shiny Shiny { get; init; } = Shiny.Never;
|
||||
public int Ball { get; init; } = 4;
|
||||
public sbyte Gender { get; init; } = -1;
|
||||
|
||||
public Ball FixedBall => (Ball)Ball;
|
||||
public sbyte OTGender { get; init; } = -1;
|
||||
public bool IsNicknamed { get; init; } = true;
|
||||
public bool EvolveOnTrade { get; init; }
|
||||
public byte Ball { get; init; } = 4;
|
||||
|
||||
public int TID { get; init; }
|
||||
public int SID { get; init; }
|
||||
public int OTGender { get; init; } = -1;
|
||||
public int EggLocation { get; init; }
|
||||
|
||||
public ushort TID { get; init; }
|
||||
public ushort SID { get; init; }
|
||||
|
||||
public IReadOnlyList<int> Moves { get; init; } = Array.Empty<int>();
|
||||
public IReadOnlyList<int> IVs { get; init; } = Array.Empty<int>();
|
||||
|
||||
public Ball FixedBall => (Ball)Ball;
|
||||
public bool EggEncounter => false;
|
||||
public int EggLocation { get; init; }
|
||||
public bool EvolveOnTrade { get; init; }
|
||||
|
||||
public int TID7
|
||||
{
|
||||
init
|
||||
{
|
||||
TID = (ushort) value;
|
||||
SID = value >> 16;
|
||||
SID = (ushort)(value >> 16);
|
||||
}
|
||||
}
|
||||
|
||||
private const string _name = "In-game Trade";
|
||||
public string Name => _name;
|
||||
public string LongName => _name;
|
||||
public bool IsNicknamed { get; init; } = true;
|
||||
public bool IsShiny => Shiny.IsShiny();
|
||||
|
||||
public IReadOnlyList<string> Nicknames { get; internal set; } = Array.Empty<string>();
|
||||
|
@ -90,7 +92,7 @@ namespace PKHeX.Core
|
|||
pk.Form = Form;
|
||||
pk.Language = lang;
|
||||
pk.OT_Name = pk.Format == 1 ? StringConverter12.G1TradeOTStr : HasTrainerName ? GetOT(lang) : sav.OT;
|
||||
pk.OT_Gender = HasTrainerName ? Math.Max(0, OTGender) : sav.Gender;
|
||||
pk.OT_Gender = HasTrainerName ? Math.Max(0, (int)OTGender) : sav.Gender;
|
||||
pk.SetNickname(HasNickname ? GetNickname(lang) : string.Empty);
|
||||
|
||||
pk.CurrentLevel = level;
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace PKHeX.Core
|
|||
public override int Generation => 2;
|
||||
public override int Location => Locations.LinkTrade2NPC;
|
||||
|
||||
public EncounterTrade2(int species, int level, int tid) : base(species, level, GameVersion.GSC)
|
||||
public EncounterTrade2(int species, int level, ushort tid) : base(species, level, GameVersion.GSC)
|
||||
{
|
||||
TID = tid;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace PKHeX.Core
|
|||
{
|
||||
public override int Generation => 8;
|
||||
public override int Location => Locations.LinkTrade6NPC;
|
||||
public IReadOnlyList<int> Relearn { get; init; } = Array.Empty<int>();
|
||||
|
||||
public byte DynamaxLevel { get; set; }
|
||||
public int FlawlessIVCount { get; init; }
|
||||
public IReadOnlyList<int> Relearn { get; init; } = Array.Empty<int>();
|
||||
public byte FlawlessIVCount { get; init; }
|
||||
|
||||
public int OT_Memory { get; set; }
|
||||
public int OT_TextVar { get; set; }
|
||||
|
|
|
@ -215,8 +215,8 @@ public static class SpriteUtil
|
|||
public static int GetDisplayGender(IEncounterTemplate enc) => enc switch
|
||||
{
|
||||
EncounterSlotGO g => (int)g.Gender & 1,
|
||||
EncounterStatic s => Math.Max(0, s.Gender),
|
||||
EncounterTrade t => Math.Max(0, t.Gender),
|
||||
EncounterStatic s => Math.Max(0, (int)s.Gender),
|
||||
EncounterTrade t => Math.Max(0, (int)t.Gender),
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue