mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-02 08:49:18 +00:00
f632aedd15
We implement simple state machine iterators to iterate through every split type encounter array, and more finely control the path we iterate through. And, by using generics, we can have the compiler generate optimized code to avoid virtual calls. In addition to this, we shift away from the big-5 encounter types and not inherit from an abstract class. This allows for creating a PK* of a specific type and directly writing properties (no virtual calls). Plus we can now fine-tune each encounter type to call specific code, and not have to worry about future game encounter types bothering the generation routines.
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Exposes details about the 3DS Console geolocation settings the trainer has set.
|
|
/// </summary>
|
|
public interface IRegionOrigin
|
|
{
|
|
/// <summary> Console hardware region. </summary>
|
|
/// <see cref="Region3DSIndex"/>
|
|
byte ConsoleRegion { get; set; }
|
|
/// <summary> Console's configured Country via System Settings. </summary>
|
|
byte Country { get; set; }
|
|
/// <summary> Console's configured Region within <see cref="Country"/> via System Settings. </summary>
|
|
byte Region { get; set; }
|
|
}
|
|
|
|
public static partial class Extensions
|
|
{
|
|
public static void SetDefaultRegionOrigins(this IRegionOrigin o, int language)
|
|
{
|
|
if (language == 1)
|
|
{
|
|
o.ConsoleRegion = 0; // Japan
|
|
o.Country = 1; // Japan
|
|
o.Region = 0;
|
|
}
|
|
else
|
|
{
|
|
o.ConsoleRegion = 1; // North America
|
|
o.Country = 49; // USA
|
|
o.Region = 7; // California
|
|
}
|
|
}
|
|
|
|
public static void CopyRegionOrigin(this IRegionOrigin source, IRegionOrigin dest)
|
|
{
|
|
dest.ConsoleRegion = source.ConsoleRegion;
|
|
dest.Country = source.Country;
|
|
dest.Region = source.Region;
|
|
}
|
|
|
|
public static void ClearRegionOrigin(this IRegionOrigin o)
|
|
{
|
|
o.ConsoleRegion = o.Region = o.Country = 0;
|
|
}
|
|
}
|