本文整理汇总了C#中Glare.Assets.AssetLoader.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# AssetLoader.Reset方法的具体用法?C# AssetLoader.Reset怎么用?C# AssetLoader.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Glare.Assets.AssetLoader
的用法示例。
在下文中一共展示了AssetLoader.Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadMatchAsset
/// <summary>Find the best <see cref="AssetFormat"/> for loading an <see cref="Asset"/>.</summary>
/// <param name="matchStrength"></param>
/// <param name="loader"></param>
/// <param name="formats"></param>
/// <param name="resolveConflict"></param>
/// <returns></returns>
public static AssetFormat LoadMatchAsset(out LoadMatchStrength matchStrength, AssetLoader loader, IEnumerable<AssetFormat> formats, ResolveLoadConflictCallback resolveConflict = null)
{
if (loader == null)
throw new ArgumentNullException("context");
if (formats == null)
throw new ArgumentNullException("formats");
AssetFormat bestFormat = null;
LoadMatchStrength bestMatch = LoadMatchStrength.None;
bool bestConflict = false;
// Attempt to find the one best loader.
foreach (AssetFormat format in formats) {
if (!format.CanLoad || !format.IsEnabled)
continue;
LoadMatchStrength match = format.LoadMatch(loader);
loader.Reset();
if (match <= LoadMatchStrength.None || match < bestMatch)
continue;
if (match == bestMatch)
bestConflict = true;
else {
bestFormat = format;
bestMatch = match;
bestConflict = false;
}
}
matchStrength = bestMatch;
// If a single best loader is found, return it.
if (!bestConflict) {
if (bestFormat == null)
throw new InvalidDataException("No loader could be found for " + loader.Name + ".");
return bestFormat;
}
// Otherwise there are multiple formats with equal match strengths; gather those together.
List<AssetFormat> conflicts = new List<AssetFormat>();
foreach (AssetFormat format in formats) {
if (!format.CanLoad || !format.IsEnabled)
continue;
loader.Reset();
LoadMatchStrength match = format.LoadMatch(loader);
if (match == bestMatch)
conflicts.Add(format);
}
// Attempt to resolve the conflict.
bestFormat = null;
if (resolveConflict != null)
bestFormat = resolveConflict(loader, conflicts, matchStrength);
// If no resolution is found, throw an exception.
if (bestFormat == null)
throw CreateConflictException(loader, matchStrength, conflicts);
// A resolution was found, so return the best format.
return bestFormat;
}
示例2: DetectVersion
/// <summary>Attempt to detect the version of the resource map, returning it or <see cref="ResourceMapVersion.None"/> if this is not a resource map or is not known to be one.</summary>
/// <param name="loader"></param>
/// <returns></returns>
public static ResourceMapVersion DetectVersion(AssetLoader loader)
{
var reader = loader.Reader;
long length = loader.Length;
// The filename must be "resource.map".
if (string.Compare(System.IO.Path.GetFileName(loader.Name), "resource.map", true) != 0)
return ResourceMapVersion.None;
// Try SCI0.
bool isSci0 = DetectVersionSci0(loader);
loader.Reset();
if (isSci0)
return ResourceMapVersion.Sci0;
// Try SCI1.
bool isSci1 = DetectVersionSci1(loader);
loader.Reset();
if (isSci1)
return ResourceMapVersion.Sci1;
// Try SCI2
bool isSci2 = DetectVersionSci2(loader);
loader.Reset();
if (isSci2)
return ResourceMapVersion.Sci2;
return ResourceMapVersion.None;
}