GenericClassPlugin

版本 v1.0.4·更新於 2026-04-15

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

模組介紹 作者原文

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.

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

bbepisTaleSpire-BepInExPackbrcoding-SetInjectionFlagPlugin

檔案與校驗

檔案名稱
GenericClassPlugin-1.0.4.zip
檔案大小
32.9 KiB