Questionable/QuestPathGenerator/RoslynElements/DialogueChoiceExtensions.cs

51 lines
2.8 KiB
C#
Raw Normal View History

2024-08-17 18:59:42 +00:00
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Questionable.Model.Questing;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
using static Questionable.QuestPathGenerator.RoslynShortcuts;
namespace Questionable.QuestPathGenerator.RoslynElements;
internal static class DialogueChoiceExtensions
{
public static ExpressionSyntax ToExpressionSyntax(this DialogueChoice dialogueChoice)
{
DialogueChoice emptyChoice = new();
return ObjectCreationExpression(
IdentifierName(nameof(DialogueChoice)))
.WithInitializer(
InitializerExpression(
SyntaxKind.ObjectInitializerExpression,
SeparatedList<ExpressionSyntax>(
SyntaxNodeList(
Assignment<EDialogChoiceType?>(nameof(DialogueChoice.Type), dialogueChoice.Type,
null)
.AsSyntaxNodeOrToken(),
Assignment(nameof(DialogueChoice.ExcelSheet), dialogueChoice.ExcelSheet,
emptyChoice.ExcelSheet)
.AsSyntaxNodeOrToken(),
Assignment(nameof(DialogueChoice.Prompt), dialogueChoice.Prompt,
emptyChoice.Prompt)
.AsSyntaxNodeOrToken(),
Assignment(nameof(DialogueChoice.Yes), dialogueChoice.Yes, emptyChoice.Yes)
.AsSyntaxNodeOrToken(),
Assignment(nameof(DialogueChoice.Answer), dialogueChoice.Answer,
emptyChoice.Answer)
.AsSyntaxNodeOrToken(),
2024-09-11 21:17:39 +00:00
Assignment(nameof(DialogueChoice.PromptIsRegularExpression),
dialogueChoice.PromptIsRegularExpression,
emptyChoice.PromptIsRegularExpression)
.AsSyntaxNodeOrToken(),
2024-08-17 18:59:42 +00:00
Assignment(nameof(DialogueChoice.AnswerIsRegularExpression),
dialogueChoice.AnswerIsRegularExpression,
emptyChoice.AnswerIsRegularExpression)
.AsSyntaxNodeOrToken(),
Assignment(nameof(DialogueChoice.DataId), dialogueChoice.DataId,
emptyChoice.DataId)
.AsSyntaxNodeOrToken(),
Assignment(nameof(DialogueChoice.SpecialCondition), dialogueChoice.SpecialCondition,
emptyChoice.SpecialCondition)
2024-08-17 18:59:42 +00:00
.AsSyntaxNodeOrToken()))));
}
}