// Returns the Operational Time or the time, in MET, since the last time the part was fully functional.
        // If a part is currently in a failure state, return will be -1 and the part should not fail again
        // This counts from mission start time until a failure, at which point it is reset to the time the
        // failure is repaired.  It is important to understand this is NOT the total flight time of the part.
        public static float GetOperatingTime(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(0);
            }

            return(core.GetOperatingTime());
        }
        public static float ForceRepair(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(-1);
            }

            return(core.ForceRepair());
        }
        // Cause a failure to occur, either a random failure or a specific one
        // If fallbackToRandom is true, then if the specified failure can't be found or can't be triggered, a random failure will be triggered instead
        public static void TriggerFailure(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return;
            }

            core.TriggerFailure();
        }
        public static void DisableFailure(Part part, String failureModuleName)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return;
            }

            core.DisableFailure(failureModuleName);
        }
        // Returns the total engineer bonus for the current vessel's current crew based on the given part's desired per engineer level bonus
        public static float GetEngineerDataBonus(Part part, float partEngineerBonus)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(1);
            }

            return(core.GetEngineerDataBonus(partEngineerBonus));
        }
        public static float ModifyFlightTime(Part part, float modifier, bool additive)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(0);
            }

            return(core.ModifyFlightTime(modifier, additive));
        }
        public static float SetDataCap(Part part, float cap)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(float.MaxValue);
            }

            return(core.SetDataCap(cap));
        }
        public static bool IsPartOperating(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(false);
            }

            return(core.IsPartOperating());
        }
        public static double GetRepairTime(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(-1);
            }

            return(core.GetRepairTime());
        }
Beispiel #10
0
        // Get the base or static failure rate
        public static double GetBaseFailureRate(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(TestFlightUtil.MIN_FAILURE_RATE);
            }

            return(core.GetBaseFailureRate());
        }
        public static double ModifyFlightTimeForScope(Part part, double modifier, String scope, bool additive)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(0);
            }

            return(core.ModifyFlightTimeForScope(modifier, scope, additive));
        }
        public static double SetDataRateLimit(Part part, double limit)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(1);
            }

            return(core.SetDataRateLimit(limit));
        }
        public static double SetDataCap(Part part, double cap)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(double.MaxValue);
            }

            return(core.SetDataCap(cap));
        }
        public static double SetTriggerMomentaryFailureModifierForScope(Part part, String trigger, double multiplier, PartModule owner, String scope)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(TestFlightUtil.MIN_FAILURE_RATE);
            }

            return(core.SetTriggerMomentaryFailureModifierForScope(trigger, multiplier, owner, scope));
        }
        public static double GetFlightTimeForScope(Part part, String scope)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(0);
            }

            return(core.GetFlightTimeForScope(scope));
        }
        public static FloatCurve GetBaseReliabilityCurveForScope(Part part, String scope)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(null);
            }

            return(core.GetBaseReliabilityCurveForScope(scope));
        }
        public static double GetMomentaryFailureRateForTriggerForScope(Part part, String trigger, String scope)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(TestFlightUtil.MIN_FAILURE_RATE);
            }

            return(core.GetMomentaryFailureRateForTriggerForScope(trigger, scope));
        }
        public static string GetRequirementsTooltip(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return("");
            }

            return(core.GetRequirementsTooltip());
        }
Beispiel #19
0
        public static float GetMaximumFlightData(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(0);
            }

            return(core.GetMaximumData());
        }
        /// <summary>
        /// 0 = OK, 1 = Minor Failure, 2 = Failure, 3 = Major Failure, -1 = Could not find TestFlight Core on Part
        /// </summary>
        /// <returns>The part status.</returns>
        public static int GetPartStatus(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(-1);
            }

            return(core.GetPartStatus());
        }
        // Simply converts the failure rate to a MTBF number, without any string formatting
        public static double FailureRateToMTBF(Part part, string alias, double failureRate, int units)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part, alias);

            if (core == null)
            {
                failureRate = Math.Max(failureRate, TestFlightUtil.MIN_FAILURE_RATE);
                double mtbfSeconds = 1.0f / failureRate;
                return(mtbfSeconds);
            }

            return(core.FailureRateToMTBF(failureRate, (TestFlightUtil.MTBFUnits)units));
        }
        // PART methods
        // These API methods all operate on a specific part, and therefore the first parameter is always the Part to which it should be applied

        public static bool TestFlightAvailable(Part part)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public static double GetBestMomentaryFailureRate(Part part, string alias)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part, alias);

            if (core == null)
            {
                return(-1);
            }

            MomentaryFailureRate mfr = core.GetBestMomentaryFailureRate();

            if (mfr.valid)
            {
                return(mfr.failureRate);
            }
            else
            {
                return(-1);
            }
        }
        public static double GetWorstMomentaryFailureRateForScope(Part part, String scope)
        {
            ITestFlightCore core = TestFlightInterface.GetCore(part);

            if (core == null)
            {
                return(-1);
            }

            MomentaryFailureRate mfr;

            mfr = core.GetWorstMomentaryFailureRateForScope(scope);
            if (mfr.valid)
            {
                return(mfr.failureRate);
            }
            else
            {
                return(-1);
            }
        }