Exemple #1
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);
     }
 }
Exemple #2
0
        public static double ParseBuildRateFormula(KCT_BuildListVessel.ListType type, int index, KCT_KSC KSC, bool UpgradedRates = false)
        {
            //N = num upgrades, I = rate index, L = VAB/SPH upgrade level, R = R&D level
            int level = 0, upgrades = 0;
            Dictionary<string, string> variables = new Dictionary<string, string>();
            if (type == KCT_BuildListVessel.ListType.VAB)
            {
                level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding);
                if (KSC.VABUpgrades.Count > index)
                    upgrades = KSC.VABUpgrades[index];
            }
            else if (type == KCT_BuildListVessel.ListType.SPH)
            {
                level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar);
                if (KSC.SPHUpgrades.Count > index)
                    upgrades = KSC.SPHUpgrades[index];
            }
            if (UpgradedRates)
                upgrades++;
            variables.Add("L", level.ToString());
            variables.Add("N", upgrades.ToString());
            variables.Add("I", index.ToString());
            variables.Add("R", KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.ResearchAndDevelopment).ToString());

            return GetStandardFormulaValue("BuildRate", variables);
        }
        /* public static double ParseMath(string input, Dictionary<string, string> variables)
        {
           // KCTDebug.Log("Input_raw: " + input);
            string raw = input;
            foreach (KeyValuePair<string, string> kvp in variables)
            {
                if (input.Contains("[" + kvp.Key + "]"))
                {
                    input = input.Replace("[" + kvp.Key + "]", kvp.Value);
                }
            }
            //KCTDebug.Log("Input_replaced: " + input);

            double currentVal = 0;
            string stack = "";
            string lastOp = "+";
            string[] ops = { "+", "-", "*", "/", "%", "^", "(", "e", "E" };
            string[] functions = { "min", "max", "l", "L", "abs", "sign" };
            for (int i = 0; i < input.Length; ++i)
            {
                string ch = input[i].ToString();
                bool isOp = false, isFunction = false;
                //  KCTDebug.Log(ch);
                foreach (string op in ops)
                {
                    if (op == ch)
                    {
                        isOp = true;
                        break;
                    }
                }
                if (!isOp)
                {
                    foreach (string fun in functions)
                    {
                        if (fun[0] == input[i])
                        {
                            isFunction = true;
                            break;
                        }
                    }
                }

                if (isOp)
                {
                    if (ch == "-" && (stack.Trim() == ""))
                    {
                        stack += ch;
                    }
                    else if (ch == "e" || ch == "E")
                    {
                        int index=i+2;
                        for (index = i+2; index < input.Length; ++index)
                        {
                            string ch2 = input[index].ToString();
                            if (ops.Contains(ch2))
                                break;
                        }
                        string sub = input.Substring(i + 1, index - i - 1);
                        double exp = ParseMath(sub, variables);
                        double newVal = double.Parse(stack) * Math.Pow(10, exp);
                        currentVal = DoMath(currentVal, lastOp, newVal.ToString());
                        stack = "0";
                        lastOp = "+";
                        i = index - 1;
                    }
                    else if (ch == "(")
                    {
                        int j = FindEndParenthesis(input, i)[0];
                        string sub = input.Substring(i + 1, j - i - 1);
                        string val = ParseMath(sub, variables).ToString();
                        input = input.Substring(0, i) + val + input.Substring(j + 1);
                        --i;
                    }
                    else
                    {
                        currentVal = DoMath(currentVal, lastOp, stack);
                        lastOp = ch;
                        stack = "";
                    }
                }
                else if (isFunction)
                {
                    int subStart = input.IndexOf('(', i)+1;
                    string function = input.Substring(i, subStart - i - 1);
                    //KCTDebug.Log(function);
                    int[] parenComma = FindEndParenthesis(input, subStart-1);
                    int j = parenComma[0];
                    int comma = parenComma[1];
                    string sub = input.Substring(subStart, j - subStart);
                    KCTDebug.Log("fn: "+function+" sub: "+sub);
                    double val = 0.0;

                    if (function == "l")
                    {
                        val = ParseMath(sub, variables);
                        val = Math.Log(val);
                    }
                    else if (function == "L")
                    {
                        val = ParseMath(sub, variables);
                        val = Math.Log10(val);
                    }
                    else if (function == "max" || function == "min")
                    {
                        string[] parts = new string[2];
                        parts[0] = input.Substring(subStart, parenComma[1] - subStart);
                        parts[1] = input.Substring(parenComma[1] + 1, j - parenComma[1] - 1);
                        double sub1 = ParseMath(parts[0], variables);
                        double sub2 = ParseMath(parts[1], variables);
                        if (function == "max")
                            val = Math.Max(sub1, sub2);
                        else if (function == "min")
                            val = Math.Min(sub1, sub2);
                    }
                    else if (function == "sign")
                    {
                        val = ParseMath(sub, variables);
                        if (val >= 0)
                            val = 1;
                        else
                            val = -1;
                    }
                    else if (function == "abs")
                    {
                        val = ParseMath(sub, variables);
                        val = Math.Abs(val);
                    }

                    input = input.Substring(0, i) + val.ToString() + input.Substring(j + 1);
                    i--;
                }
                else
                {
                    stack += ch;
                }
            }
            currentVal = DoMath(currentVal, lastOp, stack);
            KCTDebug.Log("(" + raw + ")=(" + input + ")=" + currentVal);
            return currentVal;
        }

        private static int[] FindEndParenthesis(string str, int curPos)
        {
            int depth = 0;
            int j = 0, commaPos = -1;
            for (j = curPos + 1; j < str.Length; ++j)
            {
                if (str[j] == '(') depth++;
                if (str[j] == ')') depth--;

                if (str[j] == ',' && depth == 0)
                    commaPos = j;

                if (depth < 0)
                {
                    break;
                }
            }
            return new int[] {j, commaPos};
        }

        private static double DoMath(double currentVal, string operation, string newVal)
        {
            double newValue = 0;
            if (String.IsNullOrEmpty(newVal))
                return currentVal;
            if (!double.TryParse(newVal, out newValue))
            {
                Debug.LogError("[KCT] Tried to parse a non-double value: " + newVal);
                return currentVal;
            }
            switch (operation)
            {
                case "+": currentVal += newValue; break;
                case "-": currentVal -= newValue; break;
                case "*": currentVal *= newValue; break;
                case "/": currentVal /= newValue; break;
                case "%": currentVal = currentVal % long.Parse(newVal); break;
                case "^": currentVal = Math.Pow(currentVal, newValue); break;
                default: break;
            }

            return currentVal;
        }*/
        public static double ParseBuildRateFormula(KCT_BuildListVessel.ListType type, int index, KCT_KSC KSC, bool UpgradedRates = false)
        {
            //N = num upgrades, I = rate index, L = VAB/SPH upgrade level, R = R&D level
            int level = 0, upgrades = 0;
            Dictionary<string, string> variables = new Dictionary<string, string>();
            if (type == KCT_BuildListVessel.ListType.VAB)
            {
                level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding);
                if (KSC.VABUpgrades.Count > index)
                    upgrades = KSC.VABUpgrades[index];
            }
            else if (type == KCT_BuildListVessel.ListType.SPH)
            {
                level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar);
                if (KSC.SPHUpgrades.Count > index)
                    upgrades = KSC.SPHUpgrades[index];
            }
            if (UpgradedRates)
                upgrades++;
            variables.Add("L", 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);
        }
 public KCT_BuildListVessel NewCopy(bool RecalcTime)
 {
     KCT_BuildListVessel ret = new KCT_BuildListVessel(this.shipName, this.launchSite, this.buildPoints, this.flag, this.cost);
     ret.shipNode = this.shipNode.CreateCopy();
     ret.id = Guid.NewGuid();
     if (RecalcTime)
     {
         ret.buildPoints = KCT_Utilities.GetBuildTime(ret.ExtractedPartNodes, true, this.InventoryParts.Count > 0);
     }
     ret.TotalMass = this.TotalMass;
     return ret;
 }
Exemple #5
0
        public static double GetBuildRate(KCT_BuildListVessel ship)
        {
            if (ship.type == KCT_BuildListVessel.ListType.None)
                ship.FindTypeFromLists();

            if (ship.type == KCT_BuildListVessel.ListType.VAB)
                return GetBuildRate(ship.KSC.VABList.IndexOf(ship), ship.type, ship.KSC);
            else if (ship.type == KCT_BuildListVessel.ListType.SPH)
                return GetBuildRate(ship.KSC.SPHList.IndexOf(ship), ship.type, ship.KSC);
            else
                return 0;
        }
Exemple #6
0
 public static double GetBuildRate(int index, KCT_BuildListVessel.ListType type, KCT_KSC KSC, bool UpgradedRate = false)
 {
     if (KSC == null) KSC = KCT_GameStates.ActiveKSC;
     double ret = 0;
     if (type == KCT_BuildListVessel.ListType.VAB)
     {
         if (!UpgradedRate && KSC.VABRates.Count > index)
         {
             return KSC.VABRates[index];
         }
         else if (UpgradedRate && KSC.UpVABRates.Count > index)
         {
             return KSC.UpVABRates[index];
         }
         else
         {
             return 0;
         }
     }
     else if (type == KCT_BuildListVessel.ListType.SPH)
     {
         if (!UpgradedRate && KSC.SPHRates.Count > index)
         {
             return KSC.SPHRates[index];
         }
         else if (UpgradedRate && KSC.UpSPHRates.Count > index)
         {
             return KSC.UpSPHRates[index];
         }
         else
         {
             return 0;
         }
     }
     else if (type == KCT_BuildListVessel.ListType.TechNode)
     {
         ret = KCT_GameStates.TechList[index].BuildRate;
     }
     return ret;
 }
Exemple #7
0
        public static KCT_BuildListVessel AddVesselToBuildList(KCT_BuildListVessel blv, Dictionary<String, int> inventory)
        {
            if (CurrentGameIsCareer())
            {
                //Check upgrades
                //First, mass limit
                List<string> facilityChecks = blv.MeetsFacilityRequirements();
                if (facilityChecks.Count != 0)
                {
                    //ScreenMessages.PostScreenMessage("Did not pass editor checks!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                    //ScreenMessages.PostScreenMessage(failedReason, 4.0f, ScreenMessageStyle.UPPER_CENTER);
                    PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Failed editor checks!", "Warning! This vessel did not pass the editor checks! It will still be built, but you will not be able to launch it without upgrading. Listed below are the failed checks:\n" + String.Join("\n", facilityChecks.ToArray()), "Acknowledged", false, HighLogic.UISkin);
                    //return null;
                }

                double totalCost = blv.GetTotalCost();
                double prevFunds = Funding.Instance.Funds;
                //double newFunds = SpendFunds(totalCost, TransactionReasons.VesselRollout);
                if (totalCost > prevFunds)
                {
                    KCTDebug.Log("Tried to add " + blv.shipName + " to build list but not enough funds.");
                    KCTDebug.Log("Vessel cost: " + GetTotalVesselCost(blv.shipNode) + ", Current funds: " + prevFunds);
                    var msg = new ScreenMessage("Not Enough Funds To Build!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                    ScreenMessages.PostScreenMessage(msg);
                    return null;
                }
                else
                {
                    SpendFunds(totalCost, TransactionReasons.VesselRollout);
                }
            }
            string type = "";
            if (blv.type == KCT_BuildListVessel.ListType.VAB)
            {
                KCT_GameStates.ActiveKSC.VABList.Add(blv);
                type = "VAB";
            }
            else if (blv.type == KCT_BuildListVessel.ListType.SPH)
            {
                KCT_GameStates.ActiveKSC.SPHList.Add(blv);
                type = "SPH";
            }
            if (inventory.Count > 0)
            {
                foreach (ConfigNode p in blv.ExtractedPartNodes)
                {
                   // if (KCT_Utilities.RemovePartFromInventory(p, inventory))
                    {
                        if (!KCT_Utilities.PartIsProcedural(p))
                            AddToDict(blv.InventoryParts, PartNameFromNode(p) + GetTweakScaleSize(p), KCT_Utilities.RemovePartFromInventory(p, inventory));
                           // blv.InventoryParts.Add(PartNameFromNode(p) + GetTweakScaleSize(p), 1);
                        else
                            AddToDict(blv.InventoryParts, PartNameFromNode(p), KCT_Utilities.RemovePartFromInventory(p, inventory));
                           // blv.InventoryParts.Add(PartNameFromNode(p), (int)(1000 * GetPartCostFromNode(p, false)));
                    }
                }
            }
            KCTDebug.Log("Added " + blv.shipName + " to " + type + " build list at KSC "+KCT_GameStates.ActiveKSC.KSCName+". Cost: "+blv.cost);
            KCTDebug.Log("Launch site is " + blv.launchSite);
            //KCTDebug.Log("Cost Breakdown (total, parts, fuel): " + blv.totalCost + ", " + blv.dryCost + ", " + blv.fuelCost);
            var message = new ScreenMessage("[KCT] Added " + blv.shipName + " to " + type + " build list.", 4.0f, ScreenMessageStyle.UPPER_CENTER);
            ScreenMessages.PostScreenMessage(message);
            return blv;
        }
Exemple #8
0
 public static KCT_BuildListVessel AddVesselToBuildList(KCT_BuildListVessel blv, bool useInventory)
 {
     Dictionary<String, int> inventory = new Dictionary<string, int>();
     if (useInventory)
         inventory = KCT_GameStates.PartInventory;
     return AddVesselToBuildList(blv, inventory);
 }
Exemple #9
0
        public static KCT_BuildListVessel AddVesselToBuildList(KCT_BuildListVessel blv, Dictionary<String, int> inventory)
        {
            if (CurrentGameIsCareer())
            {
                //Check upgrades
                //First, mass limit
                bool passed = true;
                string failedReason = "";
                if (blv.type == KCT_BuildListVessel.ListType.VAB)
                {
                    if (blv.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.LaunchPad)))
                    {
                        passed = false;
                        failedReason = "Mass limit exceeded!";
                    }
                    if (blv.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding)))
                    {
                        passed = false;
                        failedReason = "Part Count limit exceeded!";
                    }
                    if (HighLogic.LoadedSceneIsEditor)
                    {
                        PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(EditorLogic.fetch.ship, SpaceCenterFacility.LaunchPad, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.LaunchPad)));
                        if (!sizeCheck.Test())
                        {
                            passed = false;
                            failedReason = "Size limits exceeded!";
                        }
                    }
                }
                else if (blv.type == KCT_BuildListVessel.ListType.SPH)
                {
                    if (blv.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway)))
                    {
                        passed = false;
                        failedReason = "Mass limit exceeded!";
                    }
                    if (blv.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar)))
                    {
                        passed = false;
                        failedReason = "Part Count limit exceeded!";
                    }
                    if (HighLogic.LoadedSceneIsEditor)
                    {
                        PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(EditorLogic.fetch.ship, SpaceCenterFacility.Runway, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway)));
                        if (!sizeCheck.Test())
                        {
                            passed = false;
                            failedReason = "Size limits exceeded!";
                        }
                    }
                }
                if (!passed)
                {
                    ScreenMessages.PostScreenMessage("Did not pass editor checks!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                    ScreenMessages.PostScreenMessage(failedReason, 4.0f, ScreenMessageStyle.UPPER_CENTER);
                    return null;
                }

                double totalCost = blv.GetTotalCost();
                double prevFunds = Funding.Instance.Funds;
                //double newFunds = SpendFunds(totalCost, TransactionReasons.VesselRollout);
                if (totalCost > prevFunds)
                {
                    KCTDebug.Log("Tried to add " + blv.shipName + " to build list but not enough funds.");
                    KCTDebug.Log("Vessel cost: " + GetTotalVesselCost(blv.shipNode) + ", Current funds: " + prevFunds);
                    var msg = new ScreenMessage("Not Enough Funds To Build!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                    ScreenMessages.PostScreenMessage(msg, true);
                    return null;
                }
                else
                {
                    SpendFunds(totalCost, TransactionReasons.VesselRollout);
                }
            }
            string type = "";
            if (blv.type == KCT_BuildListVessel.ListType.VAB)
            {
                KCT_GameStates.ActiveKSC.VABList.Add(blv);
                type = "VAB";
            }
            else if (blv.type == KCT_BuildListVessel.ListType.SPH)
            {
                KCT_GameStates.ActiveKSC.SPHList.Add(blv);
                type = "SPH";
            }
            if (inventory.Count > 0)
            {
                foreach (ConfigNode p in blv.ExtractedPartNodes)
                {
                   // if (KCT_Utilities.RemovePartFromInventory(p, inventory))
                    {
                        if (!KCT_Utilities.PartIsProcedural(p))
                            AddToDict(blv.InventoryParts, PartNameFromNode(p) + GetTweakScaleSize(p), KCT_Utilities.RemovePartFromInventory(p, inventory));
                           // blv.InventoryParts.Add(PartNameFromNode(p) + GetTweakScaleSize(p), 1);
                        else
                            AddToDict(blv.InventoryParts, PartNameFromNode(p), KCT_Utilities.RemovePartFromInventory(p, inventory));
                           // blv.InventoryParts.Add(PartNameFromNode(p), (int)(1000 * GetPartCostFromNode(p, false)));
                    }
                }
            }
            KCTDebug.Log("Added " + blv.shipName + " to " + type + " build list at KSC "+KCT_GameStates.ActiveKSC.KSCName+". Cost: "+blv.cost);
            //KCTDebug.Log("Cost Breakdown (total, parts, fuel): " + blv.totalCost + ", " + blv.dryCost + ", " + blv.fuelCost);
            var message = new ScreenMessage("[KCT] Added " + blv.shipName + " to " + type + " build list.", 4.0f, ScreenMessageStyle.UPPER_CENTER);
            ScreenMessages.PostScreenMessage(message, true);
            return blv;
        }
Exemple #10
0
        public static bool RecoverActiveVesselToStorage(KCT_BuildListVessel.ListType listType)
        {
            ShipConstruct test = new ShipConstruct();
            try
            {
                KCTDebug.Log("Attempting to recover active vessel to storage.");
                GamePersistence.SaveGame("KCT_Backup", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                KCT_GameStates.recoveredVessel = new KCT_BuildListVessel(FlightGlobals.ActiveVessel);
                KCT_GameStates.recoveredVessel.type = listType;
                if (listType == KCT_BuildListVessel.ListType.VAB)
                    KCT_GameStates.recoveredVessel.launchSite = "LaunchPad";
                else
                    KCT_GameStates.recoveredVessel.launchSite = "Runway";

                //check for symmetry parts and remove those references if they can't be found
                RemoveMissingSymmetry(KCT_GameStates.recoveredVessel.shipNode);

                //test if we can actually convert it
                bool success = test.LoadShip(KCT_GameStates.recoveredVessel.shipNode);
                if (success)
                    ShipConstruction.CreateBackup(test);
                KCTDebug.Log("Load test reported success = " + success);
                if (!success)
                {
                    KCT_GameStates.recoveredVessel = null;
                    return false;
                }

                GameEvents.OnVesselRecoveryRequested.Fire(FlightGlobals.ActiveVessel);
                return true;
            }
            catch
            {
                Debug.LogError("[KCT] Error while recovering craft into inventory.");
                KCT_GameStates.recoveredVessel = null;
                ShipConstruction.ClearBackups();
                return false;
            }
        }
Exemple #11
0
 public static bool LaunchFacilityIntact(KCT_BuildListVessel.ListType type)
 {
     bool intact = true;
     if (type == KCT_BuildListVessel.ListType.VAB)
     {
         //intact = new PreFlightTests.FacilityOperational("LaunchPad", "building").Test();
         intact = new PreFlightTests.FacilityOperational("LaunchPad", "LaunchPad").Test();
     }
     else if (type == KCT_BuildListVessel.ListType.SPH)
     {
        /* if (!new PreFlightTests.FacilityOperational("Runway", "End09").Test())
             intact = false;
         if (!new PreFlightTests.FacilityOperational("Runway", "End27").Test())
             intact = false;*/
        /* if (!new PreFlightTests.FacilityOperational("Runway", "Section1").Test())
             intact = false;
         if (!new PreFlightTests.FacilityOperational("Runway", "Section2").Test())
             intact = false;
         if (!new PreFlightTests.FacilityOperational("Runway", "Section3").Test())
             intact = false;
         if (!new PreFlightTests.FacilityOperational("Runway", "Section4").Test())
             intact = false;
         if (!new PreFlightTests.FacilityOperational("Runway", "Section5").Test())
             intact = false;*/
         if (!new PreFlightTests.FacilityOperational("Runway", "Runway").Test())
             intact = false;
     }
     return intact;
 }
            public KCT_BuildListVessel ToBuildListVessel()
            {
                KCT_BuildListVessel ret = new KCT_BuildListVessel(shipName, launchSite, buildTime, flag, cost);
                ret.progress = progress;
                if (InventoryParts != null)
                {
                    int ignore;
                    if (InventoryParts.Count > 1 && int.TryParse(InventoryParts[1], out ignore))
                        ret.InventoryParts = KCT_Utilities.PartListToDictAlternating(InventoryParts);
                    else
                        ret.InventoryParts = KCT_Utilities.PartListToDict(InventoryParts);

                }
                ret.id = new Guid(shipID);
                ret.cannotEarnScience = cannotEarnScience;
                ret.TotalMass = mass;
                ret.DistanceFromKSC = kscDistance;
                return ret;
            }
 public BuildListItem FromBuildListVessel(KCT_BuildListVessel blv)
 {
     this.progress = blv.progress;
     this.buildTime = blv.buildPoints;
     this.launchSite = blv.launchSite;
     this.flag = blv.flag;
     //this.shipURL = blv.shipURL;
     this.shipName = blv.shipName;
     this.InventoryParts = KCT_Utilities.PartDictToList(blv.InventoryParts);
     this.shipID = blv.id.ToString();
     this.cannotEarnScience = blv.cannotEarnScience;
     this.cost = blv.cost;
     this.mass = blv.TotalMass;
     this.kscDistance = blv.DistanceFromKSC;
     return this;
 }
 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);
     }
 }
        public static double ParseReconditioningFormula(KCT_BuildListVessel vessel, bool isReconditioning)
        {
            // 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()}});
            Dictionary<string, string> variables = new Dictionary<string, string>();

            double loadedMass, emptyMass, loadedCost, emptyCost;
            loadedCost = vessel.GetTotalCost();
            emptyCost = vessel.emptyCost;
            loadedMass = vessel.GetTotalMass();
            emptyMass = vessel.emptyMass;

            int EditorLevel = 0, LaunchSiteLvl = 0;
            int isVABVessel = 0;
            if (vessel.type == KCT_BuildListVessel.ListType.VAB)
            {
                EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding);
                LaunchSiteLvl = KCT_GameStates.ActiveKSC.ActiveLPInstance.level;//KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad);
                isVABVessel = 1;
            }
            else
            {
                EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar);
                LaunchSiteLvl = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.Runway);
            }
            double BP = vessel.buildPoints;
            double OverallMult = KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier;
            double ReconEffect = KCT_PresetManager.Instance.ActivePreset.timeSettings.ReconditioningEffect;
            double MaxRecon = KCT_PresetManager.Instance.ActivePreset.timeSettings.MaxReconditioning;

            variables.Add("M", loadedMass.ToString());
            variables.Add("m", emptyMass.ToString());
            variables.Add("C", loadedCost.ToString());
            variables.Add("c", emptyCost.ToString());
            variables.Add("VAB", isVABVessel.ToString());
            variables.Add("BP", BP.ToString());
            variables.Add("L", LaunchSiteLvl.ToString());
            variables.Add("EL", EditorLevel.ToString());
            variables.Add("O", OverallMult.ToString());
            variables.Add("E", ReconEffect.ToString());
            variables.Add("X", MaxRecon.ToString());
            int isRecon = isReconditioning ? 1 : 0;
            variables.Add("RE", isRecon.ToString());
            variables.Add("S", KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit.ToString());

            AddCrewVariables(variables);

            return GetStandardFormulaValue("Reconditioning", variables);
        }
Exemple #16
0
 public static KCT_BuildListVessel AddVesselToBuildList(Dictionary<String, int> inventory)
 {
     KCT_BuildListVessel blv = new KCT_BuildListVessel(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, KCT_Utilities.GetBuildTime(EditorLogic.fetch.ship.SaveShip().GetNodes("PART").ToList(), true, inventory), EditorLogic.FlagURL);
     blv.shipName = EditorLogic.fetch.shipNameField.text;
     return AddVesselToBuildList(blv, inventory);
 }
        public static double ParseRolloutCostFormula(KCT_BuildListVessel vessel)
        {
            if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled || !KCT_PresetManager.Instance.ActivePreset.generalSettings.ReconditioningTimes)
                return 0;

            double loadedMass, emptyMass, loadedCost, emptyCost;
            loadedCost = vessel.GetTotalCost();
            emptyCost = vessel.emptyCost;
            loadedMass = vessel.GetTotalMass();
            emptyMass = vessel.emptyMass;

            int EditorLevel = 0, LaunchSiteLvl = 0;
            int isVABVessel = 0;
            if (vessel.type == KCT_BuildListVessel.ListType.None)
                vessel.FindTypeFromLists();
            if (vessel.type == KCT_BuildListVessel.ListType.VAB)
            {
                EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding);
                LaunchSiteLvl = KCT_GameStates.ActiveKSC.ActiveLPInstance.level;//KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad);
                isVABVessel = 1;
            }
            else if (vessel.type == KCT_BuildListVessel.ListType.SPH)
            {
                EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar);
                LaunchSiteLvl = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.Runway);
            }
            double BP = vessel.buildPoints;

            Dictionary<string, string> variables = new Dictionary<string, string>();
            variables.Add("M", loadedMass.ToString());
            variables.Add("m", emptyMass.ToString());
            variables.Add("C", loadedCost.ToString());
            variables.Add("c", emptyCost.ToString());
            variables.Add("VAB", isVABVessel.ToString());
            variables.Add("BP", BP.ToString());
            variables.Add("L", LaunchSiteLvl.ToString());
            variables.Add("EL", EditorLevel.ToString());

            AddCrewVariables(variables);

            return GetStandardFormulaValue("RolloutCost", variables);
        }
Exemple #18
0
 public static KCT_BuildListVessel AddVesselToBuildList(bool useInventory)
 {
     KCT_BuildListVessel blv = new KCT_BuildListVessel(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, KCT_Utilities.GetBuildTime(EditorLogic.fetch.ship.SaveShip().GetNodes("PART").ToList(), true, useInventory), EditorLogic.FlagURL);
     blv.shipName = EditorLogic.fetch.shipNameField.Text;
     Dictionary<String, int> inventory = new Dictionary<string,int>();
     if (useInventory)
         inventory = KCT_GameStates.PartInventory;
     return AddVesselToBuildList(blv, inventory);
 }