forked from liza/Questionable
Rework source gen
This commit is contained in:
parent
59d83cb338
commit
f76e074cd8
@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using Questionable.Model.Common;
|
||||||
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||||
|
using static Questionable.QuestPathGenerator.RoslynShortcuts;
|
||||||
|
|
||||||
|
namespace Questionable.QuestPathGenerator.RoslynElements;
|
||||||
|
|
||||||
|
internal static class AethernetShortcutExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this AethernetShortcut aethernetShortcut)
|
||||||
|
{
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(AethernetShortcut)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment<EAetheryteLocation?>(nameof(AethernetShortcut.From),
|
||||||
|
aethernetShortcut.From,
|
||||||
|
null)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment<EAetheryteLocation?>(nameof(AethernetShortcut.To),
|
||||||
|
aethernetShortcut.To,
|
||||||
|
null)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
28
QuestPathGenerator/RoslynElements/ChatMessageExtensions.cs
Normal file
28
QuestPathGenerator/RoslynElements/ChatMessageExtensions.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
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 ChatMessageExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this ChatMessage chatMessage)
|
||||||
|
{
|
||||||
|
ChatMessage emptyMessage = new();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(ChatMessage)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(ChatMessage.ExcelSheet), chatMessage.ExcelSheet,
|
||||||
|
emptyMessage.ExcelSheet)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(ChatMessage.Key), chatMessage.Key,
|
||||||
|
emptyMessage.Key)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
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 ComplexCombatDataExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this ComplexCombatData complexCombatData)
|
||||||
|
{
|
||||||
|
var emptyData = new ComplexCombatData();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(ComplexCombatData)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(ComplexCombatData.DataId), complexCombatData.DataId,
|
||||||
|
emptyData.DataId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(ComplexCombatData.MinimumKillCount),
|
||||||
|
complexCombatData.MinimumKillCount, emptyData.MinimumKillCount)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(ComplexCombatData.RewardItemId),
|
||||||
|
complexCombatData.RewardItemId,
|
||||||
|
emptyData.RewardItemId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(ComplexCombatData.RewardItemCount),
|
||||||
|
complexCombatData.RewardItemCount,
|
||||||
|
emptyData.RewardItemCount)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(ComplexCombatData.CompletionQuestVariablesFlags),
|
||||||
|
complexCombatData.CompletionQuestVariablesFlags),
|
||||||
|
Assignment(nameof(ComplexCombatData.IgnoreQuestMarker),
|
||||||
|
complexCombatData.IgnoreQuestMarker,
|
||||||
|
emptyData.IgnoreQuestMarker)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
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(),
|
||||||
|
Assignment(nameof(DialogueChoice.AnswerIsRegularExpression),
|
||||||
|
dialogueChoice.AnswerIsRegularExpression,
|
||||||
|
emptyChoice.AnswerIsRegularExpression)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(DialogueChoice.DataId), dialogueChoice.DataId,
|
||||||
|
emptyChoice.DataId)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
30
QuestPathGenerator/RoslynElements/ExcelRefExtensions.cs
Normal file
30
QuestPathGenerator/RoslynElements/ExcelRefExtensions.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
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 ExcelRefExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this ExcelRef excelRef)
|
||||||
|
{
|
||||||
|
if (excelRef.Type == ExcelRef.EType.Key)
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(ExcelRef)))
|
||||||
|
.WithArgumentList(
|
||||||
|
ArgumentList(
|
||||||
|
SingletonSeparatedList(
|
||||||
|
Argument(LiteralValue(excelRef.AsKey())))));
|
||||||
|
else if (excelRef.Type == ExcelRef.EType.RowId)
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(ExcelRef)))
|
||||||
|
.WithArgumentList(
|
||||||
|
ArgumentList(
|
||||||
|
SingletonSeparatedList(
|
||||||
|
Argument(LiteralValue(excelRef.AsRowId())))));
|
||||||
|
else
|
||||||
|
throw new Exception($"Unsupported ExcelRef type {excelRef.Type}");
|
||||||
|
}
|
||||||
|
}
|
38
QuestPathGenerator/RoslynElements/GatheredItemExtensions.cs
Normal file
38
QuestPathGenerator/RoslynElements/GatheredItemExtensions.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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 GatheredItemExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this GatheredItem gatheredItem)
|
||||||
|
{
|
||||||
|
var emptyItem = new GatheredItem();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(GatheredItem)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(GatheredItem.ItemId), gatheredItem.ItemId, emptyItem.ItemId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(GatheredItem.AlternativeItemId),
|
||||||
|
gatheredItem.AlternativeItemId,
|
||||||
|
emptyItem.AlternativeItemId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(GatheredItem.ItemCount), gatheredItem.ItemCount,
|
||||||
|
emptyItem.ItemCount)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(GatheredItem.Collectability), gatheredItem.Collectability,
|
||||||
|
emptyItem.Collectability)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(GatheredItem.QuestAcceptedAsClass),
|
||||||
|
gatheredItem.QuestAcceptedAsClass,
|
||||||
|
emptyItem.QuestAcceptedAsClass)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using Questionable.Model.Gathering;
|
||||||
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||||
|
using static Questionable.QuestPathGenerator.RoslynShortcuts;
|
||||||
|
|
||||||
|
namespace Questionable.QuestPathGenerator.RoslynElements;
|
||||||
|
|
||||||
|
internal static class GatheringLocationExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this GatheringLocation location)
|
||||||
|
{
|
||||||
|
var emptyLocation = new GatheringLocation();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(GatheringLocation)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(GatheringLocation.Position), location.Position,
|
||||||
|
emptyLocation.Position).AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(GatheringLocation.MinimumAngle), location.MinimumAngle,
|
||||||
|
emptyLocation.MinimumAngle).AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(GatheringLocation.MaximumAngle), location.MaximumAngle,
|
||||||
|
emptyLocation.MaximumAngle).AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(GatheringLocation.MinimumDistance),
|
||||||
|
location.MinimumDistance, emptyLocation.MinimumDistance)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(GatheringLocation.MaximumDistance),
|
||||||
|
location.MaximumDistance, emptyLocation.MaximumDistance)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
29
QuestPathGenerator/RoslynElements/GatheringNodeExtensions.cs
Normal file
29
QuestPathGenerator/RoslynElements/GatheringNodeExtensions.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using Questionable.Model.Gathering;
|
||||||
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||||
|
using static Questionable.QuestPathGenerator.RoslynShortcuts;
|
||||||
|
|
||||||
|
namespace Questionable.QuestPathGenerator.RoslynElements;
|
||||||
|
|
||||||
|
internal static class GatheringNodeExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this GatheringNode gatheringNode)
|
||||||
|
{
|
||||||
|
var emptyLocation = new GatheringNode();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(GatheringNode)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(GatheringNode.DataId), gatheringNode.DataId,
|
||||||
|
emptyLocation.DataId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(GatheringNode.Fly), gatheringNode.Fly, emptyLocation.Fly)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(GatheringNode.Locations), gatheringNode.Locations)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using Questionable.Model.Gathering;
|
||||||
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||||
|
using static Questionable.QuestPathGenerator.RoslynShortcuts;
|
||||||
|
|
||||||
|
namespace Questionable.QuestPathGenerator.RoslynElements;
|
||||||
|
|
||||||
|
internal static class GatheringNodeGroupExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this GatheringNodeGroup nodeGroup)
|
||||||
|
{
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(GatheringNodeGroup)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
AssignmentList(nameof(GatheringNodeGroup.Nodes), nodeGroup.Nodes)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
using System.Numerics;
|
||||||
|
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 JumpDestinationExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this JumpDestination jumpDestination)
|
||||||
|
{
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(JumpDestination)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment<Vector3?>(nameof(JumpDestination.Position), jumpDestination.Position,
|
||||||
|
null)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(JumpDestination.StopDistance), jumpDestination.StopDistance,
|
||||||
|
null)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(JumpDestination.DelaySeconds), jumpDestination.DelaySeconds,
|
||||||
|
null)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(JumpDestination.Type), jumpDestination.Type, default)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
19
QuestPathGenerator/RoslynElements/LeveIdExtensions.cs
Normal file
19
QuestPathGenerator/RoslynElements/LeveIdExtensions.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
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 LeveIdExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this LeveId leveId)
|
||||||
|
{
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(LeveId)))
|
||||||
|
.WithArgumentList(
|
||||||
|
ArgumentList(
|
||||||
|
SingletonSeparatedList(
|
||||||
|
Argument(LiteralValue(leveId.Value)))));
|
||||||
|
}
|
||||||
|
}
|
19
QuestPathGenerator/RoslynElements/QuestIdExtensions.cs
Normal file
19
QuestPathGenerator/RoslynElements/QuestIdExtensions.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
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 QuestIdExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this QuestId questId)
|
||||||
|
{
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(QuestId)))
|
||||||
|
.WithArgumentList(
|
||||||
|
ArgumentList(
|
||||||
|
SingletonSeparatedList(
|
||||||
|
Argument(LiteralValue(questId.Value)))));
|
||||||
|
}
|
||||||
|
}
|
135
QuestPathGenerator/RoslynElements/QuestStepExtensions.cs
Normal file
135
QuestPathGenerator/RoslynElements/QuestStepExtensions.cs
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
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 QuestStepExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this QuestStep step)
|
||||||
|
{
|
||||||
|
var emptyStep = new QuestStep();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(QuestStep)))
|
||||||
|
.WithArgumentList(
|
||||||
|
ArgumentList(
|
||||||
|
SeparatedList<ArgumentSyntax>(
|
||||||
|
new SyntaxNodeOrToken[]
|
||||||
|
{
|
||||||
|
Argument(LiteralValue(step.InteractionType)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(step.DataId)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(step.Position)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(step.TerritoryId))
|
||||||
|
})))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(QuestStep.StopDistance), step.StopDistance,
|
||||||
|
emptyStep.StopDistance)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.NpcWaitDistance), step.NpcWaitDistance,
|
||||||
|
emptyStep.NpcWaitDistance)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.TargetTerritoryId), step.TargetTerritoryId,
|
||||||
|
emptyStep.TargetTerritoryId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.DelaySecondsAtStart), step.DelaySecondsAtStart,
|
||||||
|
emptyStep.DelaySecondsAtStart)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Disabled), step.Disabled, emptyStep.Disabled)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.DisableNavmesh), step.DisableNavmesh,
|
||||||
|
emptyStep.DisableNavmesh)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Mount), step.Mount, emptyStep.Mount)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Fly), step.Fly, emptyStep.Fly)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Land), step.Land, emptyStep.Land)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Sprint), step.Sprint, emptyStep.Sprint)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.IgnoreDistanceToObject),
|
||||||
|
step.IgnoreDistanceToObject, emptyStep.IgnoreDistanceToObject)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Comment), step.Comment, emptyStep.Comment)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Aetheryte), step.Aetheryte, emptyStep.Aetheryte)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.AethernetShard), step.AethernetShard,
|
||||||
|
emptyStep.AethernetShard)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.AetheryteShortcut), step.AetheryteShortcut,
|
||||||
|
emptyStep.AetheryteShortcut)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.AethernetShortcut), step.AethernetShortcut,
|
||||||
|
emptyStep.AethernetShortcut)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.AetherCurrentId), step.AetherCurrentId,
|
||||||
|
emptyStep.AetherCurrentId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.ItemId), step.ItemId, emptyStep.ItemId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.GroundTarget), step.GroundTarget,
|
||||||
|
emptyStep.GroundTarget)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.ItemCount), step.ItemCount, emptyStep.ItemCount)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Emote), step.Emote, emptyStep.Emote)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.ChatMessage), step.ChatMessage,
|
||||||
|
emptyStep.ChatMessage)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Action), step.Action, emptyStep.Action)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.EnemySpawnType), step.EnemySpawnType,
|
||||||
|
emptyStep.EnemySpawnType)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.KillEnemyDataIds), step.KillEnemyDataIds)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.ComplexCombatData), step.ComplexCombatData)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.CombatDelaySecondsAtStart),
|
||||||
|
step.CombatDelaySecondsAtStart,
|
||||||
|
emptyStep.CombatDelaySecondsAtStart)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.JumpDestination), step.JumpDestination,
|
||||||
|
emptyStep.JumpDestination)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.ContentFinderConditionId),
|
||||||
|
step.ContentFinderConditionId, emptyStep.ContentFinderConditionId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.SkipConditions), step.SkipConditions,
|
||||||
|
emptyStep.SkipConditions)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.RequiredQuestVariables),
|
||||||
|
step.RequiredQuestVariables)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.RequiredGatheredItems),
|
||||||
|
step.RequiredGatheredItems),
|
||||||
|
AssignmentList(nameof(QuestStep.CompletionQuestVariablesFlags),
|
||||||
|
step.CompletionQuestVariablesFlags)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.DialogueChoices), step.DialogueChoices)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.PointMenuChoices), step.PointMenuChoices)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.PickUpQuestId), step.PickUpQuestId,
|
||||||
|
emptyStep.PickUpQuestId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.TurnInQuestId), step.TurnInQuestId,
|
||||||
|
emptyStep.TurnInQuestId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.NextQuestId), step.NextQuestId,
|
||||||
|
emptyStep.NextQuestId)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
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 QuestWorkValueExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this QuestWorkValue qwv)
|
||||||
|
{
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(QuestWorkValue)))
|
||||||
|
.WithArgumentList(
|
||||||
|
ArgumentList(
|
||||||
|
SeparatedList<ArgumentSyntax>(
|
||||||
|
new SyntaxNodeOrToken[]
|
||||||
|
{
|
||||||
|
Argument(LiteralValue(qwv.High)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(qwv.Low)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(qwv.Mode))
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this List<QuestWorkValue> list)
|
||||||
|
{
|
||||||
|
return CollectionExpression(
|
||||||
|
SeparatedList<CollectionElementSyntax>(
|
||||||
|
SyntaxNodeList(list.Select(x => ExpressionElement(
|
||||||
|
LiteralValue(x)).AsSyntaxNodeOrToken()).ToArray())));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
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 SatisfactionSupplyIdExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this SatisfactionSupplyNpcId satisfactionSupplyNpcId)
|
||||||
|
{
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(SatisfactionSupplyNpcId)))
|
||||||
|
.WithArgumentList(
|
||||||
|
ArgumentList(
|
||||||
|
SingletonSeparatedList(
|
||||||
|
Argument(LiteralValue(satisfactionSupplyNpcId.Value)))));
|
||||||
|
}
|
||||||
|
}
|
143
QuestPathGenerator/RoslynElements/SkipConditionsExtensions.cs
Normal file
143
QuestPathGenerator/RoslynElements/SkipConditionsExtensions.cs
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
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 SkipConditionsExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this SkipConditions skipConditions)
|
||||||
|
{
|
||||||
|
var emptySkip = new SkipConditions();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(SkipConditions)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(SkipConditions.StepIf), skipConditions.StepIf,
|
||||||
|
emptySkip.StepIf)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipConditions.AetheryteShortcutIf),
|
||||||
|
skipConditions.AetheryteShortcutIf, emptySkip.AetheryteShortcutIf)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(skipConditions.AethernetShortcutIf),
|
||||||
|
skipConditions.AethernetShortcutIf, emptySkip.AethernetShortcutIf)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this SkipStepConditions skipStepConditions)
|
||||||
|
{
|
||||||
|
var emptyStep = new SkipStepConditions();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(SkipStepConditions)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(SkipStepConditions.Never), skipStepConditions.Never,
|
||||||
|
emptyStep.Never)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(SkipStepConditions.CompletionQuestVariablesFlags),
|
||||||
|
skipStepConditions.CompletionQuestVariablesFlags)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipStepConditions.Flying), skipStepConditions.Flying,
|
||||||
|
emptyStep.Flying)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipStepConditions.Chocobo), skipStepConditions.Chocobo,
|
||||||
|
emptyStep.Chocobo)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipStepConditions.NotTargetable),
|
||||||
|
skipStepConditions.NotTargetable, emptyStep.NotTargetable)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(SkipStepConditions.InTerritory),
|
||||||
|
skipStepConditions.InTerritory).AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(SkipStepConditions.NotInTerritory),
|
||||||
|
skipStepConditions.NotInTerritory).AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipStepConditions.Item), skipStepConditions.Item,
|
||||||
|
emptyStep.Item)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(SkipStepConditions.QuestsAccepted),
|
||||||
|
skipStepConditions.QuestsAccepted).AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(SkipStepConditions.QuestsCompleted),
|
||||||
|
skipStepConditions.QuestsCompleted).AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipStepConditions.AetheryteLocked),
|
||||||
|
skipStepConditions.AetheryteLocked, emptyStep.AetheryteLocked)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipStepConditions.AetheryteUnlocked),
|
||||||
|
skipStepConditions.AetheryteUnlocked, emptyStep.AetheryteUnlocked)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipStepConditions.NearPosition),
|
||||||
|
skipStepConditions.NearPosition, emptyStep.NearPosition)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipStepConditions.ExtraCondition),
|
||||||
|
skipStepConditions.ExtraCondition, emptyStep.ExtraCondition)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this SkipItemConditions skipItemCondition)
|
||||||
|
{
|
||||||
|
var emptyItem = new SkipItemConditions();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(SkipItemConditions)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(SkipItemConditions.NotInInventory),
|
||||||
|
skipItemCondition.NotInInventory,
|
||||||
|
emptyItem.NotInInventory)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this NearPositionCondition nearPositionCondition)
|
||||||
|
{
|
||||||
|
var emptyCondition = new NearPositionCondition();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(NearPositionCondition)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(NearPositionCondition.Position),
|
||||||
|
nearPositionCondition.Position, emptyCondition.Position)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(NearPositionCondition.MaximumDistance),
|
||||||
|
nearPositionCondition.MaximumDistance, emptyCondition.MaximumDistance)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this SkipAetheryteCondition skipAetheryteCondition)
|
||||||
|
{
|
||||||
|
var emptyAetheryte = new SkipAetheryteCondition();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(SkipAetheryteCondition)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(SkipAetheryteCondition.Never), skipAetheryteCondition.Never,
|
||||||
|
emptyAetheryte.Never),
|
||||||
|
Assignment(nameof(SkipAetheryteCondition.InSameTerritory),
|
||||||
|
skipAetheryteCondition.InSameTerritory, emptyAetheryte.InSameTerritory),
|
||||||
|
AssignmentList(nameof(SkipAetheryteCondition.InTerritory),
|
||||||
|
skipAetheryteCondition.InTerritory),
|
||||||
|
Assignment(nameof(SkipAetheryteCondition.AetheryteLocked),
|
||||||
|
skipAetheryteCondition.AetheryteLocked, emptyAetheryte.AetheryteLocked)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipAetheryteCondition.AetheryteUnlocked),
|
||||||
|
skipAetheryteCondition.AetheryteUnlocked,
|
||||||
|
emptyAetheryte.AetheryteUnlocked)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(SkipAetheryteCondition.RequiredQuestVariablesNotMet),
|
||||||
|
skipAetheryteCondition.RequiredQuestVariablesNotMet,
|
||||||
|
emptyAetheryte.RequiredQuestVariablesNotMet)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
28
QuestPathGenerator/RoslynElements/Vector3Extensions.cs
Normal file
28
QuestPathGenerator/RoslynElements/Vector3Extensions.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System.Numerics;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||||
|
using static Questionable.QuestPathGenerator.RoslynShortcuts;
|
||||||
|
|
||||||
|
namespace Questionable.QuestPathGenerator.RoslynElements;
|
||||||
|
|
||||||
|
internal static class Vector3Extensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this Vector3 vector)
|
||||||
|
{
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(Vector3)))
|
||||||
|
.WithArgumentList(
|
||||||
|
ArgumentList(
|
||||||
|
SeparatedList<ArgumentSyntax>(
|
||||||
|
new SyntaxNodeOrToken[]
|
||||||
|
{
|
||||||
|
Argument(LiteralValue(vector.X)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(vector.Y)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(vector.Z))
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|||||||
using Questionable.Model.Common;
|
using Questionable.Model.Common;
|
||||||
using Questionable.Model.Gathering;
|
using Questionable.Model.Gathering;
|
||||||
using Questionable.Model.Questing;
|
using Questionable.Model.Questing;
|
||||||
|
using Questionable.QuestPathGenerator.RoslynElements;
|
||||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||||
|
|
||||||
namespace Questionable.QuestPathGenerator;
|
namespace Questionable.QuestPathGenerator;
|
||||||
@ -35,559 +36,48 @@ public static class RoslynShortcuts
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (value is string s)
|
return value switch
|
||||||
return LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(s));
|
|
||||||
else if (value is bool b)
|
|
||||||
return LiteralExpression(b ? SyntaxKind.TrueLiteralExpression : SyntaxKind.FalseLiteralExpression);
|
|
||||||
else if (value is short i16)
|
|
||||||
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(i16));
|
|
||||||
else if (value is int i32)
|
|
||||||
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(i32));
|
|
||||||
else if (value is byte u8)
|
|
||||||
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(u8));
|
|
||||||
else if (value is ushort u16)
|
|
||||||
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(u16));
|
|
||||||
else if (value is uint u32)
|
|
||||||
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(u32));
|
|
||||||
else if (value is float f)
|
|
||||||
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(f));
|
|
||||||
else if (value != null && value.GetType().IsEnum)
|
|
||||||
return MemberAccessExpression(
|
|
||||||
SyntaxKind.SimpleMemberAccessExpression,
|
|
||||||
IdentifierName(value.GetType().Name),
|
|
||||||
IdentifierName(value.GetType().GetEnumName(value)!));
|
|
||||||
else if (value is QuestStep step)
|
|
||||||
{
|
{
|
||||||
var emptyStep = new QuestStep();
|
null => LiteralExpression(SyntaxKind.NullLiteralExpression),
|
||||||
return ObjectCreationExpression(
|
string s => LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(s)),
|
||||||
IdentifierName(nameof(QuestStep)))
|
bool b => LiteralExpression(b ? SyntaxKind.TrueLiteralExpression : SyntaxKind.FalseLiteralExpression),
|
||||||
.WithArgumentList(
|
short i16 => LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(i16)),
|
||||||
ArgumentList(
|
int i32 => LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(i32)),
|
||||||
SeparatedList<ArgumentSyntax>(
|
byte u8 => LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(u8)),
|
||||||
new SyntaxNodeOrToken[]
|
ushort u16 => LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(u16)),
|
||||||
{
|
uint u32 => LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(u32)),
|
||||||
Argument(LiteralValue(step.InteractionType)),
|
float f => LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(f)),
|
||||||
Token(SyntaxKind.CommaToken),
|
QuestStep step => step.ToExpressionSyntax(),
|
||||||
Argument(LiteralValue(step.DataId)),
|
QuestId questId => questId.ToExpressionSyntax(),
|
||||||
Token(SyntaxKind.CommaToken),
|
LeveId leveId => leveId.ToExpressionSyntax(),
|
||||||
Argument(LiteralValue(step.Position)),
|
SatisfactionSupplyNpcId satisfactionSupplyNpcId => satisfactionSupplyNpcId.ToExpressionSyntax(),
|
||||||
Token(SyntaxKind.CommaToken),
|
Vector3 vector => vector.ToExpressionSyntax(),
|
||||||
Argument(LiteralValue(step.TerritoryId))
|
AethernetShortcut aethernetShortcut => aethernetShortcut.ToExpressionSyntax(),
|
||||||
})))
|
ChatMessage chatMessage => chatMessage.ToExpressionSyntax(),
|
||||||
.WithInitializer(
|
DialogueChoice dialogueChoice => dialogueChoice.ToExpressionSyntax(),
|
||||||
InitializerExpression(
|
JumpDestination jumpDestination => jumpDestination.ToExpressionSyntax(),
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
ExcelRef excelRef => excelRef.ToExpressionSyntax(),
|
||||||
SeparatedList<ExpressionSyntax>(
|
ComplexCombatData complexCombatData => complexCombatData.ToExpressionSyntax(),
|
||||||
SyntaxNodeList(
|
QuestWorkValue questWorkValue => questWorkValue.ToExpressionSyntax(),
|
||||||
Assignment(nameof(QuestStep.StopDistance), step.StopDistance,
|
List<QuestWorkValue> list => list.ToExpressionSyntax(), // TODO fix in AssignmentList
|
||||||
emptyStep.StopDistance)
|
SkipConditions skipConditions => skipConditions.ToExpressionSyntax(),
|
||||||
.AsSyntaxNodeOrToken(),
|
SkipStepConditions skipStepConditions => skipStepConditions.ToExpressionSyntax(),
|
||||||
Assignment(nameof(QuestStep.NpcWaitDistance), step.NpcWaitDistance,
|
SkipItemConditions skipItemCondition => skipItemCondition.ToExpressionSyntax(),
|
||||||
emptyStep.NpcWaitDistance)
|
NearPositionCondition nearPositionCondition => nearPositionCondition.ToExpressionSyntax(),
|
||||||
.AsSyntaxNodeOrToken(),
|
SkipAetheryteCondition skipAetheryteCondition => skipAetheryteCondition.ToExpressionSyntax(),
|
||||||
Assignment(nameof(QuestStep.TargetTerritoryId), step.TargetTerritoryId,
|
GatheredItem gatheredItem => gatheredItem.ToExpressionSyntax(),
|
||||||
emptyStep.TargetTerritoryId)
|
GatheringNodeGroup nodeGroup => nodeGroup.ToExpressionSyntax(),
|
||||||
.AsSyntaxNodeOrToken(),
|
GatheringNode nodeLocation => nodeLocation.ToExpressionSyntax(),
|
||||||
Assignment(nameof(QuestStep.DelaySecondsAtStart), step.DelaySecondsAtStart,
|
GatheringLocation location => location.ToExpressionSyntax(),
|
||||||
emptyStep.DelaySecondsAtStart)
|
not null when value.GetType().IsEnum => MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
|
||||||
.AsSyntaxNodeOrToken(),
|
IdentifierName(value.GetType().Name), IdentifierName(value.GetType().GetEnumName(value)!)),
|
||||||
Assignment(nameof(QuestStep.Disabled), step.Disabled, emptyStep.Disabled)
|
_ => throw new Exception($"Unsupported data type {value.GetType()} = {value}")
|
||||||
.AsSyntaxNodeOrToken(),
|
};
|
||||||
Assignment(nameof(QuestStep.DisableNavmesh), step.DisableNavmesh,
|
|
||||||
emptyStep.DisableNavmesh)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Mount), step.Mount, emptyStep.Mount)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Fly), step.Fly, emptyStep.Fly)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Land), step.Land, emptyStep.Land)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Sprint), step.Sprint, emptyStep.Sprint)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.IgnoreDistanceToObject),
|
|
||||||
step.IgnoreDistanceToObject, emptyStep.IgnoreDistanceToObject)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Comment), step.Comment, emptyStep.Comment)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Aetheryte), step.Aetheryte, emptyStep.Aetheryte)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.AethernetShard), step.AethernetShard,
|
|
||||||
emptyStep.AethernetShard)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.AetheryteShortcut), step.AetheryteShortcut,
|
|
||||||
emptyStep.AetheryteShortcut)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.AethernetShortcut), step.AethernetShortcut,
|
|
||||||
emptyStep.AethernetShortcut)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.AetherCurrentId), step.AetherCurrentId,
|
|
||||||
emptyStep.AetherCurrentId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.ItemId), step.ItemId, emptyStep.ItemId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.GroundTarget), step.GroundTarget,
|
|
||||||
emptyStep.GroundTarget)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.ItemCount), step.ItemCount, emptyStep.ItemCount)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Emote), step.Emote, emptyStep.Emote)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.ChatMessage), step.ChatMessage,
|
|
||||||
emptyStep.ChatMessage)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Action), step.Action, emptyStep.Action)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.EnemySpawnType), step.EnemySpawnType,
|
|
||||||
emptyStep.EnemySpawnType)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.KillEnemyDataIds), step.KillEnemyDataIds)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.ComplexCombatData), step.ComplexCombatData)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.CombatDelaySecondsAtStart),
|
|
||||||
step.CombatDelaySecondsAtStart,
|
|
||||||
emptyStep.CombatDelaySecondsAtStart)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.JumpDestination), step.JumpDestination,
|
|
||||||
emptyStep.JumpDestination)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.ContentFinderConditionId),
|
|
||||||
step.ContentFinderConditionId, emptyStep.ContentFinderConditionId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.SkipConditions), step.SkipConditions,
|
|
||||||
emptyStep.SkipConditions)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.RequiredQuestVariables),
|
|
||||||
step.RequiredQuestVariables)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.RequiredGatheredItems),
|
|
||||||
step.RequiredGatheredItems),
|
|
||||||
AssignmentList(nameof(QuestStep.CompletionQuestVariablesFlags),
|
|
||||||
step.CompletionQuestVariablesFlags)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.DialogueChoices), step.DialogueChoices)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.PointMenuChoices), step.PointMenuChoices)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.PickUpQuestId), step.PickUpQuestId,
|
|
||||||
emptyStep.PickUpQuestId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.TurnInQuestId), step.TurnInQuestId,
|
|
||||||
emptyStep.TurnInQuestId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.NextQuestId), step.NextQuestId,
|
|
||||||
emptyStep.NextQuestId)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is QuestId questId)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(QuestId)))
|
|
||||||
.WithArgumentList(
|
|
||||||
ArgumentList(
|
|
||||||
SingletonSeparatedList(
|
|
||||||
Argument(LiteralValue(questId.Value)))));
|
|
||||||
}
|
|
||||||
else if (value is LeveId leveId)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(LeveId)))
|
|
||||||
.WithArgumentList(
|
|
||||||
ArgumentList(
|
|
||||||
SingletonSeparatedList(
|
|
||||||
Argument(LiteralValue(leveId.Value)))));
|
|
||||||
}
|
|
||||||
else if (value is SatisfactionSupplyNpcId satisfactionSupplyNpcId)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(SatisfactionSupplyNpcId)))
|
|
||||||
.WithArgumentList(
|
|
||||||
ArgumentList(
|
|
||||||
SingletonSeparatedList(
|
|
||||||
Argument(LiteralValue(satisfactionSupplyNpcId.Value)))));
|
|
||||||
}
|
|
||||||
else if (value is Vector3 vector)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(Vector3)))
|
|
||||||
.WithArgumentList(
|
|
||||||
ArgumentList(
|
|
||||||
SeparatedList<ArgumentSyntax>(
|
|
||||||
new SyntaxNodeOrToken[]
|
|
||||||
{
|
|
||||||
Argument(LiteralValue(vector.X)),
|
|
||||||
Token(SyntaxKind.CommaToken),
|
|
||||||
Argument(LiteralValue(vector.Y)),
|
|
||||||
Token(SyntaxKind.CommaToken),
|
|
||||||
Argument(LiteralValue(vector.Z))
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
else if (value is AethernetShortcut aethernetShortcut)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(AethernetShortcut)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment<EAetheryteLocation?>(nameof(AethernetShortcut.From),
|
|
||||||
aethernetShortcut.From,
|
|
||||||
null)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment<EAetheryteLocation?>(nameof(AethernetShortcut.To), aethernetShortcut.To,
|
|
||||||
null)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is ChatMessage chatMessage)
|
|
||||||
{
|
|
||||||
ChatMessage emptyMessage = new();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(ChatMessage)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(ChatMessage.ExcelSheet), chatMessage.ExcelSheet,
|
|
||||||
emptyMessage.ExcelSheet)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(ChatMessage.Key), chatMessage.Key,
|
|
||||||
emptyMessage.Key)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is 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(),
|
|
||||||
Assignment(nameof(DialogueChoice.AnswerIsRegularExpression),
|
|
||||||
dialogueChoice.AnswerIsRegularExpression,
|
|
||||||
emptyChoice.AnswerIsRegularExpression)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(DialogueChoice.DataId), dialogueChoice.DataId, emptyChoice.DataId)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is JumpDestination jumpDestination)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(JumpDestination)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment<Vector3?>(nameof(JumpDestination.Position), jumpDestination.Position,
|
|
||||||
null)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(JumpDestination.StopDistance), jumpDestination.StopDistance, null)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(JumpDestination.DelaySeconds), jumpDestination.DelaySeconds, null)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(JumpDestination.Type), jumpDestination.Type, default)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is ExcelRef excelRef)
|
|
||||||
{
|
|
||||||
if (excelRef.Type == ExcelRef.EType.Key)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(ExcelRef)))
|
|
||||||
.WithArgumentList(
|
|
||||||
ArgumentList(
|
|
||||||
SingletonSeparatedList(
|
|
||||||
Argument(LiteralValue(excelRef.AsKey())))));
|
|
||||||
}
|
|
||||||
else if (excelRef.Type == ExcelRef.EType.RowId)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(ExcelRef)))
|
|
||||||
.WithArgumentList(
|
|
||||||
ArgumentList(
|
|
||||||
SingletonSeparatedList(
|
|
||||||
Argument(LiteralValue(excelRef.AsRowId())))));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throw new Exception($"Unsupported ExcelRef type {excelRef.Type}");
|
|
||||||
}
|
|
||||||
else if (value is ComplexCombatData complexCombatData)
|
|
||||||
{
|
|
||||||
var emptyData = new ComplexCombatData();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(ComplexCombatData)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(ComplexCombatData.DataId), complexCombatData.DataId,
|
|
||||||
emptyData.DataId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(ComplexCombatData.MinimumKillCount),
|
|
||||||
complexCombatData.MinimumKillCount, emptyData.MinimumKillCount)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(ComplexCombatData.RewardItemId), complexCombatData.RewardItemId,
|
|
||||||
emptyData.RewardItemId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(ComplexCombatData.RewardItemCount),
|
|
||||||
complexCombatData.RewardItemCount,
|
|
||||||
emptyData.RewardItemCount)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(ComplexCombatData.CompletionQuestVariablesFlags),
|
|
||||||
complexCombatData.CompletionQuestVariablesFlags),
|
|
||||||
Assignment(nameof(ComplexCombatData.IgnoreQuestMarker),
|
|
||||||
complexCombatData.IgnoreQuestMarker,
|
|
||||||
emptyData.IgnoreQuestMarker)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is QuestWorkValue qwv)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(QuestWorkValue)))
|
|
||||||
.WithArgumentList(
|
|
||||||
ArgumentList(
|
|
||||||
SeparatedList<ArgumentSyntax>(
|
|
||||||
new SyntaxNodeOrToken[]
|
|
||||||
{
|
|
||||||
Argument(LiteralValue(qwv.High)),
|
|
||||||
Token(SyntaxKind.CommaToken),
|
|
||||||
Argument(LiteralValue(qwv.Low)),
|
|
||||||
Token(SyntaxKind.CommaToken),
|
|
||||||
Argument(LiteralValue(qwv.Mode))
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
else if (value is List<QuestWorkValue> list)
|
|
||||||
{
|
|
||||||
return CollectionExpression(
|
|
||||||
SeparatedList<CollectionElementSyntax>(
|
|
||||||
SyntaxNodeList(list.Select(x => ExpressionElement(
|
|
||||||
LiteralValue(x)).AsSyntaxNodeOrToken()).ToArray())));
|
|
||||||
}
|
|
||||||
else if (value is SkipConditions skipConditions)
|
|
||||||
{
|
|
||||||
var emptySkip = new SkipConditions();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(SkipConditions)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(SkipConditions.StepIf), skipConditions.StepIf, emptySkip.StepIf)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipConditions.AetheryteShortcutIf),
|
|
||||||
skipConditions.AetheryteShortcutIf, emptySkip.AetheryteShortcutIf)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(skipConditions.AethernetShortcutIf),
|
|
||||||
skipConditions.AethernetShortcutIf, emptySkip.AethernetShortcutIf)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is SkipStepConditions skipStepConditions)
|
|
||||||
{
|
|
||||||
var emptyStep = new SkipStepConditions();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(SkipStepConditions)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(SkipStepConditions.Never), skipStepConditions.Never,
|
|
||||||
emptyStep.Never)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(SkipStepConditions.CompletionQuestVariablesFlags),
|
|
||||||
skipStepConditions.CompletionQuestVariablesFlags)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipStepConditions.Flying), skipStepConditions.Flying,
|
|
||||||
emptyStep.Flying)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipStepConditions.Chocobo), skipStepConditions.Chocobo,
|
|
||||||
emptyStep.Chocobo)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipStepConditions.NotTargetable),
|
|
||||||
skipStepConditions.NotTargetable, emptyStep.NotTargetable)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(SkipStepConditions.InTerritory),
|
|
||||||
skipStepConditions.InTerritory).AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(SkipStepConditions.NotInTerritory),
|
|
||||||
skipStepConditions.NotInTerritory).AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipStepConditions.Item), skipStepConditions.Item, emptyStep.Item)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(SkipStepConditions.QuestsAccepted),
|
|
||||||
skipStepConditions.QuestsAccepted).AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(SkipStepConditions.QuestsCompleted),
|
|
||||||
skipStepConditions.QuestsCompleted).AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipStepConditions.AetheryteLocked),
|
|
||||||
skipStepConditions.AetheryteLocked, emptyStep.AetheryteLocked)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipStepConditions.AetheryteUnlocked),
|
|
||||||
skipStepConditions.AetheryteUnlocked, emptyStep.AetheryteUnlocked)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipStepConditions.NearPosition),
|
|
||||||
skipStepConditions.NearPosition, emptyStep.NearPosition)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipStepConditions.ExtraCondition),
|
|
||||||
skipStepConditions.ExtraCondition, emptyStep.ExtraCondition)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is SkipItemConditions skipItemCondition)
|
|
||||||
{
|
|
||||||
var emptyItem = new SkipItemConditions();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(SkipItemConditions)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(SkipItemConditions.NotInInventory),
|
|
||||||
skipItemCondition.NotInInventory,
|
|
||||||
emptyItem.NotInInventory)))));
|
|
||||||
}
|
|
||||||
else if (value is NearPositionCondition nearPositionCondition)
|
|
||||||
{
|
|
||||||
var emptyCondition = new NearPositionCondition();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(NearPositionCondition)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(NearPositionCondition.Position),
|
|
||||||
nearPositionCondition.Position, emptyCondition.Position).AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(NearPositionCondition.MaximumDistance),
|
|
||||||
nearPositionCondition.MaximumDistance, emptyCondition.MaximumDistance)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is SkipAetheryteCondition skipAetheryteCondition)
|
|
||||||
{
|
|
||||||
var emptyAetheryte = new SkipAetheryteCondition();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(SkipAetheryteCondition)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(SkipAetheryteCondition.Never), skipAetheryteCondition.Never,
|
|
||||||
emptyAetheryte.Never),
|
|
||||||
Assignment(nameof(SkipAetheryteCondition.InSameTerritory),
|
|
||||||
skipAetheryteCondition.InSameTerritory, emptyAetheryte.InSameTerritory),
|
|
||||||
AssignmentList(nameof(SkipAetheryteCondition.InTerritory),
|
|
||||||
skipAetheryteCondition.InTerritory),
|
|
||||||
Assignment(nameof(SkipAetheryteCondition.AetheryteLocked),
|
|
||||||
skipAetheryteCondition.AetheryteLocked, emptyAetheryte.AetheryteLocked)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(SkipAetheryteCondition.AetheryteUnlocked),
|
|
||||||
skipAetheryteCondition.AetheryteUnlocked, emptyAetheryte.AetheryteUnlocked)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is GatheredItem gatheredItem)
|
|
||||||
{
|
|
||||||
var emptyItem = new GatheredItem();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(GatheredItem)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(GatheredItem.ItemId), gatheredItem.ItemId, emptyItem.ItemId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(GatheredItem.AlternativeItemId), gatheredItem.AlternativeItemId,
|
|
||||||
emptyItem.AlternativeItemId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(GatheredItem.ItemCount), gatheredItem.ItemCount,
|
|
||||||
emptyItem.ItemCount)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(GatheredItem.Collectability), gatheredItem.Collectability,
|
|
||||||
emptyItem.Collectability)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(GatheredItem.QuestAcceptedAsClass),
|
|
||||||
gatheredItem.QuestAcceptedAsClass,
|
|
||||||
emptyItem.QuestAcceptedAsClass)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is GatheringNodeGroup nodeGroup)
|
|
||||||
{
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(GatheringNodeGroup)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
AssignmentList(nameof(GatheringNodeGroup.Nodes), nodeGroup.Nodes)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is GatheringNode nodeLocation)
|
|
||||||
{
|
|
||||||
var emptyLocation = new GatheringNode();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(GatheringNode)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(GatheringNode.DataId), nodeLocation.DataId,
|
|
||||||
emptyLocation.DataId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(GatheringNode.Fly), nodeLocation.Fly, emptyLocation.Fly)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(GatheringNode.Locations), nodeLocation.Locations)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is GatheringLocation location)
|
|
||||||
{
|
|
||||||
var emptyLocation = new GatheringLocation();
|
|
||||||
return ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(GatheringLocation)))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(GatheringLocation.Position), location.Position,
|
|
||||||
emptyLocation.Position).AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(GatheringLocation.MinimumAngle), location.MinimumAngle,
|
|
||||||
emptyLocation.MinimumAngle).AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(GatheringLocation.MaximumAngle), location.MaximumAngle,
|
|
||||||
emptyLocation.MaximumAngle).AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(GatheringLocation.MinimumDistance),
|
|
||||||
location.MinimumDistance, emptyLocation.MinimumDistance)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(GatheringLocation.MaximumDistance),
|
|
||||||
location.MaximumDistance, emptyLocation.MaximumDistance)
|
|
||||||
.AsSyntaxNodeOrToken()))));
|
|
||||||
}
|
|
||||||
else if (value is null)
|
|
||||||
return LiteralExpression(SyntaxKind.NullLiteralExpression);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new Exception($"Unable to handle literal [{value}]: {e.StackTrace}", e);
|
throw new Exception($"Unable to handle literal [{value}]: {e}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception($"Unsupported data type {value.GetType()} = {value}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AssignmentExpressionSyntax? Assignment<T>(string name, T? value, T? defaultValue)
|
public static AssignmentExpressionSyntax? Assignment<T>(string name, T? value, T? defaultValue)
|
||||||
@ -607,7 +97,7 @@ public static class RoslynShortcuts
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new Exception($"Unable to handle assignment [{name}]: {e.Message}", e);
|
throw new Exception($"Unable to handle assignment [{name}]: {e}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,7 +123,7 @@ public static class RoslynShortcuts
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new Exception($"Unable to handle list [{name}]: {e.StackTrace}", e);
|
throw new Exception($"Unable to handle list [{name}]: {e}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,6 +295,9 @@
|
|||||||
},
|
},
|
||||||
"AetheryteUnlocked": {
|
"AetheryteUnlocked": {
|
||||||
"$ref": "https://git.carvel.li/liza/Questionable/raw/branch/master/Questionable.Model/common-schema.json#/$defs/Aetheryte"
|
"$ref": "https://git.carvel.li/liza/Questionable/raw/branch/master/Questionable.Model/common-schema.json#/$defs/Aetheryte"
|
||||||
|
},
|
||||||
|
"RequiredQuestVariablesNotMet": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
@ -10,4 +10,5 @@ public sealed class SkipAetheryteCondition
|
|||||||
public List<ushort> InTerritory { get; set; } = new();
|
public List<ushort> InTerritory { get; set; } = new();
|
||||||
public EAetheryteLocation? AetheryteLocked { get; set; }
|
public EAetheryteLocation? AetheryteLocked { get; set; }
|
||||||
public EAetheryteLocation? AetheryteUnlocked { get; set; }
|
public EAetheryteLocation? AetheryteUnlocked { get; set; }
|
||||||
|
public bool RequiredQuestVariablesNotMet { get; set; }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user