forked from aly/qstbak
281 lines
12 KiB
C#
281 lines
12 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using Dalamud.Game.ClientState.Conditions;
|
|
using Dalamud.Plugin;
|
|
using Dalamud.Plugin.Ipc;
|
|
using Dalamud.Plugin.Ipc.Exceptions;
|
|
using Dalamud.Plugin.Services;
|
|
using Microsoft.Extensions.Logging;
|
|
using Questionable.Controller;
|
|
|
|
namespace Questionable.External;
|
|
|
|
internal sealed class TextAdvanceIpc : IDisposable
|
|
{
|
|
public sealed class ExternalTerritoryConfig
|
|
{
|
|
public bool? EnableQuestAccept;
|
|
|
|
public bool? EnableQuestComplete;
|
|
|
|
public bool? EnableRewardPick;
|
|
|
|
public bool? EnableRequestHandin;
|
|
|
|
public bool? EnableCutsceneEsc;
|
|
|
|
public bool? EnableCutsceneSkipConfirm;
|
|
|
|
public bool? EnableTalkSkip;
|
|
|
|
public bool? EnableRequestFill;
|
|
|
|
public bool? EnableAutoInteract;
|
|
}
|
|
|
|
private bool _isExternalControlActivated;
|
|
|
|
private long _ipcRetryAfter;
|
|
|
|
private bool _lastCinemaModeState;
|
|
|
|
private bool _lastInCutsceneState;
|
|
|
|
private bool _lastSuppressRequestState;
|
|
|
|
private readonly QuestController _questController;
|
|
|
|
private readonly FateController _fateController;
|
|
|
|
private readonly SeasonalDutyController _seasonalDutyController;
|
|
|
|
private readonly AttunementController _attunementController;
|
|
|
|
private readonly CustomDeliveryController _customDeliveryController;
|
|
|
|
private readonly Configuration _configuration;
|
|
|
|
private readonly ICondition _condition;
|
|
|
|
private readonly IFramework _framework;
|
|
|
|
private readonly ICallGateSubscriber<bool> _isInExternalControl;
|
|
|
|
private readonly ICallGateSubscriber<string, ExternalTerritoryConfig, bool> _enableExternalControl;
|
|
|
|
private readonly ICallGateSubscriber<string, bool> _disableExternalControl;
|
|
|
|
private readonly string _pluginName;
|
|
|
|
private readonly ILogger<TextAdvanceIpc> _logger;
|
|
|
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
|
public TextAdvanceIpc(IDalamudPluginInterface pluginInterface, IFramework framework, QuestController questController, FateController fateController, SeasonalDutyController seasonalDutyController, AttunementController attunementController, CustomDeliveryController customDeliveryController, Configuration configuration, ICondition condition, ILogger<TextAdvanceIpc> logger)
|
|
{
|
|
_framework = framework;
|
|
_questController = questController;
|
|
_fateController = fateController;
|
|
_seasonalDutyController = seasonalDutyController;
|
|
_attunementController = attunementController;
|
|
_customDeliveryController = customDeliveryController;
|
|
_configuration = configuration;
|
|
_condition = condition;
|
|
_logger = logger;
|
|
_isInExternalControl = pluginInterface.GetIpcSubscriber<bool>(global::_003CModule_003E._202A_206B_206D_200C_206B_200E_200E_202A_200B_202E_206A_206F_206A_206B_200E_200D_200F_206D_206E_206A_206F_200C_206C_202C_202A_206E_202C_200B_206E_202A_206E_202B_206B_202E_202E_206A_206D_206D_202C_200F_202E<string>(-67666831));
|
|
_enableExternalControl = pluginInterface.GetIpcSubscriber<string, ExternalTerritoryConfig, bool>(global::_003CModule_003E._202E_206C_200F_206B_206A_202A_202C_206F_200C_206C_202B_206B_206D_206D_206D_202D_206E_202E_206C_206E_206D_202C_206F_200D_202D_202E_206A_206D_202A_206A_202B_200D_200C_206D_202B_200B_200D_200C_206E_206B_202E<string>(-228954423));
|
|
_disableExternalControl = pluginInterface.GetIpcSubscriber<string, bool>(global::_003CModule_003E._202A_206B_206D_200C_206B_200E_200E_202A_200B_202E_206A_206F_206A_206B_200E_200D_200F_206D_206E_206A_206F_200C_206C_202C_202A_206E_202C_200B_206E_202A_206E_202B_206B_202E_202E_206A_206D_206D_202C_200F_202E<string>(-324739652));
|
|
_pluginName = _202E_200E_200D_200F_206B_200E_200B_206E_200D_206F_202B_200C_200D_200D_206C_206F_202D_200B_202B_206A_202A_206A_202B_206A_200D_202A_206E_200E_206D_200F_206B_206A_206D_206F_200D_206A_202C_200C_202A_206D_202E(pluginInterface);
|
|
_202C_206B_206B_206D_200B_200F_206D_202D_206E_206F_202E_202C_200E_206D_206C_200C_202C_200D_206E_200D_202D_202C_200C_202C_206A_200D_206C_200D_206E_202D_202A_200E_206B_202A_206B_200E_206C_206F_206F_202D_202E(_framework, (IFramework.OnUpdateDelegate)OnUpdate);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
|
public void Dispose()
|
|
{
|
|
_200B_200C_202D_206D_202B_206C_200B_206C_200C_200D_202C_202D_200D_202E_206C_206C_200F_200B_202B_202A_206C_206E_200D_206E_206A_202E_206D_202E_202B_200F_200F_202C_202B_200D_206B_202A_206D_202D_202C_206E_202E(_framework, (IFramework.OnUpdateDelegate)OnUpdate);
|
|
if (_isExternalControlActivated)
|
|
{
|
|
try
|
|
{
|
|
_disableExternalControl.InvokeFunc(_pluginName);
|
|
}
|
|
catch (IpcError ipcError)
|
|
{
|
|
_202A_200F_202C_202B_206C_202C_200D_206A_206D_202C_200D_202E_202E_206B_202D_202B_206B_202B_206A_206A_202E_200E_200E_202B_202B_206A_206A_202E_202D_206C_206A_200E_200B_202B_206C_200F_206F_202E_200B_202E_202E((ILogger)_logger, (Exception)ipcError, global::_003CModule_003E._206C_202A_206D_206A_206E_202A_202B_206F_206D_200F_202D_200F_202D_206A_202C_202B_206D_206A_200E_200E_202D_202D_200D_200C_200D_200D_206D_206E_202A_200F_206E_206C_206D_206A_206D_202B_200F_200D_206E_200C_202E<string>(1974302231), Array.Empty<object>());
|
|
}
|
|
}
|
|
}
|
|
|
|
void IDisposable.Dispose()
|
|
{
|
|
//ILSpy generated this explicit interface implementation from .override directive in Dispose
|
|
this.Dispose();
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
|
private void OnUpdate(IFramework framework)
|
|
{
|
|
int num = ((_202B_202E_206D_202D_206E_200C_200B_200B_200C_206A_200B_200E_202A_200F_202B_200B_206E_206B_202E_206D_200E_200B_206E_206C_206F_202E_200F_206C_206F_200B_206F_206D_200F_200E_200C_200C_206A_206E_206A_202A_202E() >= _ipcRetryAfter) ? 1976969313 : 1976969312);
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = 1976969313;
|
|
int num4 = num2;
|
|
int num5 = num4 + num3;
|
|
int num6 = num4 & num3;
|
|
switch (num5 - (num6 + num6))
|
|
{
|
|
case 2:
|
|
goto IL_004d;
|
|
case 1:
|
|
return;
|
|
case 0:
|
|
try
|
|
{
|
|
OnUpdateInner();
|
|
return;
|
|
}
|
|
catch (IpcError ipcError)
|
|
{
|
|
_202A_200F_202C_202B_206C_202C_200D_206A_206D_202C_200D_202E_202E_206B_202D_202B_206B_202B_206A_206A_202E_200E_200E_202B_202B_206A_206A_202E_202D_206C_206A_200E_200B_202B_206C_200F_206F_202E_200B_202E_202E((ILogger)_logger, (Exception)ipcError, global::_003CModule_003E._202E_206C_200F_206B_206A_202A_202C_206F_200C_206C_202B_206B_206D_206D_206D_202D_206E_202E_206C_206E_206D_202C_206F_200D_202D_202E_206A_206D_202A_206A_202B_200D_200C_206D_202B_200B_200D_200C_206E_206B_202E<string>(1033634384), Array.Empty<object>());
|
|
_ipcRetryAfter = _202B_202E_206D_202D_206E_200C_200B_200B_200C_206A_200B_200E_202A_200F_202B_200B_206E_206B_202E_206D_200E_200B_206E_206C_206F_202E_200F_206C_206F_200B_206F_206D_200F_200E_200C_200C_206A_206E_206A_202A_202E() + 30000;
|
|
return;
|
|
}
|
|
}
|
|
continue;
|
|
IL_004d:
|
|
num = 1976969312;
|
|
}
|
|
}
|
|
|
|
private void OnUpdateInner()
|
|
{
|
|
//Discarded unreachable code: IL_0182
|
|
int num = (_questController.IsRunning ? (-758359221) : (-758359219));
|
|
bool flag = default(bool);
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = -758359224;
|
|
int num4 = num2;
|
|
int num5 = num4 + num3;
|
|
int num6 = num4 & num3;
|
|
int num7;
|
|
switch (num5 - (num6 + num6))
|
|
{
|
|
case 2:
|
|
if (!_isExternalControlActivated)
|
|
{
|
|
return;
|
|
}
|
|
goto case 5;
|
|
case 5:
|
|
num = ((_questController.AutomationType != QuestController.EAutomationType.Manual) ? (-758359221) : (-758359220));
|
|
break;
|
|
case 8:
|
|
num7 = (_customDeliveryController.IsRunning ? 1 : 0);
|
|
goto IL_011a;
|
|
case 1:
|
|
num = (_seasonalDutyController.IsRunning ? (-758359221) : (-758359218));
|
|
break;
|
|
case 0:
|
|
num = -758359219;
|
|
break;
|
|
case 4:
|
|
num = (_fateController.IsRunning ? (-758359221) : (-758359223));
|
|
break;
|
|
case 3:
|
|
num7 = 1;
|
|
goto IL_011a;
|
|
case 6:
|
|
num = (_attunementController.IsRunning ? (-758359221) : (-758359232));
|
|
break;
|
|
case 7:
|
|
{
|
|
if (!flag)
|
|
{
|
|
num = -758359222;
|
|
break;
|
|
}
|
|
bool cinemaMode = _configuration.General.CinemaMode;
|
|
bool flag2 = _206A_202B_202E_200F_202E_206B_200E_200B_206B_206D_206B_200F_206A_206A_206F_202C_202C_206E_206E_206B_206A_200F_200F_202D_200F_206F_206D_202C_202C_200B_202E_202B_206B_200E_206F_202E_200E_200B_200C_202C_202E(_condition, ConditionFlag.OccupiedInCutSceneEvent) || _206A_202B_202E_200F_202E_206B_200E_200B_206B_206D_206B_200F_206A_206A_206F_202C_202C_206E_206E_206B_206A_200F_200F_202D_200F_206F_206D_202C_202C_200B_202E_202B_206B_200E_206F_202E_200E_200B_200C_202C_202E(_condition, ConditionFlag.WatchingCutscene) || _206A_202B_202E_200F_202E_206B_200E_200B_206B_206D_206B_200F_206A_206A_206F_202C_202C_206E_206E_206B_206A_200F_200F_202D_200F_206F_206D_202C_202C_200B_202E_202B_206B_200E_206F_202E_200E_200B_200C_202C_202E(_condition, ConditionFlag.WatchingCutscene78);
|
|
bool flag3 = _customDeliveryController.IsRunning && !_questController.IsRunning && _questController.AutomationType == QuestController.EAutomationType.Manual && !_fateController.IsRunning && !_seasonalDutyController.IsRunning && !_attunementController.IsRunning;
|
|
bool flag4 = cinemaMode != _lastCinemaModeState || (cinemaMode && flag2 != _lastInCutsceneState) || flag3 != _lastSuppressRequestState;
|
|
if (!_isExternalControlActivated)
|
|
{
|
|
if (!_isInExternalControl.InvokeFunc())
|
|
{
|
|
ExternalTerritoryConfig arg = CreateExternalTerritoryConfig(cinemaMode, flag2, flag3);
|
|
if (_enableExternalControl.InvokeFunc(_pluginName, arg))
|
|
{
|
|
_isExternalControlActivated = true;
|
|
_lastCinemaModeState = cinemaMode;
|
|
_lastInCutsceneState = flag2;
|
|
_lastSuppressRequestState = flag3;
|
|
}
|
|
}
|
|
}
|
|
else if (flag4)
|
|
{
|
|
ExternalTerritoryConfig arg2 = CreateExternalTerritoryConfig(cinemaMode, flag2, flag3);
|
|
_enableExternalControl.InvokeFunc(_pluginName, arg2);
|
|
_lastCinemaModeState = cinemaMode;
|
|
_lastInCutsceneState = flag2;
|
|
_lastSuppressRequestState = flag3;
|
|
}
|
|
return;
|
|
}
|
|
IL_011a:
|
|
flag = (byte)num7 != 0;
|
|
num = ((!_configuration.General.ConfigureTextAdvance) ? (-758359222) : (-758359217));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static ExternalTerritoryConfig CreateExternalTerritoryConfig(bool cinemaMode, bool inCutscene, bool suppressRequestHandling)
|
|
{
|
|
bool flag = (byte)((uint)((cinemaMode ? 1 : 0) + (inCutscene ? 1 : 0)) - ((cinemaMode || inCutscene) ? 1u : 0u)) != 0;
|
|
return new ExternalTerritoryConfig
|
|
{
|
|
EnableQuestAccept = true,
|
|
EnableQuestComplete = true,
|
|
EnableRewardPick = true,
|
|
EnableRequestHandin = !suppressRequestHandling,
|
|
EnableCutsceneEsc = !cinemaMode,
|
|
EnableCutsceneSkipConfirm = !cinemaMode,
|
|
EnableTalkSkip = !flag,
|
|
EnableRequestFill = !suppressRequestHandling,
|
|
EnableAutoInteract = false
|
|
};
|
|
}
|
|
|
|
static string _202E_200E_200D_200F_206B_200E_200B_206E_200D_206F_202B_200C_200D_200D_206C_206F_202D_200B_202B_206A_202A_206A_202B_206A_200D_202A_206E_200E_206D_200F_206B_206A_206D_206F_200D_206A_202C_200C_202A_206D_202E(IDalamudPluginInterface P_0)
|
|
{
|
|
return P_0.InternalName;
|
|
}
|
|
|
|
static void _202C_206B_206B_206D_200B_200F_206D_202D_206E_206F_202E_202C_200E_206D_206C_200C_202C_200D_206E_200D_202D_202C_200C_202C_206A_200D_206C_200D_206E_202D_202A_200E_206B_202A_206B_200E_206C_206F_206F_202D_202E(IFramework P_0, IFramework.OnUpdateDelegate P_1)
|
|
{
|
|
P_0.Update += P_1;
|
|
}
|
|
|
|
static void _200B_200C_202D_206D_202B_206C_200B_206C_200C_200D_202C_202D_200D_202E_206C_206C_200F_200B_202B_202A_206C_206E_200D_206E_206A_202E_206D_202E_202B_200F_200F_202C_202B_200D_206B_202A_206D_202D_202C_206E_202E(IFramework P_0, IFramework.OnUpdateDelegate P_1)
|
|
{
|
|
P_0.Update -= P_1;
|
|
}
|
|
|
|
static void _202A_200F_202C_202B_206C_202C_200D_206A_206D_202C_200D_202E_202E_206B_202D_202B_206B_202B_206A_206A_202E_200E_200E_202B_202B_206A_206A_202E_202D_206C_206A_200E_200B_202B_206C_200F_206F_202E_200B_202E_202E(ILogger P_0, Exception P_1, string P_2, object[] P_3)
|
|
{
|
|
P_0.LogDebug(P_1, P_2, P_3);
|
|
}
|
|
|
|
static long _202B_202E_206D_202D_206E_200C_200B_200B_200C_206A_200B_200E_202A_200F_202B_200B_206E_206B_202E_206D_200E_200B_206E_206C_206F_202E_200F_206C_206F_200B_206F_206D_200F_200E_200C_200C_206A_206E_206A_202A_202E()
|
|
{
|
|
return Environment.TickCount64;
|
|
}
|
|
|
|
static bool _206A_202B_202E_200F_202E_206B_200E_200B_206B_206D_206B_200F_206A_206A_206F_202C_202C_206E_206E_206B_206A_200F_200F_202D_200F_206F_206D_202C_202C_200B_202E_202B_206B_200E_206F_202E_200E_200B_200C_202C_202E(ICondition P_0, ConditionFlag P_1)
|
|
{
|
|
return P_0[P_1];
|
|
}
|
|
}
|