예제 #1
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            EntryCostDatabase.Load(node.GetNode("Unlocks"));

            EntryCostDatabase.UpdatePartEntryCosts();

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                foreach (ConfigNode n in node.GetNodes("TLUpgrade"))
                {
                    TLUpgrade tU = null;
                    if (n.HasValue("name"))
                    {
                        string tlName = n.GetValue("name");
                        if (techLevelUpgrades.TryGetValue(tlName, out tU))
                        {
                            tU.Load(n);
                        }
                        else
                        {
                            tU = new TLUpgrade(n);
                            techLevelUpgrades[tlName] = tU;
                        }
                    }
                }
            }
        }
예제 #2
0
        public double TLSciEntryCost(string tUName)
        {
            TLUpgrade tU = null;

            if (techLevelUpgrades.TryGetValue(tUName, out tU))
            {
                return(tU.techLevelSciEntryCost);
            }
            log.error("TL {0} does not exist!", tUName);
            return(0d);
        }
예제 #3
0
        public int TLUnlocked(string tUName)
        {
            TLUpgrade tU = null;

            if (techLevelUpgrades.TryGetValue(tUName, out tU))
            {
                return(tU.currentTL);
            }
            log.error("TL {0} does not exist!", tUName);
            return(-1);
        }
예제 #4
0
        public void SetTLUnlocked(string tUName, int newVal)
        {
            TLUpgrade tU = null;

            if (techLevelUpgrades.TryGetValue(tUName, out tU))
            {
                if (newVal > tU.currentTL)
                {
                    tU.currentTL = newVal;
                }
            }
            else
            {
                log.error("TL {0} does not exist!", tUName);
            }
        }
예제 #5
0
        public static void FillUpgrades()
        {
            if (PartLoader.Instance == null || PartLoader.LoadedPartsList == null)
            {
                log.error("Partloader instance null or list null!");
                return;
            }

            configUpgrades    = new Dictionary <string, EngineConfigUpgrade>();
            techLevelUpgrades = new Dictionary <string, TLUpgrade>();

            for (int a = PartLoader.LoadedPartsList.Count; a-- > 0;)
            {
                AvailablePart ap = PartLoader.LoadedPartsList[a];

                if (ap == null || ap.partPrefab == null)
                {
                    continue;
                }

                Part part = ap.partPrefab;
                if (part.Modules == null)
                {
                    continue;
                }

                for (int i = part.Modules.Count; i-- > 0;)
                {
                    PartModule m = part.Modules[i];
                    if (m is ModuleEngineConfigs)
                    {
                        ModuleEngineConfigs mec = m as ModuleEngineConfigs;
                        mec.CheckConfigs();
                        for (int j = mec.configs.Count; j-- > 0;)
                        {
                            ConfigNode cfg     = mec.configs[j];
                            string     cfgName = cfg.GetValue("name");
                            if (!string.IsNullOrEmpty(cfgName))
                            {
                                if (RFSettings.Instance.usePartNameInConfigUnlock)
                                {
                                    cfgName = Utilities.GetPartName(ap) + cfgName;
                                }

                                // config upgrades
                                if (!configUpgrades.ContainsKey(cfgName))
                                {
                                    EngineConfigUpgrade eConfig = new EngineConfigUpgrade(cfg, cfgName);
                                    configUpgrades[cfgName] = eConfig;
                                }

                                // TL upgrades
                                if (mec.techLevel >= 0)
                                {
                                    TLUpgrade tU = new TLUpgrade(cfg, mec);
                                    techLevelUpgrades[tU.name] = tU;
                                }
                            }
                        }
                    }
                }
            }
        }