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 (EncounterSlot Slot in Area.Slots)
|
||||
Slot.Type = Slot.Type.GetSafariSlotType3();
|
||||
Slot.Type |= SlotType.Safari;
|
||||
}
|
||||
|
||||
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 (EncounterSlot Slot in Area.Slots)
|
||||
Slot.Type = Slot.Type.GetSafariSlotType4();
|
||||
Slot.Type |= SlotType.Safari;
|
||||
}
|
||||
private static void MarkG4SwarmSlots(ref EncounterArea[] Areas, EncounterArea[] SwarmAreas)
|
||||
{
|
||||
|
|
|
@ -1377,9 +1377,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
internal static bool IsSafariSlot(SlotType t)
|
||||
{
|
||||
return t == SlotType.Grass_Safari || t == SlotType.Surf_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;
|
||||
return t.HasFlag(SlotType.Safari);
|
||||
}
|
||||
internal static bool IsDexNavValid(PKM pkm)
|
||||
{
|
||||
|
|
|
@ -1,84 +1,110 @@
|
|||
namespace PKHeX.Core
|
||||
using System;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Wild Encounter data <see cref="EncounterSlot"/> Type
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Different from <see cref="EncounterType"/>, this corresponds to the method that the <see cref="IEncounterable"/> may be encountered.</remarks>
|
||||
[Flags]
|
||||
public enum SlotType
|
||||
{
|
||||
Any,
|
||||
Grass,
|
||||
Rough_Terrain,
|
||||
Yellow_Flowers,
|
||||
Purple_Flowers,
|
||||
Red_Flowers,
|
||||
Surf,
|
||||
Old_Rod,
|
||||
Good_Rod,
|
||||
Super_Rod,
|
||||
Rock_Smash,
|
||||
Horde,
|
||||
FriendSafari,
|
||||
Special,
|
||||
SOS,
|
||||
Swarm,
|
||||
Headbutt,
|
||||
Headbutt_Special,
|
||||
Pokeradar,
|
||||
HoneyTree,
|
||||
HiddenGrotto,
|
||||
BugContest,
|
||||
Grass_Safari,
|
||||
Surf_Safari,
|
||||
Old_Rod_Safari,
|
||||
Good_Rod_Safari,
|
||||
Super_Rod_Safari,
|
||||
Rock_Smash_Safari,
|
||||
Pokeradar_Safari
|
||||
/// <summary>
|
||||
/// Default (un-assigned) encounter slot type.
|
||||
/// </summary>
|
||||
Any = 0,
|
||||
/// <summary>
|
||||
/// Slot is encountered via Grass.
|
||||
/// </summary>
|
||||
Grass = 1 << 00,
|
||||
/// <summary>
|
||||
/// Slot is encountered via Surfing.
|
||||
/// </summary>
|
||||
Surf = 1 << 01,
|
||||
/// <summary>
|
||||
/// Slot is encountered via Old Rod (Fishing).
|
||||
/// </summary>
|
||||
Old_Rod = 1 << 02,
|
||||
/// <summary>
|
||||
/// Slot is encountered via Good Rod (Fishing).
|
||||
/// </summary>
|
||||
Good_Rod = 1 << 03,
|
||||
/// <summary>
|
||||
/// Slot is encountered via Super Rod (Fishing).
|
||||
/// </summary>
|
||||
Super_Rod = 1 << 04,
|
||||
/// <summary>
|
||||
/// Slot is encountered via Rock Smash.
|
||||
/// </summary>
|
||||
Rock_Smash = 1 << 05,
|
||||
/// <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
|
||||
{
|
||||
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)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
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;
|
||||
}
|
||||
return t.HasFlag(SlotType.Old_Rod) || t.HasFlag(SlotType.Good_Rod) || t.HasFlag(SlotType.Super_Rod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue