Esempio n. 1
0
        static BaseParser()
        {
            verbose = LoggingUtil.GetLogLevel(typeof(BaseParser)) == LoggingUtil.LogLevel.VERBOSE;

            // Create the precendence map
            if (precedence.Count == 0)
            {
                for (int i = 0; i < PRECENDENCE_CONSTS.Length; i++)
                {
                    foreach (string token in PRECENDENCE_CONSTS[i])
                    {
                        precedence[token] = i;
                    }
                }
            }

            // Register each type of expression parser
            foreach (Type subclass in ContractConfigurator.GetAllTypes <IExpressionParserRegistrer>())
            {
                if (subclass.IsClass && !subclass.IsAbstract)
                {
                    IExpressionParserRegistrer r = Activator.CreateInstance(subclass) as IExpressionParserRegistrer;
                    var method = subclass.GetMethod("RegisterExpressionParsers");
                    method.Invoke(r, new object[] { });
                }
            }
        }
            static DialogDetail()
            {
                // Load section types
                sectionTypes = new Dictionary <string, Type>();
                IEnumerable <Type> types = ContractConfigurator.GetAllTypes <Section>();

                foreach (Type t in types)
                {
                    sectionTypes[t.Name] = t;
                }
            }
Esempio n. 3
0
        private void Load()
        {
            ConfigNode[] experimentConfigs = GameDatabase.Instance.GetConfigNodes("CC_EXPERIMENT_DEFINITIONS");

            foreach (ConfigNode experimentConfig in experimentConfigs)
            {
                LoggingUtil.LogDebug(this, "Loading experiment definitions for " + experimentConfig.GetValue("name"));

                foreach (ConfigNode config in experimentConfig.GetNodes("EXPERIMENT"))
                {
                    string name = ConfigNodeUtil.ParseValue <string>(config, "name");
                    LoggingUtil.LogVerbose(this, "    loading experiment " + name);

                    ExperimentRules exp = new ExperimentRules(name);
                    experimentRules[name] = exp;

                    exp.ignored                 = ConfigNodeUtil.ParseValue <bool?>(config, "ignored", (bool?)false).Value;
                    exp.requireEVA              = ConfigNodeUtil.ParseValue <bool?>(config, "requireEVA", (bool?)false).Value;
                    exp.requireSurfaceSample    = ConfigNodeUtil.ParseValue <bool?>(config, "requireSurfaceSample", (bool?)false).Value;
                    exp.requireAsteroidTracking = ConfigNodeUtil.ParseValue <bool?>(config, "requireAsteroidTracking", (bool?)false).Value;
                    exp.requireAtmosphere       = ConfigNodeUtil.ParseValue <bool?>(config, "requireAtmosphere", (bool?)false).Value;
                    exp.requireNoAtmosphere     = ConfigNodeUtil.ParseValue <bool?>(config, "requireNoAtmosphere", (bool?)false).Value;
                    exp.requireSurface          = ConfigNodeUtil.ParseValue <bool?>(config, "requireSurface", (bool?)false).Value;
                    exp.requireNoSurface        = ConfigNodeUtil.ParseValue <bool?>(config, "requireNoSurface", (bool?)false).Value;
                    exp.disallowHomeSurface     = ConfigNodeUtil.ParseValue <bool?>(config, "disallowHomeSurface", (bool?)false).Value;
                    exp.disallowHomeFlying      = ConfigNodeUtil.ParseValue <bool?>(config, "disallowHomeFlying", (bool?)false).Value;
                    exp.disallowKSC             = ConfigNodeUtil.ParseValue <bool?>(config, "disallowKSC", (bool?)false).Value;
                    exp.partless                = ConfigNodeUtil.ParseValue <bool?>(config, "partless", (bool?)false).Value;
                    exp.part        = ConfigNodeUtil.ParseValue <List <string> >(config, "part", null);
                    exp.partModule  = ConfigNodeUtil.ParseValue <string>(config, "partModule", null);
                    exp.validBodies = ConfigNodeUtil.ParseValue <List <CelestialBody> >(config, "validBody", null);
                }

                // Add the experiment modules
                foreach (ConfigNode config in experimentConfig.GetNodes("MODULE"))
                {
                    string name = ConfigNodeUtil.ParseValue <string>(config, "name");
                    LoggingUtil.LogVerbose(this, "    loading module " + name);

                    experimentModules.Add(name);
                }
            }

            // Add experiment modules based on class
            foreach (Type expModule in ContractConfigurator.GetAllTypes <ModuleScienceExperiment>())
            {
                LoggingUtil.LogVerbose(this, "    adding module for class " + expModule.Name);
                experimentModules.AddUnique(expModule.Name);
            }

            loaded = true;
        }
Esempio n. 4
0
            public void OnLoad(ConfigNode configNode)
            {
                condition  = ConfigNodeUtil.ParseValue <TriggerCondition>(configNode, "condition");
                position   = ConfigNodeUtil.ParseValue <Position>(configNode, "position");
                width      = ConfigNodeUtil.ParseValue <float>(configNode, "width");
                height     = ConfigNodeUtil.ParseValue <float>(configNode, "height");
                title      = ConfigNodeUtil.ParseValue <string>(configNode, "title", "");
                titleColor = ConfigNodeUtil.ParseValue <Color>(configNode, "titleColor");
                parameter  = ConfigNodeUtil.ParseValue <string>(configNode, "parameter", "");

                IEnumerable <Type> sectionTypes = ContractConfigurator.GetAllTypes <Section>();

                foreach (ConfigNode sectionNode in configNode.GetNodes())
                {
                    Type type = sectionTypes.Where(t => t.Name == sectionNode.name).FirstOrDefault();
                    if (type == null)
                    {
                        throw new ArgumentException("Couldn't find dialog box section of type " + sectionNode.name);
                    }
                    Section section = (Section)Activator.CreateInstance(type);
                    section.OnLoad(sectionNode);
                    sections.Add(section);
                }
            }