46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using HarmonyLib;
|
|
|
|
namespace IdleSpectator;
|
|
|
|
/// <summary>War genesis/end patches from mutation discovery.</summary>
|
|
[HarmonyPatch]
|
|
public static class WarEventPatches
|
|
{
|
|
[HarmonyPatch(typeof(WarManager), nameof(WarManager.newWar))]
|
|
[HarmonyPostfix]
|
|
public static void PostfixNewWar(War __result)
|
|
{
|
|
if (__result == null || !AgentHarness.LiveFeedsAllowed)
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
WarInterestFeed.EmitFromWarObject(__result, phase: "new");
|
|
}
|
|
catch
|
|
{
|
|
// Fallback: poll path still covers ongoing wars.
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(WarManager), nameof(WarManager.endWar))]
|
|
[HarmonyPostfix]
|
|
public static void PostfixEndWar(object[] __args)
|
|
{
|
|
if (!AgentHarness.LiveFeedsAllowed || __args == null || __args.Length == 0 || __args[0] == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
WarInterestFeed.EmitFromWarObject(__args[0], phase: "end");
|
|
}
|
|
catch
|
|
{
|
|
// ignore
|
|
}
|
|
}
|
|
}
|