Comments (3)
If you want to patch only if there's a condition then you can just make a Harmony instance and patch/unpatch it as needed, you'll just need to patch in a way that only affects that specific patch, so either PatchAll(Type) or Patch().
It's much easier to just always patch and check the condition inside of the patch. If the patched method doesn't run often then there will be no real performance effect.
from harmonyx.
can u give me example like
`[HarmonyPatch(typeof(MissionManager), nameof(MissionManager.SetMission))]
class Patch73141
{
static void Prefix()
{
if (patchmissions == true)
{
Console.WriteLine("Patched!");
return;
}
else
{
Console.WriteLine("there should be no patch but still patched :(");
}
}
}`
like that ( it's alwasy patching even patchmissions == false )
from harmonyx.
If you want to patch a single method then you can do something like this https://github.com/IllusionMods/IllusionModdingAPI/blob/dc09eed2c1b740e32f63400e5efde527ddad7077/src/KKSAPI/MainGame/TopicApi.cs#L242-L243 and then do h.UnpatchSelf() to remove the patch. You can then patch again, rinse and repeat.
from harmonyx.
Related Issues (20)
- [Wiki] Typos in section 1.4 HOT 1
- [Wiki] Error using the provided postfix in section 1.4 HOT 1
- When will v2.11.0 be published on NuGet? HOT 2
- Android IL2CPP Support
- v2.11.0: patch with "ref string" on "static external" method produces garbage HOT 5
- Harmony doesn't work when path contains non-ANSI characters HOT 1
- How do I call a private function within a postpatch HOT 8
- How do I find the asset directory of stuff stored in a unity game? HOT 1
- Pass-through transpiler messes up leave labels in inner `MoveNext()` with `try/finally` block HOT 2
- IDK HOT 2
- Does it support NET6? HOT 1
- Label Jump HOT 2
- Empty Transpiler Causing Issues HOT 1
- How to override explicit interface methods? HOT 1
- When did it start to support net 7 or 8? HOT 1
- Cannot unpatch extern method patch
- Patching ref parameter with IL2Cpp results in invalid IL
- Usage with unity
- Empty Harmony Annotations Cause ArguementException: No Target Method Found HOT 2
- Skipping a patch when a method isnt found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from harmonyx.