master #3

Open
cacahuetes wants to merge 881 commits from liza/Questionable:master into cacahuetes-ShB-Healer
3 changed files with 33 additions and 0 deletions
Showing only changes of commit 2cf059ec38 - Show all commits

View 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()))));
}
}

View File

@ -107,6 +107,9 @@ internal static class QuestStepExtensions
.AsSyntaxNodeOrToken(),
AssignmentList(nameof(QuestStep.ComplexCombatData), step.ComplexCombatData)
.AsSyntaxNodeOrToken(),
Assignment(nameof(QuestStep.CombatItemUse), step.CombatItemUse,
emptyStep.CombatItemUse)
.AsSyntaxNodeOrToken(),
Assignment(nameof(QuestStep.CombatDelaySecondsAtStart),
step.CombatDelaySecondsAtStart,
emptyStep.CombatDelaySecondsAtStart)

View File

@ -71,6 +71,7 @@ public static class RoslynShortcuts
GatheringNodeGroup nodeGroup => nodeGroup.ToExpressionSyntax(),
GatheringNode nodeLocation => nodeLocation.ToExpressionSyntax(),
GatheringLocation location => location.ToExpressionSyntax(),
CombatItemUse combatItemUse => combatItemUse.ToExpressionSyntax(),
not null when value.GetType().IsEnum => MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
IdentifierName(value.GetType().Name), IdentifierName(value.GetType().GetEnumName(value)!)),
_ => throw new Exception($"Unsupported data type {value.GetType()} = {value}")