2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
public interface ILocation
|
2018-01-02 20:00:41 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
int Location { get; }
|
|
|
|
|
int EggLocation { get; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static partial class Extensions
|
|
|
|
|
{
|
|
|
|
|
public static int GetLocation(this ILocation encounter)
|
2018-01-02 20:00:41 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
return encounter.Location != 0
|
|
|
|
|
? encounter.Location
|
|
|
|
|
: encounter.EggLocation;
|
2018-01-02 20:00:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public static string? GetEncounterLocation(this ILocation Encounter, int gen, int version = -1)
|
2018-01-02 20:00:41 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
int loc = Encounter.GetLocation();
|
|
|
|
|
if (loc < 0)
|
|
|
|
|
return null;
|
2018-01-31 04:24:45 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
bool egg = loc != Encounter.Location;
|
|
|
|
|
return GameInfo.GetLocationName(egg, loc, gen, gen, (GameVersion)version);
|
2018-01-02 20:00:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|