Supercell.GUT/Supercell.GUT.Titan/Logic/Math/LogicRandom.cs

38 lines
792 B
C#
Raw Normal View History

namespace Supercell.GUT.Titan.Logic.Math;
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;
}
}