Table of Contents

Class AssetLink

Namespace
Uncreated.Warfare.Configuration
Assembly
Uncreated.Warfare.dll
public static class AssetLink
Inheritance
AssetLink
Inherited Members

Fields

public static readonly SpecialFormat AssetLinkDescriptive

Field Value

SpecialFormat
public static readonly SpecialFormat AssetLinkDescriptiveNoColor

Field Value

SpecialFormat
public static readonly SpecialFormat AssetLinkFriendly

Field Value

SpecialFormat
public static readonly SpecialFormat AssetLinkFriendlyNoColor

Field Value

SpecialFormat

Methods

Throw an error only if this asset link is invalid.

public static void AssertValid<TAsset>(this IAssetLink<TAsset>? link) where TAsset : Asset

Parameters

link IAssetLink<TAsset>

Type Parameters

TAsset

Exceptions

AssetNotFoundException

Cast an asset link from one type to another.

public static IAssetLink<Asset> Cast(IAssetLink<Asset> assetLink, Type toAssetType)

Parameters

assetLink IAssetLink<Asset>
toAssetType Type

Returns

IAssetLink<Asset>

Exceptions

InvalidCastException
ArgumentException

toAssetType must derive from SDG.Unturned.Asset.

Cast an asset link from one type to another.

public static IAssetLink<TToAsset> Cast<TFromAsset, TToAsset>(this IAssetLink<TFromAsset> assetLink) where TFromAsset : Asset where TToAsset : Asset

Parameters

assetLink IAssetLink<TFromAsset>

Returns

IAssetLink<TToAsset>

Type Parameters

TFromAsset
TToAsset

Exceptions

InvalidCastException

See if a list of asset links contains an asset link.

public static bool ContainsAsset(this IEnumerable<IAssetLink<Asset>?>? links, IAssetLink<Asset>? asset)

Parameters

links IEnumerable<IAssetLink<Asset>>
asset IAssetLink<Asset>

Returns

bool

See if a list of asset links contains an asset.

public static bool ContainsAsset<TAsset>(this IEnumerable<IAssetLink<Asset>?>? links, TAsset? asset) where TAsset : Asset

Parameters

links IEnumerable<IAssetLink<Asset>>
asset TAsset

Returns

bool

Type Parameters

TAsset

See if a list of asset links contains a GUID.

public static bool ContainsGuid(this IEnumerable<IAssetLink<Asset>?>? links, Guid guid)

Parameters

links IEnumerable<IAssetLink<Asset>>
guid Guid

Returns

bool

See if a list of asset links contains a short ID.

public static bool ContainsId(this IEnumerable<IAssetLink<Asset>?>? links, ushort id)

Parameters

links IEnumerable<IAssetLink<Asset>>
id ushort

Returns

bool

Create an asset link from an asset.

public static IAssetLink<Asset> Create(Asset? asset, Type assetType)

Parameters

asset Asset
assetType Type

Returns

IAssetLink<Asset>

Exceptions

ArgumentException

assetType must derive from SDG.Unturned.Asset.

Create an asset link from a GUID.

public static IAssetLink<Asset> Create(Guid guid, Type assetType)

Parameters

guid Guid
assetType Type

Returns

IAssetLink<Asset>

Exceptions

ArgumentException

assetType must derive from SDG.Unturned.Asset.

Create an asset link from a GUID in string form.

public static IAssetLink<Asset> Create(string guid, Type assetType)

Parameters

guid string
assetType Type

Returns

IAssetLink<Asset>

Exceptions

ArgumentException

assetType must derive from SDG.Unturned.Asset.

Create an asset link from a short ID.

public static IAssetLink<Asset> Create(ushort id, Type assetType)

Parameters

id ushort
assetType Type

Returns

IAssetLink<Asset>

Exceptions

ArgumentException

assetType must derive from SDG.Unturned.Asset.

Create an asset link from an asset reference.

public static IAssetLink<TAsset> Create<TAsset>(AssetReference<TAsset> assetReference) where TAsset : Asset

Parameters

assetReference AssetReference<TAsset>

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Create an asset link from a GUID.

public static IAssetLink<TAsset> Create<TAsset>(Guid guid) where TAsset : Asset

Parameters

guid Guid

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Create an asset link from a GUID in string form.

public static IAssetLink<TAsset> Create<TAsset>(string guid) where TAsset : Asset

Parameters

guid string

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Create an asset link from a short ID.

public static IAssetLink<TAsset> Create<TAsset>(ushort id) where TAsset : Asset

Parameters

id ushort

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Create an asset link from an asset container. May return itself if container is IAssetLink<TAsset>.

public static IAssetLink<TAsset> Create<TAsset>(IAssetContainer container) where TAsset : Asset

Parameters

container IAssetContainer

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Create an asset link from an asset.

public static IAssetLink<TAsset> Create<TAsset>(TAsset? asset) where TAsset : Asset

Parameters

asset TAsset

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Returns an empty asset link.

public static IAssetLink<Asset> Empty(Type assetType)

Parameters

assetType Type

Returns

IAssetLink<Asset>

Returns an empty asset link.

public static IAssetLink<TAsset> Empty<TAsset>() where TAsset : Asset

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Read an asset link from a configuration section.

public static IAssetLink<TAsset> GetAssetLink<TAsset>(this IConfiguration configuration) where TAsset : Asset

Parameters

configuration IConfiguration

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Read an asset link from a configuration at a given key path.

public static IAssetLink<TAsset> GetAssetLink<TAsset>(this IConfiguration configuration, string key) where TAsset : Asset

Parameters

configuration IConfiguration
key string

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Resolve an asset from an asset link, or throw an error

public static TAsset GetAssetOrFail<TAsset>(this IAssetLink<TAsset>? link) where TAsset : Asset

Parameters

link IAssetLink<TAsset>

Returns

TAsset

Type Parameters

TAsset

Exceptions

AssetNotFoundException

Resolve an asset from an asset link, or throw an error

public static TAsset GetAssetOrFail<TAsset>(this IAssetLink<TAsset>? link, string propertyName) where TAsset : Asset

Parameters

link IAssetLink<TAsset>
propertyName string

Returns

TAsset

Type Parameters

TAsset

Exceptions

AssetNotFoundException

Determines the value of the generic argument of IAssetLink<TAsset> given an object of any asset link type.

public static Type GetAssetType(IAssetLink<Asset> assetLink)

Parameters

assetLink IAssetLink<Asset>

Returns

Type

Returns a max 48 length string with the item name, defaulting to '00000000000000000000000000000000'.

public static string GetDatabaseName(this Asset? asset)

Parameters

asset Asset

Returns

string

Returns a max 48 length string with the item name, defaulting to '00000000000000000000000000000000'.

public static string GetDatabaseName(this IAssetLink<Asset>? assetLink)

Parameters

assetLink IAssetLink<Asset>

Returns

string

Compare an asset link to another asset link.

public static bool MatchAsset(this IAssetLink<Asset>? link, IAssetContainer? container)

Parameters

link IAssetLink<Asset>
container IAssetContainer

Returns

bool

Compare an asset link to another asset link.

public static bool MatchAsset(this IAssetLink<Asset>? link, IAssetLink<Asset>? asset)

Parameters

link IAssetLink<Asset>
asset IAssetLink<Asset>

Returns

bool

Compare an asset link to an asset.

public static bool MatchAsset<TAsset>(this IAssetLink<TAsset>? link, TAsset? asset) where TAsset : Asset

Parameters

link IAssetLink<TAsset>
asset TAsset

Returns

bool

Type Parameters

TAsset

Compare an asset link to a GUID.

public static bool MatchGuid(this IAssetLink<Asset>? link, Guid guid)

Parameters

link IAssetLink<Asset>
guid Guid

Returns

bool

Compare an asset link to a short ID.

public static bool MatchId(this IAssetLink<Asset>? link, ushort id)

Parameters

link IAssetLink<Asset>
id ushort

Returns

bool

Create an asset link from an asset.

public static IAssetLink<Asset> Parse(string? value, Type assetType)

Parameters

value string
assetType Type

Returns

IAssetLink<Asset>

Exceptions

ArgumentException

assetType must derive from SDG.Unturned.Asset.

Create an asset link from an asset.

public static IAssetLink<TAsset> Parse<TAsset>(string? value) where TAsset : Asset

Parameters

value string

Returns

IAssetLink<TAsset>

Type Parameters

TAsset

Read an IAssetLink<TAsset> from a yaml parser.

public static object? ReadYaml(IParser parser, Type type)

Parameters

parser IParser
type Type

Returns

object

Convert an asset to a display string.

public static string ToDisplayString<TAsset>(TAsset? asset) where TAsset : Asset

Parameters

asset TAsset

Returns

string

Type Parameters

TAsset

Convert an asset to a display string.

public static string ToDisplayString<TAsset>(TAsset? asset, ushort id, Guid guid) where TAsset : Asset

Parameters

asset TAsset
id ushort
guid Guid

Returns

string

Type Parameters

TAsset

Attempt to resolve an asset from an asset variant dictionary.

public static bool TryGetAsset<TAsset>(this AssetVariantDictionary<TAsset>? reference, string? variant, out TAsset? asset) where TAsset : Asset

Parameters

reference AssetVariantDictionary<TAsset>
variant string
asset TAsset

Returns

bool

Type Parameters

TAsset

Attempt to resolve an asset from an asset link.

public static bool TryGetAsset<TAsset>(this IAssetLink<TAsset>? link, out TAsset? asset) where TAsset : Asset

Parameters

link IAssetLink<TAsset>
asset TAsset

Returns

bool

Type Parameters

TAsset

Attempt to resolve the GUID from an asset link.

public static bool TryGetGuid(this IAssetLink<Asset>? link, out Guid guid)

Parameters

link IAssetLink<Asset>
guid Guid

Returns

bool

Attempt to resolve the GUID from an asset variant dictionary.

public static bool TryGetGuid<TAsset>(this AssetVariantDictionary<TAsset>? reference, string? variant, out Guid guid) where TAsset : Asset

Parameters

reference AssetVariantDictionary<TAsset>
variant string
guid Guid

Returns

bool

Type Parameters

TAsset

Attempt to resolve the short ID from an asset link.

public static bool TryGetId(this IAssetLink<Asset>? link, out ushort id)

Parameters

link IAssetLink<Asset>
id ushort

Returns

bool

Attempt to resolve the short ID from an asset variant dictionary.

public static bool TryGetId<TAsset>(this AssetVariantDictionary<TAsset>? reference, string? variant, out ushort id) where TAsset : Asset

Parameters

reference AssetVariantDictionary<TAsset>
variant string
id ushort

Returns

bool

Type Parameters

TAsset

Create an asset link from a string.

public static bool TryParse(string? value, Type assetType, out IAssetLink<Asset> asset)

Parameters

value string
assetType Type
asset IAssetLink<Asset>

Returns

bool

true if parsing was successful or the string was null/empty (outputting an empty asset), otherwise false.

Create an asset link from a string.

public static bool TryParse<TAsset>(string? value, out IAssetLink<TAsset> asset) where TAsset : Asset

Parameters

value string
asset IAssetLink<TAsset>

Returns

bool

true if parsing was successful or the string was null/empty (outputting an empty asset), otherwise false.

Type Parameters

TAsset

Write an IAssetLink<TAsset> to a yaml emitter.

public static void WriteYaml(IEmitter emitter, IAssetLink<Asset>? assetLink)

Parameters

emitter IEmitter
assetLink IAssetLink<Asset>