83 lines
2.2 KiB
C#
83 lines
2.2 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 Emote
|
|
{
|
|
internal sealed class Factory : ITaskFactory
|
|
{
|
|
public IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
|
|
{
|
|
EInteractionType interactionType = step.InteractionType;
|
|
if ((interactionType == EInteractionType.SinglePlayerDuty || (uint)(interactionType - 28) <= 1u) ? true : false)
|
|
{
|
|
if (!step.Emote.HasValue)
|
|
{
|
|
return Array.Empty<ITask>();
|
|
}
|
|
}
|
|
else if (step.InteractionType != EInteractionType.Emote)
|
|
{
|
|
return Array.Empty<ITask>();
|
|
}
|
|
ArgumentNullException.ThrowIfNull(step.Emote, "step.Emote");
|
|
Mount.UnmountTask unmountTask = new Mount.UnmountTask();
|
|
if (step.DataId.HasValue)
|
|
{
|
|
UseOnObject useOnObject = new UseOnObject(step.Emote.Value, step.DataId.Value);
|
|
return new global::_003C_003Ez__ReadOnlyArray<ITask>(new ITask[2] { unmountTask, useOnObject });
|
|
}
|
|
UseOnSelf useOnSelf = new UseOnSelf(step.Emote.Value);
|
|
return new global::_003C_003Ez__ReadOnlyArray<ITask>(new ITask[2] { unmountTask, useOnSelf });
|
|
}
|
|
}
|
|
|
|
internal sealed record UseOnObject(EEmote Emote, uint DataId) : ITask
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return $"Emote({Emote} on {DataId})";
|
|
}
|
|
}
|
|
|
|
internal sealed class UseOnObjectExecutor(ChatFunctions chatFunctions) : AbstractDelayedTaskExecutor<UseOnObject>()
|
|
{
|
|
protected override bool StartInternal()
|
|
{
|
|
chatFunctions.UseEmote(base.Task.DataId, base.Task.Emote);
|
|
return true;
|
|
}
|
|
|
|
public override bool ShouldInterruptOnDamage()
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
internal sealed record UseOnSelf(EEmote Emote) : ITask
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return $"Emote({Emote})";
|
|
}
|
|
}
|
|
|
|
internal sealed class UseOnSelfExecutor(ChatFunctions chatFunctions) : AbstractDelayedTaskExecutor<UseOnSelf>()
|
|
{
|
|
protected override bool StartInternal()
|
|
{
|
|
chatFunctions.UseEmote(base.Task.Emote);
|
|
return true;
|
|
}
|
|
|
|
public override bool ShouldInterruptOnDamage()
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|