ReflectionPlugin
Provides reflection helpers to operate using types without needing to reference their assemblies at runtime.
模組介紹 作者原文
Reflection Plugin
This unofficial TaleSpire dependency plugin 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.
This is a succesor to the short lived GenClassPlugin. It uses Reflection styles operations but provides helpers functions
for easily getting references to types, methods, field, properties and events.
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
Type(string typeName, string has = null, string hasType = null, int resultIndex = 0)
Creates a System.Type based on the string typeName. If the "has" array is provided the type must have properties or fields
that match the names provide in the array. If the "hasType" array is provided, the type must have properties of the type
specified (using string names). Lastly if the match returns multiple results, the resultIndex can be used to chose which
Type to actually use.
If a type will be used frequently, defining a variable to hold it will be more efficient since the code will not have to
try to find the corresponding type each time.
For example:
System.Type _LocalClient = Type("_LocalClient");
object cid = Reflection.Property(_LocalClient, "SelectedCreatureId").GetValue(null);
ClosedType(string typeBase, string typeClosed, string has = null, string hasType = null, int resultIndex = 0)
Same as the Type method above but allows creation of Type that close other types (e.g. types in the format A).
For example:
System.Type _SimpleSingletonBehaviourControllerManager = Reflection.ClosedType("SimpleSingletonBehaviour", "ControllerManager");
New(Type type, object constructorParamaters)
Creates a new instance of the given type using the constructor parameters provided. Usually chained with Type (see above).
For example: `
object counter = Reflection.New(Type("CreatureGuid"), new object { cid.ToString() });
HasMethod(Type type, string methodName, string parameterTypes = null)
Check if the given type has the specified method. If the parameterTypes array is provided, the method must match the
parameter types specified (using string names). A null parameter in the parameterTypes array means any type.
Usually chained with Type (see above). For example: `HasMethod(Type("Counter"),"Increment", new string { "System.Single" });`
Method(Type type, string methodName, string parameterTypes = null)
Returns the specified method on the specified type. If the parameterTypes array is provided, the method must match the
parameter types specified (using string names). A null parameter in the parameterTypes array means any type.
Used first method found if search results in multiple matching methods.
Usually chained with Type (see above). For example: `Method(Type("Counter"),"Increment", new string { "System.Single" });`
Methods(Type type, string methodName, string parameterTypes = null)
Returns the specified methods on the specified type. If the parameterTypes array is provided, the method must match the
parameter types specified (using string names). A null parameter in the parameterTypes array means any type.
Returns all methods matching the search parameters.
Usually chained with Type (see above). For example: `Methods(Type("Counter"),"Increment");`
Execute(MethodInfo method, object instance, object parameters, int resultIndex = 0)
Invokes the specified method using the specified instance and the specified parameters. Normally the method returns the
return value of the invoked method. Any out parameters are updated in the array of input parameters. However, to make it
easier to access a single out parameter directly, the resultIndex can be used to indicated the result to be returned.
If the invoked me
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: