private void ConvertListForEditing(InventoryList itmList, ref List <WillowSaveGame.BankEntry> itmBank) { // Populate itmList with items created from the WillowSaveGame data lists itmList.ClearSilent(); for (int i = 0; i < itmBank.Count; i++) { List <int> itmBankValues = new List <int>() { itmBank[i].Quantity, itmBank[i].Quality, itmBank[i].EquipedSlot, itmBank[i].Level, itmBank[i].Junk, itmBank[i].Locked }; // Store a reference to the parts list List <string> parts = itmBank[i].Strings; // Detach the parts list from the bank entry. itmBank[i].Strings = null; // Items have a different part order in the bank and in the backpack // Part Index Index // Inventory Bank // Item Grade 0 1 // Item Type 1 0 // Body 2 3 // Left 3 4 // Right 4 5 // Material 5 6 // Manufacturer 6 2 // Prefix 7 7 // Title 8 8 int itmType = itmBank[i].TypeId - 1; // Convert all items into the backpack part order. Weapons use // the same format for both backpack and bank. if (itmType == InventoryType.Item) { string temp = parts[1]; parts[1] = parts[0]; parts[0] = temp; temp = parts[2]; parts[2] = parts[3]; parts[3] = parts[4]; parts[4] = parts[5]; parts[5] = parts[6]; parts[6] = temp; } // Create an inventory entry with the re-ordered parts list and add it itmList.AddSilent(new InventoryEntry((byte)(itmBank[i].TypeId - 1), parts, itmBankValues)); //Item/Weapon in bank have their type increase by 1, we reduce TypeId by 1 to manipulate them like other list } itmList.OnListReload(); // Release the WillowSaveGame bank data now that the data is converted // to the format that the WillowTree UI uses. It gets recreated at save time. itmBank = null; }
private void ConvertListForEditing <T>(InventoryList itmList, ref List <T> objs) where T : WillowSaveGame.Object { // Populate itmList with items created from the WillowSaveGame data lists itmList.ClearSilent(); foreach (var obj in objs) { itmList.AddSilent(new InventoryEntry(itmList.invType, obj.Strings, obj.GetValues())); } itmList.OnListReload(); objs = null; }
private void ConvertListForEditing(InventoryList itmList, ref List <List <string> > itmStrings, ref List <List <int> > itmValues) { // Populate itmList with items created from the WillowSaveGame data lists itmList.ClearSilent(); for (int i = 0; i < itmStrings.Count; i++) { itmList.AddSilent(new InventoryEntry(itmList.invType, itmStrings[i], itmValues[i])); } itmList.OnListReload(); // Release the WillowSaveGame data lists now that the data is converted // to the format that the WillowTree UI uses. itmStrings = null; itmValues = null; }