Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- using System.Collections.Generic;
- using Plus.HabboHotel.Quests;
- using Plus.HabboHotel.Rooms;
- using Plus.HabboHotel.Items;
- using Plus.HabboHotel.Items.Wired;
- using Plus.Communication.Packets.Outgoing.Rooms.Furni;
- using Plus.Communication.Packets.Outgoing.Rooms.Engine;
- using Plus.Database.Interfaces;
- using Plus.HabboHotel.Rooms.Games.Football;
- using System.Drawing;
- using Plus.Football;
- namespace Plus.Communication.Packets.Incoming.Rooms.Engine
- {
- class UseFurnitureEvent : IPacketEvent
- {
- public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
- {
- if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
- return;
- if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room Room))
- return;
- int itemID = Packet.PopInt();
- Item Item = Room.GetRoomItemHandler().GetItem(itemID);
- if (Item == null)
- return;
- bool hasRights = false;
- if (Room.CheckRights(Session, false, true))
- hasRights = true;
- if (Item.GetBaseItem().InteractionType == InteractionType.banzaitele)
- return;
- if (Item.GetBaseItem().InteractionType == InteractionType.TONER)
- {
- if (!Room.CheckRights(Session, true))
- return;
- if (Room.TonerData.Enabled == 0)
- Room.TonerData.Enabled = 1;
- else
- Room.TonerData.Enabled = 0;
- Room.SendPacket(new ObjectUpdateComposer(Item, Room.OwnerId));
- Item.UpdateState();
- using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
- {
- dbClient.RunQuery("UPDATE `room_items_toner` SET `enabled` = '" + Room.TonerData.Enabled + "' LIMIT 1");
- }
- return;
- }
- RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
- if (User == null)
- return;
- else if (Item.Data.InteractionType == InteractionType.FOOTBALL)
- {
- if (Item.SquareBehind == User.Coordinate || Item.SquareInFront == User.Coordinate || Item.SquareLeft == User.Coordinate || Item.SquareRight == User.Coordinate)
- {
- if(Room.GetSoccer() != null)
- {
- Soccer Soccer = Room.GetSoccer();
- if (!Room.GetGameMap().CanRollItemHere(User.SquareInFront.X, User.SquareInFront.Y))
- return;
- Item.ExtraData = "9";
- Item.BallTryGoThrough = 0;
- Item.Shoot = false;
- Item.ballIsMoving = true;
- Item.ballMover = User.GetClient();
- Item.comeDirection = ComeDirection.GetComeDirection(Item.Coordinate, Item.Coordinate, User.RotBody);
- Soccer.MoveBallProcess(Item);
- }
- }
- }
- User.UnIdle();
- Boolean Toggle = true;
- if (Item.GetBaseItem().InteractionType == InteractionType.WF_FLOOR_SWITCH_1 || Item.GetBaseItem().InteractionType == InteractionType.WF_FLOOR_SWITCH_2)
- {
- if (!Gamemap.TilesTouching(Item.GetX, Item.GetY, User.X, User.Y))
- {
- Toggle = false;
- }
- }
- string oldData = Item.ExtraData;
- int request = Packet.PopInt();
- Item.Interactor.OnTrigger(Session, Item, request, hasRights);
- if (Toggle)
- Item.GetRoom().GetWired().TriggerEvent(WiredBoxType.TriggerStateChanges, Session.GetHabbo(), Item);
- PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.EXPLORE_FIND_ITEM, Item.GetBaseItem().Id);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement