public static void Add_PetInventory(PetInventoryInfo inv_inf) { if (Globals.gamedata.my_pet.inventory.ContainsKey(inv_inf.ID)) { //already in list, update Globals.gamedata.my_pet.inventory[inv_inf.ID] = inv_inf; } else { //Not in list, add it Globals.gamedata.my_pet.inventory.Add(inv_inf.ID, inv_inf); } }
public static void PetInventory_Update(ByteBuffer buff) { uint cnt = buff.ReadUInt16(); Globals.PetInventoryLock.EnterWriteLock(); try { for (int i = 0; i < cnt; i++) { uint change = buff.ReadUInt16(); PetInventoryInfo inv_inf = new PetInventoryInfo(); inv_inf.Load(buff); if (inv_inf.Count == 0) { change = 3; } switch (change) { case 1: //add Add_PetInventory(inv_inf); break; case 2: //modify Add_PetInventory(inv_inf); break; case 3: //delete Remove_PetInventory(inv_inf.ID); break; } } } finally { Globals.PetInventoryLock.ExitWriteLock(); } }
public static void PetItemList(ByteBuffer buffe) { uint count = buffe.ReadUInt16(); Globals.PetInventoryLock.EnterReadLock(); try { foreach (PetInventoryInfo inv_inf in Globals.gamedata.my_pet.inventory.Values) { inv_inf.InNewList = false; } } finally { Globals.PetInventoryLock.ExitReadLock(); } Globals.PetInventoryLock.EnterWriteLock(); try { Globals.gamedata.my_pet.inventory.Clear(); for (uint i = 0; i < count; i++) { PetInventoryInfo inv_info = new PetInventoryInfo(); inv_info.Load(buffe); AddInfo.Add_PetInventory(inv_info); } } finally { Globals.PetInventoryLock.ExitWriteLock(); } }