Esempio n. 1
0
        public static QuestAction EndState(StatementSyntax expression)
        {
            if (expression is YieldStatementSyntax)
            {
                var expr = expression.As <YieldStatementSyntax>().Expression;
                if (expr == null)
                {
                    return(new QuestAction {
                        Type = QuestActionType.EndState,
                        Source = expression.ToString(),
                    });
                }
            }

            return(null);
        }
Esempio n. 2
0
        public static QuestAction SkipFrame(StatementSyntax expression)
        {
            if (expression is YieldStatementSyntax)
            {
                var expr = expression.As <YieldStatementSyntax>().Expression;
                if (expr != null && expr.Kind() == Microsoft.CodeAnalysis.CSharp.SyntaxKind.NullLiteralExpression)
                {
                    return(new QuestAction {
                        Type = QuestActionType.SkipFrame,
                        Source = expression.ToString(),
                    });
                }
            }

            return(null);
        }
Esempio n. 3
0
        public static QuestAction WaitSomeTime(StatementSyntax expression)
        {
            if (expression is YieldStatementSyntax)
            {
                var expr = expression.As <YieldStatementSyntax>().Expression.As <LiteralExpressionSyntax>();
                if (expr != null && expr.Kind() == Microsoft.CodeAnalysis.CSharp.SyntaxKind.NumericLiteralExpression)
                {
                    return(new QuestAction {
                        Type = QuestActionType.WaitSomeTime,
                        Source = expression.ToString(),
                        Properties = new Dictionary <string, object> {
                            ["time"] = expr.Token.ValueText
                        },
                    });
                }
            }

            return(null);
        }
Esempio n. 4
0
        public static void WriteStatementAsBlock(OutputWriter writer, StatementSyntax statement, bool writeBraces = true)
        {
            if (statement is BlockSyntax)
            {
                WriteBlock(writer, statement.As <BlockSyntax>(), writeBraces);
            }
            else
            {
                if (writeBraces)
                {
                    writer.OpenBrace();
                }

                Write(writer, statement);
                TriviaProcessor.ProcessTrivias(writer, statement.DescendantTrivia());

                if (writeBraces)
                {
                    writer.CloseBrace();
                }
            }
        }
Esempio n. 5
0
        public static void WriteStatementAsBlock(OutputWriter writer, StatementSyntax statement, bool writeBraces = true)
        {
            if (statement is BlockSyntax)
                WriteBlock(writer, statement.As<BlockSyntax>(), writeBraces);
            else
            {
                if (writeBraces)
                    writer.OpenBrace();

                Write(writer, statement);
                TriviaProcessor.ProcessTrivias(writer, statement.DescendantTrivia());

                if (writeBraces)
                    writer.CloseBrace();
            }
        }