Git Product home page Git Product logo

Comments (3)

ManlyMarco avatar ManlyMarco commented on July 30, 2024

One applied, patches are referenced by the ID of your harmony instance, not by the methods/types the patches came from. You can use the same patches in two different instances with different IDs, and allowing unpatching by type would not work well with this. If you need to allow external code to unpatch, then give your harmony instance a known ID that other code/plugins can use.

from harmonyx.

ghorsington avatar ghorsington commented on July 30, 2024

To add to what Marco noted, you generally can use any of harmony.Unpatch* methods to unpatch specific harmony instances by their ID. If you need to unpatch specific types, a reasonable workaround is

// Creates an instance and calls PatchAll(Type) for the given class
var instance = Harmony.CreateAndPatchAll(typeof(SomePatchClass));

// Use the patches...

// In the end, unpatch the instance
instance.UnpatchSelf();

If you need to unpatch ALL instances from a given method, use Unpatch(MethodBase, HarmonyPatchType, string) or Unpatch(MethodBase, MethodInfo)

If we were to add any more Unpatch* overloads, they need to be clearly defined with all possible edge cases outlined. For example, does UnpatchAll(Type) mean that it takes a patch type and uptaches all harmony instances that have at least one method patched from the type? Or is the type some target type and UnpatchAll unpatches all methods that are patched in the type?

Do feel free to suggest new Unpatch* overloads. However, they generally need to be thought through pretty well since even right now it's a bit of a mess with all the different overloads and their sometimes unclear behaviour. We already tried to fix some of it (for instance by adding a warning message every time someone calls UnpatchAll because of its unintended side-effects). We can't, unfortunately, change too much to keep functionality the same with vanilla Harmony.

from harmonyx.

misternebula avatar misternebula commented on July 30, 2024

Ok, thanks! I've just rewritten what I'm doing to have a new harmony instance for each patch block I do, so that's a reasonable workaround.
(By the way, what I would have needed this for is a multiplayer mod - patch blocks for server/client cases, where they can be switched around)

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.