コード例 #1
0
        public TLUpgrade(ConfigNode node, ModuleEngineConfigs mec)
        {
            techLevelEntryCost    = 0d;
            techLevelSciEntryCost = 0d;

            if (node.HasValue("name"))
            {
                bool   calc = true, sciCalc = true;
                string cfgName = node.GetValue("name");

                if (node.HasValue("entryCost"))
                {
                    if (double.TryParse(node.GetValue("entryCost"), out techLevelEntryCost))
                    {
                        calc = false;
                    }
                }
                if (node.HasValue("sciEntryCost"))
                {
                    if (double.TryParse(node.GetValue("sciEntryCost"), out techLevelSciEntryCost))
                    {
                        sciCalc = false;
                    }
                }
                if (mec.part.partInfo != null)
                {
                    double configCost = 0d;
                    if (node.HasValue("cost"))
                    {
                        double.TryParse(node.GetValue("cost"), out configCost);
                    }
                    if (calc)
                    {
                        // calculate from what we know
                        techLevelEntryCost += configCost * RFSettings.Instance.configEntryCostMultiplier;
                    }
                    if (sciCalc)
                    {
                        techLevelSciEntryCost += configCost * RFSettings.Instance.configScienceCostMultiplier;
                    }
                    techLevelEntryCost    += mec.part.partInfo.entryCost;
                    techLevelSciEntryCost += mec.part.partInfo.entryCost * RFSettings.Instance.configScienceCostMultiplier;
                }
                techLevelEntryCost    = Math.Max(0d, techLevelEntryCost * RFSettings.Instance.techLevelEntryCostFraction);
                techLevelSciEntryCost = Math.Max(0d, techLevelSciEntryCost * RFSettings.Instance.techLevelScienceEntryCostFraction);

                Load(node); // override the values if we have the real values.

                currentTL = mec.techLevel;
                name      = Utilities.GetPartName(mec.part) + cfgName;
            }
        }
コード例 #2
0
        public void onPartPurchased(AvailablePart ap)
        {
            Part part = ap.partPrefab;

            if (part != null)
            {
                for (int i = part.Modules.Count - 1; i >= 0; --i)
                {
                    PartModule m = part.Modules[i];
                    if (m is ModuleEngineConfigs)
                    {
                        ModuleEngineConfigs mec = m as ModuleEngineConfigs;
                        mec.CheckConfigs();
                        for (int j = mec.configs.Count - 1; j >= 0; --j)
                        {
                            ConfigNode cfg = mec.configs[j];
                            if (cfg.HasValue("name"))
                            {
                                string cfgName = cfg.GetValue("name");

                                // TL upgrades
                                if (mec.techLevel >= 0)
                                {
                                    string tUName = Utilities.GetPartName(ap) + cfgName;
                                    SetTLUnlocked(tUName, mec.techLevel);
                                }
                                // unlock the config if it defaults to unlocked, or if autoUnlock is on.
                                bool auto = mec.autoUnlock;
                                if (cfg.HasValue("techRequired"))
                                {
                                    string tech = cfg.GetValue("techRequired");
                                    if (tech != "" && tech != ap.TechRequired)
                                    {
                                        auto = false;
                                    }
                                }
                                bool unlocked = false;
                                if (cfg.HasValue("unlocked"))
                                {
                                    bool.TryParse(cfg.GetValue("unlocked"), out unlocked);
                                }
                                if (auto || unlocked)
                                {
                                    SetConfigUnlock(cfgName, true);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        public void onPartPurchased(AvailablePart ap)
        {
            EntryCostDatabase.SetUnlocked(ap);

            StartCoroutine(updatePartEntryCosts());

            Part part = ap.partPrefab;

            if (part != null)
            {
                for (int i = part.Modules.Count - 1; i >= 0; --i)
                {
                    PartModule m = part.Modules[i];
                    if (m is ModuleEngineConfigs)
                    {
                        ModuleEngineConfigs mec = m as ModuleEngineConfigs;
                        mec.CheckConfigs();
                        for (int j = mec.configs.Count - 1; j >= 0; --j)
                        {
                            ConfigNode cfg = mec.configs[j];
                            if (cfg.HasValue("name"))
                            {
                                string cfgName = cfg.GetValue("name");

                                // TL upgrades
                                if (mec.techLevel >= 0)
                                {
                                    string tUName = Utilities.GetPartName(ap) + cfgName;
                                    SetTLUnlocked(tUName, mec.techLevel);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public static void FillUpgrades()
        {
            if (PartLoader.Instance == null || PartLoader.LoadedPartsList == null)
            {
                Debug.LogError("*RFUM: ERROR: Partloader instance null or list null!");
                return;
            }

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

            for (int a = PartLoader.LoadedPartsList.Count - 1; a >= 0; --a)
            {
                AvailablePart ap = PartLoader.LoadedPartsList[a];
                if (ap == null)
                {
                    continue;
                }
                Part part = ap.partPrefab;
                if (part != null)
                {
                    if (part.Modules == null)
                    {
                        continue;
                    }

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

                                    // config upgrades
                                    EngineConfigUpgrade eConfig = new EngineConfigUpgrade(cfg, cfgName);
                                    configUpgrades[cfgName] = eConfig;
                                    eConfig.unlocked        = false;

                                    // TL upgrades
                                    if (mec.techLevel >= 0)
                                    {
                                        TLUpgrade tU = new TLUpgrade(cfg, mec);
                                        techLevelUpgrades[tU.name] = tU;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        public void FillUpgrades()
        {
            if (PartLoader.Instance == null || PartLoader.LoadedPartsList == null)
            {
                Debug.LogError("*RFUM: ERROR: Partloader instance null or list null!");
                return;
            }
            for (int a = PartLoader.LoadedPartsList.Count - 1; a >= 0; --a)
            {
                AvailablePart ap = PartLoader.LoadedPartsList[a];
                if (ap == null)
                {
                    continue;
                }
                Part part = ap.partPrefab;
                if (part != null)
                {
                    if (part.Modules == null)
                    {
                        continue;
                    }

                    for (int i = part.Modules.Count - 1; i >= 0; --i)
                    {
                        PartModule m = part.Modules[i];
                        if (m is ModuleEngineConfigs)
                        {
                            ModuleEngineConfigs mec = m as ModuleEngineConfigs;
                            mec.CheckConfigs();
                            for (int j = mec.configs.Count - 1; j >= 0; --j)
                            {
                                ConfigNode cfg = mec.configs[j];
                                if (cfg.HasValue("name"))
                                {
                                    string cfgName = cfg.GetValue("name");
                                    if (RFSettings.Instance.usePartNameInConfigUnlock)
                                    {
                                        cfgName = Utilities.GetPartName(ap) + cfgName;
                                    }
                                    // config upgrades
                                    EngineConfigUpgrade eConfig = new EngineConfigUpgrade(cfg, cfgName);
                                    configUpgrades[cfgName] = eConfig;
                                    if (ResearchAndDevelopment.Instance != null && ap.TechRequired != null)
                                    {
                                        if (ResearchAndDevelopment.PartModelPurchased(ap))
                                        {
                                            if (cfg.HasValue("techRequired"))
                                            {
                                                string tech = cfg.GetValue("techRequired");
                                                if (tech != "" && tech != ap.TechRequired)
                                                {
                                                    continue;
                                                }
                                            }

                                            bool unlocked = false;
                                            if (cfg.HasValue("unlocked"))
                                            {
                                                bool.TryParse(cfg.GetValue("unlocked"), out unlocked);
                                            }

                                            if (mec.autoUnlock || unlocked)
                                            {
                                                eConfig.unlocked = true;
                                            }
                                        }
                                        else
                                        {
                                            eConfig.unlocked = false;
                                        }

                                        // TL upgrades
                                        if (mec.techLevel >= 0)
                                        {
                                            TLUpgrade tU = new TLUpgrade(cfg, mec);
                                            techLevelUpgrades[tU.name] = tU;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #6
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;
                                }
                            }
                        }
                    }
                }
            }
        }