2018-01-02 20:00:41 +00:00
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
public interface ILocation
|
|
|
|
|
{
|
2020-08-30 22:44:13 +00:00
|
|
|
|
int Location { get; }
|
|
|
|
|
int EggLocation { get; }
|
2018-01-02 20:00:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static partial class Extensions
|
|
|
|
|
{
|
|
|
|
|
public static int GetLocation(this ILocation encounter)
|
|
|
|
|
{
|
2018-05-12 15:13:39 +00:00
|
|
|
|
return encounter.Location != 0
|
|
|
|
|
? encounter.Location
|
2018-01-02 20:00:41 +00:00
|
|
|
|
: encounter.EggLocation;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-02-07 06:33:13 +00:00
|
|
|
|
public static string? GetEncounterLocation(this ILocation Encounter, int gen, int version = -1)
|
2018-01-02 20:00:41 +00:00
|
|
|
|
{
|
|
|
|
|
int loc = Encounter.GetLocation();
|
|
|
|
|
if (loc < 0)
|
|
|
|
|
return null;
|
2018-01-31 04:24:45 +00:00
|
|
|
|
|
2018-11-22 18:11:51 +00:00
|
|
|
|
bool egg = loc != Encounter.Location;
|
|
|
|
|
return GameInfo.GetLocationName(egg, loc, gen, gen, (GameVersion)version);
|
2018-01-02 20:00:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|