private void DoCloudIsland(CommandArgs args) { int tryX = args.Player.TileX; int tryY = args.Player.TileY; WorldGen.CloudIsland(tryX, tryY + 9); WorldGen.IslandHouse(tryX, tryY + 1); args.Player.SendSuccessMessage("Attempted to generate an un-looted floating island at your position."); InformPlayers(); }
public override bool UseItem(Player player) { Projectile.NewProjectile(player.Center.X, player.Center.Y - 1, 0, -20f, mod.ProjectileType("Laputa"), 0, 0, player.whoAmI, player.Center.Y, cloudY); if (!Main.dedServ) { SkyManager.Instance.Activate("GoldensMisc:Laputa"); } WorldGen.CloudIsland(cloudX, cloudY); var dirt = FindDirt(cloudX, cloudY); if (dirt != Point.Zero) { WorldGen.SpreadGrass(dirt.X, dirt.Y); } int trees = Main.rand.Next(40, 50); for (int i = 0; i < trees; i++) { dirt = FindDirt(cloudX, cloudY, TileID.Grass); if (dirt == Point.Zero) { return(true); } bool canPlaceTree = true; for (int x = dirt.X - 1; x <= dirt.X + 1; x++) { if (!Main.tile[x, dirt.Y].active() || Main.tile[x, dirt.Y].type != TileID.Grass) { canPlaceTree = false; } } for (int x = dirt.X - 2; x <= dirt.X + 2; x++) { if (Main.tile[x, dirt.Y - 1].active()) { canPlaceTree = false; } } if (canPlaceTree) { WorldGen.PlaceObject(dirt.X, dirt.Y - 1, TileID.Saplings, true); WorldGen.GrowTree(dirt.X, dirt.Y - 1); } } // WorldGen.IslandHouse((int)(player.position.X / 16), (int)(player.position.Y / 16) - 100); return(true); }
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; })); }
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())); }
private void DoIsland(CommandArgs args) { int tryX = args.Player.TileX; int tryY = args.Player.TileY; if (tryY <= 50) { tryY = 51; } WorldGen.CloudIsland(tryX, tryY - 50); args.Player.SendSuccessMessage("Attempted to generate a floating island above you."); InformPlayers(); }
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 } }