mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Switch slottype to flags
simplifies some logic, adds some documentation, speeds up loading very slightly
This commit is contained in:
parent
d7300ce68f
commit
f48afaf12d
4 changed files with 96 additions and 72 deletions
|
@ -79,7 +79,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
foreach (EncounterArea Area in Areas.Where(a => a.Location == location))
|
foreach (EncounterArea Area in Areas.Where(a => a.Location == location))
|
||||||
foreach (EncounterSlot Slot in Area.Slots)
|
foreach (EncounterSlot Slot in Area.Slots)
|
||||||
Slot.Type = Slot.Type.GetSafariSlotType3();
|
Slot.Type |= SlotType.Safari;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly int[] Roaming_MetLocation_FRLG =
|
private static readonly int[] Roaming_MetLocation_FRLG =
|
||||||
|
|
|
@ -148,7 +148,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
foreach (EncounterArea Area in Areas.Where(a => a.Location == location))
|
foreach (EncounterArea Area in Areas.Where(a => a.Location == location))
|
||||||
foreach (EncounterSlot Slot in Area.Slots)
|
foreach (EncounterSlot Slot in Area.Slots)
|
||||||
Slot.Type = Slot.Type.GetSafariSlotType4();
|
Slot.Type |= SlotType.Safari;
|
||||||
}
|
}
|
||||||
private static void MarkG4SwarmSlots(ref EncounterArea[] Areas, EncounterArea[] SwarmAreas)
|
private static void MarkG4SwarmSlots(ref EncounterArea[] Areas, EncounterArea[] SwarmAreas)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1377,9 +1377,7 @@ namespace PKHeX.Core
|
||||||
}
|
}
|
||||||
internal static bool IsSafariSlot(SlotType t)
|
internal static bool IsSafariSlot(SlotType t)
|
||||||
{
|
{
|
||||||
return t == SlotType.Grass_Safari || t == SlotType.Surf_Safari ||
|
return t.HasFlag(SlotType.Safari);
|
||||||
t == SlotType.Rock_Smash_Safari || t == SlotType.Pokeradar_Safari ||
|
|
||||||
t == SlotType.Old_Rod_Safari || t == SlotType.Good_Rod_Safari || t == SlotType.Super_Rod_Safari;
|
|
||||||
}
|
}
|
||||||
internal static bool IsDexNavValid(PKM pkm)
|
internal static bool IsDexNavValid(PKM pkm)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,84 +1,110 @@
|
||||||
namespace PKHeX.Core
|
using System;
|
||||||
|
|
||||||
|
namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wild Encounter data <see cref="EncounterSlot"/> Type
|
/// Wild Encounter data <see cref="EncounterSlot"/> Type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Different from <see cref="EncounterType"/>, this corresponds to the method that the <see cref="IEncounterable"/> may be encountered.</remarks>
|
/// Different from <see cref="EncounterType"/>, this corresponds to the method that the <see cref="IEncounterable"/> may be encountered.</remarks>
|
||||||
|
[Flags]
|
||||||
public enum SlotType
|
public enum SlotType
|
||||||
{
|
{
|
||||||
Any,
|
/// <summary>
|
||||||
Grass,
|
/// Default (un-assigned) encounter slot type.
|
||||||
Rough_Terrain,
|
/// </summary>
|
||||||
Yellow_Flowers,
|
Any = 0,
|
||||||
Purple_Flowers,
|
/// <summary>
|
||||||
Red_Flowers,
|
/// Slot is encountered via Grass.
|
||||||
Surf,
|
/// </summary>
|
||||||
Old_Rod,
|
Grass = 1 << 00,
|
||||||
Good_Rod,
|
/// <summary>
|
||||||
Super_Rod,
|
/// Slot is encountered via Surfing.
|
||||||
Rock_Smash,
|
/// </summary>
|
||||||
Horde,
|
Surf = 1 << 01,
|
||||||
FriendSafari,
|
/// <summary>
|
||||||
Special,
|
/// Slot is encountered via Old Rod (Fishing).
|
||||||
SOS,
|
/// </summary>
|
||||||
Swarm,
|
Old_Rod = 1 << 02,
|
||||||
Headbutt,
|
/// <summary>
|
||||||
Headbutt_Special,
|
/// Slot is encountered via Good Rod (Fishing).
|
||||||
Pokeradar,
|
/// </summary>
|
||||||
HoneyTree,
|
Good_Rod = 1 << 03,
|
||||||
HiddenGrotto,
|
/// <summary>
|
||||||
BugContest,
|
/// Slot is encountered via Super Rod (Fishing).
|
||||||
Grass_Safari,
|
/// </summary>
|
||||||
Surf_Safari,
|
Super_Rod = 1 << 04,
|
||||||
Old_Rod_Safari,
|
/// <summary>
|
||||||
Good_Rod_Safari,
|
/// Slot is encountered via Rock Smash.
|
||||||
Super_Rod_Safari,
|
/// </summary>
|
||||||
Rock_Smash_Safari,
|
Rock_Smash = 1 << 05,
|
||||||
Pokeradar_Safari
|
/// <summary>
|
||||||
|
/// Slot is encountered via a Horde.
|
||||||
|
/// </summary>
|
||||||
|
Horde = 1 << 06,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered via the Friend Safari.
|
||||||
|
/// </summary>
|
||||||
|
FriendSafari = 1 << 07,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered through special means. Used to signify special slots for Gen2, sometimes for later follow-up).
|
||||||
|
/// </summary>
|
||||||
|
Special = 1 << 08,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered via SOS signal.
|
||||||
|
/// </summary>
|
||||||
|
SOS = 1 << 09,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered in a Swarm.
|
||||||
|
/// </summary>
|
||||||
|
Swarm = 1 << 10,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered via Headbutt.
|
||||||
|
/// </summary>
|
||||||
|
Headbutt = 1 << 11,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered via the Poké Radar.
|
||||||
|
/// </summary>
|
||||||
|
Pokeradar = 1 << 12,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered via a Honey Tree.
|
||||||
|
/// </summary>
|
||||||
|
HoneyTree = 1 << 13,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered via a Hidden Grotto.
|
||||||
|
/// </summary>
|
||||||
|
HiddenGrotto = 1 << 14,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered via the Bug Catching Contest.
|
||||||
|
/// </summary>
|
||||||
|
BugContest = 1 << 15,
|
||||||
|
/// <summary>
|
||||||
|
/// Slot is encountered in the Safari Zone.
|
||||||
|
/// </summary>
|
||||||
|
Safari = 1 << 16, // always used as a modifier to another slot type
|
||||||
|
|
||||||
|
Rough_Terrain = 1 << 17,
|
||||||
|
Yellow_Flowers = 1 << 18,
|
||||||
|
Purple_Flowers = 1 << 19,
|
||||||
|
Red_Flowers = 1 << 20,
|
||||||
|
|
||||||
|
// Combined
|
||||||
|
Headbutt_Special = Headbutt | Special,
|
||||||
|
|
||||||
|
Grass_Safari = Grass | Safari,
|
||||||
|
Surf_Safari = Surf | Safari,
|
||||||
|
Old_Rod_Safari = Old_Rod | Safari,
|
||||||
|
Good_Rod_Safari = Good_Rod | Safari,
|
||||||
|
Super_Rod_Safari = Super_Rod | Safari,
|
||||||
|
Rock_Smash_Safari = Rock_Smash | Safari,
|
||||||
|
Pokeradar_Safari = Pokeradar | Safari,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static partial class Extensions
|
public static partial class Extensions
|
||||||
{
|
{
|
||||||
internal static SlotType GetSafariSlotType3(this SlotType t)
|
|
||||||
{
|
|
||||||
switch (t)
|
|
||||||
{
|
|
||||||
case SlotType.Grass: return SlotType.Grass_Safari;
|
|
||||||
case SlotType.Surf: return SlotType.Surf_Safari;
|
|
||||||
case SlotType.Old_Rod: return SlotType.Old_Rod_Safari;
|
|
||||||
case SlotType.Good_Rod: return SlotType.Good_Rod_Safari;
|
|
||||||
case SlotType.Super_Rod: return SlotType.Super_Rod_Safari;
|
|
||||||
case SlotType.Rock_Smash: return SlotType.Rock_Smash_Safari;
|
|
||||||
default: return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal static SlotType GetSafariSlotType4(this SlotType t)
|
|
||||||
{
|
|
||||||
switch (t)
|
|
||||||
{
|
|
||||||
case SlotType.Grass: return SlotType.Grass_Safari;
|
|
||||||
case SlotType.Surf: return SlotType.Surf_Safari;
|
|
||||||
case SlotType.Old_Rod: return SlotType.Old_Rod_Safari;
|
|
||||||
case SlotType.Good_Rod: return SlotType.Good_Rod_Safari;
|
|
||||||
case SlotType.Super_Rod: return SlotType.Super_Rod_Safari;
|
|
||||||
case SlotType.Pokeradar: return SlotType.Pokeradar_Safari;
|
|
||||||
default: return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal static bool IsFishingRodType(this SlotType t)
|
internal static bool IsFishingRodType(this SlotType t)
|
||||||
{
|
{
|
||||||
switch (t)
|
return t.HasFlag(SlotType.Old_Rod) || t.HasFlag(SlotType.Good_Rod) || t.HasFlag(SlotType.Super_Rod);
|
||||||
{
|
|
||||||
case SlotType.Old_Rod:
|
|
||||||
case SlotType.Good_Rod:
|
|
||||||
case SlotType.Super_Rod:
|
|
||||||
case SlotType.Old_Rod_Safari:
|
|
||||||
case SlotType.Good_Rod_Safari:
|
|
||||||
case SlotType.Super_Rod_Safari:
|
|
||||||
return true;
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue