Skip to content
EvilEngine.Conversion

AdapterContext class

public sealed class AdapterContext

What an adapter registers everything through in Register. Each of its calls adds one thing to the engine’s mount registry or conversion pipeline and records it under the adapter.

The host makes one per adapter from its adapter.toml, so the checks here follow the manifest: an adapter can only register the games its manifest lists, and only bind converters to those games or to its own id.

Assembly
EvilEngine.Conversion
Commit
4ff877b1

Members

Id property

public string Id { get; }

The adapter’s id, id from its adapter.toml. It shows up in every error the context throws, and it’s the content namespace AddOwnConverter binds to.

Registered property

public IReadOnlyList<object> Registered { get; }

Everything this adapter has registered so far, in the order it was added: games, containers, finders and converters. The boot reads it to describe each adapter in its transcript. For an adapter with no games it prints the type names, as in adapter pak 0.1.0: PakContainer.

Alone method

public static AdapterContext Alone(string id, IReadOnlyCollection<string> games)

Makes a context for one adapter, from its id and the games its manifest lists, over an empty registry and pipeline of its own. The host makes the real ones for you; this is for a test that runs an adapter’s Register without a whole host, then checks Registered.

var context = AdapterContext.Alone("quake", ["quake", "quake-rerelease"]);
new Quake().Register(context);
Assert.Contains(context.Registered, thing => thing is QuakeGame);

AddContainer method

public void AddContainer(IContainerAdapter container)

Registers an IContainerAdapter, a reader for an archive or disc image format that the mount core can then open like a folder.

Containers are asked in the order they were registered, and the first whose Recognises says yes opens the file. Adapters register in load order, so an adapter that loads earlier gets asked first.

AddFinder method

public void AddFinder(IFinder finder)

Registers an IFinder, which lists the games a storefront has installed. Its installs are offered under Available games in the main menu, and it answers store hints when a game looks for content outside its folder.

AddGame method

public void AddGame(IGameAdapter game)

Registers an IGameAdapter, which recognises one game’s install and plans its mount.

Throws InvalidOperationException when the game’s Game isn’t in games in the adapter’s manifest. Register the game before binding converters to it, since AddConverter only accepts games this context has already added.

AddConverter method

public void AddConverter(string @namespace, IConverter converter)

Binds an IConverter to a content namespace, so it converts content of its kind for that game. A mounted game’s namespace is its game name, such as quake for quake:id1/maps/e1m1.

Throws InvalidOperationException when the namespace isn’t a game this adapter has registered with AddGame, which also means you can’t bind to another adapter’s game. The pipeline throws InvalidOperationException too when a converter with the same Id is already bound to that namespace for the same kind.

Converters for one namespace and kind are tried in the order they were bound, so bind the most specific first.

AddOwnConverter method

public void AddOwnConverter(IConverter converter)

Binds an IConverter to the namespace named after the adapter itself, for content the adapter carries rather than any one game: the source adapter puts the shaders every Source game shares under source: this way. If no namespace of that name is open yet, it opens an empty one in memory first.

Throws InvalidOperationException when the adapter has registered a game with the same name as its own id. Then the namespace belongs to that game, so use AddConverter with the game’s name instead.