Beispiel #1
0
        void Maintenance()
        {
            usedBurnTime         = 0;
            usageExperienceCoeff = 0;
            r = ReliabilityProgress.fetch.GetExponent(part.name);
            currentBaseRatedTime = ProbabilityLib.ATangentCumulativePercentArg(r, topBaseRatedTime);
            setBurnTime          = currentBaseRatedTime * (1 + extraBurnTimePercent * (topMaxRatedTime / topBaseRatedTime - 1) / 100);

            ignitionsLeft = setIgnitions;

            UpdateIndicators();

            reliabilityStatus = "nominal";
            nominal           = true;

            Enable();

            failAtBurnTime = -1;

            maintenanceCost = 0;
            Events["MaintenanceEvent"].guiActiveEditor = false;
        }
Beispiel #2
0
 void SetFailTime()
 {
     failAtBurnTime = ProbabilityLib.ATangentRandom(r, topBaseRatedTime);
 }
Beispiel #3
0
        public void Update()
        {
            if (!inEditor && newBorn)
            {
                throw new Exception("EngineDecay MODULE thinks it is not in editor but not initialized yet");
            }

            if (inEditor)
            {
                newBorn = false;

                if (!useSRBCost)
                {
                    maintenanceCost = (int)(knownPartCost * (1f + extraBurnTimePercent * maxCostRatedTimeCoeff / 100f) * maintenanceAtRatedTimeCoeff * usedBurnTime / setBurnTime);

                    if (maintenanceCost > knownPartCost * (1f + extraBurnTimePercent * maxCostRatedTimeCoeff / 100f))
                    {
                        maintenanceCost = (int)(knownPartCost * (1f + extraBurnTimePercent * maxCostRatedTimeCoeff / 100f));
                    }
                }
                else
                {
                    if (ignitionsLeft == setIgnitions)
                    {
                        maintenanceCost = 0;
                    }
                    else
                    {
                        maintenanceCost = (int)(knownPartCost * maintenanceAtRatedTimeCoeff);
                    }
                }

                if (maintenanceCost > 0 || !nominal)
                {
                    Events["Maintenance"].guiActiveEditor = true;
                    Events["Maintenance"].guiName         = String.Format("maintenance: {0}", maintenanceCost);
                }

                if (prevEBTP != extraBurnTimePercent || prevEIP != extraIgnitionsPercent)
                {
                    if (maintenanceCost > 0)
                    {
                        Maintenance();
                    }

                    if (topBaseRatedTime != -1)
                    {
                        currentBaseRatedTime = ProbabilityLib.ATangentCumulativePercentArg(r, topBaseRatedTime);

                        setBurnTime  = currentBaseRatedTime * (1 + extraBurnTimePercent * (topMaxRatedTime / topBaseRatedTime - 1) / 100);
                        usedBurnTime = 0;
                    }

                    if (baseIgnitions != -1)
                    {
                        setIgnitions  = (int)(baseIgnitions + extraIgnitionsPercent * (maxIgnitions - baseIgnitions) / 100);
                        ignitionsLeft = setIgnitions;
                    }

                    UpdateIndicators();

                    maintenanceCost = 0;
                    Events["Maintenance"].guiActiveEditor = false;

                    prevEBTP = extraBurnTimePercent;
                    prevEIP  = extraIgnitionsPercent;

                    failAtBurnTime = -1;
                }
            }
        }
Beispiel #4
0
        public void Update()
        {
            if (PayToPlaySettings.Enable)
            {
                if (!inEditor && newBorn)
                {
                    throw new Exception("EngineDecay MODULE thinks it is not in editor but not initialized yet");
                }

                if (inEditor)
                {
                    newBorn = false;

                    UpdateMaintenanceCost();

                    List <Part> counterparts = part.symmetryCounterparts;
                    if (counterparts.Count() != 0)
                    {
                        if (symmetryMaintenanceCost == -1)
                        {
                            foreach (Part i in counterparts)
                            {
                                EngineDecay engineDecay = i.FindModuleImplementing <EngineDecay>();
                                if (engineDecay != null)
                                {
                                    symmetryMaintenanceCost += engineDecay.UpdateMaintenanceCost();
                                }
                                else
                                {
                                    UnityEngine.Debug.Log("EngineDecay found a counterpart without EngineDecay, it is really WEIRD!");
                                }
                            }

                            foreach (Part i in counterparts)
                            {
                                EngineDecay engineDecay = i.FindModuleImplementing <EngineDecay>();
                                if (engineDecay != null)
                                {
                                    engineDecay.symmetryMaintenanceCost = symmetryMaintenanceCost;
                                    if (symmetryMaintenanceCost > 0)
                                    {
                                        engineDecay.Events["SymmetryMaintenance"].guiName         = string.Format("Symmetry Maintenance: {0}", symmetryMaintenanceCost);
                                        engineDecay.Events["SymmetryMaintenance"].guiActiveEditor = true;
                                    }
                                }
                                else
                                {
                                    UnityEngine.Debug.Log("EngineDecay found a counterpart without EngineDecay, it is really WEIRD!");
                                }
                            }
                        }

                        if (symmetryMaintenanceCost > 0)
                        {
                            Events["SymmetryMaintenance"].guiName         = string.Format("Symmetry Maintenance: {0}", symmetryMaintenanceCost);
                            Events["SymmetryMaintenance"].guiActiveEditor = true;
                        }
                    }

                    if (prevEBTP != extraBurnTimePercent || prevEIP != extraIgnitionsPercent)
                    {
                        if (maintenanceCost > 0)
                        {
                            SymmetryMaintenance();
                        }

                        if (topBaseRatedTime != -1)
                        {
                            currentBaseRatedTime = ProbabilityLib.ATangentCumulativePercentArg(r, topBaseRatedTime);

                            setBurnTime  = currentBaseRatedTime * (1 + extraBurnTimePercent * (topMaxRatedTime / topBaseRatedTime - 1) / 100);
                            usedBurnTime = 0;
                        }

                        if (baseIgnitions != -1)
                        {
                            setIgnitions  = (int)(baseIgnitions + extraIgnitionsPercent * (maxIgnitions - baseIgnitions) / 100);
                            ignitionsLeft = setIgnitions;
                        }

                        UpdateIndicators();

                        maintenanceCost = 0;
                        Events["MaintenanceEvent"].guiActiveEditor = false;

                        prevEBTP = extraBurnTimePercent;
                        prevEIP  = extraIgnitionsPercent;

                        failAtBurnTime = -1;
                    }
                }
            }
        }