worldbox-observer-mod/IdleSpectator/ActorChroniclePatches.cs
DazedAnon c11b87aa2e Implement gravestone features and enhance Lore interactions.
- Add gravestone management with max stack and lifetime settings
- Introduce new commands for grave interactions in scenarios
- Update Lore handling to include gravestone context and details
- Refactor death cause formatting for improved readability
- Increment version to 0.28.11 in mod.json
2026-07-17 16:32:10 -05:00

76 lines
2 KiB
C#

using HarmonyLib;
namespace IdleSpectator;
/// <summary>
/// Feeds character History from kills, deaths, lovers, and best friends.
/// </summary>
[HarmonyPatch]
public static class ActorChroniclePatches
{
[HarmonyPatch(typeof(Actor), "newKillAction")]
[HarmonyPostfix]
public static void PostfixNewKill(Actor __instance, Actor pDeadUnit)
{
Chronicle.NoteKill(__instance, pDeadUnit);
}
[HarmonyPatch(typeof(Actor), "die")]
[HarmonyPrefix]
public static void PrefixDie(Actor __instance, out Actor __state)
{
__state = null;
try
{
if (__instance == null)
{
return;
}
// Capture living dossier before die() clears state - used by Fallen archive.
Chronicle.CaptureFinalDossier(__instance);
BaseSimObject attacker = __instance.attackedBy;
if (attacker != null && !attacker.isRekt() && attacker.isActor() && attacker != __instance)
{
__state = attacker.a;
}
}
catch
{
__state = null;
}
}
[HarmonyPatch(typeof(Actor), "die")]
[HarmonyPostfix]
public static void PostfixDie(Actor __instance, AttackType pType, bool pCountDeath, Actor __state)
{
if (!pCountDeath || __instance == null)
{
return;
}
Chronicle.NoteDeath(__instance, pType, __state);
GraveMarkers.AddDeath(__instance);
}
[HarmonyPatch(typeof(Actor), nameof(Actor.becomeLoversWith))]
[HarmonyPostfix]
public static void PostfixLovers(Actor __instance, Actor pTarget)
{
Chronicle.NoteLovers(__instance, pTarget);
}
[HarmonyPatch(typeof(Actor), nameof(Actor.setBestFriend))]
[HarmonyPostfix]
public static void PostfixBestFriend(Actor __instance, Actor pActor, bool pNew)
{
if (!pNew)
{
return;
}
Chronicle.NoteBestFriends(__instance, pActor);
}
}