123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- // using System;
- //
- //
- // namespace CombatLibrary.CombatLibrary.CombatCore.Utility
- // {
- // public class CombatRandom
- // {
- // // private const int MBIG = 2147483647;
- // // private const int MSEED = 161803398;
- // // private const int MZ = 0;
- // public int inext;
- // public int inextp;
- // private int[] SeedArray = new int[56];
- //
- // public int randCount;
- //
- // public CombatRandom()
- // : this(Environment.TickCount)
- // {
- // }
- //
- //
- // public CombatRandom(int Seed)
- // {
- // int num1 = 161803398 - (Seed == int.MinValue ? int.MaxValue : Math.Abs(Seed));
- // this.SeedArray[55] = num1;
- // int num2 = 1;
- // for (int index1 = 1; index1 < 55; ++index1)
- // {
- // int index2 = 21 * index1 % 55;
- // this.SeedArray[index2] = num2;
- // num2 = num1 - num2;
- // if (num2 < 0)
- // num2 += int.MaxValue;
- // num1 = this.SeedArray[index2];
- // }
- //
- // for (int index3 = 1; index3 < 5; ++index3)
- // {
- // for (int index4 = 1; index4 < 56; ++index4)
- // {
- // this.SeedArray[index4] -= this.SeedArray[1 + (index4 + 30) % 55];
- // if (this.SeedArray[index4] < 0)
- // this.SeedArray[index4] += int.MaxValue;
- // }
- // }
- //
- // this.inext = 0;
- // this.inextp = 21;
- // Seed = 1;
- // }
- //
- // protected virtual float Sample() => this.InternalSample() * (float)4.6566128752458E-10;
- //
- // private int InternalSample()
- // {
- // int inext = this.inext;
- // int inextp = this.inextp;
- // int index1;
- // if ((index1 = inext + 1) >= 56)
- // index1 = 1;
- // int index2;
- // if ((index2 = inextp + 1) >= 56)
- // index2 = 1;
- // int num = this.SeedArray[index1] - this.SeedArray[index2]+randCount;
- // if (num == int.MaxValue)
- // --num;
- // if (num < 0)
- // num += int.MaxValue;
- // // this.SeedArray[index1] = num;
- // this.inext = index1;
- // this.inextp = index2;
- // randCount+=1000000;
- // if (randCount < 0)
- // {
- //
- // randCount = 0;
- // }
- //
- // return num;
- // }
- //
- //
- // public virtual int Next() => this.InternalSample();
- //
- // private float GetSampleForLargeRange()
- // {
- // int num = this.InternalSample();
- // if (this.InternalSample() % 2 == 0)
- // num = -num;
- // return (num + (float)2147483646.0) / (float)4294967293.0;
- // }
- //
- //
- // public virtual int Next(int minValue, int maxValue)
- // {
- // if (minValue > maxValue)
- // throw new ArgumentOutOfRangeException(("Argument_MinMaxValue"));
- // long num = (long) maxValue - (long) minValue;
- // return num <= (long) int.MaxValue ? (int) (this.Sample() * num) + minValue : (int) ((long) (this.GetSampleForLargeRange() * num) + (long) minValue);
- // }
- //
- //
- // public virtual int Next(int maxValue)
- // {
- // if (maxValue < 0)
- // throw new ArgumentOutOfRangeException("ArgumentOutOfRange_MustBePositive");
- // return (int) (this.Sample() *maxValue);
- // }
- //
- //
- //
- //
- // public virtual void NextBytes(byte[] buffer)
- // {
- // if (buffer == null)
- // throw new ArgumentNullException(nameof(buffer));
- // for (int index = 0; index < buffer.Length; ++index)
- // buffer[index] = (byte) (this.InternalSample() % 256);
- // }
- // }
- // }
|