Advertisement
Guest User

Untitled

a guest
May 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Collections.Generic;
  5.  
  6. using Plus.HabboHotel.Quests;
  7. using Plus.HabboHotel.Rooms;
  8. using Plus.HabboHotel.Items;
  9. using Plus.HabboHotel.Items.Wired;
  10. using Plus.Communication.Packets.Outgoing.Rooms.Furni;
  11. using Plus.Communication.Packets.Outgoing.Rooms.Engine;
  12.  
  13. using Plus.Database.Interfaces;
  14. using Plus.HabboHotel.Rooms.Games.Football;
  15. using System.Drawing;
  16. using Plus.Football;
  17.  
  18. namespace Plus.Communication.Packets.Incoming.Rooms.Engine
  19. {
  20. class UseFurnitureEvent : IPacketEvent
  21. {
  22. public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
  23. {
  24. if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
  25. return;
  26.  
  27. if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room Room))
  28. return;
  29.  
  30. int itemID = Packet.PopInt();
  31. Item Item = Room.GetRoomItemHandler().GetItem(itemID);
  32. if (Item == null)
  33. return;
  34.  
  35. bool hasRights = false;
  36. if (Room.CheckRights(Session, false, true))
  37. hasRights = true;
  38.  
  39. if (Item.GetBaseItem().InteractionType == InteractionType.banzaitele)
  40. return;
  41.  
  42. if (Item.GetBaseItem().InteractionType == InteractionType.TONER)
  43. {
  44. if (!Room.CheckRights(Session, true))
  45. return;
  46. if (Room.TonerData.Enabled == 0)
  47. Room.TonerData.Enabled = 1;
  48. else
  49. Room.TonerData.Enabled = 0;
  50.  
  51. Room.SendPacket(new ObjectUpdateComposer(Item, Room.OwnerId));
  52.  
  53. Item.UpdateState();
  54.  
  55. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  56. {
  57. dbClient.RunQuery("UPDATE `room_items_toner` SET `enabled` = '" + Room.TonerData.Enabled + "' LIMIT 1");
  58. }
  59. return;
  60. }
  61.  
  62. RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
  63. if (User == null)
  64. return;
  65.  
  66. else if (Item.Data.InteractionType == InteractionType.FOOTBALL)
  67. {
  68. if (Item.SquareBehind == User.Coordinate || Item.SquareInFront == User.Coordinate || Item.SquareLeft == User.Coordinate || Item.SquareRight == User.Coordinate)
  69. {
  70. if(Room.GetSoccer() != null)
  71. {
  72. Soccer Soccer = Room.GetSoccer();
  73. if (!Room.GetGameMap().CanRollItemHere(User.SquareInFront.X, User.SquareInFront.Y))
  74. return;
  75.  
  76. Item.ExtraData = "9";
  77. Item.BallTryGoThrough = 0;
  78. Item.Shoot = false;
  79. Item.ballIsMoving = true;
  80. Item.ballMover = User.GetClient();
  81.  
  82. Item.comeDirection = ComeDirection.GetComeDirection(Item.Coordinate, Item.Coordinate, User.RotBody);
  83. Soccer.MoveBallProcess(Item);
  84. }
  85. }
  86. }
  87.  
  88. User.UnIdle();
  89.  
  90. Boolean Toggle = true;
  91. if (Item.GetBaseItem().InteractionType == InteractionType.WF_FLOOR_SWITCH_1 || Item.GetBaseItem().InteractionType == InteractionType.WF_FLOOR_SWITCH_2)
  92. {
  93. if (!Gamemap.TilesTouching(Item.GetX, Item.GetY, User.X, User.Y))
  94. {
  95. Toggle = false;
  96. }
  97. }
  98.  
  99. string oldData = Item.ExtraData;
  100. int request = Packet.PopInt();
  101.  
  102. Item.Interactor.OnTrigger(Session, Item, request, hasRights);
  103.  
  104. if (Toggle)
  105. Item.GetRoom().GetWired().TriggerEvent(WiredBoxType.TriggerStateChanges, Session.GetHabbo(), Item);
  106.  
  107. PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.EXPLORE_FIND_ITEM, Item.GetBaseItem().Id);
  108. }
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement