Esempio n. 1
0
        public override void RandomUpdate(int i, int j)
        {
            if (!Main.hardMode)
            {
                return;
            }
            WeightedRandom <(int, int)> rand = new WeightedRandom <(int, int)>();
            Tile current;

            for (int y = -3; y < 4; y++)
            {
                for (int x = -3; x < 4; x++)
                {
                    current = Main.tile[i + x, j + y];
                    if (OriginWorld.ConvertTileWeak(ref current.type, OriginWorld.evil_riven, false))
                    {
                        if (Main.tile[i + x, j + y - 1].type != TileID.Sunflower)
                        {
                            rand.Add((i + x, j + y));
                        }
                    }
                }
            }
            if (rand.elements.Count > 0)
            {
                (int x, int y)pos = rand.Get();
                OriginWorld.ConvertTileWeak(ref Main.tile[pos.x, pos.y].type, OriginWorld.evil_riven);
                WorldGen.SquareTileFrame(pos.x, pos.y);
                NetMessage.SendTileSquare(-1, pos.x, pos.y, 1);
            }
        }
Esempio n. 2
0
        public override void RandomUpdate(int i, int j)
        {
            int retryCount = 0;

retry:
            if (retryCount++ > 100)
            {
                return;
            }
            switch (WorldGen.genRand.Next(Main.hardMode?3:2))
            {
            case 0:
                WeightedRandom <(int, int)> rand = new WeightedRandom <(int, int)>();
                Tile current;
                for (int y = -1; y < 2 && (j + y) < Main.worldSurface; y++)
                {
                    for (int x = -1; x < 2; x++)
                    {
                        current = Main.tile[i + x, j + y];
                        if (current.type == TileID.Grass)
                        {
                            if (Main.tile[i + x, j + y - 1].type != TileID.Sunflower)
                            {
                                rand.Add((i + x, j + y));
                            }
                        }
                        else if (current.type == TileID.Dirt)
                        {
                            if (!(Main.tile[i + x - 1, j + y].active() && Main.tile[i + x + 1, j + y].active() && Main.tile[i + x, j + y - 1].active() && Main.tile[i + x, j + y + 1].active()))
                            {
                                rand.Add((i + x, j + y));
                            }
                        }
                    }
                }
                if (rand.elements.Count > 0)
                {
                    (int x, int y)pos = rand.Get();
                    OriginWorld.ConvertTileWeak(ref Main.tile[pos.x, pos.y].type, OriginWorld.evil_wastelands);
                    OriginWorld.ConvertWall(ref Main.tile[pos.x, pos.y].wall, OriginWorld.evil_wastelands);
                    WorldGen.SquareTileFrame(pos.x, pos.y);
                    NetMessage.SendTileSquare(-1, pos.x, pos.y, 1);
                }
                else
                {
                    goto retry;
                }
                break;

            case 1:
                if (!Main.tile[i, j - 1].active() && !(Main.tile[i, j].slope() != 0 || Main.tile[i, j].halfBrick()))
                {
                    Main.tile[i, j - 1].ResetToType((ushort)ModContent.TileType <Defiled_Foliage>());
                }
                else
                {
                    goto retry;
                }
                break;

            case 2:
                base.RandomUpdate(i, j);
                break;
            }
        }