Code mods and Harmony
Write a mod
Put the game's extension interfaces in a shared API assembly. Reference a compatible version from the mod and declare the DLL, entry type, and API version range in the code block of content-pack.json. The entry type is a public, concrete IGameMod implementation with a parameterless constructor. Register gameplay extensions in lifecycle methods.
Start a trusted session
- Resolve a content pack plan and set
CodeApiVersion. - Tell the player the DLL will run with the game's process permissions. Store approval for the package version and file fingerprint.
- Call
GameModHost.PrepareAsyncwith shared contract assemblies, services, the dispatcher, and aTrustPolicy. - Pass
modHost.AdmissiontoContentCatalogLoader.LoadAsync. Prepare resources, then callStartAsync. - Await disposal of the mod host at the end of the game session. Restart the game after changing enabled mods, versions, or ordering.
To patch methods, install GeWuYou.GFramework.Game.Harmony in the host and configure HarmonyModExtension. Manage patches and their removal using the mod's own owner. For gameplay the public API exposes, use its interfaces directly.
See the Dodge the Creeps mod contracts.