Finding Target Methods
Before writing a patch, you must first figure out "which game method to modify." This is one of the most time-consuming parts of Harmony development.
Tool Selection
| Tool | Description |
|---|---|
| dnSpy | Decompiler + debugger in one, most commonly used |
| ILSpy | Lightweight decompiler, can view IL |
| Il2CppInspector | Decompiler for Il2Cpp dumps |
ADOFAI is a Mono game, so you can directly decompile the managed DLL in the game directory:
A Dance of Fire and Ice\ADofAI_Data\Managed\Assembly-CSharp.dllSearch Strategies
1. Infer Method Names from Game Features
Want to research "judgment" → search judge, hit, perfect (note: research only, do not modify — see Development Guidelines); want to modify "camera" → search camera. dnSpy's Analyze / Search can locate by keyword.
2. Search from Strings
In-game UI text (like button text "Play") appears as strings in IL. Search for strings in dnSpy, then look at methods that reference them to quickly locate relevant logic.
3. Backtrace from Fields / Properties
If you know which field a value is stored in → right-click the field → Analyze → see "who reads/writes it" to find methods that operate on it.
Confirming the Signature
Once you find a candidate method, record three things:
// Class name
// Method name
// Parameter types (key for distinguishing overloads)Example: you want to patch Scoring.UpdateScore, and its signature is public void UpdateScore(float add).
The corresponding patch:
[HarmonyPatch(typeof(Scoring), nameof(Scoring.UpdateScore))]
public static class UpdateScore_Postfix
{
public static void Postfix(ref float __result) { /* ... */ }
}If the method has multiple overloads, you must specify with
new Type[] { typeof(float) }.
Viewing IL (Preparing for Transpiler)
In dnSpy, switch the method view to the IL tab to see the instruction sequence that corresponds one-to-one with CodeInstruction.
Decompiling Copyright-Protected Binaries
WARNING
Decompiling game binaries is for understanding and debugging only. Do not put original DLLs or other game binaries into your Mod artifacts, release packages, or GitHub repositories — they are copyright-protected. See Development Guidelines.
Verifying the Target is "Really Correct"
After applying a patch, verify it's actually being called with a log:
public static void Postfix()
{
MyMod.Logger.Log("UpdateScore was called");
}If the log doesn't appear, go back to Patch Lifecycle to troubleshoot.
What You Learned
- Locating methods with dnSpy / ILSpy
- Three search strategies: features, strings, field backtracing
- Recording signatures and confirming patches work
Next Step
Add configurable settings to your Mod → Settings System