Difference between revisions of "Modding Tutorials/Harmony"

From RimWorld Wiki
Jump to navigation Jump to search
m (clean up links)
(Remove recommendation of HugsLib for new users and instead recommend they use it only when necessary (wanting to utilize HugsLib's API) and not when wanting to utilize Harmony directly.)
Line 5: Line 5:
  
  
Harmony is the current best practice for changing the runtime execution of code in RimWorld. The best method of incorporating it in your Mod is to depend on the HugsLib Mod.
+
Harmony is the current best practice for changing the runtime execution of code in RimWorld.
 +
 
 +
To integrate Harmony into your mod for use, download the latest stable release and add it as a reference to your C# project. Make sure that you also include the dll, (0Harmony.dll) in your mod's assemblies folder. Please DO NOT use HugsLib for an "easy" Harmony implementation due to the fact that HugsLib becomes an unnecessary and unutilized dependency for mods and beginners grow accustomed to using HugsLib in all their mods even if they never touch HugsLib's API in their code. This is a bad practice, especially for beginners new to RimWorld Modding. Please only use HugsLib when you want to utilize some of its features!
  
 
Harmony is great for running code patches before (Prefix) or after (Postfix) an existing method. Usually this is all you need for your Mod. Because this does not change existing functionality of RimWorld, it MOST LIKELY does not impact other mods and runs in parallel with other Harmony patches.
 
Harmony is great for running code patches before (Prefix) or after (Postfix) an existing method. Usually this is all you need for your Mod. Because this does not change existing functionality of RimWorld, it MOST LIKELY does not impact other mods and runs in parallel with other Harmony patches.
Line 11: Line 13:
  
 
= Links =  
 
= Links =  
 +
 +
[https://github.com/pardeike/Harmony/releases Harmony's Releases] - Link to Harmony's latest release(s) for download.
  
 
[https://github.com/pardeike/Harmony/wiki Harmony's Wiki] - General outline of how to use Harmony
 
[https://github.com/pardeike/Harmony/wiki Harmony's Wiki] - General outline of how to use Harmony

Revision as of 07:49, 20 October 2018

Modding Tutorials


Harmony - A library for patching, replacing and decorating .NET and Mono methods during runtime


Harmony is the current best practice for changing the runtime execution of code in RimWorld.

To integrate Harmony into your mod for use, download the latest stable release and add it as a reference to your C# project. Make sure that you also include the dll, (0Harmony.dll) in your mod's assemblies folder. Please DO NOT use HugsLib for an "easy" Harmony implementation due to the fact that HugsLib becomes an unnecessary and unutilized dependency for mods and beginners grow accustomed to using HugsLib in all their mods even if they never touch HugsLib's API in their code. This is a bad practice, especially for beginners new to RimWorld Modding. Please only use HugsLib when you want to utilize some of its features!

Harmony is great for running code patches before (Prefix) or after (Postfix) an existing method. Usually this is all you need for your Mod. Because this does not change existing functionality of RimWorld, it MOST LIKELY does not impact other mods and runs in parallel with other Harmony patches.


Links

Harmony's Releases - Link to Harmony's latest release(s) for download.

Harmony's Wiki - General outline of how to use Harmony

RimWorldModGuide on Harmony - gives some concrete examples and helpful explanations

Harmony's Author's Transpiler tutorial - Tutorial and example of using Harmony Transpiler, with helpful links (inject your code inside a RimWorld class's code - #DeepMagic)

Harmony Thread - Harmony thread on Ludeon Studio's Forum. Announcements of new versions, and the forum in general is a reasonable place to ask questions.

HugsLib - uses Harmony internally and gives modders useful tools (Mod options, etc)