72 lines
2 KiB
C#
72 lines
2 KiB
C#
using ai.behaviours;
|
|
using HarmonyLib;
|
|
using UnityEngine;
|
|
|
|
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, InterestOwnership.Signal, pActor, "Boat unloads: {a}");
|
|
}
|
|
|
|
[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, InterestOwnership.Signal, pActor, "Boat trade: {a}");
|
|
}
|
|
|
|
[HarmonyPatch(typeof(BehBoatTransportDoLoading), nameof(BehBoatTransportDoLoading.execute))]
|
|
[HarmonyPostfix]
|
|
public static void PostfixLoad(Actor pActor, BehResult __result)
|
|
{
|
|
if (pActor == null || !pActor.isAlive() || __result == BehResult.Stop)
|
|
{
|
|
return;
|
|
}
|
|
|
|
EmitBoat("boat_load", 55f, InterestOwnership.Ambient, pActor, "Boat loads: {a}");
|
|
}
|
|
|
|
private static void EmitBoat(
|
|
string eventId,
|
|
float strength,
|
|
InterestOwnership owns,
|
|
Actor actor,
|
|
string labelTemplate)
|
|
{
|
|
if (AgentHarness.Busy)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string label = (labelTemplate ?? "{a}").Replace("{a}", EventFeedUtil.SafeName(actor));
|
|
string key = "boat:" + eventId + ":" + EventFeedUtil.SafeId(actor);
|
|
EventFeedUtil.Register(
|
|
key,
|
|
"boat",
|
|
"Travel",
|
|
label,
|
|
eventId,
|
|
strength,
|
|
owns,
|
|
actor.current_position,
|
|
actor);
|
|
}
|
|
}
|