/// <summary> /// Load the Map Files /// </summary> public void LoadOverrideMaps() { defaultmap = new Hashtable(); modelmap = new Hashtable(); defaultmap[true] = new CacheItems(); defaultmap[false] = new CacheItems(); foreach (CacheContainer cc in Containers) { if (cc.Type == ContainerType.MaterialOverride && cc.Valid) { foreach (MMATCacheItem mci in cc.Items) { CacheItems l = (CacheItems)defaultmap[mci.Default]; l.Add(mci); l = (CacheItems)modelmap[mci.ModelName]; if (l == null) { l = new CacheItems(); modelmap[mci.ModelName] = l; } l.Add(mci); } } } //foreach }
public override object Clone() { CacheItems list = new CacheItems(); foreach (ICacheItem item in this) { list.Add(item); } return(list); }
/// <summary> /// Load the Container from the Stream /// </summary> /// <param name="reader">the Stream Reader</param> internal void Load(System.IO.BinaryReader reader) { valid = ContainerValid.FileNotFound; items.Clear(); int offset = reader.ReadInt32(); version = reader.ReadByte(); type = (ContainerType)reader.ReadByte(); int count = reader.ReadInt32(); long pos = reader.BaseStream.Position; try { if (version <= VERSION) { reader.BaseStream.Seek(offset, System.IO.SeekOrigin.Begin); added = DateTime.FromFileTime(reader.ReadInt64()); filename = reader.ReadString(); if (System.IO.File.Exists(filename)) { DateTime mod = System.IO.File.GetLastWriteTime(filename); if (mod <= added) { valid = ContainerValid.Yes; } else { valid = ContainerValid.Modified; } } if (valid == ContainerValid.Yes) { switch (type) { case ContainerType.Object: { for (int i = 0; i < count; i++) { ObjectCacheItem oci = new ObjectCacheItem(); oci.Load(reader); items.Add(oci); } break; } case ContainerType.MaterialOverride: { for (int i = 0; i < count; i++) { MMATCacheItem oci = new MMATCacheItem(); oci.Load(reader); items.Add(oci); } break; } case ContainerType.Rcol: { for (int i = 0; i < count; i++) { RcolCacheItem oci = new RcolCacheItem(); oci.Load(reader); items.Add(oci); } break; } case ContainerType.Want: { for (int i = 0; i < count; i++) { WantCacheItem oci = new WantCacheItem(); oci.Load(reader); items.Add(oci); } break; } case ContainerType.Memory: { for (int i = 0; i < count; i++) { MemoryCacheItem oci = new MemoryCacheItem(); oci.Load(reader); oci.ParentCacheContainer = this; if (oci.Version >= MemoryCacheItem.DISCARD_VERSIONS_SMALLER_THAN) { items.Add(oci); } } break; } case ContainerType.Package: { for (int i = 0; i < count; i++) { PackageCacheItem oci = new PackageCacheItem(); oci.Load(reader); items.Add(oci); } break; } } //switch } // if valid } //if VERSION else { valid = ContainerValid.UnknownVersion; } } finally { reader.BaseStream.Seek(pos, System.IO.SeekOrigin.Begin); } }