Ejemplo n.º 1
0
        public void Init()
        {
            if (this._items.Count > 0)
            {
                this._items.Clear();
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`item_name`,`public_name`,`type`,`width`,`length`,`stack_height`,`can_stack`,`can_sit`,`is_walkable`,`sprite_id`,`allow_recycle`,`allow_trade`,`allow_marketplace_sell`,`allow_gift`,`allow_inventory_stack`,`interaction_type`,`interaction_modes_count`,`vending_ids`,`height_adjustable`,`effect_id`,`wired_id`,`is_rare`,`clothing_id`, `extra_rot` FROM `furniture`");
                DataTable ItemData = dbClient.getTable();

                if (ItemData != null)
                {
                    foreach (DataRow Row in ItemData.Rows)
                    {
                        try
                        {
                            int             id                  = Convert.ToInt32(Row["id"]);
                            int             spriteID            = Convert.ToInt32(Row["sprite_id"]);
                            string          itemName            = Convert.ToString(Row["item_name"]);
                            string          PublicName          = Convert.ToString(Row["public_name"]);
                            string          type                = Row["type"].ToString();
                            int             width               = Convert.ToInt32(Row["width"]);
                            int             length              = Convert.ToInt32(Row["length"]);
                            double          height              = Convert.ToDouble(Row["stack_height"]);
                            bool            allowStack          = PlusEnvironment.EnumToBool(Row["can_stack"].ToString());
                            bool            allowWalk           = PlusEnvironment.EnumToBool(Row["is_walkable"].ToString());
                            bool            allowSit            = PlusEnvironment.EnumToBool(Row["can_sit"].ToString());
                            bool            allowRecycle        = PlusEnvironment.EnumToBool(Row["allow_recycle"].ToString());
                            bool            allowTrade          = PlusEnvironment.EnumToBool(Row["allow_trade"].ToString());
                            bool            allowMarketplace    = Convert.ToInt32(Row["allow_marketplace_sell"]) == 1;
                            bool            allowGift           = Convert.ToInt32(Row["allow_gift"]) == 1;
                            bool            allowInventoryStack = PlusEnvironment.EnumToBool(Row["allow_inventory_stack"].ToString());
                            InteractionType interactionType     = InteractionTypes.GetTypeFromString(Convert.ToString(Row["interaction_type"]));
                            int             cycleCount          = Convert.ToInt32(Row["interaction_modes_count"]);
                            string          vendingIDS          = Convert.ToString(Row["vending_ids"]);
                            List <double>   heightAdjustable    = Row["height_adjustable"].ToString() != String.Empty ? Row["height_adjustable"].ToString().Split(',').Select(x => Convert.ToDouble(x)).ToList() : new List <double>();
                            int             EffectId            = Convert.ToInt32(Row["effect_id"]);
                            int             WiredId             = Convert.ToInt32(Row["wired_id"]);
                            bool            IsRare              = PlusEnvironment.EnumToBool(Row["is_rare"].ToString());
                            int             ClothingId          = Convert.ToInt32(Row["clothing_id"]);
                            bool            ExtraRot            = PlusEnvironment.EnumToBool(Row["extra_rot"].ToString());

                            if (!this._gifts.ContainsKey(spriteID))
                            {
                                this._gifts.Add(spriteID, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, WiredId, IsRare, ClothingId, ExtraRot));
                            }

                            if (!this._items.ContainsKey(id))
                            {
                                this._items.Add(id, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, WiredId, IsRare, ClothingId, ExtraRot));
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                            Console.ReadKey();
                            Logging.WriteLine("Não foi possível carregar item #" + Convert.ToInt32(Row[0]) + ", verifiqu os dados.");
                        }
                    }
                }
            }

            //log.Info("Item Manager -> LOADED");
        }
Ejemplo n.º 2
0
        public void Init()
        {
            if (_items.Count > 0)
            {
                _items.Clear();
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `furniture`");
                DataTable ItemData = dbClient.GetTable();

                if (ItemData != null)
                {
                    foreach (DataRow Row in ItemData.Rows)
                    {
                        try
                        {
                            int             id                  = Convert.ToInt32(Row["id"]);
                            int             spriteID            = Convert.ToInt32(Row["sprite_id"]);
                            string          itemName            = Convert.ToString(Row["item_name"]);
                            string          PublicName          = Convert.ToString(Row["public_name"]);
                            string          type                = Row["type"].ToString();
                            int             width               = Convert.ToInt32(Row["width"]);
                            int             length              = Convert.ToInt32(Row["length"]);
                            double          height              = Convert.ToDouble(Row["stack_height"]);
                            bool            allowStack          = PlusEnvironment.EnumToBool(Row["can_stack"].ToString());
                            bool            allowWalk           = PlusEnvironment.EnumToBool(Row["is_walkable"].ToString());
                            bool            allowSit            = PlusEnvironment.EnumToBool(Row["can_sit"].ToString());
                            bool            allowRecycle        = PlusEnvironment.EnumToBool(Row["allow_recycle"].ToString());
                            bool            allowTrade          = PlusEnvironment.EnumToBool(Row["allow_trade"].ToString());
                            bool            allowMarketplace    = Convert.ToInt32(Row["allow_marketplace_sell"]) == 1;
                            bool            allowGift           = Convert.ToInt32(Row["allow_gift"]) == 1;
                            bool            allowInventoryStack = PlusEnvironment.EnumToBool(Row["allow_inventory_stack"].ToString());
                            InteractionType interactionType     = InteractionTypes.GetTypeFromString(Convert.ToString(Row["interaction_type"]));
                            int             behaviourData       = Convert.ToInt32(Row["behaviour_data"]);
                            int             cycleCount          = Convert.ToInt32(Row["interaction_modes_count"]);
                            string          vendingIDS          = Convert.ToString(Row["vending_ids"]);
                            string          heightAdjustable    = Convert.ToString(Row["height_adjustable"]);
                            int             EffectId            = Convert.ToInt32(Row["effect_id"]);
                            bool            IsRare              = PlusEnvironment.EnumToBool(Row["is_rare"].ToString());
                            bool            ExtraRot            = PlusEnvironment.EnumToBool(Row["extra_rot"].ToString());

                            if (!_gifts.ContainsKey(spriteID))
                            {
                                _gifts.Add(spriteID, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, behaviourData, cycleCount, vendingIDS, heightAdjustable, EffectId, IsRare, ExtraRot));
                            }

                            if (!_items.ContainsKey(id))
                            {
                                _items.Add(id, new ItemData(id, spriteID, itemName, PublicName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowMarketplace, allowGift, allowInventoryStack, interactionType, behaviourData, cycleCount, vendingIDS, heightAdjustable, EffectId, IsRare, ExtraRot));
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                            Console.ReadKey();
                            //Logging.WriteLine("Could not load item #" + Convert.ToInt32(Row[0]) + ", please verify the data is okay.");
                        }
                    }
                }
            }

            log.Info("Item Manager -> LOADED");
        }
Ejemplo n.º 3
0
        public void Init()
        {
            if (Items.Count > 0)
            {
                Items.Clear();
            }
            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `furniture`");
                var itemData = dbClient.GetTable();
                if (itemData != null)
                {
                    foreach (DataRow row in itemData.Rows)
                    {
                        try
                        {
                            var id                  = Convert.ToInt32(row["id"]);
                            var spriteId            = Convert.ToInt32(row["sprite_id"]);
                            var itemName            = Convert.ToString(row["item_name"]);
                            var publicName          = Convert.ToString(row["public_name"]);
                            var type                = row["type"].ToString();
                            var width               = Convert.ToInt32(row["width"]);
                            var length              = Convert.ToInt32(row["length"]);
                            var height              = Convert.ToDouble(row["stack_height"]);
                            var allowStack          = PlusEnvironment.EnumToBool(row["can_stack"].ToString());
                            var allowWalk           = PlusEnvironment.EnumToBool(row["is_walkable"].ToString());
                            var allowSit            = PlusEnvironment.EnumToBool(row["can_sit"].ToString());
                            var allowRecycle        = PlusEnvironment.EnumToBool(row["allow_recycle"].ToString());
                            var allowTrade          = PlusEnvironment.EnumToBool(row["allow_trade"].ToString());
                            var allowMarketplace    = Convert.ToInt32(row["allow_marketplace_sell"]) == 1;
                            var allowGift           = Convert.ToInt32(row["allow_gift"]) == 1;
                            var allowInventoryStack = PlusEnvironment.EnumToBool(row["allow_inventory_stack"].ToString());
                            var interactionType     = InteractionTypes.GetTypeFromString(Convert.ToString(row["interaction_type"]));
                            var behaviourData       = Convert.ToInt32(row["behaviour_data"]);
                            var cycleCount          = Convert.ToInt32(row["interaction_modes_count"]);
                            var vendingIds          = Convert.ToString(row["vending_ids"]);
                            var heightAdjustable    = Convert.ToString(row["height_adjustable"]);
                            var effectId            = Convert.ToInt32(row["effect_id"]);
                            var isRare              = PlusEnvironment.EnumToBool(row["is_rare"].ToString());
                            var extraRot            = PlusEnvironment.EnumToBool(row["extra_rot"].ToString());
                            if (!Gifts.ContainsKey(spriteId))
                            {
                                Gifts.Add(spriteId,
                                          new ItemData(id,
                                                       spriteId,
                                                       itemName,
                                                       publicName,
                                                       type,
                                                       width,
                                                       length,
                                                       height,
                                                       allowStack,
                                                       allowWalk,
                                                       allowSit,
                                                       allowRecycle,
                                                       allowTrade,
                                                       allowMarketplace,
                                                       allowGift,
                                                       allowInventoryStack,
                                                       interactionType,
                                                       behaviourData,
                                                       cycleCount,
                                                       vendingIds,
                                                       heightAdjustable,
                                                       effectId,
                                                       isRare,
                                                       extraRot));
                            }
                            if (!Items.ContainsKey(id))
                            {
                                Items.Add(id,
                                          new ItemData(id,
                                                       spriteId,
                                                       itemName,
                                                       publicName,
                                                       type,
                                                       width,
                                                       length,
                                                       height,
                                                       allowStack,
                                                       allowWalk,
                                                       allowSit,
                                                       allowRecycle,
                                                       allowTrade,
                                                       allowMarketplace,
                                                       allowGift,
                                                       allowInventoryStack,
                                                       interactionType,
                                                       behaviourData,
                                                       cycleCount,
                                                       vendingIds,
                                                       heightAdjustable,
                                                       effectId,
                                                       isRare,
                                                       extraRot));
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                            Console.ReadKey();

                            //Logging.WriteLine("Could not load item #" + Convert.ToInt32(Row[0]) + ", please verify the data is okay.");
                        }
                    }
                }
            }

            Log.Info("Item Manager -> LOADED");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads the items.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void LoadItems(IQueryAdapter dbClient)
        {
            Items = new Dictionary <uint, Item>();
            Items.Clear();
            GiftWrappers.Clear();

            dbClient.SetQuery("SELECT * FROM catalog_furnis");
            var table = dbClient.GetTable();

            if (table == null)
            {
                return;
            }
            List <double> heights = null;

            foreach (DataRow dataRow in table.Rows)
            {
                try
                {
                    var    id             = Convert.ToUInt32(dataRow["id"]);
                    var    type           = Convert.ToChar(dataRow["type"]);
                    var    name           = Convert.ToString(dataRow["item_name"]);
                    var    flatId         = Convert.ToInt32(dataRow["flat_id"]);
                    var    stackHeightStr = dataRow["stack_height"].ToString();
                    double stackHeight;
                    uint   modes;
                    uint.TryParse(dataRow["interaction_modes_count"].ToString(), out modes);
                    var    vendingIds           = (string)dataRow["vending_ids"];
                    string variableheights      = Convert.ToString(dataRow["variable_heights"]);
                    var    sub                  = Plus.EnumToBool(dataRow["subscriber"].ToString());
                    var    effect               = (int)dataRow["effectid"];
                    var    stackable            = Convert.ToInt32(dataRow["can_stack"]) == 1;
                    var    allowRecycle         = Convert.ToInt32(dataRow["allow_recycle"]) == 1;
                    var    allowTrade           = Convert.ToInt32(dataRow["allow_trade"]) == 1;
                    var    allowMarketplaceSell = Convert.ToInt32(dataRow["allow_marketplace_sell"]) == 1;
                    var    allowGift            = Convert.ToInt32(dataRow["allow_gift"]) == 1;
                    var    allowInventoryStack  = Convert.ToInt32(dataRow["allow_inventory_stack"]) == 1;
                    var    typeFromString       = InteractionTypes.GetTypeFromString((string)dataRow["interaction_type"]);

                    var sprite = Convert.ToInt32(dataRow["sprite_id"]);

                    int  x = Convert.ToInt32(dataRow["width"]), y = Convert.ToInt32(dataRow["length"]);
                    var  publicName = Convert.ToString(dataRow["item_name"]);
                    bool canWalk = Convert.ToInt32(dataRow["is_walkable"]) == 1, canSit = Convert.ToInt32(dataRow["can_sit"]) == 1, stackMultiple = Plus.EnumToBool(dataRow["stack_multiplier"].ToString());

                    if (name.StartsWith("external_image_wallitem_poster"))
                    {
                        PhotoId = id;
                    }
                    // Special Types of Furnis

                    /*if (name == "landscape" || name == "floor" || name == "wallpaper")
                     * {
                     *  sprite = FurniDataParser.WallItems[name].Id;
                     *  x = 1;
                     *  y = 1;
                     * }
                     * else if (type == 's' && FurniDataParser.FloorItems.ContainsKey(name))
                     * {
                     *  sprite = FurniDataParser.FloorItems[name].Id;
                     *  publicName = FurniDataParser.FloorItems[name].Name;
                     *  x = FurniDataParser.FloorItems[name].X;
                     *  y = FurniDataParser.FloorItems[name].Y;
                     *  canWalk = FurniDataParser.FloorItems[name].CanWalk;
                     *  canSit = FurniDataParser.FloorItems[name].CanSit;
                     * }
                     * else if (type == 'i' && FurniDataParser.WallItems.ContainsKey(name))
                     * {
                     *  sprite = FurniDataParser.WallItems[name].Id;
                     *  publicName = FurniDataParser.WallItems[name].Name;
                     * }
                     * else if (name.StartsWith("a0 pet", StringComparison.InvariantCulture))
                     * {
                     *  x = 1;
                     *  y = 1;
                     *  publicName = name;
                     * }
                     * else if (type != 'e' && type != 'h' && type != 'r' && type != 'b') continue;*/

                    if (name.StartsWith("present_gen"))
                    {
                        GiftWrappers.AddOld((short)sprite);
                    }
                    else if (name.StartsWith("present_wrap*"))
                    {
                        GiftWrappers.Add((short)sprite);
                    }

                    // Stack Height Values
                    if (stackHeightStr.Contains(';'))
                    {
                        var heightsStr = stackHeightStr.Split(';');
                        heights =
                            heightsStr.Select(heightStr => double.Parse(heightStr, CultureInfo.InvariantCulture))
                            .ToList();
                        stackHeight   = heights[0];
                        stackMultiple = true;
                    }
                    else
                    {
                        stackHeight = double.Parse(stackHeightStr, CultureInfo.InvariantCulture);
                    }

                    // If Can Walk
                    if (InteractionTypes.AreFamiliar(GlobalInteractions.Gate, typeFromString) ||
                        typeFromString == Interaction.BanzaiPyramid || name.StartsWith("hole"))
                    {
                        canWalk = false;
                    }

                    // Add Item
                    var value = new Item(id, (int)sprite, publicName, name, type, x, y, stackHeight, stackable, canWalk,
                                         canSit, allowRecycle, allowTrade, allowMarketplaceSell, allowGift, allowInventoryStack,
                                         typeFromString, modes, vendingIds, sub, effect, stackMultiple,
                                         (heights == null ? null : heights.ToArray()), flatId, variableheights);
                    Items.Add(id, value);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.ReadKey();
                    Out.WriteLine(
                        string.Format("Could not load item #{0}, please verify the data is okay.",
                                      Convert.ToUInt32(dataRow[0])), "Plus.Items", ConsoleColor.DarkRed);
                }
            }
        }