InitSharedData() public method

public InitSharedData ( ) : void
return void
 public static void FirstParse(Dsl.DslInfo dslInfo)
 {
     string id = dslInfo.GetId();
     if (id == "command") {
         if (dslInfo.Functions.Count == 2) {
             StorySystem.CommonCommands.CompositeCommand cmd = new CommonCommands.CompositeCommand();
             cmd.InitSharedData();
             Dsl.FunctionData first = dslInfo.First;
             cmd.Name = first.Call.GetParamId(0);
             Dsl.FunctionData second = dslInfo.Second;
             for (int ix = 0; ix < second.Call.GetParamNum(); ++ix) {
                 cmd.ArgNames.Add(second.Call.GetParamId(ix));
             }
             //注册
             StoryCommandManager.Instance.RegisterCommandFactory(cmd.Name, new CommonCommands.CompositeCommandFactory(cmd), true);
         }
     } else if (id == "value") {
         if (dslInfo.Functions.Count == 3) {
             StorySystem.CommonValues.CompositeValue val = new CommonValues.CompositeValue();
             val.InitSharedData();
             Dsl.FunctionData first = dslInfo.First;
             val.Name = first.Call.GetParamId(0);
             Dsl.FunctionData second = dslInfo.Second;
             for (int ix = 0; ix < second.Call.GetParamNum(); ++ix) {
                 val.ArgNames.Add(second.Call.GetParamId(ix));
             }
             Dsl.FunctionData third = dslInfo.Functions[2];
             val.ReturnName = third.Call.GetParamId(0);
             //注册
             StoryValueManager.Instance.RegisterValueFactory(val.Name, new CommonValues.CompositeValueFactory(val), true);
         }
     }
 }
Exemplo n.º 2
0
        public static void FirstParse(Dsl.DslInfo dslInfo)
        {
            string id = dslInfo.GetId();

            if (id == "command")
            {
                if (dslInfo.Functions.Count == 2)
                {
                    StorySystem.CommonCommands.CompositeCommand cmd = new CommonCommands.CompositeCommand();
                    cmd.InitSharedData();
                    Dsl.FunctionData first = dslInfo.First;
                    cmd.Name = first.Call.GetParamId(0);
                    Dsl.FunctionData second = dslInfo.Second;
                    for (int ix = 0; ix < second.Call.GetParamNum(); ++ix)
                    {
                        cmd.ArgNames.Add(second.Call.GetParamId(ix));
                    }
                    //注册
                    StoryCommandManager.Instance.RegisterCommandFactory(cmd.Name, new CommonCommands.CompositeCommandFactory(cmd), true);
                }
            }
            else if (id == "value")
            {
                if (dslInfo.Functions.Count == 3)
                {
                    StorySystem.CommonValues.CompositeValue val = new CommonValues.CompositeValue();
                    val.InitSharedData();
                    Dsl.FunctionData first = dslInfo.First;
                    val.Name = first.Call.GetParamId(0);
                    Dsl.FunctionData second = dslInfo.Second;
                    for (int ix = 0; ix < second.Call.GetParamNum(); ++ix)
                    {
                        val.ArgNames.Add(second.Call.GetParamId(ix));
                    }
                    Dsl.FunctionData third = dslInfo.Functions[2];
                    val.ReturnName = third.Call.GetParamId(0);
                    //注册
                    StoryValueManager.Instance.RegisterValueFactory(val.Name, new CommonValues.CompositeValueFactory(val), true);
                }
            }
        }
        public static void FirstParse(Dsl.ISyntaxComponent dslInfo)
        {
            string id = dslInfo.GetId();

            if (id == "command")
            {
                StorySystem.CommonCommands.CompositeCommand cmd = new CommonCommands.CompositeCommand();
                cmd.InitSharedData();
                var first = dslInfo as Dsl.FunctionData;
                if (null != first)
                {
                    cmd.Name = first.Call.GetParamId(0);
                }
                else
                {
                    var statement = dslInfo as Dsl.StatementData;
                    if (null != statement)
                    {
                        first    = statement.First;
                        cmd.Name = first.Call.GetParamId(0);
                        for (int i = 1; i < statement.GetFunctionNum(); ++i)
                        {
                            var funcData = statement.GetFunction(i);
                            var fid      = funcData.GetId();
                            if (fid == "args")
                            {
                                for (int ix = 0; ix < funcData.Call.GetParamNum(); ++ix)
                                {
                                    cmd.ArgNames.Add(funcData.Call.GetParamId(ix));
                                }
                            }
                            else if (fid == "opts")
                            {
                                for (int ix = 0; ix < funcData.GetStatementNum(); ++ix)
                                {
                                    var fcomp = funcData.GetStatement(ix);
                                    var fcd   = fcomp as Dsl.CallData;
                                    if (null != fcd)
                                    {
                                        cmd.OptArgs.Add(fcd.GetId(), fcd.GetParam(0));
                                    }
                                }
                            }
                            else if (fid == "body")
                            {
                            }
                            else
                            {
                                LogSystem.Error("Command {0} unknown part '{1}'", cmd.Name, fid);
                            }
                        }
                    }
                }
                //注册
                StoryCommandManager.Instance.RegisterCommandFactory(cmd.Name, new CommonCommands.CompositeCommandFactory(cmd), true);
            }
            else if (id == "value")
            {
                StorySystem.CommonValues.CompositeValue val = new CommonValues.CompositeValue();
                val.InitSharedData();
                var first = dslInfo as Dsl.FunctionData;
                if (null != first)
                {
                    val.Name = first.Call.GetParamId(0);
                }
                else
                {
                    var statement = dslInfo as Dsl.StatementData;
                    if (null != statement)
                    {
                        first    = statement.First;
                        val.Name = first.Call.GetParamId(0);
                        for (int i = 1; i < statement.GetFunctionNum(); ++i)
                        {
                            var funcData = statement.GetFunction(i);
                            var fid      = funcData.GetId();
                            if (fid == "args")
                            {
                                for (int ix = 0; ix < funcData.Call.GetParamNum(); ++ix)
                                {
                                    val.ArgNames.Add(funcData.Call.GetParamId(ix));
                                }
                            }
                            else if (fid == "ret")
                            {
                                val.ReturnName = funcData.Call.GetParamId(0);
                            }
                            else if (fid == "opts")
                            {
                                for (int ix = 0; ix < funcData.GetStatementNum(); ++ix)
                                {
                                    var fcomp = funcData.GetStatement(ix);
                                    var fcd   = fcomp as Dsl.CallData;
                                    if (null != fcd)
                                    {
                                        val.OptArgs.Add(fcd.GetId(), fcd.GetParam(0));
                                    }
                                }
                            }
                            else if (fid == "body")
                            {
                            }
                            else
                            {
                                LogSystem.Error("Value {0} unknown part '{1}'", val.Name, fid);
                            }
                        }
                    }
                }
                //注册
                StoryValueManager.Instance.RegisterValueFactory(val.Name, new CommonValues.CompositeValueFactory(val), true);
            }
        }