Supercell.GUT/Supercell.GUT.Titan/Logic/Math/LogicRandom.cs
BreadDEV 8c6a533918 [v0.0.2] you can enter menu now. but still early state
todo: improve code and finish base structures
2024-03-05 17:37:18 +07:00

37 lines
792 B
C#

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;
}
}