| Line |  | 
|---|
| 1 | using System; | 
|---|
| 2 | using System.Collections.Generic; | 
|---|
| 3 | using System.Runtime.Serialization; | 
|---|
| 4 | using System.Threading; | 
|---|
| 5 |  | 
|---|
| 6 | namespace AllocsFixes.PersistentData | 
|---|
| 7 | { | 
|---|
| 8 | [Serializable] | 
|---|
| 9 | public class Inventory | 
|---|
| 10 | { | 
|---|
| 11 | public List<InvItem> bag; | 
|---|
| 12 | public List<InvItem> belt; | 
|---|
| 13 |  | 
|---|
| 14 | public Inventory () | 
|---|
| 15 | { | 
|---|
| 16 | bag = new List<InvItem> (); | 
|---|
| 17 | belt = new List<InvItem> (); | 
|---|
| 18 | } | 
|---|
| 19 |  | 
|---|
| 20 | public void Update (PlayerDataFile pdf) | 
|---|
| 21 | { | 
|---|
| 22 | //Log.Out ("Updating player inventory - player id: " + pdf.id); | 
|---|
| 23 | ProcessInv (bag, pdf.bag); | 
|---|
| 24 | ProcessInv (belt, pdf.inventory); | 
|---|
| 25 | } | 
|---|
| 26 |  | 
|---|
| 27 | private void ProcessInv (List<InvItem> target, InventoryField[] sourceFields) | 
|---|
| 28 | { | 
|---|
| 29 | lock (target) { | 
|---|
| 30 | target.Clear (); | 
|---|
| 31 | for (int i = 0; i < sourceFields.Length; i++) { | 
|---|
| 32 | if (sourceFields [i].count > 0) { | 
|---|
| 33 | int count = sourceFields [i].count; | 
|---|
| 34 | string name = getInvFieldName (sourceFields [i]); | 
|---|
| 35 |  | 
|---|
| 36 | target.Add (new InvItem (name, count)); | 
|---|
| 37 | } else { | 
|---|
| 38 | target.Add (null); | 
|---|
| 39 | } | 
|---|
| 40 | } | 
|---|
| 41 | } | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|
| 44 | private string getInvFieldName (InventoryField item) | 
|---|
| 45 | { | 
|---|
| 46 | ItemBase iBase = ItemBase.list [item.itemValue.type]; | 
|---|
| 47 | return iBase.GetItemName(item.itemValue); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 | } | 
|---|
| 52 | } | 
|---|
| 53 |  | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.