forked from liza/Questionable
CodeGen update
This commit is contained in:
parent
b3d9ce382d
commit
2cf059ec38
29
QuestPathGenerator/RoslynElements/CombatItemUseExtensions.cs
Normal file
29
QuestPathGenerator/RoslynElements/CombatItemUseExtensions.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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 CombatItemUseExtensions
|
||||||
|
{
|
||||||
|
public static ExpressionSyntax ToExpressionSyntax(this CombatItemUse combatItemuse)
|
||||||
|
{
|
||||||
|
var emptyItemuse = new CombatItemUse();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(CombatItemUse)))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(CombatItemUse.ItemId), combatItemuse.ItemId,
|
||||||
|
emptyItemuse.ItemId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(CombatItemUse.Condition), combatItemuse.Condition, emptyItemuse.Condition)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(combatItemuse.Value), combatItemuse.Value, emptyItemuse.Value)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
|
}
|
@ -107,6 +107,9 @@ internal static class QuestStepExtensions
|
|||||||
.AsSyntaxNodeOrToken(),
|
.AsSyntaxNodeOrToken(),
|
||||||
AssignmentList(nameof(QuestStep.ComplexCombatData), step.ComplexCombatData)
|
AssignmentList(nameof(QuestStep.ComplexCombatData), step.ComplexCombatData)
|
||||||
.AsSyntaxNodeOrToken(),
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.CombatItemUse), step.CombatItemUse,
|
||||||
|
emptyStep.CombatItemUse)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
Assignment(nameof(QuestStep.CombatDelaySecondsAtStart),
|
Assignment(nameof(QuestStep.CombatDelaySecondsAtStart),
|
||||||
step.CombatDelaySecondsAtStart,
|
step.CombatDelaySecondsAtStart,
|
||||||
emptyStep.CombatDelaySecondsAtStart)
|
emptyStep.CombatDelaySecondsAtStart)
|
||||||
|
@ -71,6 +71,7 @@ public static class RoslynShortcuts
|
|||||||
GatheringNodeGroup nodeGroup => nodeGroup.ToExpressionSyntax(),
|
GatheringNodeGroup nodeGroup => nodeGroup.ToExpressionSyntax(),
|
||||||
GatheringNode nodeLocation => nodeLocation.ToExpressionSyntax(),
|
GatheringNode nodeLocation => nodeLocation.ToExpressionSyntax(),
|
||||||
GatheringLocation location => location.ToExpressionSyntax(),
|
GatheringLocation location => location.ToExpressionSyntax(),
|
||||||
|
CombatItemUse combatItemUse => combatItemUse.ToExpressionSyntax(),
|
||||||
not null when value.GetType().IsEnum => MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
|
not null when value.GetType().IsEnum => MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
|
||||||
IdentifierName(value.GetType().Name), IdentifierName(value.GetType().GetEnumName(value)!)),
|
IdentifierName(value.GetType().Name), IdentifierName(value.GetType().GetEnumName(value)!)),
|
||||||
_ => throw new Exception($"Unsupported data type {value.GetType()} = {value}")
|
_ => throw new Exception($"Unsupported data type {value.GetType()} = {value}")
|
||||||
|
Loading…
Reference in New Issue
Block a user