1
0
forked from liza/Questionable

Update source gen

This commit is contained in:
Liza 2024-07-20 21:23:54 +02:00
parent cc0c972bae
commit fc1852139f
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 34 additions and 4 deletions

View File

@ -365,6 +365,9 @@ public class QuestSourceGenerator : ISourceGenerator
.AsSyntaxNodeOrToken(), .AsSyntaxNodeOrToken(),
AssignmentList(nameof(QuestStep.SkipIf), step.SkipIf) AssignmentList(nameof(QuestStep.SkipIf), step.SkipIf)
.AsSyntaxNodeOrToken(), .AsSyntaxNodeOrToken(),
AssignmentList(nameof(QuestStep.RequiredQuestVariables),
step.RequiredQuestVariables)
.AsSyntaxNodeOrToken(),
AssignmentList(nameof(QuestStep.CompletionQuestVariablesFlags), AssignmentList(nameof(QuestStep.CompletionQuestVariablesFlags),
step.CompletionQuestVariablesFlags) step.CompletionQuestVariablesFlags)
.AsSyntaxNodeOrToken(), .AsSyntaxNodeOrToken(),

View File

@ -39,6 +39,8 @@ public static class RoslynShortcuts
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(i16)); return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(i16));
else if (value is int i32) else if (value is int i32)
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(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) else if (value is ushort u16)
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(u16)); return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(u16));
else if (value is uint u32) else if (value is uint u32)
@ -173,15 +175,40 @@ public static class RoslynShortcuts
SyntaxNodeList( SyntaxNodeList(
Assignment(nameof(ComplexCombatData.DataId), complexCombatData.DataId, default(uint)) Assignment(nameof(ComplexCombatData.DataId), complexCombatData.DataId, default(uint))
.AsSyntaxNodeOrToken(), .AsSyntaxNodeOrToken(),
Assignment(nameof(ComplexCombatData.MinimumKillCount), complexCombatData.MinimumKillCount, null) Assignment(nameof(ComplexCombatData.MinimumKillCount),
complexCombatData.MinimumKillCount, null)
.AsSyntaxNodeOrToken(), .AsSyntaxNodeOrToken(),
Assignment(nameof(ComplexCombatData.RewardItemId), complexCombatData.RewardItemId, null) Assignment(nameof(ComplexCombatData.RewardItemId), complexCombatData.RewardItemId, null)
.AsSyntaxNodeOrToken(), .AsSyntaxNodeOrToken(),
Assignment(nameof(ComplexCombatData.RewardItemCount), complexCombatData.RewardItemCount, null) Assignment(nameof(ComplexCombatData.RewardItemCount), complexCombatData.RewardItemCount,
null)
.AsSyntaxNodeOrToken(), .AsSyntaxNodeOrToken(),
AssignmentList(nameof(ComplexCombatData.CompletionQuestVariablesFlags), complexCombatData.CompletionQuestVariablesFlags) AssignmentList(nameof(ComplexCombatData.CompletionQuestVariablesFlags),
complexCombatData.CompletionQuestVariablesFlags)
.AsSyntaxNodeOrToken())))); .AsSyntaxNodeOrToken()))));
}else if (value is null) }
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))
})));
}
else if (value is List<QuestWorkValue> list)
{
return CollectionExpression(
SeparatedList<CollectionElementSyntax>(
SyntaxNodeList(list.Select(x => ExpressionElement(
LiteralValue(x)).AsSyntaxNodeOrToken()).ToArray())));
}
else if (value is null)
return LiteralExpression(SyntaxKind.NullLiteralExpression); return LiteralExpression(SyntaxKind.NullLiteralExpression);
else else
throw new Exception($"Unsupported data type {value.GetType()} = {value}"); throw new Exception($"Unsupported data type {value.GetType()} = {value}");