using System; using System.Collections.Generic; using System.Runtime.Serialization; using System.Threading; namespace AllocsFixes.PersistentData { [Serializable] public class Inventory { public List bag; public List belt; public Inventory () { bag = new List (); belt = new List (); } public void Update (PlayerDataFile pdf) { //Log.Out ("Updating player inventory - player id: " + pdf.id); ProcessInv (bag, pdf.bag); ProcessInv (belt, pdf.inventory); } private void ProcessInv (List target, InventoryField[] sourceFields) { lock (target) { target.Clear (); for (int i = 0; i < sourceFields.Length; i++) { if (sourceFields [i].count > 0) { int count = sourceFields [i].count; string name = getInvFieldName (sourceFields [i]); target.Add (new InvItem (name, count)); } else { target.Add (null); } } } } private string getInvFieldName (InventoryField item) { ItemBase iBase = ItemBase.list [item.itemValue.type]; return iBase.GetItemName(item.itemValue); } } }