Skip to content

Instantly share code, notes, and snippets.

View schtauffen's full-sized avatar

Zach Dahl schtauffen

View GitHub Profile
@pardeike
pardeike / SimpleHarmonyTranspilerTutorial.md
Last active May 22, 2023 04:43
Simple Harmony Transpiler Tutorial

About
A hopefully easy tutorial on how to make a Transpiler with Harmony
Based on patching a method in the game RimWorld

Introduction

Writing transpilers is like writing a book about how to rewrite a cookbook to make it work for the age of microwave even if that cookbook was written before microwave ovens were invented. It requires good knowledge about the language the cookbook is written in and the topics and information models the cookbook author uses.

As such, writing a transpiler is way more complex and low level than writing a simple method that prefixes, postfixes or replaces an existing method. It is required to have good understanding in general C# programming and how to manipulate abstract data structures with respect to references and relative positioning. It also requires to know the language, in this case CIL, so you can manipulate the instructions without it to get into an illegal state.

* { box-sizing: border-box; }
html, body { min-height: 100vh; margin: 0; }
div,
html,
body,
nav,
header,
hgroup,
footer,