- Introduce new narrative probes for episode grammar, ensemble balance, and prose redundancy - Implement narrative presentation coverage tracking for better event visibility - Update harness scenarios to include new narrative ingestion and persistence tests - Refactor event emission to include narrative development IDs and presentations - Expand InterestCandidate to support narrative presentation models and roles
71 lines
1.7 KiB
C#
71 lines
1.7 KiB
C#
using System;
|
|
using System.Reflection;
|
|
using HarmonyLib;
|
|
|
|
namespace IdleSpectator;
|
|
|
|
/// <summary>Reset life-saga session when the live map finishes loading or is cleared.</summary>
|
|
[HarmonyPatch]
|
|
public static class LifeSagaSessionPatches
|
|
{
|
|
[HarmonyPatch(typeof(MapBox), nameof(MapBox.finishingUpLoading))]
|
|
[HarmonyPostfix]
|
|
public static void PostfixFinishingUpLoading()
|
|
{
|
|
try
|
|
{
|
|
LifeSagaSession.OnWorldLoadFinished();
|
|
}
|
|
catch
|
|
{
|
|
// Load path must not throw into the game.
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(MapBox), nameof(MapBox.clearWorld))]
|
|
[HarmonyPrefix]
|
|
public static void PrefixClearWorld()
|
|
{
|
|
try
|
|
{
|
|
LifeSagaSession.ResetForWorldChange("clear-world");
|
|
}
|
|
catch
|
|
{
|
|
// Teardown path must not throw into the game.
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Promote narrative recovery state only after WorldBox confirms a save completed.</summary>
|
|
[HarmonyPatch]
|
|
public static class NarrativeSaveCompletionPatch
|
|
{
|
|
public static MethodBase TargetMethod()
|
|
{
|
|
Type[] types = typeof(MapBox).Assembly.GetTypes();
|
|
for (int i = 0; i < types.Length; i++)
|
|
{
|
|
MethodInfo method = AccessTools.Method(types[i], "finishSaving");
|
|
if (method != null)
|
|
{
|
|
return method;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
[HarmonyPostfix]
|
|
public static void Postfix()
|
|
{
|
|
try
|
|
{
|
|
NarrativePersistence.SaveCommittedWorld();
|
|
}
|
|
catch
|
|
{
|
|
// Saving the base world must never depend on the narrative sidecar.
|
|
}
|
|
}
|
|
}
|