public override void ProcessDecay() { while (_decayQueue.Count > 0) { Item item = _decayQueue.Dequeue(); if (item.OnDecay()) { item.Delete(); } } }
public override void ProcessDecay() { while (_decayQueue.Count > 0) { Item item = _decayQueue.Dequeue(); if (item.OnDecay()) { item.Delete(); } } while (_decayMapQueue.Count > 0) { BaseInstanceMap map = _decayMapQueue.Dequeue(); if (map.OnDecay()) { map.Delete(); } } }
protected void SaveItems(SaveMetrics metrics) { Dictionary <Serial, Item> items = World.Items; List <Item> decaying = new List <Item>(); GenericWriter idx; GenericWriter tdb; GenericWriter bin; if (World.SaveType == World.SaveOption.Normal) { idx = new BinaryFileWriter(World.ItemIndexPath, false); tdb = new BinaryFileWriter(World.ItemTypesPath, false); bin = new BinaryFileWriter(World.ItemDataPath, true); } else { idx = new AsyncWriter(World.ItemIndexPath, false); tdb = new AsyncWriter(World.ItemTypesPath, false); bin = new AsyncWriter(World.ItemDataPath, true); } idx.Write(( int )items.Count); foreach (Item item in items.Values) { if (item.Decays && item.Parent == null && item.Map != Map.Internal && (item.LastMoved + item.DecayTime) <= DateTime.Now) { decaying.Add(item); } long start = bin.Position; idx.Write(( int )item.m_TypeRef); idx.Write(( int )item.Serial); idx.Write(( long )start); item.Serialize(bin); if (metrics != null) { metrics.OnItemSaved(( int )(bin.Position - start)); } idx.Write(( int )(bin.Position - start)); item.FreeCache(); } tdb.Write(( int )World.m_ItemTypes.Count); for (int i = 0; i < World.m_ItemTypes.Count; ++i) { tdb.Write(World.m_ItemTypes[i].FullName); } idx.Close(); tdb.Close(); bin.Close(); for (int i = 0; i < decaying.Count; ++i) { Item item = decaying[i]; if (item.OnDecay()) { item.Delete(); } } }
private static void SaveItems() { ArrayList decaying = new ArrayList(); GenericWriter idx; GenericWriter tdb; GenericWriter bin; if (SaveType == SaveOption.Normal) { idx = new BinaryFileWriter(itemIdxPath, false); tdb = new BinaryFileWriter(itemTdbPath, false); bin = new BinaryFileWriter(itemBinPath, true); } else { idx = new AsyncWriter(itemIdxPath, false); tdb = new AsyncWriter(itemTdbPath, false); bin = new AsyncWriter(itemBinPath, true); } idx.Write((int)m_Items.Count); foreach (Item item in m_Items.Values) { if (item.Decays && item.Parent == null && item.Map != Map.Internal && (item.LastMoved + item.DecayTime) <= DateTime.Now) { decaying.Add(item); } long start = bin.Position; idx.Write((int)item.m_TypeRef); idx.Write((int)item.Serial); idx.Write((long)start); item.Serialize(bin); idx.Write((int)(bin.Position - start)); item.FreeCache(); } tdb.Write((int)m_ItemTypes.Count); for (int i = 0; i < m_ItemTypes.Count; ++i) { tdb.Write(((Type)m_ItemTypes[i]).FullName); } idx.Close(); tdb.Close(); bin.Close(); for (int i = 0; i < decaying.Count; ++i) { Item item = (Item)decaying[i]; if (item.OnDecay()) { item.Delete(); } } }