Esempio n. 1
0
        public void RemoveItem(GameClient session, RoomItem item)
        {
            this.FloorItems.Remove(item.ID, item.GetType());
            this.WallItems.Remove(item.ID, item.GetType());
            this.AddedAndMovedRoomItems.TryRemove(item.ID, out RoomItem item_);
            this.RoomItemStateUpdated.TryRemove(item.ID, out item_);
            this.Room.RoomGameManager.RemoveItem(item);

            if (item.IsWallItem)
            {
                this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.RemoveWallItem, new ValueHolder("ID", item.ID, "UserID", session == null ? 0 : session.GetHabbo().ID)));
            }
            else
            {
                this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.RemoveFloorItem, new ValueHolder("ID", item.ID, "UserID", session == null ? 0 : session.GetHabbo().ID)));
            }

            item.OnPickup(session);
            this.CheckItemBasedAchievements(item);

            if (item is RoomItemJukebox)
            {
                if (this.Jukebox == (RoomItemJukebox)item)
                {
                    this.Jukebox = null;
                }
            }
        }
Esempio n. 2
0
        public void AddItem(GameClient session, RoomItem item, bool newItem)
        {
            if (item.IsFloorItem)
            {
                if (!this.FloorItems.Add(item.ID, item.GetType(), item))
                {
                    session.SendNotif("Something weird happend... Placement failed");
                    return;
                }
            }
            else if (item.IsWallItem)
            {
                if (!this.WallItems.Add(item.ID, item.GetType(), item))
                {
                    session.SendNotif("Something weird happend... Placement failed");
                    return;
                }
            }

            this.Room.RoomGameManager.AddItem(item);

            if (newItem)
            {
                this.AddedAndMovedRoomItems.AddOrUpdate(item.ID, item, (key, oldValue) => item);
                this.RoomItemStateUpdated.TryRemove(item.ID);

                item.OnPlace(session);
                this.CheckItemBasedAchievements(item);
            }
            else
            {
                item.OnLoad();
            }

            if (item is RoomItemJukebox)
            {
                if (this.Jukebox == null)
                {
                    this.Jukebox = (RoomItemJukebox)item;
                }
            }
        }