private static bool HandlePaintWall(GetDataHandlerArgs args)
        {
            var Start = DateTime.Now;

            var X = args.Data.ReadInt16();
            var Y = args.Data.ReadInt16();
            var T = args.Data.ReadInt8();

            if (!args.Player.Group.HasPermission(EditHouse))
            {
                //lock (HousingDistricts.HPlayers)
                {
                    var rect = new Rectangle(X, Y, 1, 1);
                    return(House.HandlerAction((house) =>
                    {
                        if (HousingDistricts.Timeout(Start))
                        {
                            return false;
                        }
                        if (house != null && house.HouseArea.Intersects(rect))
                        {
                            if (!HTools.OwnsHouse(args.Player.User, house))
                            {
                                args.Player.SendData(PacketTypes.PaintWall, "", X, Y, Main.tile[X, Y].wallColor());
                                return true;
                            }
                        }
                        return false;
                    }));
                }
            }
            return(false);
        }
        private static bool HandleSendTileSquare(GetDataHandlerArgs args)
        {
            var Start = DateTime.Now;

            short size  = args.Data.ReadInt16();
            int   tilex = args.Data.ReadInt16();
            int   tiley = args.Data.ReadInt16();

            if (!args.Player.Group.HasPermission(EditHouse))
            {
                //lock (HousingDistricts.HPlayers)
                {
                    var rect = new Rectangle(tilex, tiley, size, size);
                    return(House.HandlerAction((house) =>
                    {
                        if (HousingDistricts.Timeout(Start))
                        {
                            return false;
                        }
                        if (house != null && house.HouseArea.Intersects(rect))
                        {
                            if (!HTools.OwnsHouse(args.Player.User, house))
                            {
                                args.Player.SendTileSquare(tilex, tiley);
                                return true;
                            }
                        }
                        return false;
                    }));
                }
            }
            return(false);
        }
Exemple #3
0
        private static bool HandleSendTileSquare(GetDataHandlerArgs args)
        {
            short size  = args.Data.ReadInt16();
            int   tilex = args.Data.ReadInt32();
            int   tiley = args.Data.ReadInt32();

            if (!args.Player.Group.HasPermission("edithouse"))
            {
                lock (HousingDistricts.HPlayers)
                {
                    foreach (House house in HousingDistricts.Houses)
                    {
                        if (house.HouseArea.Intersects(new Rectangle(tilex, tiley, 1, 1)) && house.WorldID == Main.worldID.ToString())
                        {
                            if (!HTools.OwnsHouse(args.Player.UserID.ToString(), house.Name))
                            {
                                args.Player.SendTileSquare(tilex, tiley);
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Exemple #4
0
        private static bool HandleTile(GetDataHandlerArgs args)
        {
            byte type     = args.Data.ReadInt8();
            int  x        = args.Data.ReadInt32();
            int  y        = args.Data.ReadInt32();
            byte tiletype = args.Data.ReadInt8();
            var  player   = HTools.GetPlayerByID(args.Player.Index);

            int tilex = Math.Abs(x);
            int tiley = Math.Abs(y);

            if (player.AwaitingHouseName)
            {
                if (HTools.InAreaHouseName(x, y) == null)
                {
                    args.Player.SendMessage("Tile is not in any House", Color.Yellow);
                }
                else
                {
                    args.Player.SendMessage("House Name: " + HTools.InAreaHouseName(x, y), Color.Yellow);
                }
                args.Player.SendTileSquare(x, y);
                player.AwaitingHouseName = false;
                return(true);
            }

            if (args.Player.AwaitingTempPoint > 0)
            {
                args.Player.TempPoints[args.Player.AwaitingTempPoint - 1].X = x;
                args.Player.TempPoints[args.Player.AwaitingTempPoint - 1].Y = y;
                args.Player.SendMessage("Set Temp Vector2 " + args.Player.AwaitingTempPoint, Color.Yellow);
                args.Player.SendTileSquare(x, y);
                args.Player.AwaitingTempPoint = 0;
                return(true);
            }

            if (!args.Player.Group.HasPermission("edithouse"))
            {
                lock (HousingDistricts.HPlayers)
                {
                    foreach (House house in HousingDistricts.Houses)
                    {
                        if (house.HouseArea.Intersects(new Rectangle(tilex, tiley, 1, 1)) && house.WorldID == Main.worldID.ToString())
                        {
                            if (!HTools.OwnsHouse(args.Player.UserID.ToString(), house.Name))
                            {
                                args.Player.SendTileSquare(tilex, tiley);
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
        private static bool HandleMassWire(GetDataHandlerArgs args)
        {
            var Start = DateTime.Now;

            int x1 = args.Data.ReadInt16();
            int y1 = args.Data.ReadInt16();
            int x2 = args.Data.ReadInt16();
            int y2 = args.Data.ReadInt16();

            var player = HTools.GetPlayerByID(args.Player.Index);;

            if (args.Player.AwaitingTempPoint > 0)
            {
                args.Player.TempPoints[0].X = x1;
                args.Player.TempPoints[0].Y = y1;
                args.Player.TempPoints[1].X = x2;
                args.Player.TempPoints[1].Y = y2;

                args.Player.SendMessage("Protection corners have been set!", Color.Yellow);
                args.Player.AwaitingTempPoint = 0;
                return(true);
            }
            if (!args.Player.Group.HasPermission(EditHouse))
            {
                Rectangle A = new Rectangle(Math.Min(x1, x2), args.TPlayer.direction != 1 ? y1 : y2, Math.Abs(x2 - x1) + 1, 1);
                Rectangle B = new Rectangle(args.TPlayer.direction != 1 ? x2 : x1, Math.Min(y1, y2), 1, Math.Abs(y2 - y1) + 1);

                //lock (HousingDistricts.HPlayers)
                {
                    return(House.HandlerAction((house) =>
                    {
                        if (HousingDistricts.Timeout(Start))
                        {
                            return false;
                        }
                        if (house != null && (house.HouseArea.Intersects(A) || house.HouseArea.Intersects(B)))
                        {
                            if (!HTools.OwnsHouse(args.Player.User, house))
                            {
                                return true;
                            }
                        }
                        return false;
                    }));
                }
            }
            return(false);
        }
        private static bool HandleTeleport(GetDataHandlerArgs args)
        {
            if (HConfigFile.Config.AllowRod || args.Player.Group.HasPermission(TPHouse))
            {
                return(false);
            }

            var Start = DateTime.Now;

            var Flags = args.Data.ReadInt8();
            var ID    = args.Data.ReadInt16();
            var X     = args.Data.ReadSingle();
            var Y     = args.Data.ReadSingle();

            if ((Flags & 2) != 2 && (Flags & 1) != 1 && !args.Player.Group.HasPermission(TPHouse))
            {
                //lock (HousingDistricts.HPlayers)
                {
                    var rect = new Rectangle((int)(X / 16), (int)(Y / 16), 2, 4);
                    return(House.HandlerAction((house) =>
                    {
                        if (HousingDistricts.Timeout(Start))
                        {
                            return false;
                        }
                        if (house != null && house.HouseArea.Intersects(rect))
                        {
                            if (!HTools.CanVisitHouse(args.Player.User, house))
                            {
                                args.Player.SendErrorMessage(string.Format("You do not have permission to teleport into house '{0}'.", house.Name));
                                args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y);
                                return true;
                            }
                        }
                        return false;
                    }));
                }
            }
            return(false);
        }
        private static bool HandleChest(GetDataHandlerArgs args)
        {
            var Start = DateTime.Now;

            int action = args.Data.ReadByte();
            int X      = args.Data.ReadInt16();
            int Y      = args.Data.ReadInt16();

            var player = HTools.GetPlayerByID(args.Player.Index);

            /*
             * if (player.AwaitingHouseName)
             * {
             *      if (HTools.InAreaHouseName(x, y) == null)
             *              args.Player.SendMessage("Tile is not in any House", Color.Yellow);
             *      else
             *              args.Player.SendMessage("House Name: " + HTools.InAreaHouseName(x, y), Color.Yellow);
             *
             *      args.Player.SendTileSquare(x, y);
             *      player.AwaitingHouseName = false;
             *      return true;
             * }
             *
             * if (args.Player.AwaitingTempPoint > 0)
             * {
             *      args.Player.TempPoints[args.Player.AwaitingTempPoint - 1].X = x;
             *      args.Player.TempPoints[args.Player.AwaitingTempPoint - 1].Y = y;
             *      if (args.Player.AwaitingTempPoint == 1)
             *              args.Player.SendMessage("Top-left corner of protection area has been set!", Color.Yellow);
             *
             *      if (args.Player.AwaitingTempPoint == 2)
             *              args.Player.SendMessage("Bottom-right corner of protection area has been set!", Color.Yellow);
             *
             *      args.Player.SendTileSquare(x, y);
             *      args.Player.AwaitingTempPoint = 0;
             *      return true;
             * }
             */

            if (!args.Player.Group.HasPermission(EditHouse))
            {
                //lock (HousingDistricts.HPlayers)
                {
                    var rect = new Rectangle(X, Y, 1, 1);
                    return(House.HandlerAction((house) =>
                    {
                        if (HousingDistricts.Timeout(Start))
                        {
                            return false;
                        }
                        if (house != null && house.HouseArea.Intersects(rect))
                        {
                            if (!HTools.OwnsHouse(args.Player.User, house))
                            {
                                args.Player.SendTileSquare(X, Y);
                                return true;
                            }
                        }
                        return false;
                    }));
                }
            }
            return(false);
        }