Exemplo n.º 1
0
        private static void EventSink_WorldLoad()
        {
            Persistence.Deserialize(
                m_Path,
                reader =>
            {
                m_Mobiles.AddRange(reader.ReadMobileList().Cast <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;
                    foreach (BaseCollectionMobile mob in mobs)
                    {
                        if (mob.CollectionID == (Collection)collection)
                        {
                            mob.SetData(data);
                            toRemove = mobs.IndexOf(mob);
                            break;
                        }
                    }
                    if (toRemove >= 0)
                    {
                        mobs.RemoveAt(toRemove);
                    }
                }
            });
        }
Exemplo n.º 2
0
        private static void EventSink_WorldSave(WorldSaveEventArgs e)
        {
            List <BaseCollectionMobile> newMobiles = new List <BaseCollectionMobile>();

            foreach (BaseCollectionMobile mob in m_Mobiles)
            {
                if (!mob.Deleted)
                {
                    newMobiles.Add(mob);
                }
            }
            m_Mobiles = newMobiles;

            Persistence.Serialize(
                m_Path,
                writer =>
            {
                writer.WriteMobileList(m_Mobiles);
                writer.Write(m_Mobiles.Count);
                foreach (BaseCollectionMobile mob in m_Mobiles)
                {
                    writer.Write((int)mob.CollectionID);
                    CollectionData data = mob.GetData();
                    data.Write(writer);
                    m_Collections[mob.CollectionID] = data;
                }
            });
        }
Exemplo n.º 3
0
		private static void EventSink_WorldLoad()
		{
			Persistence.Deserialize(
				m_Path,
				reader =>
				{
					m_Mobiles.AddRange(reader.ReadMobileList().Cast<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;
						foreach (BaseCollectionMobile mob in mobs)
						{
							if(mob.CollectionID == (Collection)collection)
							{
								mob.SetData(data);
								toRemove = mobs.IndexOf(mob);
								break;
							}
						}
						if (toRemove >= 0)
							mobs.RemoveAt(toRemove);
					}
				});

		}
		public void SetData(CollectionData data)
		{
			Points = data.Points;
			StartTier = data.StartTier;
			NextTier = data.NextTier;
			DailyDecay = data.DailyDecay;
			m_Tier = data.Tier;
			m_DonationTitle = data.DonationTitle;
			m_Tiers = data.Tiers;
		}
		public CollectionData GetData()
		{
			CollectionData ret = new CollectionData();

			ret.Collection = CollectionID;
			ret.Points = Points;
			ret.StartTier = StartTier;
			ret.NextTier = NextTier;
			ret.DailyDecay = DailyDecay;
			ret.Tier = Tier;
			ret.DonationTitle = m_DonationTitle;
			ret.Tiers = m_Tiers;

			return ret;
		}