Example #1
0
    private void DBLoad_Character_Item()
    {
        DatabaseLoading("items", (reader) =>
        {
            switch (reader.Name)
            {
            case "item":
                {
                    int id                = int.Parse(reader.GetAttribute("id"));
                    string name           = reader.GetAttribute("name");
                    string path           = reader.GetAttribute("path");
                    string description    = reader.GetAttribute("description");
                    int type              = int.Parse(reader.GetAttribute("type"));
                    float sizeInInventory = float.Parse(reader.GetAttribute("sizeInInventory"));
                    float yPosInInventory = float.Parse(reader.GetAttribute("yPosInInventory"));

                    float[] values;
                    if (!MathX.ParseFloatArrayFromString(reader.GetAttribute("inventoryPosition"), out values))
                    {
                        values = new float[3];
                    }
                    Vector3 inventoryPosition = new Vector3(values[0], values[1], values[2]);

                    if (!MathX.ParseFloatArrayFromString(reader.GetAttribute("inventoryPosition"), out values))
                    {
                        values = new float[3];
                    }
                    Vector3 inventoryRotation = new Vector3(values[0], values[1], values[2]);

                    db_item item           = new db_item();
                    item.id                = id;
                    item.name              = name;
                    item.path              = path;
                    item.sizeInInventory   = sizeInInventory;
                    item.type              = (db_item.Type)type;
                    item.inventoryRotation = inventoryRotation;
                    item.description       = description;
                    item.yPosInInventory   = yPosInInventory;
                    dbItemList.Add(item);
                }
                break;
            }
        });
    }