public void Tick(StoryInstance instance, StoryMessageHandler handler, long delta)
 {
     while (m_CommandQueue.Count > 0)
     {
         IStoryCommand cmd = m_CommandQueue.Peek();
         if (cmd.Execute(instance, handler, delta, m_Iterator, m_Arguments))
         {
             m_CompositeReentry = false;
             if (m_IsBreak || m_IsContinue || m_IsReturn)
             {
                 ResetCommandQueue();
             }
             break;
         }
         else
         {
             m_CompositeReentry = false;
             cmd.Reset();
             m_CommandQueue.Dequeue();
             if (m_IsBreak || m_IsContinue || m_IsReturn)
             {
                 ResetCommandQueue();
                 break;
             }
         }
     }
 }
 public void Tick(StoryInstance instance, long delta)
 {
     if (m_IsPaused)
     {
         return;
     }
     try {
         instance.StackVariables = StackVariables;
         m_IsInTick = true;
         while (m_CommandQueue.Count > 0)
         {
             IStoryCommand cmd = m_CommandQueue.Peek();
             if (cmd.Execute(instance, delta, null, m_Arguments))
             {
                 break;
             }
             else
             {
                 cmd.Reset();
                 m_CommandQueue.Dequeue();
             }
         }
         if (m_CommandQueue.Count == 0)
         {
             m_IsTriggered = false;
         }
     } finally {
         m_IsInTick = false;
     }
 }
Esempio n. 3
0
 protected override void Load(Dsl.FunctionData functionData)
 {
     Dsl.CallData callData = functionData.Call;
     if (null != callData)
     {
         if (callData.GetParamNum() > 0)
         {
             Dsl.ISyntaxComponent param = callData.GetParam(0);
             StoryValue <int>     cond  = new StoryValue <int>();
             cond.InitFromDsl(param);
             m_Conditions.Add(cond);
         }
         List <IStoryCommand> cmds = new List <IStoryCommand>();
         for (int i = 0; i < functionData.Statements.Count; i++)
         {
             IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(functionData.Statements[i]);
             if (null != cmd)
             {
                 cmds.Add(cmd);
             }
         }
         m_LoadedIfCommands.Add(cmds);
     }
     IsCompositeCommand = true;
 }
Esempio n. 4
0
 public void Tick(StoryInstance instance, StoryMessageHandler handler, long delta)
 {
     while (m_CommandQueue.Count > 0)
     {
         if (handler.IsSuspended || handler.CanSkip && GlobalVariables.Instance.IsStorySkipped)
         {
             break;
         }
         IStoryCommand cmd = m_CommandQueue.Peek();
         if (cmd.Execute(instance, handler, delta, m_Iterator, m_Arguments))
         {
             m_CompositeReentry = false;
             if (m_IsBreak || m_IsContinue || m_IsReturn)
             {
                 ResetCommandQueue();
             }
             break;
         }
         else
         {
             m_CompositeReentry = false;
             cmd.Reset();
             if (m_CommandQueue.Count > 0)
             {
                 m_CommandQueue.Dequeue();
             }
             if (m_IsBreak || m_IsContinue || m_IsReturn)
             {
                 ResetCommandQueue();
                 break;
             }
         }
     }
 }
Esempio n. 5
0
        private void Prepare(StoryMessageHandler handler)
        {
            var runtime = StoryRuntime.New();

            handler.PushRuntime(runtime);
            var queue = runtime.CommandQueue;

            foreach (IStoryCommand cmd in queue)
            {
                cmd.Reset();
            }
            queue.Clear();
            for (int i = 0; i < m_LoadedCommands.Count; i++)
            {
                IStoryCommand cmd = m_LoadedCommands[i];
                if (null != cmd.PrologueCommand)
                {
                    queue.Enqueue(cmd.PrologueCommand);
                }
                queue.Enqueue(cmd);
                if (null != cmd.EpilogueCommand)
                {
                    queue.Enqueue(cmd.EpilogueCommand);
                }
            }
        }
Esempio n. 6
0
 private void Prepare(StackElementInfo stackInfo)
 {
     if (null != m_InitialCommands && m_FirstStackCommands.Count <= 0)
     {
         for (int i = 0; i < m_InitialCommands.Count; ++i)
         {
             IStoryCommand cmd = m_InitialCommands[i].Clone();
             m_FirstStackCommands.Add(cmd);
         }
     }
     if (m_Stack.Count <= 1)
     {
         for (int i = 0; i < m_FirstStackCommands.Count; ++i)
         {
             IStoryCommand cmd = m_FirstStackCommands[i];
             if (null != cmd.LeadCommand)
             {
                 stackInfo.m_CommandQueue.Enqueue(cmd.LeadCommand);
             }
             stackInfo.m_CommandQueue.Enqueue(cmd);
         }
     }
     else
     {
         for (int i = 0; i < m_InitialCommands.Count; ++i)
         {
             IStoryCommand cmd = m_InitialCommands[i].Clone();
             if (null != cmd.LeadCommand)
             {
                 stackInfo.m_CommandQueue.Enqueue(cmd.LeadCommand);
             }
             stackInfo.m_CommandQueue.Enqueue(cmd);
         }
     }
 }
Esempio n. 7
0
        private void PrepareIf(int ix, StoryMessageHandler handler)
        {
            var runtime = StoryRuntime.New();

            handler.PushRuntime(runtime);
            var queue = handler.PeekRuntime().CommandQueue;

            foreach (IStoryCommand cmd in queue)
            {
                cmd.Reset();
            }
            queue.Clear();
            List <IStoryCommand> cmds = m_LoadedIfCommands[ix];

            for (int i = 0; i < cmds.Count; ++i)
            {
                IStoryCommand cmd = cmds[i];
                if (null != cmd.PrologueCommand)
                {
                    queue.Enqueue(cmd.PrologueCommand);
                }
                queue.Enqueue(cmd);
                if (null != cmd.EpilogueCommand)
                {
                    queue.Enqueue(cmd.EpilogueCommand);
                }
            }
        }
Esempio n. 8
0
 protected override void Load(Dsl.FunctionData functionData)
 {
     if (functionData.IsHighOrder)
     {
         m_LocalInfoIndex = StoryCommandManager.Instance.AllocLocalInfoIndex();
         Dsl.FunctionData callData = functionData.LowerOrderFunction;
         if (null != callData)
         {
             if (callData.GetParamNum() > 0)
             {
                 Dsl.ISyntaxComponent param = callData.GetParam(0);
                 m_LoadedCondition.InitFromDsl(param);
             }
             for (int i = 0; i < functionData.GetParamNum(); i++)
             {
                 IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(functionData.GetParam(i));
                 if (null != cmd)
                 {
                     m_LoadedCommands.Add(cmd);
                 }
             }
         }
         IsCompositeCommand = true;
     }
 }
Esempio n. 9
0
 protected override bool Load(Dsl.FunctionData functionData)
 {
     if (functionData.IsHighOrder)
     {
         m_LocalInfoIndex = StoryCommandManager.Instance.AllocLocalInfoIndex();
         Dsl.FunctionData callData = functionData.LowerOrderFunction;
         if (null != callData)
         {
             if (callData.GetParamNum() > 0)
             {
                 Dsl.ISyntaxComponent param = callData.GetParam(0);
                 StoryValue <int>     cond  = new StoryValue <int>();
                 cond.InitFromDsl(param);
                 m_LoadedConditions.Add(cond);
             }
             List <IStoryCommand> cmds = new List <IStoryCommand>();
             for (int i = 0; i < functionData.GetParamNum(); i++)
             {
                 IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(functionData.GetParam(i));
                 if (null != cmd)
                 {
                     cmds.Add(cmd);
                 }
             }
             m_LoadedIfCommands.Add(cmds);
         }
     }
     return(true);
 }
Esempio n. 10
0
        protected override bool ExecCommand(StoryInstance instance, long delta, object iterator, object[] args)
        {
            bool ret = false;

            if (m_IfCommandQueue.Count == 0 && m_ElseCommandQueue.Count == 0 && !m_AlreadyExecute)
            {
                Evaluate(instance, iterator, args);
                bool isElse = true;
                for (int i = 0; i < m_Conditions.Count; ++i)
                {
                    if (m_Conditions[i].Value != 0)
                    {
                        PrepareIf(i);
                        isElse = false;
                        break;
                    }
                }
                if (isElse)
                {
                    PrepareElse();
                }
                m_AlreadyExecute = true;
            }
            if (m_IfCommandQueue.Count > 0)
            {
                while (m_IfCommandQueue.Count > 0)
                {
                    IStoryCommand cmd = m_IfCommandQueue.Peek();
                    if (cmd.Execute(instance, delta, iterator, args))
                    {
                        ret = true;
                        break;
                    }
                    else
                    {
                        cmd.Reset();
                        m_IfCommandQueue.Dequeue();
                    }
                }
            }
            if (m_ElseCommandQueue.Count > 0)
            {
                while (m_ElseCommandQueue.Count > 0)
                {
                    IStoryCommand cmd = m_ElseCommandQueue.Peek();
                    if (cmd.Execute(instance, delta, iterator, args))
                    {
                        ret = true;
                        break;
                    }
                    else
                    {
                        cmd.Reset();
                        m_ElseCommandQueue.Dequeue();
                    }
                }
            }
            return(ret);
        }
Esempio n. 11
0
        public static void FinalParse(Dsl.DslInfo dslInfo)
        {
            string id = dslInfo.GetId();

            if (id == "command")
            {
                if (dslInfo.Functions.Count == 2)
                {
                    Dsl.FunctionData     first   = dslInfo.First;
                    string               name    = first.Call.GetParamId(0);
                    IStoryCommandFactory factory = StoryCommandManager.Instance.FindFactory(name);
                    if (null != factory)
                    {
                        StorySystem.CommonCommands.CompositeCommand cmd = factory.Create() as StorySystem.CommonCommands.CompositeCommand;
                        Dsl.FunctionData second = dslInfo.Second;
                        cmd.InitialCommands.Clear();
                        for (int ix = 0; ix < second.GetStatementNum(); ++ix)
                        {
                            Dsl.ISyntaxComponent syntaxComp = second.GetStatement(ix);
                            IStoryCommand        sub        = StoryCommandManager.Instance.CreateCommand(syntaxComp);
                            cmd.InitialCommands.Add(sub);
                        }
                    }
                    else
                    {
                        LogSystem.Error("Can't find command factory '{0}'", name);
                    }
                }
            }
            else if (id == "value")
            {
                if (dslInfo.Functions.Count == 3)
                {
                    Dsl.FunctionData   first   = dslInfo.First;
                    string             name    = first.Call.GetParamId(0);
                    IStoryValueFactory factory = StoryValueManager.Instance.FindFactory(name);
                    if (null != factory)
                    {
                        StorySystem.CommonValues.CompositeValue val = factory.Build() as StorySystem.CommonValues.CompositeValue;
                        Dsl.FunctionData second = dslInfo.Second;
                        Dsl.FunctionData third  = dslInfo.Functions[2];
                        val.InitialCommands.Clear();
                        for (int ix = 0; ix < third.GetStatementNum(); ++ix)
                        {
                            Dsl.ISyntaxComponent syntaxComp = third.GetStatement(ix);
                            IStoryCommand        sub        = StoryCommandManager.Instance.CreateCommand(syntaxComp);
                            val.InitialCommands.Add(sub);
                        }
                    }
                    else
                    {
                        LogSystem.Error("Can't find value factory '{0}'", name);
                    }
                }
            }
        }
 private void RefreshCommands(Dsl.FunctionData handlerData)
 {
     m_LoadedCommands.Clear();
     for (int i = 0; i < handlerData.Statements.Count; i++)
     {
         IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(handlerData.Statements[i]);
         if (null != cmd)
         {
             m_LoadedCommands.Add(cmd);
         }
     }
 }
Esempio n. 13
0
 private void RefreshCommands(Dsl.FunctionData handlerData)
 {
     m_LoadedCommands.Clear();
     for (int i = 0; i < handlerData.GetParamNum(); i++)
     {
         IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(handlerData.GetParam(i));
         if (null != cmd)
         {
             m_LoadedCommands.Add(cmd);
         }
     }
 }
Esempio n. 14
0
 private void RefreshCommand(ScriptableData.FunctionData handlerData)
 {
     m_listLoadedCommands.Clear();
     foreach (var data in handlerData.Statements)
     {
         IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(data);
         if (cmd != null)
         {
             m_listLoadedCommands.Add(cmd);
         }
     }
 }
 public void Prepare()
 {
     Reset();
     for (int i = 0; i < m_LoadedCommands.Count; i++)
     {
         IStoryCommand cmd = m_LoadedCommands[i];
         if (null != cmd.LeadCommand)
         {
             m_CommandQueue.Enqueue(cmd.LeadCommand);
         }
         m_CommandQueue.Enqueue(cmd);
     }
 }
Esempio n. 16
0
        protected override bool ExecCommand(StoryInstance instance, long delta, object iterator, object[] args)
        {
            bool ret = true;

            while (ret)
            {
                if (m_CommandQueue.Count == 0 && !m_AlreadyExecute)
                {
                    Evaluate(instance, iterator, args);
                    if (m_Condition.Value != 0)
                    {
                        Prepare();
                        ++m_CurCount;
                        ret = true;
                        m_AlreadyExecute = true;
                    }
                    else
                    {
                        ret = false;
                    }
                }
                else
                {
                    while (m_CommandQueue.Count > 0)
                    {
                        IStoryCommand cmd = m_CommandQueue.Peek();
                        if (cmd.Execute(instance, delta, m_CurCount - 1, args))
                        {
                            break;
                        }
                        else
                        {
                            cmd.Reset();
                            m_CommandQueue.Dequeue();
                        }
                    }
                    ret = true;
                    if (m_CommandQueue.Count > 0)
                    {
                        break;
                    }
                    else
                    {
                        m_AlreadyExecute = false;
                    }
                }
            }
            return(ret);
        }
    /// <summary>
    /// 创建一个命令
    /// </summary>
    /// <param name="commandConfig"></param>
    /// <returns></returns>
    public IStoryCommand CreateCommand(ScriptableData.ISyntaxComponent commandConfig)
    {
        IStoryCommand        command = null;
        string               type    = commandConfig.GetId();
        IStoryCommandFactory factory = GetFactory(type);

        if (factory != null)
        {
            command = factory.Create(commandConfig);
        }
        else
        {
            m_log.Error("创建命令失败,命令类型:" + type);
        }
        return(command);
    }
Esempio n. 18
0
 private void PrepareElse()
 {
     foreach (IStoryCommand cmd in m_ElseCommandQueue)
     {
         cmd.Reset();
     }
     m_ElseCommandQueue.Clear();
     for (int i = 0; i < m_LoadedElseCommands.Count; ++i)
     {
         IStoryCommand cmd = m_LoadedElseCommands[i];
         if (null != cmd.LeadCommand)
         {
             m_ElseCommandQueue.Enqueue(cmd.LeadCommand);
         }
         m_ElseCommandQueue.Enqueue(cmd);
     }
 }
Esempio n. 19
0
 private void Prepare(StoryRuntime runtime)
 {
     if (null != m_InitialCommands)
     {
         for (int i = 0; i < m_InitialCommands.Count; ++i)
         {
             IStoryCommand cmd = m_InitialCommands[i].Clone();
             if (null != cmd.PrologueCommand)
             {
                 runtime.CommandQueue.Enqueue(cmd.PrologueCommand);
             }
             runtime.CommandQueue.Enqueue(cmd);
             if (null != cmd.EpilogueCommand)
             {
                 runtime.CommandQueue.Enqueue(cmd.EpilogueCommand);
             }
         }
     }
 }
 public void Prepare()
 {
     Reset();
     PushLocalInfo(m_LocalInfo);
     PushRuntime(m_Runtime);
     for (int i = 0; i < m_LoadedCommands.Count; i++)
     {
         IStoryCommand cmd = m_LoadedCommands[i];
         if (null != cmd.PrologueCommand)
         {
             m_Runtime.CommandQueue.Enqueue(cmd.PrologueCommand);
         }
         m_Runtime.CommandQueue.Enqueue(cmd);
         if (null != cmd.EpilogueCommand)
         {
             m_Runtime.CommandQueue.Enqueue(cmd.EpilogueCommand);
         }
     }
 }
Esempio n. 21
0
        protected override bool Load(Dsl.StatementData statementData)
        {
            Load(statementData.First);
            int ct = statementData.Functions.Count;

            for (int stIx = 1; stIx < ct; ++stIx)
            {
                Dsl.FunctionData functionData = statementData.Functions[stIx];
                if (null != functionData)
                {
                    string funcId = functionData.GetId();
                    if (funcId == "elseif")
                    {
                        Load(functionData);
                    }
                    else if (funcId == "else")
                    {
                        if (stIx == ct - 1)
                        {
                            for (int i = 0; i < functionData.GetParamNum(); i++)
                            {
                                IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(functionData.GetParam(i));
                                if (null != cmd)
                                {
                                    m_LoadedElseCommands.Add(cmd);
                                }
                            }
                        }
                        else
                        {
#if DEBUG
                            string err = string.Format("[StoryDsl] else must be the last function !!! line:{0}", functionData.GetLine());
                            throw new Exception(err);
#else
                            GameFramework.LogSystem.Error("[StoryDsl] else must be the last function !!!");
#endif
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 22
0
 protected override void Load(Dsl.FunctionData functionData)
 {
     Dsl.CallData callData = functionData.Call;
     if (null != callData)
     {
         if (callData.GetParamNum() > 0)
         {
             m_LoadedList.InitFromDsl(callData.GetParam(0));
         }
         for (int i = 0; i < functionData.Statements.Count; i++)
         {
             IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(functionData.Statements[i]);
             if (null != cmd)
             {
                 m_LoadedCommands.Add(cmd);
             }
         }
     }
     IsCompositeCommand = true;
 }
Esempio n. 23
0
 public void Tick(StoryInstance instance, long delta)
 {
     while (m_queueCommandQueue.Count > 0)
     {
         IStoryCommand cmd = m_queueCommandQueue.Peek();
         if (cmd.Execute(instance, delta))
         {
             break;
         }
         else
         {
             cmd.Reset();
             m_queueCommandQueue.Dequeue();
         }
     }
     if (m_queueCommandQueue.Count == 0)
     {
         m_bIsTriggered = false;
     }
 }
Esempio n. 24
0
 protected override bool Load(Dsl.FunctionData functionData)
 {
     if (functionData.IsHighOrder)
     {
         m_LocalInfoIndex = StoryCommandManager.Instance.AllocLocalInfoIndex();
         Dsl.FunctionData callData = functionData.LowerOrderFunction;
         if (callData.GetParamNum() > 0)
         {
             m_LoadedList.InitFromDsl(callData.GetParam(0));
         }
         for (int i = 0; i < functionData.GetParamNum(); i++)
         {
             IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(functionData.GetParam(i));
             if (null != cmd)
             {
                 m_LoadedCommands.Add(cmd);
             }
         }
     }
     return(true);
 }
Esempio n. 25
0
        private void PrepareIf(int ix)
        {
            Queue <IStoryCommand> queue = m_IfCommandQueue;

            foreach (IStoryCommand cmd in queue)
            {
                cmd.Reset();
            }
            queue.Clear();
            List <IStoryCommand> cmds = m_LoadedIfCommands[ix];

            for (int i = 0; i < cmds.Count; ++i)
            {
                IStoryCommand cmd = cmds[i];
                if (null != cmd.LeadCommand)
                {
                    queue.Enqueue(cmd.LeadCommand);
                }
                queue.Enqueue(cmd);
            }
        }
Esempio n. 26
0
        private void Prepare(StoryMessageHandler handler)
        {
            var runtime = StoryRuntime.New();

            handler.PushRuntime(runtime);
            if (null != m_InitialCommands)
            {
                for (int i = 0; i < m_InitialCommands.Count; ++i)
                {
                    IStoryCommand cmd = m_InitialCommands[i].Clone();
                    if (null != cmd.PrologueCommand)
                    {
                        runtime.CommandQueue.Enqueue(cmd.PrologueCommand);
                    }
                    runtime.CommandQueue.Enqueue(cmd);
                    if (null != cmd.EpilogueCommand)
                    {
                        runtime.CommandQueue.Enqueue(cmd.EpilogueCommand);
                    }
                }
            }
        }
Esempio n. 27
0
        protected override bool ExecCommand(StoryInstance instance, long delta, object iterator, object[] args)
        {
            bool ret = false;

            if (m_Stack.Count > 0)
            {
                StackElementInfo stackInfo = m_Stack.Peek();
                instance.StackVariables = stackInfo.m_StackVariables;
                if (stackInfo.m_CommandQueue.Count == 0 && !stackInfo.m_AlreadyExecute)
                {
                    Evaluate(instance, iterator, args);
                    Prepare(stackInfo);
                    stackInfo.m_AlreadyExecute = true;
                }
                if (stackInfo.m_CommandQueue.Count > 0)
                {
                    while (stackInfo.m_CommandQueue.Count > 0)
                    {
                        IStoryCommand cmd = stackInfo.m_CommandQueue.Peek();
                        if (cmd.Execute(instance, delta, iterator, args))
                        {
                            ret = true;
                            break;
                        }
                        else
                        {
                            cmd.Reset();
                            stackInfo.m_CommandQueue.Dequeue();
                        }
                    }
                }
                if (!ret)
                {
                    PopStack(instance);
                    stackInfo.m_AlreadyExecute = false;
                }
            }
            return(ret);
        }
Esempio n. 28
0
 protected override void Load(Dsl.FunctionData functionData)
 {
     Dsl.CallData callData = functionData.Call;
     if (null != callData)
     {
         for (int i = 0; i < callData.GetParamNum(); ++i)
         {
             Dsl.ISyntaxComponent param = callData.GetParam(i);
             StoryValue           val   = new StoryValue();
             val.InitFromDsl(param);
             m_LoadedIterators.Add(val);
         }
         for (int i = 0; i < functionData.Statements.Count; i++)
         {
             IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(functionData.Statements[i]);
             if (null != cmd)
             {
                 m_LoadedCommands.Add(cmd);
             }
         }
     }
     IsCompositeCommand = true;
 }
Esempio n. 29
0
 protected override bool Load(Dsl.FunctionData functionData)
 {
     if (functionData.IsHighOrder)
     {
         m_LocalInfoIndex = StoryCommandManager.Instance.AllocLocalInfoIndex();
         Dsl.FunctionData callData = functionData.LowerOrderFunction;
         for (int i = 0; i < callData.GetParamNum(); ++i)
         {
             Dsl.ISyntaxComponent param = callData.GetParam(i);
             StoryValue           val   = new StoryValue();
             val.InitFromDsl(param);
             m_LoadedIterators.Add(val);
         }
         for (int i = 0; i < functionData.GetParamNum(); i++)
         {
             IStoryCommand cmd = StoryCommandManager.Instance.CreateCommand(functionData.GetParam(i));
             if (null != cmd)
             {
                 m_LoadedCommands.Add(cmd);
             }
         }
     }
     return(true);
 }
        public static void FinalParse(Dsl.ISyntaxComponent dslInfo)
        {
            string id = dslInfo.GetId();

            if (id == "command")
            {
                string name      = string.Empty;
                var    first     = dslInfo as Dsl.FunctionData;
                var    statement = dslInfo as Dsl.StatementData;
                if (null != first)
                {
                    name = first.Call.GetParamId(0);
                }
                else
                {
                    if (null != statement)
                    {
                        first = statement.First;
                        name  = first.Call.GetParamId(0);
                    }
                }

                IStoryCommandFactory factory = StoryCommandManager.Instance.FindFactory(name);
                if (null != factory)
                {
                    StorySystem.CommonCommands.CompositeCommand cmd = factory.Create() as StorySystem.CommonCommands.CompositeCommand;
                    cmd.InitialCommands.Clear();

                    Dsl.FunctionData bodyFunc = null;
                    if (null != statement)
                    {
                        for (int i = 0; i < statement.GetFunctionNum(); ++i)
                        {
                            var funcData = statement.GetFunction(i);
                            var fid      = funcData.GetId();
                            if (funcData.HaveStatement() && fid != "opts")
                            {
                                bodyFunc = funcData;
                            }
                        }
                    }
                    else
                    {
                        bodyFunc = first;
                    }
                    if (null != bodyFunc)
                    {
                        for (int ix = 0; ix < bodyFunc.GetStatementNum(); ++ix)
                        {
                            Dsl.ISyntaxComponent syntaxComp = bodyFunc.GetStatement(ix);
                            IStoryCommand        sub        = StoryCommandManager.Instance.CreateCommand(syntaxComp);
                            cmd.InitialCommands.Add(sub);
                        }
                    }
                    else
                    {
                        LogSystem.Error("Can't find command {0}'s body", name);
                    }
                }
                else
                {
                    LogSystem.Error("Can't find command {0}'s factory", name);
                }
            }
            else if (id == "value")
            {
                string name      = string.Empty;
                var    first     = dslInfo as Dsl.FunctionData;
                var    statement = dslInfo as Dsl.StatementData;
                if (null != first)
                {
                    name = first.Call.GetParamId(0);
                }
                else
                {
                    if (null != statement)
                    {
                        first = statement.First;
                        name  = first.Call.GetParamId(0);
                    }
                }

                IStoryValueFactory factory = StoryValueManager.Instance.FindFactory(name);
                if (null != factory)
                {
                    StorySystem.CommonValues.CompositeValue val = factory.Build() as StorySystem.CommonValues.CompositeValue;
                    val.InitialCommands.Clear();

                    Dsl.FunctionData bodyFunc = null;
                    if (null != statement)
                    {
                        for (int i = 0; i < statement.GetFunctionNum(); ++i)
                        {
                            var funcData = statement.GetFunction(i);
                            var fid      = funcData.GetId();
                            if (funcData.HaveStatement() && fid != "opts")
                            {
                                bodyFunc = funcData;
                            }
                        }
                    }
                    else
                    {
                        bodyFunc = first;
                    }
                    if (null != bodyFunc)
                    {
                        for (int ix = 0; ix < bodyFunc.GetStatementNum(); ++ix)
                        {
                            Dsl.ISyntaxComponent syntaxComp = bodyFunc.GetStatement(ix);
                            IStoryCommand        sub        = StoryCommandManager.Instance.CreateCommand(syntaxComp);
                            val.InitialCommands.Add(sub);
                        }
                    }
                    else
                    {
                        LogSystem.Error("Can't find value {0}'s body", name);
                    }
                }
                else
                {
                    LogSystem.Error("Can't find value {0}'s factory", name);
                }
            }
        }