Zetrith / Prepatcher

Structured assembly rewriting library/mod for RW
MIT License
74 stars 7 forks source link

Prepatcher

Latest API version

Structured assembly rewriting library/mod for RimWorld

Workshop: https://steamcommunity.com/sharedfiles/filedetails/?id=2934420800

The project has three main logical components:

Installation

Users

The mod is currently no longer distributed through GitHub's Releases tab.

Prepatcher is a provider of the Harmony library for RimWorld mods and can be used instead of HarmonyRimWorld. It patches the mod loading system so that:

Having both Prepatcher and the Harmony mod active won't cause any problems.

Modders

Add the Zetrith.Prepatcher nuget package to your mod's project:

<PackageReference Include="Zetrith.Prepatcher" Version="<version>" />

Similar to Harmony, the package distributes an API to be used for compiling only and the actual runtime library is installed by the user once using the mod downloaded from here.

To make a RimWorld mod correctly depend on Prepatcher, put this in About.xml:

<modDependencies>
    <li>
        <packageId>zetrith.prepatcher</packageId>
        <displayName>Prepatcher</displayName>
        <steamWorkshopUrl>steam://url/CommunityFilePage/2934420800</steamWorkshopUrl>
        <downloadUrl>https://github.com/Zetrith/Prepatcher/releases/latest</downloadUrl>
    </li>
</modDependencies>

Library example (declaring field addition):

[PrepatcherField]
public static extern ref int MyInt(this TargetClass target);

For more details and features, see https://github.com/Zetrith/Prepatcher/wiki

Compiling

Clone anywhere and go to the Source folder. Run dotnet build and/or dotnet test. If you want to run it ingame clone to the Mods folder.