private static void EventSink_WorldLoad() { Persistence.Deserialize( m_Path, reader => { m_Mobiles.AddRange(reader.ReadMobileList().OfType <BaseCollectionMobile>()); List <BaseCollectionMobile> mobs = new List <BaseCollectionMobile>(); mobs.AddRange(m_Mobiles); int count = reader.ReadInt(); for (int i = 0; i < count; ++i) { int collection = reader.ReadInt(); CollectionData data = new CollectionData(); data.Read(reader); int toRemove = -1; for (var index = 0; index < mobs.Count; index++) { BaseCollectionMobile mob = mobs[index]; if (mob.CollectionID == (Collection)collection) { mob.SetData(data); toRemove = mobs.IndexOf(mob); break; } } if (toRemove >= 0) { mobs.RemoveAt(toRemove); } } }); }
public static void RegisterMobile(BaseCollectionMobile mob) { if (!m_Mobiles.Contains(mob)) { m_Mobiles.Add(mob); if (m_Collections.ContainsKey(mob.CollectionID)) { mob.SetData(m_Collections[mob.CollectionID]); } } }