namespace PKHeX.Core;
///
/// Exposes details about an encounter with a specific location ID required.
///
public interface ILocation
{
///
/// Met Location ID the encounter is found at.
///
int Location { get; }
///
/// Egg Location ID the encounter is obtained with.
///
int EggLocation { get; }
}
public static partial class Extensions
{
public static int GetLocation(this ILocation enc)
{
return enc.Location != 0
? enc.Location
: enc.EggLocation;
}
public static string? GetEncounterLocation(this ILocation enc, int gen, int version = -1)
{
int loc = enc.GetLocation();
if (loc < 0)
return null;
bool egg = loc != enc.Location;
return GameInfo.GetLocationName(egg, loc, gen, gen, (GameVersion)version);
}
}