2024-03-05 10:37:18 +00:00
|
|
|
|
namespace Supercell.GUT.Titan.Logic.Math;
|
2024-03-04 13:19:32 +00:00
|
|
|
|
|
|
|
|
|
public class LogicRandom
|
|
|
|
|
{
|
|
|
|
|
public int IteratedRandomSeed { get; set; }
|
|
|
|
|
|
|
|
|
|
public LogicRandom()
|
|
|
|
|
{
|
|
|
|
|
this.IteratedRandomSeed = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Destruct()
|
|
|
|
|
{
|
|
|
|
|
this.IteratedRandomSeed = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Rand(int max)
|
|
|
|
|
{
|
|
|
|
|
if (max >= 1)
|
|
|
|
|
{
|
|
|
|
|
int v3 = this.IteratedRandomSeed;
|
|
|
|
|
if (this.IteratedRandomSeed == 0)
|
|
|
|
|
v3 = -1;
|
|
|
|
|
int v4 = v3 ^ (v3 << 13) ^ ((v3 ^ (v3 << 13)) >> 0x11);
|
|
|
|
|
int v5 = v4 ^ (32 * v4);
|
|
|
|
|
this.IteratedRandomSeed = v5;
|
|
|
|
|
int temp;
|
|
|
|
|
if (v5 > -1)
|
|
|
|
|
temp = v5;
|
|
|
|
|
else
|
|
|
|
|
temp = -v5;
|
|
|
|
|
return temp % max;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|