Skip to content

Instantly share code, notes, and snippets.

View pardeike's full-sized avatar
💭
Innovating 🛠

Andreas Pardeike pardeike

💭
Innovating 🛠
View GitHub Profile
@pardeike
pardeike / pawn.json
Last active February 25, 2020 22:17
{
"pawn": {
"name": "MJ Golden",
"age": "50 (89)",
"gender": "Female",
"bodyType": null,
"storyTitle": "Urbworld entrepreneur",
"traits": [
{
"name": "Careful shooter",
using System;
using System.Collections;
public class Program
{
// simulating a Harmony Passthrough Postfix
// (run it here: https://dotnetfiddle.net/qMPu6m)
//
// A passthrough postfix can be used to execute code between yields
// of an enumerator method. Normally, you cannot patch those methods
[1/19/2020 4:56:07.594 PM] Interrupt: Enqueueing RunSelectedOperation
[1/19/2020 4:56:07.594 PM] Enqueue operation 'RunSelectedOperation', hashcode:19063038
[1/19/2020 4:56:07.594 PM] Operation left in the the queue: 1
[1/19/2020 4:56:07.594 PM] 'RunSelectedOperation', hashcode:19063038
[1/19/2020 4:56:07.594 PM]
[1/19/2020 4:56:07.594 PM] Operation Dequeue : 'RunSelectedOperation'
[1/19/2020 4:56:07.685 PM] Starting programmatic build of containers...
[1/19/2020 4:56:07.812 PM] Completed programmatic build of containers.
[1/19/2020 4:56:07.812 PM] TestContainer update (build) complete : 126 ms
void Main()
{
var harmony = new Harmony("test");
harmony.PatchAll();
var group = new StatusItemGroup();
var items = new List<StatusItemGroup.Entry>() { StatusItemGroup.Entry.Make("A"), StatusItemGroup.Entry.Make("B") };
Traverse.Create(group).Field("items").SetValue(items);
var enumerator = group.GetEnumerator();
using System;
using HarmonyLib;
namespace NoInlining
{
public class MainClass
{
public static void Main(string[] args)
{
var harmony = new Harmony("test");
@pardeike
pardeike / RimWorld_1.0_to_1.1.md
Last active January 1, 2024 09:49
How to update your Mod from RimWorld from 1.0 to 1.1 and Harmony 1.2.0.1 to 2.0

Updating RimWorld from 1.0 to 1.1

Introduction

My name is Andreas Pardeike, aka Brrainz, or the creator of Harmony. This guide is my personal attempt to help everyone through the journey of upgrading their mods. I am not affiliated with LUDEON studios or with developing RimWorld. It's just a personal thank you from me to the community.

Scope

This guide will help modders to update their C# mod to RimWorld 1.1. I will tell you how you upgrade to Harmony 2 and why. It will also serve as a guide to common changes that I encountered while I upgraded my own Camera+ mod. During the guide, I will use Visual Studio 2019. It's community edition is free. If you use a different IDE, please adapt your changes.

@pardeike
pardeike / RimworldAddingExtraPathCostsSafeTranspiler.cs
Created February 20, 2020 20:43
A robust transpiler to add extra pathing costs to FindPath in RimWorld
[HarmonyPatch(typeof(PathFinder), "FindPath")]
[HarmonyPatch(new Type[] { typeof(IntVec3), typeof(LocalTargetInfo), typeof(TraverseParms), typeof(PathEndMode) })]
public static class PathFinder_FindPath_Patch
{
static int GetExtraCosts(Pawn pawn, int gridIdx)
{
return 0; // extra costs to add for gridIdx
}
static readonly MethodInfo m_CellToIndex_int_int = AccessTools.Method(typeof(CellIndices), nameof(CellIndices.CellToIndex), new Type[] { typeof(int), typeof(int) });
<modDependencies>
<li>
<packageId>brrainz.harmony</packageId>
<displayName>Harmony</displayName>
<steamWorkshopUrl>steam://url/CommunityFilePage/2009463077</steamWorkshopUrl>
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
</li>
</modDependencies>
@pardeike
pardeike / ReportModProblems.txt
Last active March 5, 2020 03:35
How to report mod problems in the right way
My biggest stress factor is always gamers
who have 300 mods and something does not
work.
They come to me with insufficient information
and are hard to contact back. The way they
send information is incomplete and often
useless.
So here are my pro tips for making it easier
using HarmonyLib;
using System;
using System.Net;
namespace TestProcessResponse
{
class Program
{
static void Main(string[] args)
{