TagTool.Cache.ResourceReference.GetLocation C# (CSharp) Method

GetLocation() public method

Gets the location of the resource by checking its location flags.
The resource does not have a location flag set
public GetLocation ( ) : ResourceLocation
return ResourceLocation
        public ResourceLocation GetLocation()
        {
            if (OldLocationFlags != 0)
            {
                if ((OldLocationFlags & OldResourceLocationFlags.InResources) != 0)
                    return ResourceLocation.Resources;
                if ((OldLocationFlags & OldResourceLocationFlags.InTextures) != 0)
                    return ResourceLocation.Textures;
                if ((OldLocationFlags & OldResourceLocationFlags.InTexturesB) != 0)
                    return ResourceLocation.TexturesB;
                if ((OldLocationFlags & OldResourceLocationFlags.InAudio) != 0)
                    return ResourceLocation.Audio;
                if ((OldLocationFlags & OldResourceLocationFlags.InVideo) != 0)
                    return ResourceLocation.Video;
            }
            else if (NewLocationFlags != 0)
            {
                // FIXME: haxhaxhax, maybe we should just have separate types for the old and new reference layouts?
                if ((NewLocationFlags & NewResourceLocationFlags.InResources) != 0)
                    return ResourceLocation.Resources;
                if ((NewLocationFlags & NewResourceLocationFlags.InTextures) != 0)
                    return ResourceLocation.Textures;
                if ((NewLocationFlags & NewResourceLocationFlags.InTexturesB) != 0)
                    return ResourceLocation.TexturesB;
                if ((NewLocationFlags & NewResourceLocationFlags.InAudio) != 0)
                    return ResourceLocation.Audio;
                if ((NewLocationFlags & NewResourceLocationFlags.InVideo) != 0)
                    return ResourceLocation.Video;
                if ((NewLocationFlags & NewResourceLocationFlags.InRenderModels) != 0)
                    return ResourceLocation.RenderModels;
                if ((NewLocationFlags & NewResourceLocationFlags.InLightmaps) != 0)
                    return ResourceLocation.Lightmaps;
            }
            throw new InvalidOperationException("The resource does not have a location flag set");
        }

Usage Example

Example #1
0
        private LoadedCache GetCache(ResourceReference resource)
        {
            LoadedCache cache;

            if (!_loadedCaches.TryGetValue(resource.GetLocation(), out cache))
            {
                throw new InvalidOperationException("The requested resource is located in " + resource.GetLocation() + ", but the corresponding cache file has not been loaded.");
            }
            return(cache);
        }
All Usage Examples Of TagTool.Cache.ResourceReference::GetLocation