mirror of
https://gitgud.io/LonelyRain/rjw-quirks.git
synced 2024-08-15 00:03:31 +00:00
31 lines
945 B
C#
31 lines
945 B
C#
|
using HarmonyLib;
|
|||
|
using RimWorld;
|
|||
|
using rjwquirks.Modules.Shared.Events;
|
|||
|
using Verse;
|
|||
|
|
|||
|
namespace rjwquirks.HarmonyPatches
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Patch to generate events on record changes
|
|||
|
/// </summary>
|
|||
|
[HarmonyPatch(typeof(Pawn_RecordsTracker))]
|
|||
|
public static class Patch_RecordsTracker_NotifyRecordChanged
|
|||
|
{
|
|||
|
[HarmonyPatch(nameof(Pawn_RecordsTracker.Increment))]
|
|||
|
[HarmonyPostfix]
|
|||
|
public static void IncrementPostfix(Pawn_RecordsTracker __instance, RecordDef def)
|
|||
|
{
|
|||
|
NotifyEvent(__instance.pawn, def);
|
|||
|
}
|
|||
|
|
|||
|
[HarmonyPatch(nameof(Pawn_RecordsTracker.AddTo))]
|
|||
|
[HarmonyPostfix]
|
|||
|
public static void AddToPostfix(Pawn_RecordsTracker __instance, RecordDef def)
|
|||
|
{
|
|||
|
NotifyEvent(__instance.pawn, def);
|
|||
|
}
|
|||
|
|
|||
|
private static void NotifyEvent(Pawn pawn, RecordDef def) => RjwEventManager.NotifyEvent(new RjwEvent(RjwEventDefOf.RecordChanged, pawn.Named(RjwEventArgNames.Pawn), def.Named(RjwEventArgNames.Record)));
|
|||
|
}
|
|||
|
}
|