Ejemplo n.º 1
0
        public void compile(List<Token> tokens)
        {
            DoNothingNode nothingStart = new DoNothingNode();
            compiler.Nodes.AddLast(nothingStart);
            compiler.Nodes.Last.Previous.Value.Next = compiler.Nodes.Last.Value;
            compiler.Nodes.Last.Value.Prev = compiler.Nodes.Last.Previous.Value;

            List<List<Token>> body = compiler.compileBody(tokens);
            foreach (List<Token> bodyPart in body)
            {
                compiler.compilePart(bodyPart);
            }
        }
        public ConversationNode ToConversationNode(SclConversation conversation)
        {
            ConversationNode first = new DoNothingNode();
            ConversationNode last  = first;

            foreach (var statement in Statements)
            {
                ConversationNode from = statement.ToConversationNode(conversation);
                last.FollowingNode = from;
                last = from;
            }
            return(first);
        }
Ejemplo n.º 3
0
        public override ConversationNode ToConversationNode(SclConversation conversation)
        {
            switch (Command)
            {
            case "/goto":
                return(new DelayedMoveNode((friend) =>
                {
                    return conversation.GetNodeFromLabel(this.Arguments[0]);
                }));

            case "/end":
                return(new DelayedMoveNode((f) => null));

            case "/escape":
                return(new DelayedMoveNode((friend) =>
                {
                    friend.Memory.ConversationStack.Pop();
                    return conversation.GetNodeFromLabel(this.Arguments[0]);
                }));

            case "/label":
                DoNothingNode n = new DoNothingNode();
                conversation.AddLabeledNode(this.Arguments[0], n);
                return(n);

            case "/picture":
                return(new ImageFileLine("Data/" + this.Arguments[0]));

            case "/file":
                return(new DocumentFileLine("Data/" + this.Arguments[0]));

            case "/input":
                return(new Nodes.SetVariableNode(this.Arguments[0]));

            case "/set":
                return(new LambdaActionNode(async(friend) =>
                {
                    friend.Data.SetVariable(this.Arguments[0], this.Arguments[1]);
                    await friend.Overseer.Speaking.SendSystemMessage(friend, "Configuration property '" + Arguments[0] + "' set to '" + this.Arguments[1] + "'.");
                    friend.SavePersistentMemory();
                }));

            default:
                if (Command.StartsWith("/special:"))
                {
                    string specialName = Command.Substring("/special:".Length);
                    return(new SpecialActionNode(specialName, Arguments));
                }
                return(new DoNothingNode());
            }
        }
Ejemplo n.º 4
0
 public void AddLabeledNode(string label, DoNothingNode node)
 {
     _labeledNodes.Add(label, node);
 }
Ejemplo n.º 5
0
 public void visit(DoNothingNode dnn)
 {
 }