Пример #1
0
        public void SendObjects(GameClient Session)
        {
            Room Room = Session.GetHabbo().CurrentRoom;

            Session.SendMessage(new HeightMapComposer(Room.GetGameMap().Model.Heightmap));
            Session.SendMessage(new FloorHeightMapComposer(Room.GetGameMap().Model.GetRelativeHeightmap(), Room.GetGameMap().StaticModel.WallHeight));

            foreach (RoomUser RoomUser in _roomUserManager.GetUserList().ToList())
            {
                if (RoomUser == null)
                {
                    continue;
                }

                bool LoadBot  = true;
                bool ShowUser = true;

                if (RoomUser.IsBot)
                {
                    if (RoomUser.GetBotRoleplay() != null)
                    {
                        if (RoomUser.GetBotRoleplay().Invisible)
                        {
                            LoadBot = false;
                        }
                    }
                }


                if (LoadBot)
                {
                    if (RoomUser.IsBot)
                    {
                        Session.SendMessage(new UsersComposer(RoomUser));
                    }
                    else
                    {
                        if (RoomUser.GetClient() != null)
                        {
                            if (RoomUser.GetClient().GetRoleplay() != null)
                            {
                                if (RoomUser.GetClient().GetRoleplay().Invisible)
                                {
                                    ShowUser = false;
                                }
                            }
                        }
                    }

                    if (Session.GetRoomUser() == null)
                    {
                        return;
                    }

                    if (this.TutorialEnabled)
                    {
                        ShowUser = false;
                    }

                    if (ShowUser)
                    {
                        Session.SendMessage(new UsersComposer(RoomUser));
                    }
                    else
                    {
                        Session.SendMessage(new UsersComposer(Session.GetRoomUser()));
                    }
                }

                if (RoomUser.IsBot && RoomUser.BotData.DanceId > 0)
                {
                    Session.SendMessage(new DanceComposer(RoomUser, RoomUser.BotData.DanceId));
                }
                else if (!RoomUser.IsBot && !RoomUser.IsPet && RoomUser.IsDancing)
                {
                    Session.SendMessage(new DanceComposer(RoomUser, RoomUser.DanceId));
                }

                if (RoomUser.IsAsleep)
                {
                    Session.SendMessage(new SleepComposer(RoomUser, true));
                }

                if (RoomUser.CarryItemID > 0 && RoomUser.CarryTimer > 0)
                {
                    Session.SendMessage(new CarryObjectComposer(RoomUser.VirtualId, RoomUser.CarryItemID));
                }

                if (!RoomUser.IsBot && !RoomUser.IsPet && RoomUser.CurrentEffect > 0)
                {
                    Room.SendMessage(new AvatarEffectComposer(RoomUser.VirtualId, RoomUser.CurrentEffect));
                }
            }

            Session.SendMessage(new UserUpdateComposer(_roomUserManager.GetUserList().ToList()));
            Session.SendMessage(new ObjectsComposer(Session, Room.GetRoomItemHandler().GetFloor.ToArray(), this));
            Session.SendMessage(new ItemsComposer(Room.GetRoomItemHandler().GetWall.ToArray(), this));
        }
Пример #2
0
        public void LoadFurniture()
        {
            if (_floorItems.Count > 0)
            {
                _floorItems.Clear();
            }
            if (_wallItems.Count > 0)
            {
                _wallItems.Clear();
            }

            List <Item> Items = ItemLoader.GetItemsForRoom(_room.Id, _room);

            foreach (Item Item in Items.ToList())
            {
                if (Item == null)
                {
                    continue;
                }

                if (Item.UserID == 0)
                {
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE `items` SET `user_id` = @UserId WHERE `id` = @ItemId LIMIT 1");
                        dbClient.AddParameter("ItemId", Item.Id);
                        dbClient.AddParameter("UserId", _room.OwnerId);
                        dbClient.RunQuery();
                    }
                }

                if (Item.IsFloorItem)
                {
                    if (!_room.GetGameMap().ValidTile(Item.GetX, Item.GetY))
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE `items` SET `room_id` = '0' WHERE `id` = '" + Item.Id + "' LIMIT 1");
                        }

                        GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserId(Item.UserID);
                        if (Client != null)
                        {
                            Client.Habbo.GetInventoryComponent().AddNewItem(Item.Id, Item.BaseItem, Item.ExtraData, Item.GroupId, true, true, Item.LimitedNo, Item.LimitedTot);
                            Client.Habbo.GetInventoryComponent().UpdateItems(false);
                        }
                        continue;
                    }

                    if (!_floorItems.ContainsKey(Item.Id))
                    {
                        _floorItems.TryAdd(Item.Id, Item);
                    }
                }
                else if (Item.IsWallItem)
                {
                    if (string.IsNullOrWhiteSpace(Item.wallCoord))
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("UPDATE `items` SET `wall_pos` = @WallPosition WHERE `id` = '" + Item.Id + "' LIMIT 1");
                            dbClient.AddParameter("WallPosition", ":w=0,2 l=11,53 l");
                            dbClient.RunQuery();
                        }

                        Item.wallCoord = ":w=0,2 l=11,53 l";
                    }

                    try
                    {
                        Item.wallCoord = WallPositionCheck(":" + Item.wallCoord.Split(':')[1]);
                    }
                    catch
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("UPDATE `items` SET `wall_pos` = @WallPosition WHERE `id` = '" + Item.Id + "' LIMIT 1");
                            dbClient.AddParameter("WallPosition", ":w=0,2 l=11,53 l");
                            dbClient.RunQuery();
                        }

                        Item.wallCoord = ":w=0,2 l=11,53 l";
                    }

                    if (!_wallItems.ContainsKey(Item.Id))
                    {
                        _wallItems.TryAdd(Item.Id, Item);
                    }
                }
            }

            foreach (Item Item in _floorItems.Values.ToList())
            {
                if (Item.IsRoller)
                {
                    mGotRollers = true;
                }
                else if (Item.GetBaseItem().InteractionType == InteractionType.MOODLIGHT)
                {
                    if (_room.MoodlightData == null)
                    {
                        _room.MoodlightData = new MoodlightData(Item.Id);
                    }
                }
                else if (Item.GetBaseItem().InteractionType == InteractionType.TONER)
                {
                    if (_room.TonerData == null)
                    {
                        _room.TonerData = new TonerData(Item.Id);
                    }
                }
                else if (Item.IsWired)
                {
                    if (_room == null)
                    {
                        continue;
                    }

                    if (_room.GetWired() == null)
                    {
                        continue;
                    }

                    _room.GetWired().LoadWiredBox(Item);
                }
                else if (Item.GetBaseItem().InteractionType == InteractionType.HOPPER)
                {
                    HopperCount++;
                }
            }
        }
Пример #3
0
        /*internal bool IsValidMovement(int CoordX, int CoordY)
         * {
         *  if (CoordX < 0 || CoordY < 0 || CoordX >= Model.MapSizeX || CoordY >= Model.MapSizeY)
         *      return false;
         *
         *  if (SquareHasUsers(CoordX, CoordY))
         *      return false;
         *
         *  if (GetCoordinatedItems(new Point(CoordX, CoordY)).Count > 0 && !SquareIsOpen(CoordX, CoordY, false))
         *      return false;
         *
         *  return Model.SqState[CoordX, CoordY] == SquareState.OPEN;
         * }*/

        public bool IsValidStep2(RoomUser User, Vector2D From, Vector2D To, bool EndOfPath, bool Override)
        {
            if (User == null)
            {
                return(false);
            }
            if (!ValidTile(To.X, To.Y))
            {
                return(false);
            }
            if (Override)
            {
                return(true);
            }

            /*
             * 0 = blocked
             * 1 = open
             * 2 = last step
             * 3 = door
             * */
            var Items = _room.GetGameMap().GetAllRoomItemForSquare(To.X, To.Y);

            if (Items.Count > 0)
            {
                var HasGroupGate = Items.Count(x => x.GetBaseItem().InteractionType == InteractionType.GuildGate) > 0;
                if (HasGroupGate)
                {
                    var I = Items.FirstOrDefault(x => x.GetBaseItem().InteractionType == InteractionType.GuildGate);
                    if (I != null)
                    {
                        Group Group = null;
                        if (!PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(I.GroupId, out Group))
                        {
                            return(false);
                        }
                        if (User.GetClient() == null || User.GetClient().GetHabbo() == null)
                        {
                            return(false);
                        }

                        if (Group.IsMember(User.GetClient().GetHabbo().Id))
                        {
                            I.InteractingUser = User.GetClient().GetHabbo().Id;
                            I.ExtraData       = "1";
                            I.UpdateState(false, true);
                            I.RequestUpdate(4, true);
                            return(true);
                        }

                        if (User.Path.Count > 0)
                        {
                            User.Path.Clear();
                        }
                        User.PathRecalcNeeded = false;
                        return(false);
                    }
                }
            }

            var    Chair    = false;
            double HighestZ = -1;

            foreach (var Item in Items.ToList())
            {
                if (Item == null)
                {
                    continue;
                }

                if (Item.GetZ < HighestZ)
                {
                    Chair = false;
                    continue;
                }

                HighestZ = Item.GetZ;
                if (Item.GetBaseItem().IsSeat)
                {
                    Chair = true;
                }
            }

            if (GameMap[To.X, To.Y] == 3 && !EndOfPath && !Chair || GameMap[To.X, To.Y] == 0 ||
                GameMap[To.X, To.Y] == 2 && !EndOfPath)
            {
                if (User.Path.Count > 0)
                {
                    User.Path.Clear();
                }
                User.PathRecalcNeeded = true;
            }
            var HeightDiff = SqAbsoluteHeight(To.X, To.Y) - SqAbsoluteHeight(From.X, From.Y);

            if (HeightDiff > 1.5 && !User.RidingHorse)
            {
                return(false);
            }

            var userx = _room.GetRoomUserManager().GetUserForSquare(To.X, To.Y);

            if (userx == null)
            {
                return(true);
            }

            return(userx.IsWalking || !EndOfPath);
        }