Ejemplo n.º 1
0
        public static Task AsyncGenerateIsland(int island, int posX, int posY)
        {
            WorldRefill.isTaskRunning = true;
            WorldRefill.realcount     = 1;
            switch (island)
            {
            case 0:
                WorldGen.FloatingIsland(posX, posY);
                for (int x = posX - 20; x < posX + 20; x++)
                {
                    int cloudsurface()
                    {
                        int cY = posY;

                        while (Main.tile[x, cY].active())
                        {
                            cY--;
                        }
                        cY++;
                        return(cY);
                    };
                    WorldGen.SpreadGrassDirect(posX, cloudsurface());
                }
                WorldGen.IslandHouse(posX, posY - 6 /*, WorldGen.floatingIslandStyle[WorldGen.genRand.Next(0, WorldGen.floatingIslandStyle.Count() - 1)]*/);
                break;

            case 3:
                WorldGen.CloudLake(posX, posY);
                break;

            case 4:
                WorldGen.CloudIsland(posX, posY);
                for (int x = posX - 20; x < posX + 20; x++)
                {
                    int cloudsurface()
                    {
                        int cY = posY;

                        while (Main.tile[x, cY].active())
                        {
                            cY--;
                        }
                        cY++;
                        return(cY);
                    };
                    WorldGen.SpreadGrassDirect(posX, cloudsurface());
                }
                WorldGen.IslandHouse(posX, posY - 6 /*, WorldGen.floatingIslandStyle[WorldGen.genRand.Next(0, WorldGen.floatingIslandStyle.Count() - 1)]*/);
                break;
            }
            return(Task.Run(() => { WorldRefill.isTaskRunning = false; }));
        }
Ejemplo n.º 2
0
        public static Task AsyncGenerateIsland(int island, int posX, int posY)
        {
            WorldRefill.isTaskRunning = true;
            WorldRefill.realcount     = 1;
            return(Task.Run(() =>
            {
                switch (island)
                {
                case 0:
                    WorldGen.CloudIsland(posX, posY);

                    for (int x = posX - 20; x < posX + 20; x++)
                    {
                        int cloudsurface()
                        {
                            int cY = posY;
                            while (Main.tile[x, cY].active())
                            {
                                cY--;
                            }
                            cY++;
                            return cY;
                        };
                        WorldGen.SpreadGrassDirect(posX, cloudsurface());
                    }



                    WorldGen.IslandHouse(posX, posY - 6, WorldGen.floatingIslandStyle[WorldGen.genRand.Next(0, WorldGen.floatingIslandStyle.Count() - 1)]);

                    break;

                case 1:
                    WorldGen.DesertCloudIsland(posX, posY);
                    WorldGen.IslandHouse(posX, posY - 6, WorldGen.floatingIslandStyle[WorldGen.genRand.Next(0, WorldGen.floatingIslandStyle.Count() - 1)]);

                    break;

                case 2:

                    WorldGen.SnowCloudIsland(posX, posY);
                    WorldGen.IslandHouse(posX, posY - 6, WorldGen.floatingIslandStyle[WorldGen.genRand.Next(0, WorldGen.floatingIslandStyle.Count() - 1)]);


                    break;

                case 3:
                    WorldGen.CloudLake(posX, posY);
                    break;
                }
            }).ContinueWith((d) => FinishGen()));
        }
Ejemplo n.º 3
0
        public override void ModifyWorldGenTasks(List <GenPass> tasks, ref float totalWeight)
        {
            Mod Overrated = ModLoader.GetMod("CalamityMod");

            if (Overrated == null)
            {
                #region
                int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Floating Islands"));
                if (ShiniesIndex != -1)
                {
                    tasks.RemoveAt(ShiniesIndex);
                }
                ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Floating Island Houses"));
                if (ShiniesIndex != -1)
                {
                    tasks.RemoveAt(ShiniesIndex);
                }
                int skyLakes = 1;
                if (Main.maxTilesX > 8000)
                {
                    int skyLakes2 = skyLakes;
                    skyLakes = skyLakes2 + 1;
                }
                if (Main.maxTilesX > 6000)
                {
                    int skyLakes2 = skyLakes;
                    skyLakes = skyLakes2 + 1;
                }
                ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Full Desert"));
                if (ShiniesIndex != -1)
                {
                    tasks.Insert(ShiniesIndex + 1, new PassLegacy("Giving Sky Fortress space", delegate(GenerationProgress progress)
                    {
                        numIslandHouses  = 0;
                        houseCount       = 0;
                        progress.Message = Lang.gen[12].Value;
                        for (int k = 0; k < (int)((double)Main.maxTilesX * 0.0008) + skyLakes; k++)
                        {
                            int num  = 1000;
                            int num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
                            if (WorldGen.dungeonX < Main.maxTilesX * .5f)
                            {
                                num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
                            }
                            else
                            {
                                num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
                            }

                            while (--num > 0)
                            {
                                bool flag2 = true;
                                while (num2 > Main.maxTilesX / 2 - 80 && num2 < Main.maxTilesX / 2 + 80)
                                {
                                    if (WorldGen.dungeonX < Main.maxTilesX * .5f)
                                    {
                                        num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
                                    }
                                    else
                                    {
                                        num2 = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.3), (int)((double)Main.maxTilesX * 0.7));
                                    }
                                }
                                for (int l = 0; l < numIslandHouses; l++)
                                {
                                    if (num2 > fihX[l] - 180 && num2 < fihX[l] + 180)
                                    {
                                        flag2 = false;
                                        break;
                                    }
                                }
                                if (flag2)
                                {
                                    flag2    = false;
                                    int num3 = 0;
                                    int num4 = 200;
                                    while ((double)num4 < Main.worldSurface)
                                    {
                                        if (Main.tile[num2, num4].active())
                                        {
                                            num3  = num4;
                                            flag2 = true;
                                            break;
                                        }
                                        num4++;
                                    }
                                    if (flag2)
                                    {
                                        int num5 = WorldGen.genRand.Next(90, num3 - 100);
                                        num5     = Math.Min(num5, (int)WorldGen.worldSurfaceLow - 50);
                                        if (k < skyLakes)
                                        {
                                            skyLake[numIslandHouses] = true;
                                            WorldGen.CloudLake(num2, num5);
                                        }
                                        else
                                        {
                                            WorldGen.CloudIsland(num2, num5);
                                        }
                                        fihX[numIslandHouses] = num2;
                                        fihY[numIslandHouses] = num5;
                                        numIslandHouses++;
                                    }
                                }
                            }
                        }
                    }));
                    ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Jungle Trees"));
                    if (ShiniesIndex != -1)
                    {
                        #region

                        tasks.Insert(ShiniesIndex + 1, new PassLegacy("Giving Sky Fortress space", delegate(GenerationProgress progress)
                        {
                            for (int k = 0; k < numIslandHouses; k++)
                            {
                                if (!skyLake[k])
                                {
                                    WorldGen.IslandHouse(fihX[k], fihY[k]);
                                }
                            }
                        }));

                        #endregion
                    }
                }
                #endregion
            }
        }