public void Add(Mobile mobile)
 {
     lock (mySyncRoot)
     {
         if (!myMobileList.ContainsKey(mobile.Serial))
         {
             myMobileList.Add(mobile.Serial, mobile);
             OnCollectionChanged();
         }
     }
 }
 /// <summary>
 /// Get mobile from specified client.
 /// </summary>
 /// <param name="index">Client index.</param>
 /// <param name="serial">Serial of mobile to get.</param>
 /// <param name="mobile">Mobile (out).</param>
 /// <returns>False if not found.</returns>
 public static bool GetMobile(int index, int serial, out Mobile mobile)
 {
     ClientInfo ci;
     if (GetClient(index, out ci))
         return ci.Mobiles.GetMobile(serial, out mobile);
     mobile = null;
     return false;
 }
 /// <summary>
 /// Find all mobiles with matching IDs in specified client.
 /// </summary>
 /// <returns>True on success.</returns>
 public static bool FindMobiles(int index, int[] ids, out Mobile[] mobiles)
 {
     ClientInfo ci;
     if (GetClient(index, out ci))
         return ci.Mobiles.FindMobiles(ids, out mobiles);
     mobiles = null;
     return false;
 }
 /// <summary>
 /// Find mobile with matching ID in specified client.
 /// </summary>
 /// <returns>True on success.</returns>
 public static bool FindMobile(int index, int id, out Mobile mobile)
 {
     ClientInfo ci;
     if (GetClient(index, out ci))
         return ci.Mobiles.FindMobile(id, out mobile);
     mobile = null;
     return false;
 }
 /// <summary>
 /// Find first mobile that matches specified ID.
 /// </summary>
 /// <returns>True on success.</returns>
 public bool FindMobile(int id, out Mobile mobile)
 {
     lock (mySyncRoot)
     {
         foreach (Mobile m in myMobileList.Values)
         {
             if (m.ID == id)
             {
                 mobile = m;
                 return true;
             }
         }
     }
     mobile = null;
     return false;
 }
 public Mobile[] GetMobiles()
 {
     lock (mySyncRoot)
     {
         Mobile[] mobileArray = new Mobile[myMobileList.Values.Count];
         myMobileList.Values.CopyTo(mobileArray, 0);
         return mobileArray;
     }
 }
 public bool GetMobile(int serial, out Mobile mobile)
 {
     return myMobileList.TryGetValue(serial, out mobile);
 }
 public bool FindMobiles(int[] ids, out Mobile[] mobiles)
 {
     List<Mobile> mobileList = new List<Mobile>();
     lock (mySyncRoot)
     {
         foreach (Mobile m in myMobileList.Values)
         {
             foreach (int i in ids)
             {
                 if (m.ID == i && !mobileList.Contains(m)) mobileList.Add(m);
             }
         }
     }
     if (mobileList.Count > 0)
     {
         mobiles = mobileList.ToArray();
         return true;
     }
     mobiles = null;
     return false;
 }
 public bool FindMobiles(int id, out Mobile[] mobiles)
 {
     List<Mobile> mobileList = new List<Mobile>();
     lock (mySyncRoot)
     {
         foreach (Mobile m in myMobileList.Values)
             if (m.ID == id) mobileList.Add(m);
     }
     if (mobileList.Count > 0)
     {
         mobiles = mobileList.ToArray();
         return true;
     }
     mobiles = null;
     return false;
 }
 public bool FindMobileByLayerSerial(Layer layer, int serial, out Mobile mobile)
 {
     lock (mySyncRoot)
     {
         foreach (Mobile m in myMobileList.Values)
         {
             Item item;
             if (m.GetEquippedItem( layer, out item ))
             {
                 if (item.Serial == serial)
                 {
                     mobile = m;
                     return true;
                 }
             }
         }
     }
     mobile = null;
     return false;
 }