61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using ai.behaviours;
|
|
using HarmonyLib;
|
|
|
|
namespace IdleSpectator;
|
|
|
|
/// <summary>Boat transport/trade interest patches from mutation discovery.</summary>
|
|
[HarmonyPatch]
|
|
public static class BoatEventPatches
|
|
{
|
|
[HarmonyPatch(typeof(BehBoatTransportUnloadUnits), nameof(BehBoatTransportUnloadUnits.execute))]
|
|
[HarmonyPostfix]
|
|
public static void PostfixUnload(Actor pActor, BehResult __result)
|
|
{
|
|
if (pActor == null || !pActor.isAlive() || __result == BehResult.Stop)
|
|
{
|
|
return;
|
|
}
|
|
|
|
EmitBoat("boat_unload", 72f, pActor, EventReason.Boat(pActor, "unload"));
|
|
}
|
|
|
|
[HarmonyPatch(typeof(BehBoatMakeTrade), nameof(BehBoatMakeTrade.execute))]
|
|
[HarmonyPostfix]
|
|
public static void PostfixTrade(Actor pActor, BehResult __result)
|
|
{
|
|
if (pActor == null || !pActor.isAlive() || __result == BehResult.Stop)
|
|
{
|
|
return;
|
|
}
|
|
|
|
EmitBoat("boat_trade", 68f, pActor, EventReason.Boat(pActor, "trade"));
|
|
}
|
|
|
|
[HarmonyPatch(typeof(BehBoatTransportDoLoading), nameof(BehBoatTransportDoLoading.execute))]
|
|
[HarmonyPostfix]
|
|
public static void PostfixLoad(Actor pActor, BehResult __result)
|
|
{
|
|
// Loading is routine transport churn - unload/trade stay on Layer A.
|
|
_ = pActor;
|
|
_ = __result;
|
|
}
|
|
|
|
private static void EmitBoat(string eventId, float strength, Actor actor, string label)
|
|
{
|
|
if (!AgentHarness.LiveFeedsAllowed)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string key = "boat:" + eventId + ":" + EventFeedUtil.SafeId(actor);
|
|
EventFeedUtil.Register(
|
|
key,
|
|
"boat",
|
|
"Travel",
|
|
label,
|
|
eventId,
|
|
strength,
|
|
actor.current_position,
|
|
actor);
|
|
}
|
|
}
|