예제 #1
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            if (KCT_Utilities.CurrentGameIsMission())
            {
                return;
            }
            Log.Trace("Reading from persistence.");
            GameStates.KSCs.Clear();
            GameStates.ActiveKSC = null;
            //KCT_Utilities.SetActiveKSC("Stock");
            GameStates.TechList.Clear();
            GameStates.TechUpgradesTotal = 0;

            DataStorage kctVS = new DataStorage();
            ConfigNode  CN    = node.GetNode(kctVS.GetType().Name);

            if (CN != null)
            {
                ConfigNode.LoadObjectFromConfig(kctVS, CN);
            }

            foreach (ConfigNode ksc in node.GetNodes("KSC"))
            {
                string name = ksc.GetValue("KSCName");
                SpaceCenterConstruction loaded_KSC = new SpaceCenterConstruction(name);
                loaded_KSC.FromConfigNode(ksc);
                if (loaded_KSC != null && loaded_KSC.KSCName != null && loaded_KSC.KSCName.Length > 0)
                {
                    loaded_KSC.RDUpgrades[1] = GameStates.TechUpgradesTotal;
                    if (GameStates.KSCs.Find(k => k.KSCName == loaded_KSC.KSCName) == null)
                    {
                        GameStates.KSCs.Add(loaded_KSC);
                    }
                }
            }
            KCT_Utilities.SetActiveKSCToRSS();


            ConfigNode tmp = node.GetNode("TechList");

            if (tmp != null)
            {
                foreach (ConfigNode techNode in tmp.GetNodes("Tech"))
                {
                    KCT_TechStorageItem techStorageItem = new KCT_TechStorageItem();
                    ConfigNode.LoadObjectFromConfig(techStorageItem, techNode);
                    KCT_TechItem techItem = techStorageItem.ToTechItem();
                    techItem.protoNode = new ProtoTechNode(techNode.GetNode("ProtoNode"));
                    GameStates.TechList.Add(techItem);
                }
            }

            KCT_GUI.CheckToolbar();
            GameStates.erroredDuringOnLoad.OnLoadFinish();
            //KerbalConstructionTime.DelayedStart();
        }
예제 #2
0
        public static double ParseBuildRateFormula(BuildListVessel.ListType type, int index, SpaceCenterConstruction KSC, bool UpgradedRates = false)
        {
            //N = num upgrades, I = rate index, L = VAB/SPH upgrade level, R = R&D level
            int level = 0, upgrades = 0, levelMax = 0;
            Dictionary <string, string> variables = new Dictionary <string, string>();

            if (type == BuildListVessel.ListType.VAB)
            {
                level    = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding);
                levelMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.VehicleAssemblyBuilding);
                if (KSC.VABUpgrades.Count > index)
                {
                    upgrades = KSC.VABUpgrades[index];
                }
            }
            else if (type == BuildListVessel.ListType.SPH)
            {
                level    = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar);
                levelMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.SpaceplaneHangar);
                if (KSC.SPHUpgrades.Count > index)
                {
                    upgrades = KSC.SPHUpgrades[index];
                }
            }
            if (UpgradedRates)
            {
                upgrades++;
            }
            variables.Add("L", level.ToString());
            variables.Add("LM", level.ToString());
            variables.Add("N", upgrades.ToString());
            variables.Add("I", index.ToString());
            variables.Add("R", KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.ResearchAndDevelopment).ToString());
            //int numNodes = RDController.Instance != null ? RDController.Instance.nodes.FindAll(n => n.IsResearched).Count : 0;
            int numNodes = 0;

            if (ResearchAndDevelopment.Instance != null)
            {
                numNodes = ResearchAndDevelopment.Instance.snapshot.GetData().GetNodes("Tech").Length;
            }
            variables.Add("S", numNodes.ToString());

            AddCrewVariables(variables);

            return(GetStandardFormulaValue("BuildRate", variables));
        }