示例#1
0
        public void RecalculateBuildRates()
        {
            VABRates.Clear();
            SPHRates.Clear();
            double rate  = 0.1;
            int    index = 0;

            while (rate > 0)
            {
                rate = KCT_MathParsing.ParseBuildRateFormula(KCT_BuildListVessel.ListType.VAB, index, this);
                if (rate >= 0)
                {
                    VABRates.Add(rate);
                }
                index++;
            }
            rate  = 0.1;
            index = 0;
            while (rate > 0)
            {
                rate = KCT_MathParsing.ParseBuildRateFormula(KCT_BuildListVessel.ListType.SPH, index, this);
                if (rate >= 0)
                {
                    SPHRates.Add(rate);
                }
                index++;
            }
        }
示例#2
0
 public void SetBP(double cost)
 {
     // BP = Math.Sqrt(cost) * 2000 * KCT_GameStates.timeSettings.OverallMultiplier;
     BP = KCT_MathParsing.GetStandardFormulaValue("KSCUpgrade", new Dictionary <string, string>()
     {
         { "C", cost.ToString() }, { "O", KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier.ToString() }
     });
 }
示例#3
0
        public double GetRushCost()
        {
            if (rushCost > -1)
            {
                return(rushCost);
            }

            rushCost = KCT_MathParsing.ParseRushCostFormula(this);
            return(rushCost);
        }
示例#4
0
        public KCT_AirlaunchPrep(KCT_BuildListVessel vessel, string id)
        {
            Direction    = PrepDirection.Mount;
            associatedID = id;
            progress     = 0;

            BP   = KCT_MathParsing.ParseAirlaunchTimeFormula(vessel);
            cost = KCT_MathParsing.ParseAirlaunchCostFormula(vessel);
            name = Name_Mount;
        }
示例#5
0
        public double UpdateBuildRate()
        {
            //  double max = double.Parse(KCT_GameStates.formulaSettings.NodeMax);
            double rate = KCT_MathParsing.ParseNodeRateFormula(scienceCost);

            //KCT_MathParsing.GetStandardFormulaValue("Node",
            //  new Dictionary<string, string>() { { "N", KCT_GameStates.TechUpgradesTotal.ToString() }, { "S", scienceCost.ToString() }, {"R", KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.ResearchAndDevelopment).ToString() } });
            //  if (max > 0 && rate > max) rate = max;
            bRate_int = rate;
            return(bRate_int);
        }
示例#6
0
        public double GetTotalCost()
        {
            if (cost == 0 || emptyCost == 0)
            {
                cost            = KCT_Utilities.GetTotalVesselCost(shipNode);
                emptyCost       = KCT_Utilities.GetTotalVesselCost(shipNode, false);
                integrationCost = (float)KCT_MathParsing.ParseIntegrationCostFormula(this);
            }

            return(cost + integrationCost);
        }
示例#7
0
        public static double CalculateBP(double cost)
        {
            double bp = KCT_MathParsing.GetStandardFormulaValue("KSCUpgrade", new Dictionary <string, string>()
            {
                { "C", cost.ToString() }, { "O", KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier.ToString() }
            });

            if (bp <= 0)
            {
                bp = 1;
            }

            return(bp);
        }
示例#8
0
 public KCT_Recon_Rollout(KCT_BuildListVessel vessel, RolloutReconType type, string id, string launchSite = "")
 {
     RRType       = type;
     associatedID = id;
     if (launchSite != "") //For when we add custom launchpads
     {
         launchPadID = launchSite;
     }
     else
     {
         launchPadID = vessel.launchSite;
     }
     //BP = vessel.GetTotalMass() * KCT_GameStates.timeSettings.ReconditioningEffect * KCT_GameStates.timeSettings.OverallMultiplier; //1 day per 50 tons (default) * overall multiplier
     //BP = KCT_MathParsing.GetStandardFormulaValue("Reconditioning", new Dictionary<string, string>() {{"M", vessel.GetTotalMass().ToString()}, {"O", KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier.ToString()},
     //    {"E", KCT_PresetManager.Instance.ActivePreset.timeSettings.ReconditioningEffect.ToString()}, {"X", KCT_PresetManager.Instance.ActivePreset.timeSettings.MaxReconditioning.ToString()}});
     //if (BP > KCT_GameStates.timeSettings.MaxReconditioning) BP = KCT_GameStates.timeSettings.MaxReconditioning;
     progress = 0;
     if (type == RolloutReconType.Reconditioning)
     {
         BP = KCT_MathParsing.ParseReconditioningFormula(vessel, true);
         //BP *= (1 - KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit);
         name = "LaunchPad Reconditioning";
     }
     else if (type == RolloutReconType.Rollout)
     {
         BP = KCT_MathParsing.ParseReconditioningFormula(vessel, false);
         //BP *= KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit;
         name = "Vessel Rollout";
         cost = KCT_MathParsing.ParseRolloutCostFormula(vessel);
     }
     else if (type == RolloutReconType.Rollback)
     {
         BP = KCT_MathParsing.ParseReconditioningFormula(vessel, false);
         //BP *= KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit;
         progress = BP;
         name     = "Vessel Rollback";
     }
     else if (type == RolloutReconType.Recovery)
     {
         BP = KCT_MathParsing.ParseReconditioningFormula(vessel, false);
         //BP *= KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit;
         name = "Vessel Recovery";
         double maxDist = SpaceCenter.Instance.cb.Radius * Math.PI;
         BP += BP * (vessel.DistanceFromKSC / maxDist);
     }
 }
示例#9
0
文件: KSC.cs 项目: ntwest/KCT
        public void RecalculateBuildRates()
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "." + nameof(RecalculateBuildRates);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                VABRates.Clear();
                SPHRates.Clear();
                double rate  = 0.1;
                int    index = 0;
                while (rate > 0)
                {
                    rate = KCT_MathParsing.ParseBuildRateFormula(BuildListVessel.ListType.VAB, index, this);
                    if (rate >= 0)
                    {
                        VABRates.Add(rate);
                    }
                    index++;
                }
                rate  = 0.1;
                index = 0;
                while (rate > 0)
                {
                    rate = KCT_MathParsing.ParseBuildRateFormula(BuildListVessel.ListType.SPH, index, this);
                    if (rate >= 0)
                    {
                        SPHRates.Add(rate);
                    }
                    index++;
                }

                Log.Trace("VAB Rates:");
                foreach (double v in VABRates)
                {
                    Log.Trace(v.ToString());
                }

                Log.Trace("SPH Rates:");
                foreach (double v in SPHRates)
                {
                    Log.Trace(v.ToString());
                }
            }
        }
示例#10
0
文件: KSC.cs 项目: ntwest/KCT
        public void RecalculateUpgradedBuildRates()
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "." + nameof(RecalculateUpgradedBuildRates);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                UpVABRates.Clear();
                UpSPHRates.Clear();
                double rate  = 0.1;
                int    index = 0;
                while (rate > 0)
                {
                    rate = KCT_MathParsing.ParseBuildRateFormula(BuildListVessel.ListType.VAB, index, this, true);
                    if (rate >= 0 && (index == 0 || VABRates[index - 1] > 0))
                    {
                        UpVABRates.Add(rate);
                    }
                    else
                    {
                        break;
                    }
                    index++;
                }
                rate  = 0.1;
                index = 0;
                while (rate > 0)
                {
                    rate = KCT_MathParsing.ParseBuildRateFormula(BuildListVessel.ListType.SPH, index, this, true);
                    if (rate >= 0 && (index == 0 || SPHRates[index - 1] > 0))
                    {
                        UpSPHRates.Add(rate);
                    }
                    else
                    {
                        break;
                    }
                    index++;
                }
            }
        }
示例#11
0
        public void RecalculateBuildRates()
        {
            VABRates.Clear();
            SPHRates.Clear();
            double rate  = 0.1;
            int    index = 0;

            while (rate > 0)
            {
                rate = KCT_MathParsing.ParseBuildRateFormula(KCT_BuildListVessel.ListType.VAB, index, this);
                if (rate >= 0)
                {
                    VABRates.Add(rate);
                }
                index++;
            }
            rate  = 0.1;
            index = 0;
            while (rate > 0)
            {
                rate = KCT_MathParsing.ParseBuildRateFormula(KCT_BuildListVessel.ListType.SPH, index, this);
                if (rate >= 0)
                {
                    SPHRates.Add(rate);
                }
                index++;
            }

            KCTDebug.Log("VAB Rates:");
            foreach (double v in VABRates)
            {
                KCTDebug.Log(v);
            }

            KCTDebug.Log("SPH Rates:");
            foreach (double v in SPHRates)
            {
                KCTDebug.Log(v);
            }
        }
示例#12
0
 public KCT_Recon_Rollout(Vessel vessel, RolloutReconType type, string id, string launchSite)
 {
     RRType       = type;
     associatedID = id;
     launchPadID  = launchSite;
     KCTDebug.Log("New recon_rollout at launchsite: " + launchPadID);
     //BP = vessel.GetTotalMass() * KCT_GameStates.timeSettings.ReconditioningEffect * KCT_GameStates.timeSettings.OverallMultiplier; //1 day per 50 tons (default) * overall multiplier
     //BP = KCT_MathParsing.GetStandardFormulaValue("Reconditioning", new Dictionary<string, string>() {{"M", vessel.GetTotalMass().ToString()}, {"O", KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier.ToString()},
     //    {"E", KCT_PresetManager.Instance.ActivePreset.timeSettings.ReconditioningEffect.ToString()}, {"X", KCT_PresetManager.Instance.ActivePreset.timeSettings.MaxReconditioning.ToString()}});
     //if (BP > KCT_GameStates.timeSettings.MaxReconditioning) BP = KCT_GameStates.timeSettings.MaxReconditioning;
     progress = 0;
     if (type == RolloutReconType.Reconditioning)
     {
         BP = KCT_MathParsing.ParseReconditioningFormula(new KCT_BuildListVessel(vessel), true);
         //BP *= (1 - KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit);
         name = "LaunchPad Reconditioning";
     }
     else if (type == RolloutReconType.Rollout)
     {
         BP = KCT_MathParsing.ParseReconditioningFormula(new KCT_BuildListVessel(vessel), false);
         //BP *= KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit;
         name = "Vessel Rollout";
     }
     else if (type == RolloutReconType.Rollback)
     {
         BP = KCT_MathParsing.ParseReconditioningFormula(new KCT_BuildListVessel(vessel), false);
         //BP *= KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit;
         name     = "Vessel Rollback";
         progress = BP;
     }
     else if (type == RolloutReconType.Recovery)
     {
         //BP *= KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit;
         BP   = KCT_MathParsing.ParseReconditioningFormula(new KCT_BuildListVessel(vessel), false);
         name = "Vessel Recovery";
         double KSCDistance = (float)SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(vessel.latitude, vessel.longitude));
         double maxDist     = SpaceCenter.Instance.cb.Radius * Math.PI;
         BP += BP * (KSCDistance / maxDist);
     }
 }
示例#13
0
        public void RecalculateUpgradedBuildRates()
        {
            UpVABRates.Clear();
            UpSPHRates.Clear();
            double rate  = 0.1;
            int    index = 0;

            while (rate > 0)
            {
                rate = KCT_MathParsing.ParseBuildRateFormula(KCT_BuildListVessel.ListType.VAB, index, this, true);
                if (rate >= 0 && (index == 0 || VABRates[index - 1] > 0))
                {
                    UpVABRates.Add(rate);
                }
                else
                {
                    break;
                }
                index++;
            }
            rate  = 0.1;
            index = 0;
            while (rate > 0)
            {
                rate = KCT_MathParsing.ParseBuildRateFormula(KCT_BuildListVessel.ListType.SPH, index, this, true);
                if (rate >= 0 && (index == 0 || SPHRates[index - 1] > 0))
                {
                    UpSPHRates.Add(rate);
                }
                else
                {
                    break;
                }
                index++;
            }
        }
示例#14
0
        public KCT_BuildListVessel NewCopy(bool RecalcTime)
        {
            KCT_BuildListVessel ret = new KCT_BuildListVessel(this.shipName, this.launchSite, this.effectiveCost, this.buildPoints, this.integrationPoints, this.flag, this.cost, this.integrationCost, (int)GetEditorFacility());

            ret.shipNode = this.shipNode.CreateCopy();

            //refresh all inventory parts to new
            for (int i = ret.ExtractedPartNodes.Count - 1; i >= 0; i--)
            {
                ConfigNode part = ret.ExtractedPartNodes[i];

                //foreach (ConfigNode part in ret.ExtractedPartNodes)
                //{
                ScrapYardWrapper.RefreshPart(part);
            }

            ret.id              = Guid.NewGuid();
            ret.TotalMass       = this.TotalMass;
            ret.emptyMass       = this.emptyMass;
            ret.cost            = this.cost;
            ret.integrationCost = this.integrationCost;
            ret.emptyCost       = this.emptyCost;
            ret.numStageParts   = this.numStageParts;
            ret.numStages       = this.numStages;
            ret.stagePartCost   = this.stagePartCost;

            if (RecalcTime)
            {
                ret.effectiveCost     = KCT_Utilities.GetEffectiveCost(ret.ExtractedPartNodes);
                ret.buildPoints       = KCT_Utilities.GetBuildTime(ret.effectiveCost);
                ret.integrationPoints = KCT_MathParsing.ParseIntegrationTimeFormula(ret);
                ret.integrationCost   = (float)KCT_MathParsing.ParseIntegrationCostFormula(ret);
            }

            return(ret);
        }
示例#15
0
 public KCT_Recon_Rollout(KCT_BuildListVessel vessel, RolloutReconType type, string id)
 {
     RRType       = type;
     associatedID = id;
     //BP = vessel.GetTotalMass() * KCT_GameStates.timeSettings.ReconditioningEffect * KCT_GameStates.timeSettings.OverallMultiplier; //1 day per 50 tons (default) * overall multiplier
     BP = KCT_MathParsing.GetStandardFormulaValue("Reconditioning", new Dictionary <string, string>()
     {
         { "M", vessel.GetTotalMass().ToString() }, { "O", KCT_GameStates.timeSettings.OverallMultiplier.ToString() },
         { "E", KCT_GameStates.timeSettings.ReconditioningEffect.ToString() }, { "X", KCT_GameStates.timeSettings.MaxReconditioning.ToString() }
     });
     //if (BP > KCT_GameStates.timeSettings.MaxReconditioning) BP = KCT_GameStates.timeSettings.MaxReconditioning;
     progress = 0;
     if (type == RolloutReconType.Reconditioning)
     {
         BP  *= (1 - KCT_GameStates.timeSettings.RolloutReconSplit);
         name = "LaunchPad Reconditioning";
     }
     else if (type == RolloutReconType.Rollout)
     {
         BP  *= KCT_GameStates.timeSettings.RolloutReconSplit;
         name = "Vessel Rollout";
     }
     else if (type == RolloutReconType.Rollback)
     {
         BP      *= KCT_GameStates.timeSettings.RolloutReconSplit;
         progress = BP;
         name     = "Vessel Rollback";
     }
     else if (type == RolloutReconType.Recovery)
     {
         BP  *= KCT_GameStates.timeSettings.RolloutReconSplit;
         name = "Vessel Recovery";
         double maxDist = SpaceCenter.Instance.cb.Radius * Math.PI;
         BP += BP * (vessel.DistanceFromKSC / maxDist);
     }
 }
示例#16
0
        public override void OnDecodeFromConfigNode()
        {
            KCT_GameStates.PartTracker   = ListToDict(PartTracker);
            KCT_GameStates.PartInventory = ListToDict(PartInventory);
            KCT_GameStates.BodiesVisited = BodiesVisited;

            /*  KCT_GameStates.ActiveKSC.VABUpgrades = VABUpgrades;
             * KCT_GameStates.ActiveKSC.SPHUpgrades = SPHUpgrades;
             * KCT_GameStates.ActiveKSC.RDUpgrades = RDUpgrades;*/
            KCT_GameStates.PurchasedUpgrades   = PurchasedUpgrades;
            KCT_GameStates.FundsGivenForVessel = fundsFromSimulation;
            KCT_GameStates.activeKSCName       = activeKSC;
            KCT_GUI.simLength = SimulationTime;
            KCT_GameStates.InventorySalesFigures = SalesFigures;
            KCT_GameStates.InventorySaleUpgrades = (float)KCT_MathParsing.GetStandardFormulaValue("InventorySales", new Dictionary <string, string> {
                { "V", "0" }, { "P", SalesFigures.ToString() }
            });
            KCT_GameStates.UpgradesResetCounter = UpgradesResetCounter;
            KCT_GameStates.TechUpgradesTotal    = TechUpgrades;
            KCT_GameStates.PermanentModAddedUpgradesButReallyWaitForTheAPI = SavedUpgradePointsPreAPI;

            SetSettings();
            //KCT_GameStates.firstStart = firstStart;
        }
示例#17
0
        public void vesselRecoverEvent(ProtoVessel v, bool unknownAsOfNow)
        {
            KCTDebug.Log("VesselRecoverEvent");
            if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
            {
                return;
            }
            if (!v.vesselRef.isEVA)
            {
                // if (KCT_GameStates.settings.Debug && HighLogic.LoadedScene != GameScenes.TRACKSTATION && (v.wasControllable || v.protoPartSnapshots.Find(p => p.modules.Find(m => m.moduleName.ToLower() == "modulecommand") != null) != null))
                if (KCT_GameStates.recoveredVessel != null && v.vesselName == KCT_GameStates.recoveredVessel.shipName)
                {
                    //KCT_GameStates.recoveredVessel = new KCT_BuildListVessel(v);
                    //rebuy the ship if ScrapYard isn't overriding funds
                    if (!ScrapYardWrapper.OverrideFunds)
                    {
                        KCT_Utilities.SpendFunds(KCT_GameStates.recoveredVessel.cost, TransactionReasons.VesselRollout); //pay for the ship again
                    }

                    //pull all of the parts out of the inventory
                    //This is a bit funky since we grab the part id from our part, grab the inventory part out, then try to reapply that ontop of our part
                    if (ScrapYardWrapper.Available)
                    {
                        foreach (ConfigNode partNode in KCT_GameStates.recoveredVessel.ExtractedPartNodes)
                        {
                            string     id = ScrapYardWrapper.GetPartID(partNode);
                            ConfigNode inventoryVersion = ScrapYardWrapper.FindInventoryPart(id);
                            if (inventoryVersion != null)
                            {
                                //apply it to our copy of the part
                                ConfigNode ourTracker = partNode.GetNodes("MODULE").FirstOrDefault(n => string.Equals(n.GetValue("name"), "ModuleSYPartTracker", StringComparison.Ordinal));
                                if (ourTracker != null)
                                {
                                    ourTracker.SetValue("TimesRecovered", inventoryVersion.GetValue("_timesRecovered"));
                                    ourTracker.SetValue("Inventoried", inventoryVersion.GetValue("_inventoried"));
                                }
                            }
                        }


                        //process the vessel in ScrapYard
                        ScrapYardWrapper.ProcessVessel(KCT_GameStates.recoveredVessel.ExtractedPartNodes);

                        //reset the BP
                        KCT_GameStates.recoveredVessel.buildPoints       = KCT_Utilities.GetBuildTime(KCT_GameStates.recoveredVessel.ExtractedPartNodes);
                        KCT_GameStates.recoveredVessel.integrationPoints = KCT_MathParsing.ParseIntegrationTimeFormula(KCT_GameStates.recoveredVessel);
                    }
                    if (KCT_GameStates.recoveredVessel.type == KCT_BuildListVessel.ListType.VAB)
                    {
                        KCT_GameStates.ActiveKSC.VABWarehouse.Add(KCT_GameStates.recoveredVessel);
                    }
                    else
                    {
                        KCT_GameStates.ActiveKSC.SPHWarehouse.Add(KCT_GameStates.recoveredVessel);
                    }

                    KCT_GameStates.ActiveKSC.Recon_Rollout.Add(new KCT_Recon_Rollout(KCT_GameStates.recoveredVessel, KCT_Recon_Rollout.RolloutReconType.Recovery, KCT_GameStates.recoveredVessel.id.ToString()));
                    KCT_GameStates.recoveredVessel = null;
                }
            }
        }
示例#18
0
        public KCT_BuildListVessel(Vessel vessel, KCT_BuildListVessel.ListType listType = ListType.None) //For recovered vessels
        {
            id       = Guid.NewGuid();
            shipName = vessel.vesselName;
            shipNode = FromInFlightVessel(vessel, listType);
            if (listType != ListType.None)
            {
                this.type = listType;
            }

            cost      = KCT_Utilities.GetTotalVesselCost(shipNode);
            emptyCost = KCT_Utilities.GetTotalVesselCost(shipNode, false);
            TotalMass = 0;
            emptyMass = 0;

            HashSet <int> stages = new HashSet <int>();

            //for (int i = vessel.protoVessel.protoPartSnapshots.Count - 1; i >= 0; i--)
            //{
            //    ProtoPartSnapshot p = vessel.protoVessel.protoPartSnapshots[i];

            foreach (ProtoPartSnapshot p in vessel.protoVessel.protoPartSnapshots)
            {
                stages.Add(p.inverseStageIndex);

                if (p.partPrefab != null && p.partPrefab.Modules.Contains <LaunchClamp>())
                {
                    continue;
                }

                TotalMass += p.mass;
                emptyMass += p.mass;
                //for (int i1 = p.resources.Count - 1; i1 >= 0; i1--)
                //{
                //    ProtoPartResourceSnapshot rsc = p.resources[i1];

                foreach (ProtoPartResourceSnapshot rsc in p.resources)
                {
                    PartResourceDefinition def = PartResourceLibrary.Instance.GetDefinition(rsc.resourceName);
                    if (def != null)
                    {
                        TotalMass += def.density * (float)rsc.amount;
                    }
                }
            }
            cannotEarnScience = true;
            numStages         = stages.Count;
            // FIXME ignore stageable part count and cost - it'll be fixed when we put this back in the editor.

            effectiveCost = KCT_Utilities.GetEffectiveCost(shipNode.GetNodes("PART").ToList());
            buildPoints   = KCT_Utilities.GetBuildTime(effectiveCost);
            flag          = HighLogic.CurrentGame.flagURL;

            DistanceFromKSC = (float)SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(vessel.latitude, vessel.longitude));

            rushBuildClicks   = 0;
            integrationPoints = KCT_MathParsing.ParseIntegrationTimeFormula(this);
            integrationCost   = (float)KCT_MathParsing.ParseIntegrationCostFormula(this);

            progress = buildPoints + integrationPoints;
        }
示例#19
0
        public KCT_BuildListVessel(ShipConstruct s, String ls, double effCost, double bP, String flagURL)
        {
            ship     = s;
            shipNode = s.SaveShip();
            shipName = s.shipName;
            //Get total ship cost
            float fuel;

            cost      = s.GetShipCosts(out emptyCost, out fuel);
            TotalMass = s.GetShipMass(true, out emptyMass, out fuel);

            HashSet <int> stages = new HashSet <int>();

            numStageParts = 0;
            stagePartCost = 0d;
            //for (int i = s.Parts.Count - 1; i >= 0; i--)
            //{
            //    Part p = s.Parts[i];

            foreach (Part p in s.Parts)
            {
                if (p.stagingOn)
                {
                    stages.Add(p.inverseStage);
                    ++numStageParts;
                    stagePartCost += p.GetModuleCosts(p.partInfo.cost, ModifierStagingSituation.CURRENT) + p.partInfo.cost;
                }
            }
            numStages = stages.Count;

            launchSite    = ls;
            effectiveCost = effCost;
            buildPoints   = bP;
            progress      = 0;
            flag          = flagURL;
            if (s.shipFacility == EditorFacility.VAB)
            {
                type = ListType.VAB;
            }
            else if (s.shipFacility == EditorFacility.SPH)
            {
                type = ListType.SPH;
            }
            else
            {
                type = ListType.None;
            }
            id = Guid.NewGuid();
            cannotEarnScience = false;

            //get the crew from the editorlogic
            DesiredManifest = new List <string>();
            if (CrewAssignmentDialog.Instance?.GetManifest()?.CrewCount > 0)
            {
                //var pcm = CrewAssignmentDialog.Instance.GetManifest().GetAllCrew(true) ?? new List<ProtoCrewMember>();
                //for (int i = pcm.Count - 1; i >= 0; i--)
                //{
                //    ProtoCrewMember crew = pcm[i];
                foreach (ProtoCrewMember crew in CrewAssignmentDialog.Instance.GetManifest().GetAllCrew(true) ?? new List <ProtoCrewMember>())
                {
                    DesiredManifest.Add(crew?.name ?? string.Empty);
                }
            }

            if (effectiveCost == default(double))
            {
                // Can only happen in older saves that didn't have Effective cost persisted as a separate field
                // This code should be safe to remove after a while.
                effectiveCost = KCT_Utilities.GetEffectiveCost(shipNode.GetNodes("PART").ToList());
            }

            integrationPoints = KCT_MathParsing.ParseIntegrationTimeFormula(this);
            integrationCost   = (float)KCT_MathParsing.ParseIntegrationCostFormula(this);
        }
示例#20
0
 public KCT_Recon_Rollout(Vessel vessel, RolloutReconType type, string id, string launchSite)
 {
     RRType       = type;
     associatedID = id;
     launchPadID  = launchSite;
     KCTDebug.Log("New recon_rollout at launchsite: " + launchPadID);
     progress = 0;
     if (type == RolloutReconType.Reconditioning)
     {
         try
         {
             BP = KCT_MathParsing.ParseReconditioningFormula(new KCT_BuildListVessel(vessel), true);
         }
         catch
         {
             KCTDebug.Log("Error while determining BP for recon_rollout");
         }
         finally
         {
             name = "LaunchPad Reconditioning";
         }
     }
     else if (type == RolloutReconType.Rollout)
     {
         try
         {
             BP = KCT_MathParsing.ParseReconditioningFormula(new KCT_BuildListVessel(vessel), false);
         }
         catch
         {
             KCTDebug.Log("Error while determining BP for recon_rollout");
         }
         finally
         {
             name = "Vessel Rollout";
         }
     }
     else if (type == RolloutReconType.Rollback)
     {
         try
         {
             BP = KCT_MathParsing.ParseReconditioningFormula(new KCT_BuildListVessel(vessel), false);
         }
         catch
         {
             KCTDebug.Log("Error while determining BP for recon_rollout");
         }
         finally
         {
             name     = "Vessel Rollback";
             progress = BP;
         }
     }
     else if (type == RolloutReconType.Recovery)
     {
         try
         {
             BP = KCT_MathParsing.ParseReconditioningFormula(new KCT_BuildListVessel(vessel), false);
         }
         catch
         {
             KCTDebug.Log("Error while determining BP for recon_rollout");
         }
         finally
         {
             name = "Vessel Recovery";
             double KSCDistance = (float)SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(vessel.latitude, vessel.longitude));
             double maxDist     = SpaceCenter.Instance.cb.Radius * Math.PI;
             BP += BP * (KSCDistance / maxDist);
         }
     }
 }
示例#21
0
        public static double CalculateBP(double cost, SpaceCenterFacility facilityType)
        {
            int isAdm = 0, isAC = 0, isLP = 0, isMC = 0, isRD = 0, isRW = 0, isTS = 0, isSPH = 0, isVAB = 0;

            switch (facilityType)
            {
            case SpaceCenterFacility.Administration:
                isAdm = 1;
                break;

            case SpaceCenterFacility.AstronautComplex:
                isAC = 1;
                break;

            case SpaceCenterFacility.LaunchPad:
                isLP = 1;
                break;

            case SpaceCenterFacility.MissionControl:
                isMC = 1;
                break;

            case SpaceCenterFacility.ResearchAndDevelopment:
                isRD = 1;
                break;

            case SpaceCenterFacility.Runway:
                isRW = 1;
                break;

            case SpaceCenterFacility.TrackingStation:
                isTS = 1;
                break;

            case SpaceCenterFacility.SpaceplaneHangar:
                isSPH = 1;
                break;

            case SpaceCenterFacility.VehicleAssemblyBuilding:
                isVAB = 1;
                break;

            default:
                break;
            }
            var variables = new Dictionary <string, string>()
            {
                { "C", cost.ToString() },
                { "O", KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier.ToString() },
                { "Adm", isAdm.ToString() },
                { "AC", isAC.ToString() },
                { "LP", isLP.ToString() },
                { "MC", isMC.ToString() },
                { "RD", isRD.ToString() },
                { "RW", isRW.ToString() },
                { "TS", isTS.ToString() },
                { "SPH", isSPH.ToString() },
                { "VAB", isVAB.ToString() }
            };

            double bp = KCT_MathParsing.GetStandardFormulaValue("KSCUpgrade", variables);

            if (bp <= 0)
            {
                bp = 1;
            }

            return(bp);
        }