58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Questionable.Controller.Steps.Common;
|
|
using Questionable.Functions;
|
|
using Questionable.Model;
|
|
using Questionable.Model.Questing;
|
|
|
|
namespace Questionable.Controller.Steps.Interactions;
|
|
|
|
internal static class Say
|
|
{
|
|
internal sealed class Factory(ExcelFunctions excelFunctions) : ITaskFactory
|
|
{
|
|
public IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
|
|
{
|
|
EInteractionType interactionType = step.InteractionType;
|
|
if ((uint)(interactionType - 28) <= 1u)
|
|
{
|
|
if (step.ChatMessage == null)
|
|
{
|
|
return Array.Empty<ITask>();
|
|
}
|
|
}
|
|
else if (step.InteractionType != EInteractionType.Say)
|
|
{
|
|
return Array.Empty<ITask>();
|
|
}
|
|
ArgumentNullException.ThrowIfNull(step.ChatMessage, "step.ChatMessage");
|
|
string? text = excelFunctions.GetDialogueText(quest, step.ChatMessage.ExcelSheet, step.ChatMessage.Key, isRegex: false).GetString();
|
|
ArgumentNullException.ThrowIfNull(text, "excelString");
|
|
Mount.UnmountTask unmountTask = new Mount.UnmountTask();
|
|
Task task = new Task(text);
|
|
return new global::_003C_003Ez__ReadOnlyArray<ITask>(new ITask[2] { unmountTask, task });
|
|
}
|
|
}
|
|
|
|
internal sealed record Task(string ChatMessage) : ITask
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return "Say(" + ChatMessage + ")";
|
|
}
|
|
}
|
|
|
|
internal sealed class UseChat(ChatFunctions chatFunctions) : AbstractDelayedTaskExecutor<Task>()
|
|
{
|
|
protected override bool StartInternal()
|
|
{
|
|
chatFunctions.ExecuteCommand("/say " + base.Task.ChatMessage);
|
|
return true;
|
|
}
|
|
|
|
public override bool ShouldInterruptOnDamage()
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|