58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using Dalamud.Plugin.Services;
|
|
using Questionable.Model;
|
|
using Questionable.Model.Questing;
|
|
|
|
namespace Questionable.Controller.DebugCommands;
|
|
|
|
internal sealed class SimulateQuestCommandHandler : IDebugCommandHandler
|
|
{
|
|
private readonly QuestController _questController;
|
|
|
|
private readonly QuestRegistry _questRegistry;
|
|
|
|
private readonly IChatGui _chatGui;
|
|
|
|
public string CommandName => "sim";
|
|
|
|
public SimulateQuestCommandHandler(QuestController questController, QuestRegistry questRegistry, IChatGui chatGui)
|
|
{
|
|
_questController = questController;
|
|
_questRegistry = questRegistry;
|
|
_chatGui = chatGui;
|
|
}
|
|
|
|
public void Execute(string[] arguments)
|
|
{
|
|
if (arguments.Length >= 1 && ElementId.TryFromString(arguments[0], out ElementId elementId) && elementId != null)
|
|
{
|
|
if (_questRegistry.TryGetQuest(elementId, out Quest quest))
|
|
{
|
|
byte sequence = 0;
|
|
int step = 0;
|
|
if (arguments.Length >= 2 && byte.TryParse(arguments[1], out var result))
|
|
{
|
|
QuestSequence questSequence = quest.FindSequence(result);
|
|
if (questSequence != null)
|
|
{
|
|
sequence = questSequence.Sequence;
|
|
if (arguments.Length >= 3 && int.TryParse(arguments[2], out var result2) && questSequence.FindStep(result2) != null)
|
|
{
|
|
step = result2;
|
|
}
|
|
}
|
|
}
|
|
_questController.SimulateQuest(quest, sequence, step);
|
|
_chatGui.Print($"Simulating quest {elementId} ({quest.Info.Name}).", "Questionable", 576);
|
|
}
|
|
else
|
|
{
|
|
_chatGui.PrintError($"Unknown quest {elementId}.", "Questionable", 576);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_questController.SimulateQuest(null, 0, 0);
|
|
_chatGui.Print("Cleared simulated quest.", "Questionable", 576);
|
|
}
|
|
}
|
|
}
|