GenericClassPlugin

v1.0.4·Updated 2026-04-15

Provides reflection access to types, methods, field, properties and events

About this mod Author’s original text

Generic Class Plugin

This unofficial TaleSpire dependency pluigin which allows plugins to access types, methods, fields, properties and events

using reflection. This allows plugins to access BR libraries without needing to add the BR assembly as a reference which

makes the plugin more resilient if BR changes the namespace or location of the type.

Install

Use R2ModMan or similar installer to install this asset pack.

Generally this plugin will be added automatically as a dependency of another plugin that uses it.

Usage

The plugin exposes the Generic class as `LordAshes.GenClassPlugin.Generic`.

Static types

To reference a static type use a syntax similart to:

`LordAshes.GenClassPlugin.Generic _InitiativeManager = new GenClassPlugin.Generic("InitiativeManager");`

Non-Static types

To reference instances of a type use a syntax similar to:

`LordAshes.GenClassPlugin.Generic cid = new GenClassPlugin.Generic("CreatureGuid", genericElement.GetType().GetRuntimeField("CreatureGuid").GetValue(genericElement));`

In the example above CreatureGuid is the type and we provide it a instance from the property of another object.

Resolving ambiguity

In some cases, the name alone is not sufficient to identify a type becuase there may be many different sources that use the same type name. Since using a full namespace

name would defeat the purpose of this endeavour, a mechanism is provided to try to narrow down the choice.

When calling the Generic constructor, the second parameter can be an array of strings. This lists fields and/or properties that the type must have in addition to matching the name.

For example:

`LordAshes.GenClassPlugin.Generic _InitiativeManager = new GenClassPlugin.Generic("InitiativeManager", new string { "TurnIndex", "TurnsCount" });`

Generic Class

The Generic class provides a way to store and interact with objects of various types without needing to provide a reference to that type. By avoiding any direct reference to

any non-referenced types, adding references can be avoided and this means a more resilient solution if those (no longer referenced) assemblies change.

The Generic class provides:

`Instance()`: A reference to the instance of the given class.

`Type()`: A reference to the type.

`Invoke(method,parameters)`: Executes a method on a static type or a type instance. The first parameter is the method name. Following parameters are the parameters sent to the method.

`Get(name)`: Gets the value of a field or proprty with the given name.

`GetAsGeneric(name)`: Gets the value of a field or proprty with the given name and converts it to a Generic Class.

`Set(name, value)`: Sets the value of a field or proprty with the given name.

`AddEvent(name, handler)`: Adds a handler to the name event.

Assembly access

The Generic Class plugin does not actually load any assemblies. As such, it has access to any types that have already been loaded into memory. Since the main purpose of this plugin

is to provide access to BR types and the BR types would be loaded by core Talespire, any types in BR assemblies should be available. As such, if using this to access types besides

BR assembly types, it may be necessary to load the assembley into memory before being able to access it with this plugin.

Install & use Install: follow the bundled instructions

  1. Unzip the archive from playbuff and read the bundled readme / instructions first.
  2. Most mods rely on the game's mod loader — the usual route is a community mod manager (such as r2modman): pick this game, install, and it handles the loader and dependencies.
  3. For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
  4. Launch the game to confirm it loaded; mods with listed dependencies need those installed as well.

Install locations vary a lot between mods — the bundled readme is the most reliable guide.

Dependencies

Install these first, or the mod will not work:

bbepisTaleSpire-BepInExPackbrcoding-SetInjectionFlagPlugin

File & checksum

Filename
GenericClassPlugin-1.0.4.zip
File size
32.9 KiB