Files, Streams and the Resource Manager
The Torque engine uses many resources - terrain files, bitmaps, shapes, material lists, fonts and interiors, to list just a few examples. In order to manage a large number of game resources effectively and provide a common interface for loading and saving resources, Torque uses the ResManager.
Resources have the special property that only one instance of a resource will ever be loaded at a time. Resource objects are reference counted so that when a second request is made for the same resource, the original loaded instance is returned. The resource manager also defines a resource template class that acts as a transparent pointer to various types of game resources.
A list of searchable paths are fed to the ResManager via the setModPaths() function. This function also scans the specified paths for all the files contained therein, creating a ResourceObject for each one. These are all stored in a ResDictionary, allowing rapid lookup of a specified file.
In addition, a "writeable path" may be set using setWriteablePath(). The writable path is used to store files downloaded from game servers.
The Resource system also supports Volume files, which appeared in Tribes 1 as .vol files and Tribes 2 as .vl2 files, but in reality as ZIP files. When ResManager encounters a file with a .zip extension, it opens it and adds all the items in the ZIP's contents list to the list of known files.
ResManager automatically deals with the complexities related to opening a ZIP file and streaming a specific file in it, so your resource implementation doesn't need to concern itself with where the data is coming from.
ResourceObject and Resource<T>
As mentioned above, ResManager maintains a list of all the files it knows about using ResourceObjects. The Resource<T> template is provided to manage references to ResourceObjects; it ensures that the resource is properly refcounted.