Class AssetCollection<TAssetInterface>
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
Represents a collection of polymorphic asset types.
public sealed class AssetCollection<TAssetInterface> : IAssetCollection where TAssetInterface : IBuildableAsset<IAssetInstance>
Type Parameters
TAssetInterfaceThe base asset type this collection is for
- Inheritance
-
AssetCollection<TAssetInterface>
- Implements
- Inherited Members
- Extension Methods
Constructors
AssetCollection(ILogger?)
Represents a collection of polymorphic asset types.
public AssetCollection(ILogger? logger)
Parameters
loggerILogger
Fields
OnAssetBuilt
public Action<Entity?, TAssetInterface> OnAssetBuilt
Field Value
Methods
AddAsset<TAssetVariant>(TAssetVariant, bool)
public void AddAsset<TAssetVariant>(TAssetVariant asset, bool replaceExisting = false) where TAssetVariant : TAssetInterface
Parameters
assetTAssetVariantreplaceExistingbool
Type Parameters
TAssetVariant
GetRegisteredElementTypes()
public IEnumerable<Type> GetRegisteredElementTypes()
Returns
GetRegisteredVariantTypes()
public IEnumerable<Type> GetRegisteredVariantTypes()
Returns
RegisterElement<TElement>()
public AssetCollection<TAssetInterface> RegisterElement<TElement>()
Returns
- AssetCollection<TAssetInterface>
Type Parameters
TElement
RegisterVariant<TAssetVariant>()
public AssetCollection<TAssetInterface> RegisterVariant<TAssetVariant>() where TAssetVariant : TAssetInterface
Returns
- AssetCollection<TAssetInterface>
Type Parameters
TAssetVariant
TryBuildAsset<TInstance>(string, Entity, JsonObject, out TInstance)
Attempts to build an asset by asset ID for a specific entity.
public bool TryBuildAsset<TInstance>(string assetId, Entity entity, JsonObject entityJson, out TInstance instance)
Parameters
assetIdstringThe asset ID.
entityEntityThe entity that owns the instance.
entityJsonJsonObjectThe subobject (from the entity's JSON data) that references this asset (if any). This can be used to override or configure certain aspects of the asset on a per-entity basis.
instanceTInstanceThe built instance.
Returns
- bool
Bool indicating success.
Type Parameters
TInstanceThe asset instance type.
TryBuildAsset<TInstance>(string, out TInstance)
Attempts to build an asset by asset ID.
public bool TryBuildAsset<TInstance>(string assetId, out TInstance instance)
Parameters
assetIdstringThe asset ID.
instanceTInstanceThe built instance.
Returns
- bool
Bool indicating success.
Type Parameters
TInstanceThe asset instance type.
TryGetAsset(string, out TAssetInterface)
public bool TryGetAsset(string id, out TAssetInterface asset)
Parameters
idstringassetTAssetInterface
Returns
TryGetElementType(string, out Type)
public bool TryGetElementType(string discriminator, out Type type)
Parameters
Returns
TryGetVariantType(string, out Type)
public bool TryGetVariantType(string discriminator, out Type variantType)