using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Uber.Storage; using Uber.Collections; namespace Uber.HabboHotel.Items { class ItemManager { private SafeDictionary Items; public ItemManager() { this.Items = new SafeDictionary(); } public void LoadItems() { this.Items = null; this.Items = new SafeDictionary(); DataTable ItemData = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { ItemData = dbClient.ReadDataTable("SELECT * FROM furniture"); } if (ItemData != null) { foreach (DataRow Row in ItemData.Rows) { try { Items.Add((uint)Row["id"], new Item(Convert.ToUInt32(Row["id"]), Convert.ToInt32(Row["sprite_id"]), (string)Row["public_name"], (string)Row["item_name"], (string)Row["type"], (int)Row["width"], (int)Row["length"], (Double)Row["stack_height"], UberEnvironment.EnumToBool(Row["can_stack"].ToString()), UberEnvironment.EnumToBool(Row["is_walkable"].ToString()), UberEnvironment.EnumToBool(Row["can_sit"].ToString()), UberEnvironment.EnumToBool(Row["allow_recycle"].ToString()), UberEnvironment.EnumToBool(Row["allow_trade"].ToString()), UberEnvironment.EnumToBool(Row["allow_marketplace_sell"].ToString()), UberEnvironment.EnumToBool(Row["allow_gift"].ToString()), UberEnvironment.EnumToBool(Row["allow_inventory_stack"].ToString()), (string)Row["interaction_type"], (int)Row["interaction_modes_count"], (string)Row["vending_ids"])); } catch (Exception e) { UberEnvironment.GetLogging().WriteLine("Could not load item #" + (uint)Row["id"] + ", please verify the data is okay. Reason: " + e.Message, Core.LogLevel.Error); } } } UberEnvironment.GetLogging().WriteLine("Loaded " + Items.Count + " item defenition(s)."); } public Boolean ContainsItem(uint Id) { return Items.ContainsKey(Id); } public Item GetItem(uint Id) { if (ContainsItem(Id)) { return Items[Id]; } return null; } } }