[1.5] HugsLib (11.0.3) Lightweight modding library

Started by UnlimitedHugs, December 15, 2016, 02:20:14 PM

Previous topic - Next topic

UnlimitedHugs

Quote from: Zhentar on January 08, 2017, 12:47:15 PM
HugsLib would need one small change to support detouring constructors: The parameters to Detourprovider.TryIndependentDetour have to be changed from type MethodInfo to MethodBase.

Since that would break part of the API, I'll schedule it for the next update.
Also, that base call is crazy. But I guess you do what you gotta do. Props to him for the idea, though.

@Wishmaster
In the meantime, you could copy the TryIndepentDetour method to your mod and change the parameter types as Zhentar said, if there's no way around that detour.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

notfood

Quote from: Zhentar on January 08, 2017, 01:02:57 PM
And as long as I'm sharing crazy things ZorbaTHut has figured out, here's how to call the base class from a detoured override: https://github.com/zorbathut/icanfixit/blob/master/Building_Detour.cs

Nice find. This must be stickied in the Help subforum somewhere.

lllMWNlll

https://gist.github.com/ba9bc685af36733bc8f381d8ffccdc71

Hey, Hugs...

I'm testing several mods, i just closed and opened again Rimworld.exe from testing mods and i did have this log with some bugs.
Hope i can help with something. I still going to test 17 mods more, i also will post this to the other mods that shows up there.

faltonico

Please PLEASE don't do an update for a single translation =S

UnlimitedHugs

Quote from: lllMWNlll on January 13, 2017, 10:09:07 AM
I'm testing several mods, i just closed and opened again Rimworld.exe from testing mods and i did have this log with some bugs.

You probably mean the warning.
It's caused by one of Fluffy's mods, he already knows about it and might have already released a fix. In any case, this particular one won't cause trouble.

Quote from: faltonico on January 13, 2017, 10:33:40 AM
Please PLEASE don't do an update for a single translation =S

What's wrong with releasing an update?
You don't have to update if you installed manually, and Steam will just update automatically.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam


UnlimitedHugs

Quote from: gendalf on January 13, 2017, 10:54:37 PM
no minimap ?

Sorry, that's way out of the scope of this library :)
A minimap would fare much better as a standalone mod, since it's not a feature other mods rely on.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

faltonico

Quote from: UnlimitedHugs on January 13, 2017, 04:48:24 PM
Quote from: faltonico on January 13, 2017, 10:33:40 AM
Please PLEASE don't do an update for a single translation =S

What's wrong with releasing an update?
You don't have to update if you installed manually, and Steam will just update automatically.
Well i was kind of disappointed.. like "only for that?!" XD
But you are right sry :p

Brrainz

Hi everyone,

I would like to introduce a new library I wrote for the community. It is called Harmony and I have created a thread in Tools about it: https://ludeon.com/forums/index.php?topic=29517.0

The purpose of this lib is to take Detour() to the next level. My goal here was:

- keep the original method intact
- include methods where the class cannot be subclassed
- allow more than one patch for the same method
- define priorities so users don't have to reorder mods
- have mods identify themselves so they can look up who patched what
- have no global state
- have no external mod that users need to install separately
- have the code open and accessible to the public
- to be compatible with all the platforms and other versions of Harmony in the future

All this said, I want to say that I don't want to compete with HugsLib. Instead, I wish we could incorporate Harmony into HugsLib and replace the old Detour(). I will advocate this even to other potential clients like CCL. I also want people to test the living hell out of it - I have only tested it on 64bit Intel Win10 and my new MacBook. The tricky part in it is based on the work of Michael Turutanov with this great AsmHelper and this is already in use by Achtung and works for a lot of people but I had a friend report that it gives an access violation on this AMD/Win10 machine.

The library itself exists on GitHub here: https://github.com/pardeike/Harmony and I made a small example mod that toys with the Unity camera (A16) and uses Harmony here: https://github.com/pardeike/CameraPlus

Let me know if this sounds interesting so we can either discuss this here or in its own thread.

Cheers,
Andreas Pardeike

notfood


UnlimitedHugs

Quote from: pardeike on January 14, 2017, 03:48:10 AM
I would like to introduce a new library I wrote for the community. It is called Harmony and I have created a thread in Tools about it: https://ludeon.com/forums/index.php?topic=29517.0

Yesss, you made it! Kudos to you for your dedication and hard work.
Looks like we have lots of testing to do. Once it's stable, it could be distributed with HugsLib and integrated with the existing attribute system- for those who want to use it. The classic detour could be kept as a fallback, perhaps activated with a command line argument.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

Brrainz

Keeping the old Detour can proof to be tricky. The whole point of retiring it is to not replicate original game code when you patch things. So Harmony introduces prefix and postfix methods. A bit hard to have a fallback to the old way.

System.Linq

In some cases, replicating old game code is necessary if you mean to replace functionality. Postfix/prefix for new content is a very welcome addition, however.

Brrainz

Since a prefix can return false to suppress the execution of the original, you can have the replacement functionality too. Plus others can still prefix or postfix your patch too.

System.Linq

Oh, in that case, well done. I look forward to seeing it incorporated into HugsLib and ushering in a new era of compatibility.