private static bool ValidateBeneathFloor(int leftTileX, int floorTileY) { int maxX = leftTileX + ScaffoldingErectorKitItem.ScaffoldWidth; int maxY = ScaffoldingErectorKitItem.GetFurthestAllowedGroundTileY(floorTileY); int framingPlankType = ModContent.TileType <FramingPlankTile>(); // Find at least one 'earth' tile beneath for (int x = leftTileX; x < maxX; x++) { for (int y = floorTileY; y < maxY; y++) { Tile tile = Main.tile[x, y]; if (tile?.active() != true) { continue; } if (TileLibraries.IsSolid(tile, false, false) && tile.type != framingPlankType) { return(true); } } } return(false); }
private bool UpdateGround(Gore gore, out bool lockFrames) { lockFrames = false; if (gore.drawOffset.X == 0f) { //Main.NewText("bounce "+gore.GetHashCode()); gore.drawOffset.X = 0.001f; SoundLibraries.PlaySound(TMRMod.Instance, "ShellBounce", gore.position); } int tileX = (int)gore.position.X >> 4; int tileY = (int)gore.position.Y >> 4; Tile tile = Main.tile[tileX, tileY]; if (TileLibraries.IsSolid(tile, false, false)) { if (tile.slope() != 0) { return(false); } tile = Main.tile[tileX, tileY - 1]; if (!TileLibraries.IsSolid(tile, false, false)) { gore.drawOffset.Y = 8f; gore.position.Y -= 16f; } else { return(false); } } gore.rotation = (float)Math.PI * 0.5f; if (gore.velocity.X == 0) { lockFrames = true; gore.frameCounter = 2; } return(true); }
//// private static int FindScaffoldFloorY(int leftTileX, int tileY, int width, int height) { int maxX = leftTileX + width; int maxY = Math.Min(tileY + (height + 1), Main.maxTilesY); // Find immediate 'ground' (any solid, non-actuated matter) for (int y = tileY; y < maxY; y++) { for (int x = leftTileX; x < maxX; x++) { if (TileLibraries.IsSolid(Main.tile[x, y], true, false)) { return(y); } } } return(maxY); }
public static void MakeScaffold(int leftTileX, int floorTileY) { int width = ScaffoldingErectorKitItem.ScaffoldWidth; int height = ScaffoldingErectorKitItem.ScaffoldHeight; var rect = new Rectangle( leftTileX, floorTileY - height, width, height ); var postTileDef = new TileDrawDefinition { NotActive = true, WallType = WallID.RichMahoganyFence }; var platTileDef = new TileDrawDefinition { SkipWall = true, TileType = TileID.Platforms }; // int findFloor(int myTileX, int myTileY) { int y; for (y = myTileY; !TileLibraries.IsSolid(Main.tile[myTileX, y], true, true); y++) { if (y >= Main.maxTilesY - 1) { break; } } return(y); } // int rightTileX = rect.X + rect.Width - 1; int lPostFloorY = findFloor(leftTileX, rect.Bottom); int rPostFloorY = findFloor(rightTileX, rect.Bottom); // Posts if (Main.tile[leftTileX - 1, rect.Y].wall != WallID.RichMahoganyFence) { TileDrawPrimitivesLibraries.DrawRectangle( filter: TilePattern.NonSolid, area: new Rectangle(leftTileX, rect.Y, 1, lPostFloorY - rect.Y), hollow: null, place: (x, y) => postTileDef ); } if (Main.tile[rightTileX + 1, rect.Y].wall != WallID.RichMahoganyFence) { TileDrawPrimitivesLibraries.DrawRectangle( filter: TilePattern.NonSolid, area: new Rectangle(rightTileX, rect.Y, 1, rPostFloorY - rect.Y), hollow: null, place: (x, y) => postTileDef ); } // Platforms TileDrawPrimitivesLibraries.DrawRectangle( filter: TilePattern.NonSolid, area: new Rectangle(rect.X, rect.Y, width, 1), hollow: null, place: (x, y) => platTileDef ); // Main.PlaySound(SoundID.Item69, rect.Center.ToVector2() * 16); // if (Main.netMode == NetmodeID.Server) { //LogLibraries.Log( "!!!MakeScaffold " + rect.ToString() ); TileRectangleModPacketProtocol.Send(rect); } }