Пример #1
0
        private ScalarValue GetPartRunTime(PartValue part)
        {
            TestFlightCore.TestFlightCore coreMod = GetCoreModule(part);
            if (coreMod != null)
            {
                return(coreMod.GetOperatingTime());
            }

            return(-1f);
        }
Пример #2
0
        private ScalarValue GetPartReliability(PartValue part, ScalarValue time)
        {
            TestFlightCore.TestFlightCore coreMod = GetCoreModule(part);
            if (coreMod != null)
            {
                double currentFailRate = coreMod.GetBaseFailureRate();
                return(TestFlightAPI.TestFlightUtil.FailureRateToReliability(currentFailRate, time));
            }

            return(-1f);
        }
Пример #3
0
        private ScalarValue GetPartFailureRate(PartValue part)
        {
            TestFlightCore.TestFlightCore coreMod = GetCoreModule(part);
            if (coreMod != null)
            {
                double currentFailRate = coreMod.GetBaseFailureRate();
                return(currentFailRate);
            }

            return(-1f);
        }
Пример #4
0
        private ScalarValue GetPartMTBF(PartValue part)
        {
            TestFlightCore.TestFlightCore coreMod = GetCoreModule(part);
            if (coreMod != null)
            {
                double currentFailRate = coreMod.GetBaseFailureRate();
                return(TestFlightAPI.TestFlightUtil.FailureRateToMTBF(currentFailRate, TestFlightUtil.MTBFUnits.SECONDS));
            }

            return(-1f);
        }
Пример #5
0
        private BooleanValue GetPartFailed(PartValue part)
        {
            TestFlightCore.TestFlightCore coreMod = GetCoreModule(part);
            if (coreMod != null)
            {
                Int32 partFailed = coreMod.GetPartStatus();
                return(partFailed > 0);
            }

            return(false);
        }
Пример #6
0
        public void OnTreeSpawn(RDController controller)
        {
            if (TestFlightManagerScenario.Instance == null || controller.nodes == null)
            {
                return;
            }
            List <RDNode> nodes = controller.nodes;

            if (this.baseCost == null)
            {
                baseCost = new Dictionary <string, int>();
                for (int i = 0; i < nodes.Count; i++)
                {
                    RDNode node = nodes[i];
                    if (node != null && node.tech != null)
                    {
                        baseCost.Add(nodes[i].tech.techID, nodes[i].tech.scienceCost);
                    }
                }
            }
            for (int n = 0; n < nodes.Count; n++)
            {
                RDNode node = nodes[n];
                if (node != null && node.tech != null && !node.IsResearched && node.tech.partsAssigned != null)
                {
                    float discount             = 0f;
                    List <AvailablePart> parts = node.tech.partsAssigned;
                    for (int p = 0; p < parts.Count; p++)
                    {
                        if (parts[p] != null)
                        {
                            Part prefab = parts[p].partPrefab;
                            TestFlightPartData partData = TestFlightManagerScenario.Instance.GetPartDataForPart(parts[p].name);
                            if (partData != null && prefab != null)
                            {
                                TestFlightCore core       = (TestFlightCore)prefab.Modules.OfType <TestFlightCore>().FirstOrDefault();
                                float          flightData = partData.GetFloat("flightData");
                                if (core != null && flightData > core.startFlightData)
                                {
                                    discount += (int)(((flightData - core.startFlightData) / (core.maxData - core.startFlightData)) * core.scienceDataValue);
                                }
                            }
                        }
                    }
                    if (discount > 0)
                    {
                        node.tech.scienceCost = (int)Math.Max(0, baseCost[node.tech.techID] - discount);
                    }
                }
            }
        }
Пример #7
0
        private ScalarValue GetIgnitionChance(EngineValue engine)
        {
            TestFlightCore.TestFlightCore coreMod = GetCoreModule(engine);
            if (coreMod != null)
            {
                foreach (var module in engine.Part.Modules)
                {
                    var relMod = module as TestFlightFailure_IgnitionFail;

                    if (relMod != null)
                    {
                        double ignitionChance = relMod.baseIgnitionChance.Evaluate(coreMod.GetInitialFlightData());
                        if (ignitionChance > 0)
                        {
                            return(ignitionChance);
                        }
                    }
                }
            }

            return(-1f);
        }