private Climate.WeatherState GetWeatherState(uint seed) { int num1 = (int)SeedRandom.Wanghash(ref seed); bool flag1 = (double)SeedRandom.Value(ref seed) < (double)this.Weather.CloudChance; bool flag2 = (double)SeedRandom.Value(ref seed) < (double)this.Weather.FogChance; bool flag3 = (double)SeedRandom.Value(ref seed) < (double)this.Weather.RainChance; int num2 = (double)SeedRandom.Value(ref seed) < (double)this.Weather.StormChance ? 1 : 0; float num3 = flag1 ? SeedRandom.Value(ref seed) : 0.0f; float num4 = flag2 ? 1f : 0.0f; float num5 = flag3 ? 1f : 0.0f; float num6 = num2 != 0 ? SeedRandom.Value(ref seed) : 0.0f; if ((double)num5 > 0.0) { num5 = Mathf.Max(num5, 0.5f); num4 = Mathf.Max(num4, num5); num3 = Mathf.Max(num3, num5); } return(new Climate.WeatherState() { Clouds = num3, Fog = num4, Wind = num6, Rain = num5 }); }
public void Tick() { double num1 = 10000000.0 * (1440.0 / (double)SynchronizedClock.DayLengthInMinutes); for (int index = 0; index < this.events.Count; ++index) { SynchronizedClock.TimedEvent timedEvent = this.events[index]; long ticks1 = timedEvent.ticks; long ticks2 = SynchronizedClock.Ticks; long num2 = (long)((double)timedEvent.delta * num1); long num3 = ticks1 / num2 * num2; uint num4 = (uint)((ulong)num3 % (ulong)uint.MaxValue); int num5 = (int)SeedRandom.Wanghash(ref num4); long num6 = (long)((double)SeedRandom.Range(ref num4, -timedEvent.variance, timedEvent.variance) * num1); long num7 = num3 + num2 + num6; if (ticks1 < num7 && ticks2 >= num7) { timedEvent.action(num4); timedEvent.ticks = ticks2; } else if (ticks2 > ticks1 || ticks2 < num3) { timedEvent.ticks = ticks2; } this.events[index] = timedEvent; } }
public void Tick() { long num = (long)10000000; double dayLengthInMinutes = 1440 / (double)SynchronizedClock.DayLengthInMinutes; double num1 = (double)num * dayLengthInMinutes; for (int i = 0; i < this.events.Count; i++) { SynchronizedClock.TimedEvent item = this.events[i]; long num2 = item.ticks; long ticks = SynchronizedClock.Ticks; long num3 = (long)((double)item.delta * num1); long num4 = num2 / num3 * num3; uint num5 = (uint)(num4 % (ulong)-1); SeedRandom.Wanghash(ref num5); long num6 = (long)((double)SeedRandom.Range(ref num5, -item.variance, item.variance) * num1); long num7 = num4 + num3 + num6; if (num2 < num7 && ticks >= num7) { item.action(num5); item.ticks = ticks; } else if (ticks > num2 || ticks < num4) { item.ticks = ticks; } this.events[i] = item; } }
private uint GetSeedFromLong(long val) { uint x = (uint)((val % 4294967295L + uint.MaxValue) % 4294967295L); SeedRandom.Wanghash(ref x); SeedRandom.Wanghash(ref x); SeedRandom.Wanghash(ref x); return(x); }
private Climate.WeatherState GetWeatherState(uint seed) { object obj; object obj1; SeedRandom.Wanghash(ref seed); bool flag = SeedRandom.Value(ref seed) < this.Weather.CloudChance; bool flag1 = SeedRandom.Value(ref seed) < this.Weather.FogChance; bool flag2 = SeedRandom.Value(ref seed) < this.Weather.RainChance; bool flag3 = SeedRandom.Value(ref seed) < this.Weather.StormChance; float single = (flag ? SeedRandom.Value(ref seed) : 0f); if (flag1) { obj = 1; } else { obj = null; } float single1 = (float)obj; if (flag2) { obj1 = 1; } else { obj1 = null; } float single2 = (float)obj1; float single3 = (flag3 ? SeedRandom.Value(ref seed) : 0f); if (single2 > 0f) { single2 = Mathf.Max(single2, 0.5f); single1 = Mathf.Max(single1, single2); single = Mathf.Max(single, single2); } Climate.WeatherState weatherState = new Climate.WeatherState() { Clouds = single, Fog = single1, Wind = single3, Rain = single2 }; return(weatherState); }
public static float Wanghash01(ref uint x) { return((float)((float)SeedRandom.Wanghash(ref x)) * 2.32830644E-10f); }