Giter Club home page Giter Club logo

Comments (3)

ManlyMarco avatar ManlyMarco commented on June 18, 2024 1

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.

orcun9988 avatar orcun9988 commented on June 18, 2024

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.

ManlyMarco avatar ManlyMarco commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.