Scripting API
Scripting API
LocalizedAsset
Class in Abyss.Core, from Abyss.Core.
A localized asset: an image, a sound or a font that is a file for each of a game's languages, as its .localized file names them, its default and a file for each language that has one of its own. Anything that uses it names it as it would name the image, and shows the file of the language the player uses, switching at once as it changes.
public sealed class LocalizedAssetRemarks
A language with no file of its own falls back as a string does: pt-BR shows pt's file where there is one, else the default (FileFor).
The file is JSON, as a material's is:
{ "abyssLocalized": 1, "default": "ui/flag.png", "languages": { "ru": "ui/flag-ru.png" }, "ids": { "default": "…", "ru": "…" }}Constructors
LocalizedAsset
public LocalizedAsset(LocalizedFile @default)A localized asset with default as its default and no language's file.
Parameters
default
Properties
Default
public LocalizedFile Default { get; set; }What every language with no file of its own shows.
Languages
public SortedDictionary<string, LocalizedFile> Languages { get; }Each language's own file, by the language's code.
Kind
public LocalizedKind? Kind { get; }What it is, by its default's extension; null where that is no image, sound or font.
Methods
Is
public static bool Is(string path)Whether a path names a localized asset, by its extension.
Parameters
path
KindOf
public static LocalizedKind? KindOf(string path)What a file can be the default or a language's file of, by its extension; null for any other.
Parameters
path
NameOf
public static string NameOf(LocalizedKind kind)What a kind is called after "localized": image, sound, font.
Parameters
kind
FileFor
public string FileFor(string? language, string? @default, Func<string, bool> available)The file a player using language is shown: the first of it and the languages it falls back to (LocalizedAsset.Chain) with a file of its own that is available, else the default; where the default is not either, any language's file that is, so a game with a language's pack and not the default's shows something; else the default.
Parameters
language: The language in use, or null where the game is not localized.default: The game's default language.available: Whether a file is there to be shown: in a pack mounted, say.
Chain
public static IEnumerable<string> Chain(string language, string? @default)The languages a string or a file is looked for in for a player using language: it, each shorter code of it — pt-BR, then pt — then the game's default.
Parameters
languagedefault
Resolved
public LocalizedAsset Resolved(AssetDatabase database)It with each file named where it is now, found by its identity; one that is not found as it was.
Parameters
database
AllIn
public static List<(string Path, AssetGuid Id, LocalizedAsset Asset)> AllIn(AssetDatabase database, List<string>? problems = null)Every localized asset of the project database knows, by its path and identity, each file named where it is now; one that cannot be read is left out, and why is in problems.
Parameters
databaseproblems
WhyNot
public string? WhyNot(string path)Why a file cannot be one of its files, or null where it can: of the kind its default is, and no localized asset.
Parameters
path
Parse
public static LocalizedAsset Parse(string json)Reads a localized asset's file.
Parameters
json
Exceptions
FormatException: It is not one this build reads.
ToJson
public string ToJson(bool ids = true)Its file, as LocalizedAsset.Parse reads it; with no identities where ids is false, as a pack keeps it.
Parameters
ids
Constants
Extension
public const string Extension = ".localized"A localized asset's extension.
CurrentVersion
public const int CurrentVersion = 1The version of the file this build writes and reads up to.
