2024-05-26 19:45:26 +00:00
|
|
|
|
using System;
|
2024-06-08 19:16:57 +00:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
using Dalamud.Extensions.MicrosoftLogging;
|
2024-05-25 21:51:37 +00:00
|
|
|
|
using Dalamud.Game;
|
|
|
|
|
using Dalamud.Game.ClientState.Objects;
|
|
|
|
|
using Dalamud.Interface.Windowing;
|
|
|
|
|
using Dalamud.Plugin;
|
|
|
|
|
using Dalamud.Plugin.Services;
|
2024-06-08 19:16:57 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2024-05-25 21:51:37 +00:00
|
|
|
|
using Questionable.Controller;
|
2024-07-14 01:42:30 +00:00
|
|
|
|
using Questionable.Controller.CombatModules;
|
2024-07-12 08:31:34 +00:00
|
|
|
|
using Questionable.Controller.NavigationOverrides;
|
2024-07-12 19:18:53 +00:00
|
|
|
|
using Questionable.Controller.Steps.Shared;
|
|
|
|
|
using Questionable.Controller.Steps.Common;
|
2024-08-03 09:17:20 +00:00
|
|
|
|
using Questionable.Controller.Steps.Gathering;
|
2024-07-12 19:18:53 +00:00
|
|
|
|
using Questionable.Controller.Steps.Interactions;
|
2024-05-27 19:54:34 +00:00
|
|
|
|
using Questionable.Data;
|
2024-05-25 21:51:37 +00:00
|
|
|
|
using Questionable.External;
|
2024-07-15 22:18:10 +00:00
|
|
|
|
using Questionable.Validation;
|
|
|
|
|
using Questionable.Validation.Validators;
|
2024-05-25 21:51:37 +00:00
|
|
|
|
using Questionable.Windows;
|
2024-07-21 13:30:10 +00:00
|
|
|
|
using Questionable.Windows.QuestComponents;
|
2024-07-12 19:18:53 +00:00
|
|
|
|
using Action = Questionable.Controller.Steps.Interactions.Action;
|
2024-05-25 21:51:37 +00:00
|
|
|
|
|
|
|
|
|
namespace Questionable;
|
|
|
|
|
|
2024-06-08 19:16:57 +00:00
|
|
|
|
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
2024-05-27 19:54:34 +00:00
|
|
|
|
public sealed class QuestionablePlugin : IDalamudPlugin
|
2024-05-25 21:51:37 +00:00
|
|
|
|
{
|
2024-06-08 19:16:57 +00:00
|
|
|
|
private readonly ServiceProvider? _serviceProvider;
|
|
|
|
|
|
2024-07-03 19:00:04 +00:00
|
|
|
|
public QuestionablePlugin(IDalamudPluginInterface pluginInterface,
|
2024-06-08 19:16:57 +00:00
|
|
|
|
IClientState clientState,
|
|
|
|
|
ITargetManager targetManager,
|
|
|
|
|
IFramework framework,
|
|
|
|
|
IGameGui gameGui,
|
|
|
|
|
IDataManager dataManager,
|
|
|
|
|
ISigScanner sigScanner,
|
|
|
|
|
IObjectTable objectTable,
|
|
|
|
|
IPluginLog pluginLog,
|
|
|
|
|
ICondition condition,
|
|
|
|
|
IChatGui chatGui,
|
|
|
|
|
ICommandManager commandManager,
|
2024-06-09 14:30:53 +00:00
|
|
|
|
IAddonLifecycle addonLifecycle,
|
|
|
|
|
IKeyState keyState)
|
2024-05-25 21:51:37 +00:00
|
|
|
|
{
|
2024-05-26 19:45:26 +00:00
|
|
|
|
ArgumentNullException.ThrowIfNull(pluginInterface);
|
2024-05-25 21:51:37 +00:00
|
|
|
|
|
2024-06-08 19:16:57 +00:00
|
|
|
|
ServiceCollection serviceCollection = new();
|
|
|
|
|
serviceCollection.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace)
|
|
|
|
|
.ClearProviders()
|
2024-06-09 14:30:53 +00:00
|
|
|
|
.AddDalamudLogger(pluginLog, t => t[(t.LastIndexOf('.') + 1)..]));
|
2024-06-08 19:16:57 +00:00
|
|
|
|
serviceCollection.AddSingleton<IDalamudPlugin>(this);
|
|
|
|
|
serviceCollection.AddSingleton(pluginInterface);
|
|
|
|
|
serviceCollection.AddSingleton(clientState);
|
|
|
|
|
serviceCollection.AddSingleton(targetManager);
|
|
|
|
|
serviceCollection.AddSingleton(framework);
|
|
|
|
|
serviceCollection.AddSingleton(gameGui);
|
|
|
|
|
serviceCollection.AddSingleton(dataManager);
|
|
|
|
|
serviceCollection.AddSingleton(sigScanner);
|
|
|
|
|
serviceCollection.AddSingleton(objectTable);
|
2024-06-13 15:35:33 +00:00
|
|
|
|
serviceCollection.AddSingleton(pluginLog);
|
2024-06-08 19:16:57 +00:00
|
|
|
|
serviceCollection.AddSingleton(condition);
|
|
|
|
|
serviceCollection.AddSingleton(chatGui);
|
|
|
|
|
serviceCollection.AddSingleton(commandManager);
|
|
|
|
|
serviceCollection.AddSingleton(addonLifecycle);
|
2024-06-09 14:30:53 +00:00
|
|
|
|
serviceCollection.AddSingleton(keyState);
|
2024-06-08 19:16:57 +00:00
|
|
|
|
serviceCollection.AddSingleton(new WindowSystem(nameof(Questionable)));
|
|
|
|
|
serviceCollection.AddSingleton((Configuration?)pluginInterface.GetPluginConfig() ?? new Configuration());
|
|
|
|
|
|
2024-07-17 13:05:24 +00:00
|
|
|
|
AddBasicFunctionsAndData(serviceCollection);
|
|
|
|
|
AddTaskFactories(serviceCollection);
|
|
|
|
|
AddControllers(serviceCollection);
|
|
|
|
|
AddWindows(serviceCollection);
|
|
|
|
|
AddQuestValidators(serviceCollection);
|
|
|
|
|
|
|
|
|
|
serviceCollection.AddSingleton<CommandHandler>();
|
|
|
|
|
serviceCollection.AddSingleton<DalamudInitializer>();
|
|
|
|
|
|
|
|
|
|
_serviceProvider = serviceCollection.BuildServiceProvider();
|
|
|
|
|
_serviceProvider.GetRequiredService<QuestRegistry>().Reload();
|
|
|
|
|
_serviceProvider.GetRequiredService<CommandHandler>();
|
|
|
|
|
_serviceProvider.GetRequiredService<DalamudInitializer>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddBasicFunctionsAndData(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-06-08 19:16:57 +00:00
|
|
|
|
serviceCollection.AddSingleton<GameFunctions>();
|
2024-06-20 19:55:48 +00:00
|
|
|
|
serviceCollection.AddSingleton<ChatFunctions>();
|
2024-07-08 18:46:01 +00:00
|
|
|
|
serviceCollection.AddSingleton<AetherCurrentData>();
|
2024-06-08 19:16:57 +00:00
|
|
|
|
serviceCollection.AddSingleton<AetheryteData>();
|
2024-08-03 09:17:20 +00:00
|
|
|
|
serviceCollection.AddSingleton<GatheringData>();
|
2024-07-29 14:54:18 +00:00
|
|
|
|
serviceCollection.AddSingleton<JournalData>();
|
2024-07-11 00:56:42 +00:00
|
|
|
|
serviceCollection.AddSingleton<QuestData>();
|
2024-06-08 19:16:57 +00:00
|
|
|
|
serviceCollection.AddSingleton<TerritoryData>();
|
|
|
|
|
serviceCollection.AddSingleton<NavmeshIpc>();
|
|
|
|
|
serviceCollection.AddSingleton<LifestreamIpc>();
|
2024-06-16 15:43:42 +00:00
|
|
|
|
serviceCollection.AddSingleton<YesAlreadyIpc>();
|
2024-07-17 13:05:24 +00:00
|
|
|
|
}
|
2024-06-08 19:16:57 +00:00
|
|
|
|
|
2024-07-17 13:05:24 +00:00
|
|
|
|
private static void AddTaskFactories(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-06-09 14:30:53 +00:00
|
|
|
|
// individual tasks
|
|
|
|
|
serviceCollection.AddTransient<MountTask>();
|
|
|
|
|
serviceCollection.AddTransient<UnmountTask>();
|
2024-08-03 09:17:20 +00:00
|
|
|
|
serviceCollection.AddTransient<MoveToLandingLocation>();
|
2024-08-03 15:26:49 +00:00
|
|
|
|
serviceCollection.AddTransient<DoGather>();
|
|
|
|
|
serviceCollection.AddTransient<DoGatherCollectable>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
|
2024-07-17 13:05:24 +00:00
|
|
|
|
// task factories
|
2024-06-09 14:30:53 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<StepDisabled.Factory, StepDisabled.Task>();
|
2024-08-03 09:17:20 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<GatheringRequiredItems.Factory, GatheringRequiredItems.StartGathering>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<AetheryteShortcut.Factory, AetheryteShortcut.UseAetheryteShortcut>();
|
2024-07-27 15:37:08 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<SkipCondition.Factory, SkipCondition.CheckSkip>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<AethernetShortcut.Factory, AethernetShortcut.UseAethernetShortcut>();
|
2024-06-18 15:51:23 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<WaitAtStart.Factory, WaitAtStart.WaitDelay>();
|
2024-07-12 21:58:48 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<Move.Factory, Move.MoveInternal, Move.ExpectToBeNearDataId, Move.Land>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
serviceCollection.AddTransient<Move.MoveBuilder>();
|
|
|
|
|
|
2024-07-11 11:11:50 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<NextQuest.Factory, NextQuest.SetQuest>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<AetherCurrent.Factory, AetherCurrent.DoAttune>();
|
|
|
|
|
serviceCollection.AddTaskWithFactory<AethernetShard.Factory, AethernetShard.DoAttune>();
|
|
|
|
|
serviceCollection.AddTaskWithFactory<Aetheryte.Factory, Aetheryte.DoAttune>();
|
2024-07-14 01:42:30 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<Combat.Factory, Combat.HandleCombat>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<Duty.Factory, Duty.OpenDutyFinder>();
|
|
|
|
|
serviceCollection.AddTaskWithFactory<Emote.Factory, Emote.UseOnObject, Emote.Use>();
|
2024-07-10 19:01:41 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<Action.Factory, Action.UseOnObject>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<Interact.Factory, Interact.DoInteract>();
|
2024-07-24 18:47:08 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<Jump.Factory, Jump.SingleJump, Jump.RepeatedJumps>();
|
|
|
|
|
serviceCollection.AddTaskWithFactory<Dive.Factory, Dive.DoDive>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<Say.Factory, Say.UseChat>();
|
2024-07-19 19:16:40 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<UseItem.Factory, UseItem.UseOnGround, UseItem.UseOnObject, UseItem.Use, UseItem.UseOnPosition>();
|
2024-06-13 15:35:33 +00:00
|
|
|
|
serviceCollection.AddTaskWithFactory<EquipItem.Factory, EquipItem.DoEquip>();
|
2024-06-20 19:55:48 +00:00
|
|
|
|
serviceCollection
|
|
|
|
|
.AddTaskWithFactory<SinglePlayerDuty.Factory, SinglePlayerDuty.DisableYesAlready,
|
|
|
|
|
SinglePlayerDuty.RestoreYesAlready>();
|
2024-06-09 14:30:53 +00:00
|
|
|
|
|
|
|
|
|
serviceCollection
|
|
|
|
|
.AddTaskWithFactory<WaitAtEnd.Factory,
|
|
|
|
|
WaitAtEnd.WaitDelay,
|
|
|
|
|
WaitAtEnd.WaitNextStepOrSequence,
|
|
|
|
|
WaitAtEnd.WaitForCompletionFlags,
|
|
|
|
|
WaitAtEnd.WaitObjectAtPosition>();
|
2024-06-24 16:15:45 +00:00
|
|
|
|
serviceCollection.AddTransient<WaitAtEnd.WaitQuestAccepted>();
|
|
|
|
|
serviceCollection.AddTransient<WaitAtEnd.WaitQuestCompleted>();
|
2024-07-17 13:05:24 +00:00
|
|
|
|
}
|
2024-06-09 14:30:53 +00:00
|
|
|
|
|
2024-07-17 13:05:24 +00:00
|
|
|
|
private static void AddControllers(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-06-08 19:16:57 +00:00
|
|
|
|
serviceCollection.AddSingleton<MovementController>();
|
2024-07-12 08:31:34 +00:00
|
|
|
|
serviceCollection.AddSingleton<MovementOverrideController>();
|
2024-06-08 19:16:57 +00:00
|
|
|
|
serviceCollection.AddSingleton<QuestRegistry>();
|
|
|
|
|
serviceCollection.AddSingleton<QuestController>();
|
|
|
|
|
serviceCollection.AddSingleton<GameUiController>();
|
|
|
|
|
serviceCollection.AddSingleton<NavigationShortcutController>();
|
2024-07-14 01:42:30 +00:00
|
|
|
|
serviceCollection.AddSingleton<CombatController>();
|
2024-08-03 09:17:20 +00:00
|
|
|
|
serviceCollection.AddSingleton<GatheringController>();
|
2024-07-14 01:42:30 +00:00
|
|
|
|
|
|
|
|
|
serviceCollection.AddSingleton<ICombatModule, RotationSolverRebornModule>();
|
2024-07-17 13:05:24 +00:00
|
|
|
|
}
|
2024-06-08 19:16:57 +00:00
|
|
|
|
|
2024-07-17 13:05:24 +00:00
|
|
|
|
private static void AddWindows(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-07-21 13:30:10 +00:00
|
|
|
|
serviceCollection.AddSingleton<UiUtils>();
|
|
|
|
|
|
|
|
|
|
serviceCollection.AddSingleton<ActiveQuestComponent>();
|
|
|
|
|
serviceCollection.AddSingleton<ARealmRebornComponent>();
|
|
|
|
|
serviceCollection.AddSingleton<CreationUtilsComponent>();
|
2024-07-29 14:54:18 +00:00
|
|
|
|
serviceCollection.AddSingleton<QuestTooltipComponent>();
|
2024-07-21 13:30:10 +00:00
|
|
|
|
serviceCollection.AddSingleton<QuickAccessButtonsComponent>();
|
|
|
|
|
serviceCollection.AddSingleton<RemainingTasksComponent>();
|
|
|
|
|
|
2024-06-18 15:51:23 +00:00
|
|
|
|
serviceCollection.AddSingleton<QuestWindow>();
|
2024-06-12 16:03:48 +00:00
|
|
|
|
serviceCollection.AddSingleton<ConfigWindow>();
|
2024-06-18 15:51:23 +00:00
|
|
|
|
serviceCollection.AddSingleton<DebugOverlay>();
|
2024-07-14 19:31:07 +00:00
|
|
|
|
serviceCollection.AddSingleton<QuestSelectionWindow>();
|
2024-07-15 22:18:10 +00:00
|
|
|
|
serviceCollection.AddSingleton<QuestValidationWindow>();
|
2024-07-29 14:54:18 +00:00
|
|
|
|
serviceCollection.AddSingleton<JournalProgressWindow>();
|
2024-07-17 13:05:24 +00:00
|
|
|
|
}
|
2024-07-15 22:18:10 +00:00
|
|
|
|
|
2024-07-17 13:05:24 +00:00
|
|
|
|
private static void AddQuestValidators(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-07-15 22:18:10 +00:00
|
|
|
|
serviceCollection.AddSingleton<QuestValidator>();
|
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, QuestDisabledValidator>();
|
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, BasicSequenceValidator>();
|
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, UniqueStartStopValidator>();
|
2024-07-16 12:43:31 +00:00
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, NextQuestValidator>();
|
2024-07-15 22:18:10 +00:00
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, CompletionFlagsValidator>();
|
2024-07-27 22:13:52 +00:00
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, AethernetShortcutValidator>();
|
2024-07-17 13:05:24 +00:00
|
|
|
|
serviceCollection.AddSingleton<JsonSchemaValidator>();
|
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator>(sp => sp.GetRequiredService<JsonSchemaValidator>());
|
2024-05-25 21:51:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2024-06-08 19:16:57 +00:00
|
|
|
|
_serviceProvider?.Dispose();
|
2024-05-25 21:51:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|