41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using System.Reflection;
|
|
using BD2.GameNames;
|
|
using BepInEx.Logging;
|
|
using HarmonyLib;
|
|
using Proto.Net;
|
|
using gamfs;
|
|
using static BD2.GameNames.Game;
|
|
|
|
namespace Bd2BetterExperience.Navigation;
|
|
|
|
// Cancel the leftover arrival callback after a commission is turned in manually;
|
|
// the game's ClearQuestNav(false) would otherwise replay its dialogue.
|
|
internal sealed class CommissionNavigation : IModule
|
|
{
|
|
private static ManualLogSource Log;
|
|
|
|
public string Id => "CommissionNavigation";
|
|
public string Description => "Stop completed manual-talk commissions from replaying navigation dialogue.";
|
|
|
|
public void Install(Harmony harmony)
|
|
{
|
|
Log = Plugin.Log;
|
|
MethodInfo target = typeof(QuestPacket).GetGameMethod("RefreshQuestNavOnQuestClear", BindingFlags.Static | BindingFlags.NonPublic);
|
|
harmony.Patch(target, prefix: new HarmonyMethod(typeof(CommissionNavigation), nameof(CancelCompletedTalkDestination)));
|
|
}
|
|
|
|
private static void CancelCompletedTalkDestination(QuestDTO __0)
|
|
{
|
|
if (__0 == null || __0.Type != (int)EQuestType.Today || __0.ConditionType != (int)Define_QuestConditionType.TalkManual)
|
|
{
|
|
return;
|
|
}
|
|
QuestNavigationManager navigation = Singleton<QuestNavigationManager>.Instance;
|
|
if (navigation.IsNavigate && navigation.NavigateQuestId == __0.Id)
|
|
{
|
|
navigation.ClearQuestNav(true);
|
|
Log.LogInfo("Cancelled completed commission talk destination: quest=" + __0.Id);
|
|
}
|
|
}
|
|
}
|