public void MakeCloud(StructureComplete cloud, Vector2 structPos) { if (cloud != null && cloud.blocks != null) { MakeStructureOnSky(cloud, (int)structPos.X, (int)structPos.Y, true); } }
public void GenerateDisneyWorlds(GenerationProgress p, GameConfiguration conf) { StructureComplete cloud = StructureData.GetStructure("OlimpusCloud1"); Vector2 structPos = new Vector2(Main.spawnTileX / 2, (int)(cloud.blocks.element.GetLength(0) / 4f * 3f) + 20); MakeCloud(cloud, structPos); cloud = StructureData.GetStructure("OlimpusCloud2"); structPos.X += cloud.blocks.element.GetLength(1); MakeCloud(cloud, structPos); cloud = StructureData.GetStructure("OlimpusLake"); structPos.X += cloud.blocks.element.GetLength(1); MakeCloud(cloud, structPos); }
private void MakeStructureOnSky(StructureComplete structure, int posX = -1, int posY = -1, bool forceMake = false) { if (structure == null) { return; } if (forceMake) { PlaceStructure(posX, posY, structure); return; } else { float widthScale = Main.maxTilesX * 1f / structure.blocks.element.GetLength(0); 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 && !forceMake) { success = true; continue; } int i = WorldGen.genRand.Next(300, Main.maxTilesX / 2 - 300); if (i <= Main.maxTilesX / 2 - 50 || i >= Main.maxTilesX / 2 + 50) { int j = (int)Math.Clamp((Main.worldSurface / 2 - WorldGen.genRand.Next(structure.blocks.element.GetLength(1))), 0, Main.worldSurface); if (j > 0) { bool placementOK = true; for (int l = i - structure.blocks.element.GetLength(0) / 2; l < i + structure.blocks.element.GetLength(0) / 2; l++) { for (int m = j - structure.blocks.element.GetLength(1) / 2; m < j + structure.blocks.element.GetLength(1) / 2; m++) { if (Main.tile[l, m].IsActive) { 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 = forceMake; } } } } if (placementOK || forceMake) { success = PlaceStructure(i, j, structure); } } } } } } }
public bool PlaceStructure(int i, int j, StructureComplete structure) { int tileType; for (int structY = 0; structY < structure.ReturnLength(1); structY++) { for (int structX = 0; structX < structure.ReturnLength(0); structX++) { int k = i - (structure.ReturnLength(0) / 2) + structX; int l = j - (structure.ReturnLength(1) / 2) + structY; int flippedY = (structure.ReturnLength(1)) - structY - 1; if (WorldGen.InWorld(k, l, 30)) { Tile tile = Framing.GetTileSafely(k, l); if (structure.blocks.types[structure.blocks.element[flippedY, structX]] >= 0 && structure.hasSlopes) { //the type of block this is tile.type = (ushort)structure.blocks.types[structure.blocks.element[flippedY, structX]]; tile.IsActive = false; //checking if the block is a platform and checking the type it is tileType = structure.blocks.types[structure.blocks.element[flippedY, structX]]; //placing the block WorldGen.PlaceTile(k, l, tileType, false, false, -1, style: (tileType == TileID.Platforms)?structure.platformsType:0); switch (structure.blockSlopes[flippedY, structX]) { default: case 0: break; case 1: tile.IsHalfBlock = true; break; case 2: tile.Slope = SlopeType.SlopeDownRight; break; case 3: tile.Slope = SlopeType.SlopeDownLeft; break; case 4: tile.Slope = SlopeType.SlopeUpRight; break; case 5: tile.Slope = SlopeType.SlopeUpLeft; break; } if (structure.hasBlockPaint && flippedY < structure.blockColors.element.GetLength(0) && structX < structure.blockColors.element.GetLength(1)) { WorldGen.paintTile(k, l, GetColorFromType(structure.blockColors.types[structure.blockColors.element[flippedY, structX]])); } tile.IsActive = true; } else { tile.IsActive = false; } //Actuate blocks if (structure.hasActuatedBlocks && structure.actuatedBlocks.GetLength(0) >= flippedY && structure.actuatedBlocks.GetLength(1) >= structX) { tile.IsActuated = structure.actuatedBlocks[flippedY, structX]; } if (structure.walls.types[structure.walls.element[flippedY, structX]] != WallID.None) { tile.wall = (ushort)structure.walls.types[structure.walls.element[flippedY, structX]]; if (structure.hasWallPaint && flippedY < structure.wallColors.element.GetLength(0) && structX < structure.wallColors.element.GetLength(1) && structure.wallColors.element[flippedY, structX] != 0) { //tile.WallColor=GetColorFromType(structure.wallColors.types[structure.wallColors.element[flippedY, structX]]); } } if (structure.containsLiquids && structure.liquids.types[structure.liquids.element[flippedY, structX]] > 0) { tile.LiquidAmount = (byte)structure.liquids.types[structure.liquids.element[flippedY, structX]]; } } } } return(true); }
public static StructureComplete GetStructure(string name) { StructureElement blocks; StructureElement walls; StructureElement liquids = StructureElement.emptyElement(); StructureElement blockPaint = StructureElement.emptyElement(); StructureElement wallPaint = StructureElement.emptyElement(); switch (name) { case "OlimpusCloud1": blocks = new StructureElement(OlimpusCloud.OlimpusCloud1Blocks, OlimpusCloud.olimpusBlockTypes); walls = new StructureElement(OlimpusCloud.OlimpusCloud1Walls, OlimpusCloud.olimpusWallTypes); return(new StructureComplete(blocks, OlimpusCloud.OlimpusCloud1Slopes, blockPaint, StructureComplete.emptyActuated(), walls, wallPaint, liquids)); case "OlimpusCloud2": blocks = new StructureElement(OlimpusCloud.OlimpusCloud2Blocks, OlimpusCloud.olimpusBlockTypes); walls = new StructureElement(OlimpusCloud.OlimpusCloud2Walls, OlimpusCloud.olimpusWallTypes); wallPaint = new StructureElement(OlimpusCloud.OlimpusCoud2wallPaint, OlimpusCloud.olimpusPaintTypes); return(new StructureComplete(blocks, OlimpusCloud.OlimpusCloud2Slopes, blockPaint, StructureComplete.BoolsFromInts(OlimpusCloud.OlimpusCloud2Actuate), walls, wallPaint, liquids)); case "OlimpusLake": blocks = new StructureElement(OlimpusCloud.OlimpusLakeBlocks, OlimpusCloud.olimpusBlockTypes); walls = new StructureElement(OlimpusCloud.OlimpusLakeWalls, OlimpusCloud.olimpusWallTypes); liquids = new StructureElement(OlimpusCloud.OlimpusLakeLiquids, OlimpusCloud.olimpusliquidTypes); blockPaint = new StructureElement(OlimpusCloud.OlimpusLakePaints, OlimpusCloud.olimpusPaintTypes); return(new StructureComplete(blocks, OlimpusCloud.OlimpusLakeSlopes, blockPaint, StructureComplete.BoolsFromInts(OlimpusCloud.OlimpusLakeActuate), walls, wallPaint, liquids, OlimpusCloud.olimpusPlatforms)); default: return(null); } }