Interface IAssetManager
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
Takes care loading, reloading and managing all files inside the assets folder. All asset names and paths are always converted to lower case.
public interface IAssetManager
- Extension Methods
Properties
AllAssets
All assets found in the assets folder
Dictionary<AssetLocation, IAsset> AllAssets { get; }
Property Value
Origins
Returns all origins in the priority order. Highest (First) to Lowest (Last)
List<IAssetOrigin> Origins { get; }
Property Value
Methods
Add(AssetLocation, IAsset)
Adds a runtime asset to the game, curently used by ModCompatiblityUtil. Allows you do add an asset found at path
but loaded from path asset
.Path.
void Add(AssetLocation path, IAsset asset)
Parameters
path
AssetLocationasset
IAsset
AddModOrigin(string, string)
void AddModOrigin(string domain, string fullPath)
Parameters
AddModOrigin(string, string, string)
void AddModOrigin(string domain, string fullPath, string pathForReservedCharsCheck)
Parameters
AddPathOrigin(string, string)
[Obsolete("Use AddModOrigin")]
void AddPathOrigin(string domain, string fullPath)
Parameters
Exists(AssetLocation)
Returns true if given asset exists in the list of loaded assets
bool Exists(AssetLocation location)
Parameters
location
AssetLocation
Returns
Get(AssetLocation)
Retrieves an asset from given path within the assets folder. Throws an exception when the asset does not exist. Remember to use lower case paths.
IAsset Get(AssetLocation Location)
Parameters
Location
AssetLocation
Returns
GetLocations(string, string)
Returns all asset locations that begins with given path and domain. If no domain is specified, all domains will be searched. The returned list is considered unsorted.
List<AssetLocation> GetLocations(string pathBegins, string domain = null)
Parameters
Returns
GetMany(string, string, bool)
Returns all assets inside given domain with the given path. If no domain is specified, all domains will be searched. The returned list is considered unsorted.
List<IAsset> GetMany(string pathBegins, string domain = null, bool loadAsset = true)
Parameters
Returns
GetManyInCategory(string, string, string, bool)
Returns all assets inside given category with the given path. If no domain is specified, all domains will be searched. The returned list is considered unsorted.
List<IAsset> GetManyInCategory(string categoryCode, string pathBegins, string domain = null, bool loadAsset = true)
Parameters
categoryCode
stringSee class AssetCategory
pathBegins
stringdomain
stringloadAsset
bool
Returns
GetMany<T>(ILogger, string, string)
Searches for all assets in given basepath and uses Newtonsoft.Json to automatically turn them into objects. Will log an error to given ILogger if it can't parse the json file and continue with the next asset. Remember to use lower case paths. If no domain is specified, all domains will be searched. The returned list is considered unsorted.
Dictionary<AssetLocation, T> GetMany<T>(ILogger logger, string pathBegins, string domain = null)
Parameters
Returns
Type Parameters
T
Get<T>(AssetLocation)
Retrieves an asset from given path within the assets folder and uses JSON.NET to automatically turn them into objects. Throws an exception when the asset does not exist or the conversion failed. Remember to use lower case paths.
T Get<T>(AssetLocation location)
Parameters
location
AssetLocation
Returns
- T
Type Parameters
T
Reload(AssetCategory)
Reloads all assets in given base location path. It returns the amount of the found locations.
int Reload(AssetCategory category)
Parameters
category
AssetCategory
Returns
Reload(AssetLocation)
Reloads all assets in given base location path. It returns the amount of the found locations.
int Reload(AssetLocation baseLocation)
Parameters
baseLocation
AssetLocation
Returns
TryGet(AssetLocation, bool)
Retrieves an asset from given path within the assets folder. Returns null when the asset does not exist. Remember to use lower case paths.
Mods must not call TryGet to get assets before AssetsLoaded stage in a ModSystem - do not load assets in the Start() method! (Or if you absolutely have to load assets in Start(), use IAssetManager.Get(), but it will throw an exception for anything except a base asset.)
IAsset TryGet(AssetLocation Location, bool loadAsset = true)
Parameters
Location
AssetLocationloadAsset
bool