mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-13 18:25:24 -05:00
Extend core api
add copy/fetch new
This commit is contained in:
@@ -7,4 +7,9 @@ internal interface IGeneration
|
||||
{
|
||||
int Generation { get; set; }
|
||||
}
|
||||
|
||||
public static partial class Extensions
|
||||
{
|
||||
internal static PKM GetBlank(this IGeneration gen) => PKMConverter.GetBlank(gen.Generation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,21 @@ public interface ITrainerInfo
|
||||
|
||||
int Generation { get; }
|
||||
}
|
||||
|
||||
public static partial class Extensions
|
||||
{
|
||||
public static void ApplyToPKM(this ITrainerInfo info, PKM pk)
|
||||
{
|
||||
pk.OT_Name = info.OT;
|
||||
pk.TID = info.TID;
|
||||
pk.SID = info.SID;
|
||||
pk.OT_Gender = info.Gender;
|
||||
pk.Language = info.Language;
|
||||
pk.Version = info.Game;
|
||||
|
||||
pk.Country = info.Country;
|
||||
pk.Region = info.SubRegion;
|
||||
pk.ConsoleRegion = info.ConsoleRegion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -458,5 +458,10 @@ public static PKM GetBlank(Type t)
|
||||
var argCount = constructors.First().GetParameters().Length;
|
||||
return (PKM)Activator.CreateInstance(t, new object[argCount]);
|
||||
}
|
||||
public static PKM GetBlank(int gen)
|
||||
{
|
||||
var type = Type.GetType($"PKHeX.Core.PK{gen}");
|
||||
return GetBlank(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user