差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
appendix:harmonyがある時 [2024/12/29 00:23] fumble |
appendix:harmonyがある時 [2024/12/29 00:31] (現在) fumble |
||
---|---|---|---|
行 62: | 行 62: | ||
static void ILManipulator(ILContext il, MethodBase original, ILLabel retLabel) | static void ILManipulator(ILContext il, MethodBase original, ILLabel retLabel) | ||
static void SomeOtherILManipulator(ILContext ctx, MethodBase orig) | static void SomeOtherILManipulator(ILContext ctx, MethodBase orig) | ||
+ | </ | ||
+ | |||
+ | 渡すときはHarmonyMethod(MethodInfo method)の変換、つまりコンストラクターを呼んで変換させる。 | ||
+ | <code csharp> | ||
+ | var transpilermethod = typeof(トランスパイラーのあるクラス).GetMethod(トランスパイラーのメソッド名); | ||
+ | var transpiler = Activator.CreateInstance(typeHarmonyMethod, | ||
</ | </ | ||
行 82: | 行 88: | ||
var opecode = fldOpecode.GetValue(instruction); | var opecode = fldOpecode.GetValue(instruction); | ||
var operand = fldOperand.GetValue(instruction); | var operand = fldOperand.GetValue(instruction); | ||
- | if (opecode.Equals(変えたいところのOpCode) && operand.Equals(変えたいところのOperand)) | + | if (opecode.Equals(変えたいところのOpCode) |
newInstructions.Add(Activator.CreateInstance(type, | newInstructions.Add(Activator.CreateInstance(type, | ||
else | else | ||
行 91: | 行 97: | ||
} | } | ||
</ | </ | ||
- | 引数をIEnumerableで受けて戻り値をobjectとかで宣言してしまいます。 | + | 引数をIEnumerableで受けて戻り値をobjectとかで宣言してしまいます。\\ |
引数で貰った IEnumerable< | 引数で貰った IEnumerable< | ||