Table of Contents

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

TAssetInterface

The 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

logger ILogger

Fields

OnAssetBuilt

public Action<Entity?, TAssetInterface> OnAssetBuilt

Field Value

Action<Entity, TAssetInterface>

Methods

AddAsset<TAssetVariant>(TAssetVariant, bool)

public void AddAsset<TAssetVariant>(TAssetVariant asset, bool replaceExisting = false) where TAssetVariant : TAssetInterface

Parameters

asset TAssetVariant
replaceExisting bool

Type Parameters

TAssetVariant

GetRegisteredElementTypes()

public IEnumerable<Type> GetRegisteredElementTypes()

Returns

IEnumerable<Type>

GetRegisteredVariantTypes()

public IEnumerable<Type> GetRegisteredVariantTypes()

Returns

IEnumerable<Type>

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

assetId string

The asset ID.

entity Entity

The entity that owns the instance.

entityJson JsonObject

The 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.

instance TInstance

The built instance.

Returns

bool

Bool indicating success.

Type Parameters

TInstance

The 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

assetId string

The asset ID.

instance TInstance

The built instance.

Returns

bool

Bool indicating success.

Type Parameters

TInstance

The asset instance type.

TryGetAsset(string, out TAssetInterface)

public bool TryGetAsset(string id, out TAssetInterface asset)

Parameters

id string
asset TAssetInterface

Returns

bool

TryGetElementType(string, out Type)

public bool TryGetElementType(string discriminator, out Type type)

Parameters

discriminator string
type Type

Returns

bool

TryGetVariantType(string, out Type)

public bool TryGetVariantType(string discriminator, out Type variantType)

Parameters

discriminator string
variantType Type

Returns

bool