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(); } }
public override T Load <T>(string name) { try { // Try to load from the FileMarshal. string path = FixPath(Path.Combine(rootDirectory, name)); if (FileMarshal.TryLoad(path, out T file)) { return(file); } // Otherwise, return from MG content manager. return(base.Load <T>(name)); } catch (ArgumentNullException e) { if (Screen.IsFullHeadless) { throw new HeadlessNotSupportedException("Content could not be loaded in fully headless display mode.", e); } throw; } }
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(); }