コード例 #1
0
        ////////////////

        public bool Check(int tileX, int tileY)
        {
            Tile tile = Main.tile[tileX, tileY];

            if (this.IsWire != null)
            {
                if (TileHelpers.IsWire(tile) != this.IsWire)
                {
                    return(false);
                }
            }

            if (this.IsSolid != null)
            {
                if (TileHelpers.IsSolid(tile, this.IsPlatformSolid, this.IsActuatedSolid) != this.IsSolid)
                {
                    return(false);
                }
            }

            if (this.HasWall != null)
            {
                if ((tile.wall > 0) != this.HasWall)
                {
                    return(false);
                }
            }

            if (this.HasLava != null)
            {
                if (tile.lava() != this.HasLava)
                {
                    return(false);
                }
            }

            if (this.HasHoney != null)
            {
                if (tile.honey() != this.HasHoney)
                {
                    return(false);
                }
            }

            if (this.HasWater != null)
            {
                if (tile.liquid > 0 != this.HasWater)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
        public static Vector2 DropToGround(Vector2 worldPos)
        {
            int x = (int)worldPos.X / 16;
            int y = (int)worldPos.Y / 16;

            do
            {
                y++;
            } while(y <= (Main.maxTilesY - 42) && !TileHelpers.IsSolid(Framing.GetTileSafely(x, y)));
            y--;

            return(new Vector2(worldPos.X, y * 16));
        }
コード例 #3
0
        public static bool FindNearbyRandomAirTile(int tileX, int tileY, int radius, out int toX, out int toY)
        {
            Tile tile      = null;
            int  wtf       = 0;
            bool isBlocked = false;

            toX = 0;
            toY = 0;

            if (tileX + radius <= 0 || tileX - radius >= Main.mapMaxX)
            {
                return(false);
            }
            if (tileY + radius <= 0 || tileY - radius >= Main.mapMaxY)
            {
                return(false);
            }

            do
            {
                do
                {
                    toX = Main.rand.Next(-radius, radius) + tileX;
                }while(toX <= 0 || toX >= Main.mapMaxX);
                do
                {
                    toY = Main.rand.Next(-radius, radius) + tileY;
                }while(toY <= 0 || toY >= Main.mapMaxY);

                //tile = Main.tile[toX, toY];
                tile = Framing.GetTileSafely(toX, toY);
                if (wtf++ > 100)
                {
                    return(false);
                }

                bool _;
                isBlocked = TileHelpers.IsSolid(tile, true, true) ||
                            TileWallHelpers.IsDungeon(tile, out _) ||
                            TileHelpers.IsWire(tile) ||
                            tile.lava();
            } while(isBlocked && ((tile != null && tile.type != 0) || Lighting.Brightness(toX, toX) == 0));

            return(true);
        }
コード例 #4
0
        public static bool HasNearbySolid(int tileX, int tileY, int proximityInTiles)
        {
            int minX = Math.Max(tileX - proximityInTiles, 0);
            int maxX = Math.Min(tileX + proximityInTiles, Main.maxTilesX - 1);
            int minY = Math.Max(tileY - proximityInTiles, 0);
            int maxY = Math.Min(tileY + proximityInTiles, Main.maxTilesY - 1);

            for (int i = minX; i <= maxX; i++)
            {
                for (int j = minY; j <= maxY; j++)
                {
                    if (TileHelpers.IsSolid(Main.tile[i, j]))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }