Exemple #1
0
        public Boolean BlockOnPoint(iPoint Point)
        {
            foreach (Item Item in GetBlocks().Values)
            {
                if (Item.Point.Compare(Point))
                {
                    return true;
                }
            }

            return false;
        }
Exemple #2
0
        public RoomModel(DataRow Row)
        {
            Security.SecurityCounter Counter = new Security.SecurityCounter(-1);

            Id = BrickEngine.GetConvertor().ObjectToString(Row[Counter.Next]);
            Map = BrickEngine.GetConvertor().ObjectToString(Row[Counter.Next]);

            Door = new iPoint(-1, -1);

            Door.X = BrickEngine.GetConvertor().ObjectToShort(Row[Counter.Next]) - 1;
            Door.Y = BrickEngine.GetConvertor().ObjectToShort(Row[Counter.Next]);
            Door.Z = BrickEngine.GetConvertor().ObjectToDouble(Row[Counter.Next]);
            DoorRot = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);

            LimitUsers = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);

            GenerateLines();
        }
Exemple #3
0
        public Item(Dictionary<int, Object> Row)
        {
            SecurityCounter Counter = new SecurityCounter(-1);

            Id = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);
            BaseId = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);
            OwnerId = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);
            RoomId = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);

            int X = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);
            int Y = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);
            double Z = BrickEngine.GetConvertor().ObjectToDouble(Row[Counter.Next]);

            this.Point = new iPoint(X, Y, Z);

            Rotation = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);
            WallPoint = BrickEngine.GetConvertor().ObjectToString(Row[Counter.Next]);
            ExtraData = BrickEngine.GetConvertor().ObjectToString(Row[Counter.Next]);
            InsideItemId = BrickEngine.GetConvertor().ObjectToInt32(Row[Counter.Next]);
        }
 public PathfinderNode(double Distance, iPoint Point, Boolean Diagonal)
 {
     this.Distance = Distance;
     this.Point = Point;
     this.Diagonal = Diagonal;
 }
Exemple #5
0
        private List<iPoint> CollectCrossCoords(iPoint CenterPoint)
        {
            var PointList = new List<iPoint>();

            short[,] CrossTiles = new short[4, 2] { { 0, -1 }, { 0, 1 }, { -1, 0 }, { 1, 0 } };

            for (int i = 0; i < CrossTiles.GetLength(0); i++)
            {
                int Xupdater = CrossTiles[i, 0];
                int Yupdater = CrossTiles[i, 1];

                PointList.Add(new iPoint(CenterPoint.X + Xupdater, CenterPoint.Y + Yupdater));
            }

            return PointList;
        }
Exemple #6
0
        private void MoveItemToRoom(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                // Outside room placing FTW.
                return;
            }

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                // Only Place in your own room.
                return;
            }

            int LimitX = Client.GetUser().GetRoom().GetRoomModel().XLength;
            int LimitY = Client.GetUser().GetRoom().GetRoomModel().YLength;

            int RoomId = Client.GetUser().RoomId;

            if (RoomId <= 0)
            {
                return;
            }

            // Get Point + Item Info.
            string PointInfo = Request.PopFixedString();

            // Split them in a array.
            string[] InfoSplit = PointInfo.Split(' ');

            // Gain ItemId & Verify
            int ItemId = BrickEngine.GetConvertor().ObjectToInt32(InfoSplit[0]);

            if (ItemId <= 0)
            {
                return;
            }

            VirtualRoomEngine RoomEngine = BrickEngine.GetRoomReactor().GetVirtualRoom(RoomId, RoomRunningState.Alive).GetRoomEngine();

            if (RoomEngine == null)
            {
                return;
            }

            if (InfoSplit[1].Contains(':'))
            {
                string Verify = RoomEngine.VerifyWallPosition(PointInfo.Substring(Array.IndexOf(PointInfo.ToCharArray(), ':')));

                if (string.IsNullOrEmpty(Verify) || !Verify.StartsWith(":"))
                {
                    return;
                }

                // Gain Item & Verify
                Item Item = null;

                if ((Item = BrickEngine.GetItemReactor().GetItem(ItemId)) == null)
                {
                    return;
                }

                Item.RoomId = RoomId;
                Item.WallPoint = Verify;

                RoomEngine.HandleIncomingItem(Item, Verify, Client.GetUser().GetRoomUser());
            }
            else
            {
                // Gain Point X & Verify
                int PointX = BrickEngine.GetConvertor().ObjectToInt32(InfoSplit[1]);

                if (PointX < 0 || PointX >= LimitX)
                {
                    return;
                }

                // Gain Point Y & Verify
                int PointY = BrickEngine.GetConvertor().ObjectToInt32(InfoSplit[2]);

                if (PointY < 0 || PointY >= LimitY)
                {
                    return;
                }

                // Gain Item Rot & Verify
                int ItemRot = BrickEngine.GetConvertor().ObjectToInt32(InfoSplit[3]);

                if (ItemRot < 0 || ItemRot > 6)
                {
                    return;
                }

                // Gain Item & Verify
                Item Item = null;

                if ((Item = BrickEngine.GetItemReactor().GetItem(ItemId)) == null)
                {
                    return;
                }

                // Already in a room
                if (Item.Place.Equals(ItemPlace.Room))
                {
                    return;
                }

                iPoint NewPlace = new iPoint(PointX, PointY);

                if (RoomEngine.LinkedPoint(Item, NewPlace, ItemRot))
                {
                    return;
                }

                Double PointZ = RoomEngine.GetTileHeight(NewPlace, Item.GetBaseItem().LengthZ, ItemId);

                if (PointZ < 0.0)
                {
                    PointZ = RoomEngine.GetTileHeight(NewPlace);
                }

                NewPlace.Z = PointZ;

                // Update Info & Cache
                Item.Point = NewPlace;
                Item.Rotation = ItemRot;
                Item.RoomId = RoomId;

                RoomEngine.HandleIncomingItem(Item, NewPlace, ItemRot, Client.GetUser().GetRoomUser());
            }

            Response Response = new Response(99);
            Response.AppendInt32(ItemId);
            Client.SendResponse(Response);
        }
Exemple #7
0
        private void PickUpItem(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                // Outside room placing FTW.
                return;
            }

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                // Only Pickup as owner.
                return;
            }

            // Avoid junk
            Request.PopWiredInt32();

            int ItemId = Request.PopWiredInt32();

            if (ItemId <= 0)
            {
                return;
            }

            // Gain Item & Verify
            Item Item = null;

            if ((Item = BrickEngine.GetItemReactor().GetItem(ItemId)) == null)
            {
                return;
            }

            // Already moved =)
            if (Item.Place.Equals(ItemPlace.Inventory))
            {
                return;
            }

            VirtualRoomEngine RoomEngine = Client.GetUser().GetRoom().GetRoomEngine();

            if (RoomEngine == null)
            {
                return;
            }

            Item.RoomId = 0;

            if (Item.GetBaseItem().InternalType.ToLower().Equals("s"))
            {
                int OldRotation = Item.Rotation;

                iPoint OldPlace = Item.Point;
                iPoint NewPlace = new iPoint(-1, -1, 0.0);

                int ItemRot = 0;

                Item.Rotation = ItemRot;
                Item.Point = NewPlace;

                RoomEngine.HandleIncomingItemPickUp(Item, OldPlace, NewPlace, OldRotation, ItemRot, Client.GetUser().GetRoomUser());
            }
            else
            {
                RoomEngine.HandleIncomingItemPickUp(Item, Client.GetUser().GetRoomUser());
            }

            Client.SendResponse(new Response(101));
        }
        private void PickAll(Client Client, List<string> Params)
        {
            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, RightsType.Founder))
            {
                return;
            }

            lock (Client.GetUser().GetRoom().GetRoomEngine().GetItems())
            {
                foreach (Item Item in Client.GetUser().GetRoom().GetRoomEngine().GetItems())
                {
                    int OldRotation = Item.Rotation;

                    iPoint OldPlace = Item.Point;
                    iPoint NewPlace = new iPoint(-1, -1, 0.0);

                    int NewRotation = 0;

                    Item.RoomId = 0;
                    Item.Rotation = NewRotation;
                    Item.Point = NewPlace;

                    Client.GetUser().GetRoom().GetRoomEngine().HandleIncomingItemPickUp(Item, OldPlace, NewPlace, OldRotation, NewRotation, Client.GetUser().GetRoomUser());

                    Client.SendResponse(new Response(101));
                }
            }
        }
 public double GetTileHeight(iPoint Point)
 {
     return HeightMap[Point.X, Point.Y];
 }
        public List<Item> GetFloorItemsOnTile(iPoint Point)
        {
            var List = new List<Item>();

            foreach (Item Item in GetFloorItems())
            {
                if (Item.Point.Compare(Point))
                {
                    List.Add(Item);
                    continue;
                }

                foreach (iPoint AffectedPoint in BrickEngine.GetItemReactor().GetAffectedPoints(Item.Point, Item.GetBaseItem().LengthY, Item.GetBaseItem().LengthX, Item.Rotation))
                {
                    if (AffectedPoint.Compare(Point) && !List.Contains(Item))
                    {
                        List.Add(Item);
                    }
                }
            }

            return List;
        }
        public VirtualRoomUser GenerateRoomPet(int PetId, iPoint Place, int Rot)
        {
            VirtualRoomUser User = new VirtualRoomUser(VirtualIdCounter.Next, PetId, RoomId, Rot);
            User.UpdatePoint(Place);

            User.Point.Z = GetTileHeight(Place);

            Response EnterMessage = new Response(28);
            EnterMessage.AppendInt32(1); // Amount, just 1
            User.GetResponse(EnterMessage);
            BroadcastResponse(EnterMessage);

            lock (RoomPets)
            {
                RoomPets.Add(User.VirtualId, User);
            }

            BrickEngine.GetPetReactor().GetPetInfo(PetId).X = Place.X;
            BrickEngine.GetPetReactor().GetPetInfo(PetId).Y = Place.Y;
            BrickEngine.GetPetReactor().GetPetInfo(PetId).Rot = Rot;

            return User;
        }
        public void GenerateMatrix()
        {
            this.Matrix = new TileState[GetRoom().GetRoomModel().XLength, GetRoom().GetRoomModel().YLength];
            this.HeightMap = new double[GetRoom().GetRoomModel().XLength, GetRoom().GetRoomModel().YLength];

            for (short y = 0; y < GetRoom().GetRoomModel().YLength; y++)
            {
                for (short x = 0; x < GetRoom().GetRoomModel().XLength; x++)
                {
                    HeightMap[x, y] = GetRoom().GetRoomModel().DefaultHeightMap[x, y];

                    iPoint Point = new iPoint(x, y);

                    if (GetFloorItemsOnTile(Point).Count > 0)
                    {
                        foreach (Item Item in GetFloorItemsOnTile(Point))
                        {
                            if (!Item.GetBaseItem().EnableSit)
                            {
                                HeightMap[x, y] += Item.GetBaseItem().LengthZ;
                            }

                            if (Item.GetBaseItem().EnableSit)
                            {
                                Matrix[x, y] = TileState.Walkable_laststep;
                            }
                            else if (Item.GetBaseItem().EnableWalk)
                            {
                                Matrix[x, y] = TileState.Walkable;
                            }
                            else
                            {
                                Matrix[x, y] = TileState.Blocked;
                            }
                        }
                    }
                    else
                    {
                        Matrix[x, y] = GetRoom().GetRoomModel().DefaultTiles[x, y];
                    }
                }
            }
        }
        public Boolean CanWalk(iPoint Point)
        {
            if (!GetRoom().AllowWalkthough)
            {
                foreach (VirtualRoomUser User in GetUsers())
                {
                    if (User.Point.Compare(Point))
                    {
                        return false;
                    }
                }

                foreach (VirtualRoomUser Pet in GetPets())
                {
                    if (Pet.Point.Compare(Point))
                    {
                        return false;
                    }
                }
            }

            return true;
        }
        public void UpdateUsersOnPoint(iPoint Point)
        {
            foreach (VirtualRoomUser User in GetUsers())
            {
                if (User.Point.Compare(Point))
                {
                    User.UpdateStatus(true);
                }
            }

            foreach (VirtualRoomUser Pet in GetPets())
            {
                if (Pet.Point.Compare(Point))
                {
                    Pet.UpdateStatus(true);
                }
            }
        }
Exemple #15
0
        public List<iPoint> GeneratePath(iPoint Start, iPoint End)
        {
            lock (Lock)
            {
                var List = new List<iPoint>();

                if (Start.Compare(End))
                {
                    return List;
                }

                iPoint WorkingTile = Start;
                iPoint OldTile = new iPoint(-1,-1);

                short[,] AroundTiles = new short[8, 2] { { 0, -1 }, { 0, 1 }, { -1, 0 }, { 1, 0 }, { -1, -1 }, { 1, -1 }, { -1, 1 }, { 1, 1 } };

                if (End.X >= Model.XLength || End.Y >= Model.YLength || Tiles[End.X, End.Y] == TileState.Blocked)
                {
                    return List;
                }

                do
                {
                    var TilesAround = new List<PathfinderNode>();

                    for (short i = 0; i < AroundTiles.GetLength(0); i++)
                    {
                        int X = (WorkingTile.X + AroundTiles[i, 0]);
                        int Y = (WorkingTile.Y + AroundTiles[i, 1]);

                        Boolean Diagonal = (i > 3);

                        if (X < 0 || Y < 0 || X >= Model.XLength || Y >= Model.YLength)
                        {
                            continue;
                        }

                        double Height = HeightMap[X, Y];

                        iPoint NexTile = new iPoint(X, Y, Height);

                        if (!GetRoom().GetRoomEngine().CanWalk(NexTile))
                        {
                            continue;
                        }

                        var State = Tiles[NexTile.X, NexTile.Y];

                        if (State == TileState.Walkable || (NexTile.Compare(End) && State == TileState.Walkable_laststep))
                        {
                            TilesAround.Add(new PathfinderNode(TileDistance(NexTile, End), NexTile, Diagonal));
                        }
                    }

                    if (TilesAround.Count > 0)
                    {
                        var Sorted = (from node in TilesAround orderby node.Distance ascending select node).ToList();

                        if (!List.Contains(Sorted[0].Point))
                        {
                            WorkingTile = Sorted[0].Point;

                            List.Add(Sorted[0].Point);
                        }
                        else
                        {
                            FoundPath = true;
                        }

                        if (End.Compare(WorkingTile))
                        {
                            FoundPath = true;
                        }
                    }
                    else
                    {
                        FoundPath = true;
                    }
                }
                while (!FoundPath);

                return List;
            }
        }
        public void Teleport(iPoint Point)
        {
            this.Point = Point;
            this.UpdateStatus(true);

            BrickEngine.GetEffectsHandler().RunFreeEffect(GetClient(), 4);
        }
 public void UpdatePoint(iPoint Point)
 {
     this.Point = Point;
 }
        public double GetTileHeight(iPoint Point, double Min, int ItemId)
        {
            if (GetFloorItemsOnTile(Point).Count <= 0)
            {
                Min = 0.0;
            }
            else
            {
                int i = 0;

                foreach (Item Item in GetFloorItemsOnTile(Point))
                {
                    if (Item.Id == ItemId)
                    {
                        i++;
                    }
                }

                if (i <= 0)
                {
                    Min = 0.0;
                }
            }

            return HeightMap[Point.X, Point.Y] - Min;
        }
Exemple #19
0
 public static int Calculate(iPoint a, iPoint b)
 {
     return Calculate(a.X, a.Y, b.X, b.Y);
 }
        public void HandleIncomingItemPickUp(Item Item, iPoint OldPlace, iPoint NewPlace, int OldRotation, int Rotation, VirtualRoomUser User)
        {
            // Handling Messages (FIRST, to avoid laggys)
            Response Response = new Response();

            if (Item.GetBaseItem().InternalType.ToLower().Equals("s"))
            {
                Response.Initialize(94);
            }
            else
            {
                Response.Initialize(84);
            }

            Response.AppendRawInt32(Item.Id);
            Response.AppendChar(2);
            Response.AppendBoolean(false);

            BroadcastResponse(Response);

            GenerateMatrix();

            UpdateUsersOnPoint(OldPlace);

            foreach (iPoint Point in BrickEngine.GetItemReactor().GetAffectedPoints(OldPlace, Item.GetBaseItem().LengthY, Item.GetBaseItem().LengthX, OldRotation))
            {
                UpdateUsersOnPoint(Point);
            }

            Item.GetTrigger().OnRemove(Item, User);

            if (Item.GetBaseItem().ExternalType.ToLower().Equals("default"))
            {
                Item.ExtraData = "0";

                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', extra_data = '0', point_x = @x, point_y = @y, point_z = @z, rotation = @rot WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.AddParam("x", NewPlace.X);
                    Reactor.AddParam("y", NewPlace.Y);
                    Reactor.AddParam("z", NewPlace.Z.ToString().Replace(',', '.'));
                    Reactor.AddParam("rot", Rotation);
                    Reactor.ExcuteQuery();
                }
            }
            else
            {
                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', point_x = @x, point_y = @y, point_z = @z, rotation = @rot WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.AddParam("x", NewPlace.X);
                    Reactor.AddParam("y", NewPlace.Y);
                    Reactor.AddParam("z", NewPlace.Z.ToString().Replace(',', '.'));
                    Reactor.AddParam("rot", Rotation);
                    Reactor.ExcuteQuery();
                }
            }
        }
Exemple #21
0
        private void UpdateFloorItem(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                // Outside room placing FTW.
                return;
            }

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Rights))
            {
                // Only Update with rights.
                return;
            }

            int LimitX = Client.GetUser().GetRoom().GetRoomModel().XLength;
            int LimitY = Client.GetUser().GetRoom().GetRoomModel().YLength;

            int ItemId = Request.PopWiredInt32();

            if (ItemId <= 0)
            {
                return;
            }

            int PointX = Request.PopWiredInt32();

            if (PointX < 0 || PointX >= LimitX)
            {
                return;
            }

            int PointY = Request.PopWiredInt32();

            if (PointY < 0 || PointY >= LimitY)
            {
                return;
            }

            int ItemRot = Request.PopWiredInt32();

            if (ItemRot < 0 || ItemRot > 6)
            {
                return;
            }

            // Gain Item & Verify
            Item Item = null;

            if ((Item = BrickEngine.GetItemReactor().GetItem(ItemId)) == null)
            {
                return;
            }

            // Still in inventory!?
            if (Item.Place.Equals(ItemPlace.Inventory))
            {
                return;
            }

            VirtualRoomEngine RoomEngine = Client.GetUser().GetRoom().GetRoomEngine();

            if (RoomEngine == null)
            {
                return;
            }

            int OldRotation = Item.Rotation;

            iPoint OldPlace = Item.Point;
            iPoint NewPlace = new iPoint(PointX, PointY);

            if (RoomEngine.LinkedPoint(Item, NewPlace, ItemRot))
            {
                return;
            }

            Double PointZ = RoomEngine.GetTileHeight(NewPlace, Item.GetBaseItem().LengthZ, ItemId);

            if (PointZ < 0.0)
            {
                PointZ = RoomEngine.GetTileHeight(NewPlace);
            }

            NewPlace.Z = PointZ;

            // Update Info & Cache
            Item.Point = NewPlace;
            Item.Rotation = ItemRot;

            RoomEngine.HandleIncomingItemUpdate(Item, OldPlace, NewPlace, OldRotation, ItemRot, Client.GetUser().GetRoomUser());
        }
        // Already Updated @cache
        public void HandleIncomingItemUpdate(Item Item, iPoint OldPlace, iPoint NewPlace, int OldRotation, int Rotation, VirtualRoomUser User)
        {
            // Handling Messages (FIRST, to avoid laggys)
            Response Response = new Response(95);
            Item.GetRoomResponse(Response);
            BroadcastResponse(Response);

            GenerateMatrix();

            UpdateUsersOnPoint(OldPlace);

            foreach (iPoint Point in BrickEngine.GetItemReactor().GetAffectedPoints(OldPlace, Item.GetBaseItem().LengthY, Item.GetBaseItem().LengthX, OldRotation))
            {
                UpdateUsersOnPoint(Point);
            }

            UpdateUsersOnPoint(NewPlace);

            foreach (iPoint Point in BrickEngine.GetItemReactor().GetAffectedPoints(NewPlace, Item.GetBaseItem().LengthY, Item.GetBaseItem().LengthX, Rotation))
            {
                UpdateUsersOnPoint(Point);
            }

            Item.GetTrigger().OnUpdate(Item, User);

            // Update Info & MySQL
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE items SET point_x = @x, point_y = @y, point_z = @z, rotation = @rot WHERE id = @itemid LIMIT 1");
                Reactor.AddParam("itemid", Item.Id);
                Reactor.AddParam("x", NewPlace.X);
                Reactor.AddParam("y", NewPlace.Y);
                Reactor.AddParam("z", NewPlace.Z.ToString().Replace(',', '.'));
                Reactor.AddParam("rot", Rotation);
                Reactor.ExcuteQuery();
            }
        }
Exemple #23
0
        private void MovePetToRoom(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                // Outside room placing FTW.
                return;
            }

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                // Only Place in your own room.
                return;
            }

            int PetId = Request.PopWiredInt32();

            if (PetId <= 0)
            {
                return;
            }

            PetInfo Info = BrickEngine.GetPetReactor().GetPetInfo(PetId);

            if (Info == null)
            {
                return;
            }

            if (Info.UserId != Client.GetUser().HabboId)
            {
                return;
            }

            if (Client.GetUser().GetRoom().GetRoomEngine().GetPets().Count >= PetReactor.MAX_PETS_PER_ROOM)
            {
                Client.Notif(string.Format("A room can only contains {0} pets.",PetReactor.MAX_PETS_PER_ROOM), false);
                return;
            }

            int LimitX = Client.GetUser().GetRoom().GetRoomModel().XLength;
            int LimitY = Client.GetUser().GetRoom().GetRoomModel().YLength;

            int X = Request.PopWiredInt32();

            if (X < 0 || X >= LimitX)
            {
                return;
            }

            int Y = Request.PopWiredInt32();

            if (Y < 0 || Y >= LimitY)
            {
                return;
            }

            iPoint Place = new iPoint(X, Y);

            VirtualRoomEngine RoomEngine = BrickEngine.GetRoomReactor().GetVirtualRoom(Client.GetUser().RoomId, RoomRunningState.Alive).GetRoomEngine();

            if (RoomEngine == null)
            {
                return;
            }

            Info.RoomId = Client.GetUser().RoomId;

            int Rot = Rotation.Calculate(Place, Client.GetUser().GetRoomUser().Point);

            RoomEngine.GenerateRoomPet(PetId, Place, Rot);

            Response RemoveMessage = new Response(604);
            RemoveMessage.AppendInt32(PetId);
            Client.SendResponse(RemoveMessage);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE user_pets SET room_id = @roomid WHERE id = @petid LIMIT 1");
                Reactor.AddParam("roomid", Client.GetUser().RoomId);
                Reactor.AddParam("petid", PetId);
                Reactor.ExcuteQuery();
            }
        }
        public Boolean LinkedPoint(Item Furni, iPoint NextPoint, int Rotation)
        {
            foreach (Item Item in GetFloorItemsOnTile(NextPoint))
            {
                if (Item.Id.Equals(Furni.Id))
                {
                    continue;
                }

                if (!Item.GetBaseItem().EnableStack)
                {
                    return true;
                }
            }

            foreach (iPoint Point in BrickEngine.GetItemReactor().GetAffectedPoints(NextPoint, Furni.GetBaseItem().LengthY, Furni.GetBaseItem().LengthX, Rotation))
            {
                foreach (Item Item in GetFloorItemsOnTile(Point))
                {
                    if (Item.Id.Equals(Furni.Id))
                    {
                        continue;
                    }

                    if (!Item.GetBaseItem().EnableStack)
                    {
                        return true;
                    }
                }
            }

            return false;
        }
Exemple #25
0
        private List<int> GetHabboIdsForPoint(iPoint Point)
        {
            var List = new List<int>();

            foreach (VirtualRoomUser User in GetEngine().GetUsers())
            {
                if (User.Point.Compare(Point))
                {
                    List.Add(User.HabboId);
                }
            }

            return List;
        }
        public void Prepare()
        {
            UserHandler = new Timer(new TimerCallback(HandleUsers), UserHandler, 0, 500);
            PetsHandler = new Timer(new TimerCallback(HandlePets), PetsHandler, 100, 500);

            GenerateMatrix();

            foreach (PetInfo Info in BrickEngine.GetPetReactor().GetPetsForRoom(RoomId))
            {
                int Rot = Info.Rot;

                iPoint Place = new iPoint(Info.X, Info.Y);

                if (!Place.Compare(GetRoom().GetRoomModel().Door))
                {
                    if ((Place.X <= 0 && Place.Y <= 0) || Place.X >= GetRoom().GetRoomModel().XLength || Place.Y >= GetRoom().GetRoomModel().YLength)
                    {
                        Place = GetRoom().GetRoomModel().Door;
                    }

                    if (!Matrix[Place.X, Place.Y].Equals(TileState.Walkable) || !CanWalk(Place))
                    {
                        Place = GetRoom().GetRoomModel().Door;
                    }
                }

                if (Rot < 0)
                {
                    Rot = GetRoom().GetRoomModel().DoorRot;
                }

                GenerateRoomPet(Info.Id, Place, Rot);
            }
        }
 public double GetTileHeight(iPoint Point)
 {
     try { return GetRoomModel().DefaultHeightMap[Point.X, Point.Y]; }
     catch { return 0.0; }
 }
Exemple #28
0
        private void FocusOnTile(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            if (Client.GetUser().GetRoomUser().IsWalking)
            {
                return;
            }

            int X = Request.PopWiredInt32();
            int Y = Request.PopWiredInt32();

            iPoint MainPlace = Client.GetUser().GetRoomUser().Point;
            iPoint FocusPlace = new iPoint(X,Y);

            if (MainPlace.Compare(FocusPlace) || Client.GetUser().GetRoomUser().NeedsLastWalk)
            {
                return;
            }

            int RotationToPoint = Rotation.Calculate(MainPlace,FocusPlace);

            Client.GetUser().GetRoomUser().RotBody = RotationToPoint;
            Client.GetUser().GetRoomUser().RotHead = RotationToPoint;
            Client.GetUser().GetRoomUser().UpdateStatus(true);
        }
        public void RedeemPresent(Client Client, Item Item)
        {
            iPoint OldPlace = Item.Point;
            int OldRot = Item.Rotation;

            iPoint NewPlace = new iPoint(-1, -1);
            int NewRot = 0;

            Client.GetUser().GetRoom().GetRoomEngine().HandleIncomingItemPickUp(Item, OldPlace, NewPlace, OldRot, NewRot, Client.GetUser().GetRoomUser());

            Item.RoomId = 0;
            Item.Rotation = NewRot;
            Item.Point = NewPlace;
            Item.BaseId = Item.InsideItemId;
            Item.InsideItemId = -1;

            Response ResponseA = new Response(219);
            ResponseA.AppendInt32(Item.Id);
            Client.SendResponse(ResponseA);

            Response ResponseB = new Response(129);
            ResponseB.AppendStringWithBreak(Item.GetBaseItem().InternalType.ToLower());
            ResponseB.AppendInt32(Item.GetBaseItem().SpriteId);
            ResponseB.AppendStringWithBreak(Item.GetBaseItem().InternalName);
            Client.SendResponse(ResponseB);

            Response Response = new Response(832);
            Response.AppendInt32(1);
            Response.AppendInt32(Item.GetBaseItem().InternalType.ToLower().Equals("s") ? 1 : 2);
            Response.AppendInt32(1);
            Response.AppendInt32(Item.Id);
            Client.SendResponse(Response);

            Client.SendResponse(new Response(101));

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE items SET base_id = @baseid, inside_base_id = '-1' WHERE id = @itemid LIMIT 1");
                Reactor.AddParam("baseid", Item.BaseId);
                Reactor.AddParam("itemid", Item.Id);
                Reactor.ExcuteQuery();
            }
        }
Exemple #30
0
 private int TileDistance(iPoint Start, iPoint End)
 {
     return Math.Abs(Start.X - End.X) + Math.Abs(Start.Y - End.Y);
 }