mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-30 07:50:32 +00:00
88830e0d00
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now. Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes. Adds functionality for Batch Editor commands to `>`, `<` and <=/>= TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants. Main window has a new layout to account for DPI scaling (8 point grid) Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724) Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720) Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714) Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691) Added: Properties for ribbon/mark count (closes #3659) Fixed: Traded SV eggs are now checked correctly (closes #3692)
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
public static partial class Util
|
|
{
|
|
public static Random Rand => Random.Shared;
|
|
|
|
public static uint Rand32() => Rand32(Rand);
|
|
public static uint Rand32(this Random rnd) => ((uint)rnd.Next(1 << 30) << 2) | (uint)rnd.Next(1 << 2);
|
|
public static ulong Rand64(this Random rnd) => rnd.Rand32() | ((ulong)rnd.Rand32() << 32);
|
|
|
|
/// <summary>
|
|
/// Shuffles the order of items within a collection of items.
|
|
/// </summary>
|
|
/// <typeparam name="T">Item type</typeparam>
|
|
/// <param name="items">Item collection</param>
|
|
public static void Shuffle<T>(Span<T> items) => Shuffle(items, 0, items.Length, Rand);
|
|
|
|
/// <summary>
|
|
/// Shuffles the order of items within a collection of items.
|
|
/// </summary>
|
|
/// <typeparam name="T">Item type</typeparam>
|
|
/// <param name="items">Item collection</param>
|
|
/// <param name="start">Starting position</param>
|
|
/// <param name="end">Ending position</param>
|
|
/// <param name="rnd">RNG object to use</param>
|
|
public static void Shuffle<T>(Span<T> items, int start, int end, Random rnd)
|
|
{
|
|
for (int i = start; i < end; i++)
|
|
{
|
|
int index = i + rnd.Next(end - i);
|
|
(items[index], items[i]) = (items[i], items[index]);
|
|
}
|
|
}
|
|
}
|