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;
        }
    }
    protected void Start()
    {
        uint num = base.transform.position.Seed(World.Seed + this.Seed);

        if (SeedRandom.Value(ref num) > this.Probability)
        {
            for (int i = 0; i < (int)this.Candidates.Length; i++)
            {
                GameManager.Destroy(this.Candidates[i], 0f);
            }
            GameManager.Destroy(this, 0f);
            return;
        }
        int num1 = SeedRandom.Range(num, 0, base.transform.childCount);

        for (int j = 0; j < (int)this.Candidates.Length; j++)
        {
            GameObject candidates = this.Candidates[j];
            if (j != num1)
            {
                GameManager.Destroy(candidates, 0f);
            }
            else
            {
                candidates.SetActive(true);
            }
        }
        GameManager.Destroy(this, 0f);
    }
Пример #4
0
    public virtual void LoadoutPlayer(BasePlayer player)
    {
        PlayerInventoryProperties playerInventoryProperties;

        if (IsTeamGame())
        {
            if (player.gamemodeteam == -1)
            {
                Debug.LogWarning("Player loading out without team assigned, auto assigning!");
                AutoAssignTeam(player);
            }
            playerInventoryProperties = teams[player.gamemodeteam].teamloadouts[SeedRandom.Range((uint)player.userID, 0, teams[player.gamemodeteam].teamloadouts.Length)];
        }
        else
        {
            playerInventoryProperties = loadouts[SeedRandom.Range((uint)player.userID, 0, loadouts.Length)];
        }
        if ((bool)playerInventoryProperties)
        {
            playerInventoryProperties.GiveToPlayer(player);
        }
        else
        {
            player.inventory.GiveItem(ItemManager.CreateByName("hazmatsuit", 1, 0uL), player.inventory.containerWear);
        }
    }
Пример #5
0
    public static bool makeCactus(Vector3 pos, Queue <VoxelMod>[,] queue, int minHeight, int maxHeight)
    {
        int height = SeedRandom.Get((int)pos.x, (int)pos.y) % (maxHeight - minHeight + 1) + minHeight;

        int chunkX = (int)pos.x / VoxelData.chunkSize;
        int chunkY = (int)pos.z / VoxelData.chunkSize;

        pos.x -= chunkX * VoxelData.chunkSize;
        pos.z -= chunkY * VoxelData.chunkSize;

        if (queue[chunkX, chunkY] == null)
        {
            queue[chunkX, chunkY] = new Queue <VoxelMod>();
        }

        for (int i = 0; i < height; i++)
        {
            queue[chunkX, chunkY].Enqueue(new VoxelMod(new Vector3(pos.x, pos.y + i, pos.z), Blocks.cactus));
        }

        pos.x += chunkX * VoxelData.chunkSize;
        pos.z += chunkY * VoxelData.chunkSize;

        return(true);
    }
Пример #6
0
    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
        });
    }
    protected void Start()
    {
        uint num1 = SeedEx.Seed(((Component)this).get_transform().get_position(), World.Seed + this.Seed);

        if ((double)SeedRandom.Value(ref num1) > (double)this.Probability)
        {
            for (int index = 0; index < this.Candidates.Length; ++index)
            {
                GameManager.Destroy(this.Candidates[index], 0.0f);
            }
            GameManager.Destroy((Component)this, 0.0f);
        }
        else
        {
            int num2 = SeedRandom.Range(num1, 0, ((Component)this).get_transform().get_childCount());
            for (int index = 0; index < this.Candidates.Length; ++index)
            {
                GameObject candidate = this.Candidates[index];
                if (index == num2)
                {
                    candidate.SetActive(true);
                }
                else
                {
                    GameManager.Destroy(candidate, 0.0f);
                }
            }
            GameManager.Destroy((Component)this, 0.0f);
        }
    }
Пример #8
0
    private WeatherPreset GetWeatherPreset(uint seed)
    {
        float max = Weather.ClearChance + Weather.DustChance + Weather.FogChance + Weather.OvercastChance + Weather.StormChance + Weather.RainChance;
        float num = SeedRandom.Range(ref seed, 0f, max);

        if (num < Weather.RainChance)
        {
            return(GetWeatherPreset(seed, WeatherPresetType.Rain));
        }
        if (num < Weather.RainChance + Weather.StormChance)
        {
            return(GetWeatherPreset(seed, WeatherPresetType.Storm));
        }
        if (num < Weather.RainChance + Weather.StormChance + Weather.OvercastChance)
        {
            return(GetWeatherPreset(seed, WeatherPresetType.Overcast));
        }
        if (num < Weather.RainChance + Weather.StormChance + Weather.OvercastChance + Weather.FogChance)
        {
            return(GetWeatherPreset(seed, WeatherPresetType.Fog));
        }
        if (num < Weather.RainChance + Weather.StormChance + Weather.OvercastChance + Weather.FogChance + Weather.DustChance)
        {
            return(GetWeatherPreset(seed, WeatherPresetType.Dust));
        }
        return(GetWeatherPreset(seed, WeatherPresetType.Clear));
    }
Пример #9
0
 private void OnEnable()
 {
     this.isRegistered = false;
     if (Object.op_Equality((Object)SingletonComponent <AiManager> .Instance, (Object)null) || !((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled() || AiManager.nav_disable)
     {
         ((Behaviour)this).set_enabled(false);
     }
     else
     {
         this.agent = (IAIAgent)((Component)this).GetComponent <IAIAgent>();
         if (this.agent == null)
         {
             return;
         }
         if (this.agent.Entity.isClient)
         {
             ((Behaviour)this).set_enabled(false);
         }
         else
         {
             this.agent.AgentTypeIndex = this.AgentTypeIndex;
             this.Invoke(new Action(this.DelayedRegistration), SeedRandom.Value((uint)Mathf.Abs(((Object)this).GetInstanceID())) * 3f);
         }
     }
 }
Пример #10
0
    public static Prefab <T> LoadRandom <T>(
        string folder,
        ref uint seed,
        GameManager manager = null,
        PrefabAttribute.Library attribute = null,
        bool useProbabilities             = true)
        where T : Component
    {
        if (string.IsNullOrEmpty(folder))
        {
            return((Prefab <T>)null);
        }
        if (manager == null)
        {
            manager = Prefab.DefaultManager;
        }
        if (attribute == null)
        {
            attribute = Prefab.DefaultAttribute;
        }
        string[] prefabNames = Prefab.FindPrefabNames(folder, useProbabilities);
        if (prefabNames.Length == 0)
        {
            return((Prefab <T>)null);
        }
        string     str       = prefabNames[SeedRandom.Range(ref seed, 0, prefabNames.Length)];
        GameObject prefab    = manager.FindPrefab(str);
        T          component = prefab.GetComponent <T>();

        return(new Prefab <T>(str, prefab, component, manager, attribute));
    }
Пример #11
0
    public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale)
    {
        uint num = pos.Seed(World.Seed) + 4;

        if (SeedRandom.Value(ref num) > 0.5f)
        {
            return;
        }
        switch (this.FlipAxis)
        {
        case DecorFlip.AxisType.X:
        case DecorFlip.AxisType.Z:
        {
            rot = Quaternion.AngleAxis(180f, rot * Vector3.up) * rot;
            return;
        }

        case DecorFlip.AxisType.Y:
        {
            rot = Quaternion.AngleAxis(180f, rot * Vector3.forward) * rot;
            return;
        }

        default:
        {
            return;
        }
        }
    }
Пример #12
0
    public override void Process(uint seed)
    {
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;
        Vector3          position1 = TerrainMeta.Position;
        Vector3          size      = TerrainMeta.Size;
        float            x1        = (float)position1.x;
        float            z1        = (float)position1.z;
        float            num1      = (float)(position1.x + size.x);
        float            num2      = (float)(position1.z + size.z);

        PlaceMonument.SpawnInfo spawnInfo1 = new PlaceMonument.SpawnInfo();
        int num3 = int.MinValue;
        Prefab <MonumentInfo> prefab1 = Prefab.Load <MonumentInfo>(this.Monument.resourceID, (GameManager)null, (PrefabAttribute.Library)null);

        for (int index = 0; index < 10000; ++index)
        {
            float  x2     = SeedRandom.Range(ref seed, x1, num1);
            float  z2     = SeedRandom.Range(ref seed, z1, num2);
            float  normX  = TerrainMeta.NormalizeX(x2);
            float  normZ  = TerrainMeta.NormalizeZ(z2);
            float  num4   = SeedRandom.Value(ref seed);
            double factor = (double)this.Filter.GetFactor(normX, normZ);
            if (factor * factor >= (double)num4)
            {
                float   height = heightMap.GetHeight(normX, normZ);
                Vector3 pos;
                ((Vector3) ref pos).\u002Ector(x2, height, z2);
                Quaternion localRotation = prefab1.Object.get_transform().get_localRotation();
                Vector3    localScale    = prefab1.Object.get_transform().get_localScale();
                prefab1.ApplyDecorComponents(ref pos, ref localRotation, ref localScale);
                if ((!Object.op_Implicit((Object)prefab1.Component) || prefab1.Component.CheckPlacement(pos, localRotation, localScale)) && (prefab1.ApplyTerrainAnchors(ref pos, localRotation, localScale, this.Filter) && prefab1.ApplyTerrainChecks(pos, localRotation, localScale, this.Filter)) && (prefab1.ApplyTerrainFilters(pos, localRotation, localScale, (SpawnFilter)null) && prefab1.ApplyWaterChecks(pos, localRotation, localScale) && !prefab1.CheckEnvironmentVolumes(pos, localRotation, localScale, EnvironmentType.Underground)))
                {
                    PlaceMonument.SpawnInfo spawnInfo2 = new PlaceMonument.SpawnInfo();
                    spawnInfo2.prefab   = (Prefab)prefab1;
                    spawnInfo2.position = pos;
                    spawnInfo2.rotation = localRotation;
                    spawnInfo2.scale    = localScale;
                    int num5 = -Mathf.RoundToInt(Vector3Ex.Magnitude2D(pos));
                    if (num5 > num3)
                    {
                        num3       = num5;
                        spawnInfo1 = spawnInfo2;
                    }
                }
            }
        }
        if (num3 == int.MinValue)
        {
            return;
        }
        Prefab     prefab2   = spawnInfo1.prefab;
        Vector3    position2 = spawnInfo1.position;
        Quaternion rotation  = spawnInfo1.rotation;
        Vector3    scale     = spawnInfo1.scale;

        prefab2.ApplyTerrainPlacements(position2, rotation, scale);
        prefab2.ApplyTerrainModifiers(position2, rotation, scale);
        World.AddPrefab("Monument", prefab2.ID, position2, rotation, scale);
    }
Пример #13
0
 public static T GetRandom <T>(this T[] array, ref uint seed)
 {
     if (array == null || array.Length == 0)
     {
         return(default(T));
     }
     return(array[SeedRandom.Range(ref seed, 0, array.Length)]);
 }
Пример #14
0
    public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale)
    {
        uint seed = pos.Seed(World.Seed) + 1;

        pos.x += scale.x * SeedRandom.Range(ref seed, MinOffset.x, MaxOffset.x);
        pos.y += scale.y * SeedRandom.Range(ref seed, MinOffset.y, MaxOffset.y);
        pos.z += scale.z * SeedRandom.Range(ref seed, MinOffset.z, MaxOffset.z);
    }
Пример #15
0
 public static T GetRandom <T>(this List <T> list, ref uint seed)
 {
     if (list == null || list.Count == 0)
     {
         return(default(T));
     }
     return(list[SeedRandom.Range(ref seed, 0, list.Count)]);
 }
Пример #16
0
 public int Sign()
 {
     if (SeedRandom.Xorshift(ref this.Seed) % 2 != 0)
     {
         return(-1);
     }
     return(1);
 }
Пример #17
0
 public static int Sign(ref uint seed)
 {
     if (SeedRandom.Xorshift(ref seed) % 2 != 0)
     {
         return(-1);
     }
     return(1);
 }
Пример #18
0
    public override void Process(uint seed)
    {
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;
        Vector3          position  = TerrainMeta.Position;
        Vector3          size      = TerrainMeta.Size;
        float            single    = position.x;
        float            single1   = position.z;
        float            single2   = position.x + size.x;
        float            single3   = position.z + size.z;

        PlaceMonument.SpawnInfo spawnInfo = new PlaceMonument.SpawnInfo();
        int num = -2147483648;
        Prefab <MonumentInfo> prefab = Prefab.Load <MonumentInfo>(this.Monument.resourceID, null, null);

        for (int i = 0; i < 10000; i++)
        {
            float single4 = SeedRandom.Range(ref seed, single, single2);
            float single5 = SeedRandom.Range(ref seed, single1, single3);
            float single6 = TerrainMeta.NormalizeX(single4);
            float single7 = TerrainMeta.NormalizeZ(single5);
            float single8 = SeedRandom.Value(ref seed);
            float factor  = this.Filter.GetFactor(single6, single7);
            if (factor * factor >= single8)
            {
                float      height  = heightMap.GetHeight(single6, single7);
                Vector3    vector3 = new Vector3(single4, height, single5);
                Quaternion obj     = prefab.Object.transform.localRotation;
                Vector3    obj1    = prefab.Object.transform.localScale;
                prefab.ApplyDecorComponents(ref vector3, ref obj, ref obj1);
                if ((!prefab.Component || prefab.Component.CheckPlacement(vector3, obj, obj1)) && prefab.ApplyTerrainAnchors(ref vector3, obj, obj1, this.Filter) && prefab.ApplyTerrainChecks(vector3, obj, obj1, this.Filter) && prefab.ApplyTerrainFilters(vector3, obj, obj1, null) && prefab.ApplyWaterChecks(vector3, obj, obj1) && !prefab.CheckEnvironmentVolumes(vector3, obj, obj1, EnvironmentType.Underground))
                {
                    PlaceMonument.SpawnInfo spawnInfo1 = new PlaceMonument.SpawnInfo()
                    {
                        prefab   = prefab,
                        position = vector3,
                        rotation = obj,
                        scale    = obj1
                    };
                    int num1 = -Mathf.RoundToInt(vector3.Magnitude2D());
                    if (num1 > num)
                    {
                        num       = num1;
                        spawnInfo = spawnInfo1;
                    }
                }
            }
        }
        if (num != -2147483648)
        {
            Prefab     prefab1    = spawnInfo.prefab;
            Vector3    vector31   = spawnInfo.position;
            Quaternion quaternion = spawnInfo.rotation;
            Vector3    vector32   = spawnInfo.scale;
            prefab1.ApplyTerrainPlacements(vector31, quaternion, vector32);
            prefab1.ApplyTerrainModifiers(vector31, quaternion, vector32);
            World.AddPrefab("Monument", prefab1.ID, vector31, quaternion, vector32);
        }
    }
Пример #19
0
    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);
    }
Пример #20
0
    public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale)
    {
        uint  num1 = SeedEx.Seed(pos, World.Seed) + 2U;
        float num2 = SeedRandom.Range(ref num1, (float)this.MinRotation.x, (float)this.MaxRotation.x);
        float num3 = SeedRandom.Range(ref num1, (float)this.MinRotation.y, (float)this.MaxRotation.y);
        float num4 = SeedRandom.Range(ref num1, (float)this.MinRotation.z, (float)this.MaxRotation.z);

        rot = Quaternion.op_Multiply(Quaternion.Euler(num2, num3, num4), rot);
    }
Пример #21
0
    public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale)
    {
        uint  num     = pos.Seed(World.Seed) + 2;
        float single  = SeedRandom.Range(ref num, this.MinRotation.x, this.MaxRotation.x);
        float single1 = SeedRandom.Range(ref num, this.MinRotation.y, this.MaxRotation.y);
        float single2 = SeedRandom.Range(ref num, this.MinRotation.z, this.MaxRotation.z);

        rot = Quaternion.Euler(single, single1, single2) * rot;
    }
Пример #22
0
    public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale)
    {
        uint  seed = pos.Seed(World.Seed) + 3;
        float t    = SeedRandom.Value(ref seed);

        scale.x *= Mathf.Lerp(MinScale.x, MaxScale.x, t);
        scale.y *= Mathf.Lerp(MinScale.y, MaxScale.y, t);
        scale.z *= Mathf.Lerp(MinScale.z, MaxScale.z, t);
    }
Пример #23
0
    public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale)
    {
        uint  num    = pos.Seed(World.Seed) + 3;
        float single = SeedRandom.Value(ref num);

        scale.x *= Mathf.Lerp(this.MinScale.x, this.MaxScale.x, single);
        scale.y *= Mathf.Lerp(this.MinScale.y, this.MaxScale.y, single);
        scale.z *= Mathf.Lerp(this.MinScale.z, this.MaxScale.z, single);
    }
Пример #24
0
    public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale)
    {
        uint  seed = pos.Seed(World.Seed) + 2;
        float x    = SeedRandom.Range(ref seed, MinRotation.x, MaxRotation.x);
        float y    = SeedRandom.Range(ref seed, MinRotation.y, MaxRotation.y);
        float z    = SeedRandom.Range(ref seed, MinRotation.z, MaxRotation.z);

        rot = Quaternion.Euler(x, y, z) * rot;
    }
        public RandomizerLog(string seed)
        {
            generatedItems = new List <Location>();
            orderedItems   = new List <Location>();
            this.seed      = seed;

            string y = Regex.Replace(seed, @"\D", "");

            random = new SeedRandom(int.Parse(y));
        }
Пример #26
0
 public static void Shuffle <T>(this T[] array, ref uint seed)
 {
     for (int i = 0; i < (int)array.Length; i++)
     {
         int num  = SeedRandom.Range(ref seed, 0, (int)array.Length);
         int num1 = SeedRandom.Range(ref seed, 0, (int)array.Length);
         T   t    = array[num];
         array[num]  = array[num1];
         array[num1] = t;
     }
 }
Пример #27
0
 public static void Shuffle <T>(this T[] array, ref uint seed)
 {
     for (int index1 = 0; index1 < array.Length; ++index1)
     {
         int index2 = SeedRandom.Range(ref seed, 0, array.Length);
         int index3 = SeedRandom.Range(ref seed, 0, array.Length);
         T   obj    = array[index2];
         array[index2] = array[index3];
         array[index3] = obj;
     }
 }
Пример #28
0
    protected void Start()
    {
        uint num = base.transform.position.Seed(World.Seed + this.Seed);

        if (SeedRandom.Value(ref num) > this.Probability)
        {
            GameManager.Destroy(this, 0f);
            return;
        }
        GameManager.Destroy(base.gameObject, 0f);
    }
Пример #29
0
 public static void Shuffle <T>(this T[] array, ref uint seed)
 {
     for (int i = 0; i < array.Length; i++)
     {
         int num  = SeedRandom.Range(ref seed, 0, array.Length);
         int num2 = SeedRandom.Range(ref seed, 0, array.Length);
         T   val  = array[num];
         array[num]  = array[num2];
         array[num2] = val;
     }
 }
Пример #30
0
 public static void Shuffle <T>(this List <T> list, ref uint seed)
 {
     for (int i = 0; i < list.Count; i++)
     {
         int item = SeedRandom.Range(ref seed, 0, list.Count);
         int num  = SeedRandom.Range(ref seed, 0, list.Count);
         T   t    = list[item];
         list[item] = list[num];
         list[num]  = t;
     }
 }