Пример #1
0
        public void Reload()
        {
            loaded       = true;
            timeInactive = 0.0f;

            // Tell the FileMarshal to load files in the background.
            foreach (string str in PreloadFiles)
            {
                string path = FixPath(Path.Combine(rootDirectory, str));
                if (FileMarshal.TryGet(path, out FileMarshal.File file))
                {
                    FileMarshal.FlagBackgroundLoad(file);
                }
            }

            // Sort all references.
            orderedReferences.Clear();
            orderedReferences.AddRange(AllRefs);
            orderedReferences.Sort((x, y) => x.LoadOrder.CompareTo(y.LoadOrder));

            // Reload all references in order from lowest to highest LoadOrder.
            // All references are loaded initially in order to build up the dependencies.
            foreach (IAsset reference in orderedReferences)
            {
                reference.Load();
            }

            // Remove unneeded references. TODO: Might cause an exception, investigate.
            foreach (IAsset reference in orderedReferences)
            {
                reference.Purge();
            }
        }
Пример #2
0
        public override void Unload()
        {
            loaded = false;

            // Tell the FileMarshal to unload files in the background.
            foreach (string str in PreloadFiles)
            {
                string path = FixPath(Path.Combine(rootDirectory, str));
                if (FileMarshal.TryGet(path, out FileMarshal.File file))
                {
                    FileMarshal.FlagBackgroundUnload(file);
                }
            }

            // Unload all assets from this content loader from memory.
            foreach (IAsset asset in AllRefs)
            {
                asset.Unload();
            }
            base.Unload();
        }