mirror of
https://github.com/thebreaddev/Supercell.GUT.git
synced 2024-11-14 01:14:37 +00:00
8c6a533918
todo: improve code and finish base structures
37 lines
792 B
C#
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;
|
|
}
|
|
}
|