Advertisement
Guest User

itemmanager.cs

a guest
Aug 24th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using Butterfly.Core;
  5. using Butterfly.HabboHotel.Items;
  6. using Database_Manager.Database.Session_Details.Interfaces;
  7.  
  8. namespace Butterfly.HabboHotel.Items
  9. {
  10. class ItemManager
  11. {
  12. private Dictionary<UInt32, Item> Items;
  13.  
  14. internal ItemManager()
  15. {
  16. Items = new Dictionary<uint, Item>();
  17. }
  18.  
  19. internal void LoadItems(IQueryAdapter dbClient)
  20. {
  21. Items = new Dictionary<uint, Item>();
  22.  
  23. dbClient.setQuery("SELECT * FROM items_base");
  24. DataTable ItemData = dbClient.getTable();
  25.  
  26. if (ItemData != null)
  27. {
  28. uint id;
  29. string publicName;
  30. string itemName;
  31. string type;
  32. int width;
  33. int length;
  34. double height;
  35. bool allowStack;
  36. bool allowSit;
  37. bool allowWalk;
  38. int spriteID;
  39. bool allowRecycle;
  40. bool allowTrade;
  41. bool allowMarketplace;
  42. bool allowGift;
  43. bool allowInventoryStack;
  44. InteractionType interactionType;
  45. int cycleCount;
  46. string vendingIDS;
  47.  
  48. foreach (DataRow dRow in ItemData.Rows)
  49. {
  50. try
  51. {
  52. id = Convert.ToUInt32(dRow[0]);
  53. publicName = (string)dRow[1];
  54. itemName = (string)dRow[2];
  55. type = (string)dRow[3];
  56. width = (int)dRow[4];
  57. length = (int)dRow[5];
  58. height = Convert.ToDouble(dRow[6]);
  59. allowStack = Convert.ToInt32(dRow[7]) == 1;
  60. allowSit = Convert.ToInt32(dRow[8]) == 1;
  61. allowWalk = Convert.ToInt32(dRow[9]) == 1;
  62. spriteID = (int)dRow[10];
  63. allowRecycle = Convert.ToInt32(dRow[11]) == 1;
  64. allowTrade = Convert.ToInt32(dRow[12]) == 1;
  65. allowMarketplace = Convert.ToInt32(dRow[13]) == 1;
  66. allowGift = Convert.ToInt32(dRow[14]) == 1;
  67. allowInventoryStack = Convert.ToInt32(dRow[15]) == 1;
  68. interactionType = InterractionTypes.GetTypeFromString((string)dRow[16]);
  69. cycleCount = (int)dRow[17];
  70. vendingIDS = (string)dRow[18];
  71.  
  72. Item item = new Item(id, publicName, itemName, type, width, length, height, allowStack, allowSit, allowWalk, spriteID, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS);
  73. Items.Add(id, item);
  74. }
  75. catch (Exception e)
  76. {
  77. Console.WriteLine(e.ToString());
  78. Console.ReadKey();
  79. Logging.WriteLine("Could not load item #" + Convert.ToUInt32(dRow[0]) + ", please verify the data is okay.");
  80. }
  81. }
  82. }
  83. }
  84.  
  85. internal Boolean ContainsItem(uint Id)
  86. {
  87. return Items.ContainsKey(Id);
  88. }
  89.  
  90. internal Item GetItem(uint Id)
  91. {
  92. if (ContainsItem(Id))
  93. return Items[Id];
  94.  
  95. return null;
  96. }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement