mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-19 15:51:58 +00:00
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using HarmonyLib;
|
|
|
|
namespace EHR;
|
|
|
|
[HarmonyPatch(typeof(HashRandom))]
|
|
internal class HashRandomPatch
|
|
{
|
|
[HarmonyPatch(nameof(HashRandom.FastNext))]
|
|
[HarmonyPrefix]
|
|
private static bool FastNext([HarmonyArgument(0)] int maxInt, ref int __result)
|
|
{
|
|
if (IRandom.Instance is HashRandomWrapper) return true;
|
|
|
|
__result = IRandom.Instance.Next(maxInt);
|
|
|
|
return false;
|
|
}
|
|
|
|
[HarmonyPatch(nameof(HashRandom.Next), typeof(int))]
|
|
[HarmonyPrefix]
|
|
private static bool MaxNext([HarmonyArgument(0)] int maxInt, ref int __result)
|
|
{
|
|
if (IRandom.Instance is HashRandomWrapper) return true;
|
|
|
|
__result = IRandom.Instance.Next(maxInt);
|
|
|
|
return false;
|
|
}
|
|
|
|
[HarmonyPatch(nameof(HashRandom.Next), typeof(int), typeof(int))]
|
|
[HarmonyPrefix]
|
|
private static bool MinMaxNext([HarmonyArgument(0)] int minInt, [HarmonyArgument(1)] int maxInt, ref int __result)
|
|
{
|
|
if (IRandom.Instance is HashRandomWrapper) return true;
|
|
|
|
__result = IRandom.Instance.Next(minInt, maxInt);
|
|
|
|
return false;
|
|
}
|
|
} |