Exemplo n.º 1
0
        public static int GetXYTilePercentage(string tiletype, int X, int Y, int Width, int Height)
        {
            double amountofmatchedtiles = 0;
            double totaltilecount       = 0;
            byte   type;

            if (QTools.GetTileTypeFromName(tiletype, out type))
            {
                for (int i = X; i < (X + Width); i++)
                {
                    for (int j = Y; j < (Y + Height); j++)
                    {
                        if (Main.tile[i, j].active && Main.tile[i, j].type == type)
                        {
                            amountofmatchedtiles++;
                        }
                        totaltilecount++;
                    }
                }
            }
            if (totaltilecount != 0)
            {
                return((int)((amountofmatchedtiles / totaltilecount) * 100));
            }
            return(0);
        }
Exemplo n.º 2
0
        public static int GetRegionTilePercentage(string tiletype, string regionname)
        {
            double amountofmatchedtiles = 0;
            double totaltilecount       = 0;

            TShockAPI.DB.Region r;
            byte type;

            if (QTools.GetTileTypeFromName(tiletype, out type))
            {
                if ((r = TShock.Regions.ZacksGetRegionByName(regionname)) != null)
                {
                    for (int i = r.Area.X; i < (r.Area.X + r.Area.Width); i++)
                    {
                        for (int j = r.Area.Y; j < (r.Area.Y + r.Area.Height); j++)
                        {
                            if (Main.tile[i, j].active && Main.tile[i, j].type == type)
                            {
                                amountofmatchedtiles++;
                            }
                            totaltilecount++;
                        }
                    }
                }
            }
            if (totaltilecount != 0)
            {
                return((int)((amountofmatchedtiles / totaltilecount) * 100));
            }
            return(0);
        }
Exemplo n.º 3
0
        public static void WallEdit(int x, int y, string wall)
        {
            byte type;

            if (QTools.GetTileTypeFromName(wall, out type))
            {
                if (type < 255)
                {
                    Main.tile[x, y].wall = (byte)type;
                }
                QTools.UpdateTile(x, y);
            }
            else
            {
                throw new Exception("Invalid Wall Name");
            }
        }
Exemplo n.º 4
0
        public static void TileEdit(int x, int y, string tile)
        {
            byte type;

            if (QTools.GetTileTypeFromName(tile, out type))
            {
                if (type < 253)
                {
                    Main.tile[x, y].type        = (byte)type;
                    Main.tile[x, y].active      = true;
                    Main.tile[x, y].liquid      = 0;
                    Main.tile[x, y].skipLiquid  = true;
                    Main.tile[x, y].frameNumber = 0;
                    Main.tile[x, y].frameX      = -1;
                    Main.tile[x, y].frameY      = -1;
                }
                else if (type == 253)
                {
                    Main.tile[x, y].active         = false;
                    Main.tile[x, y].skipLiquid     = false;
                    Main.tile[x, y].lava           = false;
                    Main.tile[x, y].liquid         = 255;
                    Main.tile[x, y].checkingLiquid = false;
                }
                else if (type == 254)
                {
                    Main.tile[x, y].active         = false;
                    Main.tile[x, y].skipLiquid     = false;
                    Main.tile[x, y].lava           = true;
                    Main.tile[x, y].liquid         = 255;
                    Main.tile[x, y].checkingLiquid = false;
                }
                if ((Main.tile[x, y].type == 53) || (Main.tile[x, y].type == 253) || (Main.tile[x, y].type == 254))
                {
                    WorldGen.SquareTileFrame(x, y, false);
                }
                QTools.UpdateTile(x, y);
            }
            else
            {
                throw new Exception("Invalid Tile Name");
            }
        }