TerrariaHooks
v0.19 - Update MonoMod
请告诉任何仍使用此旧版本更新其MOD的MOD开发人员。
Hookgen的Terraria“食谱”,导致其他mod可以取决于TML MOD。
由Monomod构建。
此mod是其他mod的助手。只需安装mod,它就不会自行更改Terraria。
On . Terraria . Player . CheckMana += ( orig , player , amount , pay , blockQuickMana ) => {
// We can either make this act as a method replacement
// or just call our code around the original code.
// Let's double the mana cost of everything.
// We can pass on custom values.
bool spendable = orig ( player , amount * 2 , pay , blockQuickMana ) ;
// ... but give back half of it if it was spent.
if ( spendable && pay ) {
player . statMana += amount / 2 ;
}
// We can return custom values.
return spendable ;
}
对于一个扩展的例子,请看一下这个要旨。
使用“钩子”检测方法何时运行,更改其运行方式甚至更换。
每当您的mod卸载时,“钩子”就会自动撤消。这是由Terrariahooks为您处理的。
通过IL ... +=(...)=> {...}在运行时操作任何方法,使用Cecil和许多助手。
特别感谢Chicken-Bones在此过程中提供的好主意和反馈!
使用RunTimedEtour快速移植您现有的“方法交换”代码。
请注意,这需要您在卸载时撤消绕道。
如果您需要更多信息,请阅读Monomod RuntimedEtour Readme。
如果您想在mod中使用Terrariahooks:
TerrariaHooks.dll
。lib
文件夹中。build.txt
中,添加modReferences = TerrariaHooks
Load
方法中。git clone --recursive https://github.com/0x0ade/TerrariaHookGen.git
_input
中更新文件./TerrariaHookGen/bin/Debug/TerrariaHookGen.exe _input .
./tModLoaderServer.exe -build 'path/to/TerrariaHooks' -eac
该存储库胜过整个过程。它归结为:
./MonoMod.RuntimeDetour.HookGen.exe --private Terraria.exe TerrariaHooksPre.dll
./ILRepack.exe /out:TerrariaHooks.dll TerrariaHooksPre.dll MonoMod. * .dll MonoMod.exe
当在Terraria目录中运行上述两行(存在所有依赖关系)时,它会为您的Terraria.exe
生成TerrariaHooks.dll
。
该存储库的唯一目的是完全自动化该过程,并允许出版TerrariaHooks.dll
作为TML mod。