Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void MakeWell()
- {
- float widthScale = (Main.maxTilesX / 4200f); //something about floating numbers
- int numberToGenerate = WorldGen.genRand.Next(1, (int)(2f * widthScale));
- for (int k = 0; k < numberToGenerate; k++)
- {
- bool success = false;
- int attempts = 0;
- while (!success)
- {
- attempts++;
- if (attempts > 1000)
- {
- success = true;
- continue;
- }
- int i = WorldGen.genRand.Next(300, Main.maxTilesX - 300);
- if (i <= Main.maxTilesX / 2 - 50 || i >= Main.maxTilesX / 2 + 50)
- {
- int j = 0;
- while (!Main.tile[i, j].active() && (double)j < Main.worldSurface)
- {
- j++;
- }
- if (Main.tile[i, j].type == TileID.Dirt) //spawn on type of tile
- {
- j--;
- if (j > 150)
- {
- bool placementOK = true;
- for (int l = i - 4; l < i + 4; l++)
- {
- for (int m = j - 6; m < j + 20; m++) //i don't know what this line does
- {
- if (Main.tile[l, m].active())
- {
- int type = (int)Main.tile[l, m].type;
- if (type == TileID.BlueDungeonBrick || type == TileID.GreenDungeonBrick || type == TileID.PinkDungeonBrick || type == TileID.Cloud || type == TileID.RainCloud)
- {
- placementOK = false;
- }
- }
- }
- }
- if (placementOK)
- {
- success = PlaceWell(i, j);
- }
- }
- }
- }
- }
- }
- }
- int[,] wellshape = new int[,]
- {
- {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- {1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1 },
- {1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1 },
- {1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1 },
- {1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1 },
- {1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1 },
- {0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1 }, //trying to put a door here
- {0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1 },
- {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- };
- int[,] wellshapeWall = new int[,]
- {
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
- {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
- {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
- {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
- {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
- {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
- {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- };
- int[,] wellshapeWater = new int[,]
- {
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 },
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
- };
- public bool PlaceWell(int i, int j)
- {
- if (!WorldGen.SolidTile(i, j + 1))
- {
- return false;
- }
- if (Main.tile[i, j].active())
- {
- return false;
- }
- if (j < 150)
- {
- return false;
- }
- for (int y = 0; y < wellshape.GetLength(0); y++)
- {
- for (int x = 0; x < wellshape.GetLength(1); x++)
- {
- int k = i - 3 + x;
- int l = j - 6 + y;
- if (WorldGen.InWorld(k, l, 30))
- WorldGen.PlaceTile(k + -1, l + 2, 10, true, false, 0, 4); //placing the door
- if (WorldGen.InWorld(k, l, 30))
- {
- Tile tile = Framing.GetTileSafely(k, l);
- switch (wellshape[y, x]) {
- case 1:
- tile.type = TileID.PearlstoneBrick; //roof
- tile.active(true);
- break;
- case 2:
- tile.type = TileID.SilverBrick; //base edge
- tile.active(true);
- tile.halfBrick(true);
- break;
- case 3:
- tile.type = TileID.CopperBrick; //left slant
- tile.active(true);
- tile.slope(2); //to get the correct slope shader
- break;
- case 4:
- tile.type = TileID.MeteoriteBrick; //right slant
- tile.active(true);
- tile.slope(1);
- break;
- case 5:
- tile.active(false); //nothing here
- break;
- case 6:
- tile.type = TileID.Rope;
- tile.active(true);
- break;
- }
- switch (wellshapeWall[y, x])
- {
- case 1:
- tile.wall = WallID.SnowBrick; //wall of well
- break;
- }
- switch (wellshapeWater[y, x])
- {
- case 1:
- tile.liquid = 255; //fills with corresponding biome liquid
- break;
- }
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement