コード例 #1
0
 private GUIStyle getStyle(VesselInfo.Status status)
 {
     if (status == VesselInfo.Status.CRITICAL)
     {
         return(criticalStyle);
     }
     else if (status == VesselInfo.Status.LOW)
     {
         return(warningStyle);
     }
     else
     {
         return(labelStyle);
     }
 }
コード例 #2
0
        private void ShowWarnings(Vessel vessel, double resourceRemaining, double max, double consumptionRate, string resourceName, ref VesselInfo.Status status)
        {
            const double multiplier   = 1.1;
            const double warningLevel = 0.10;

            int   currentWarpRateIndex = TimeWarp.CurrentRateIndex;
            float currentWarpRate      = TimeWarp.fetch.warpRates[currentWarpRateIndex];

            if ((resourceRemaining / consumptionRate) < (currentWarpRate * multiplier))
            {
                if (status != VesselInfo.Status.CRITICAL)
                {
                    if (currentWarpRateIndex > 0)
                    {
                        Debug.Log("TAC Life Support (LifeSupportController) [" + this.GetInstanceID().ToString("X") + "][" + Time.time + "]: @CRITICAL, warp rate: " + currentWarpRate);
                        TimeWarp.SetRate(currentWarpRateIndex - 1, false);
                    }
                    else
                    {
                        ScreenMessages.PostScreenMessage(vessel.vesselName + " - " + resourceName + " depleted!", 15.0f, ScreenMessageStyle.UPPER_CENTER);
                        Debug.Log("TAC Life Support (LifeSupportController) [" + this.GetInstanceID().ToString("X") + "][" + Time.time + "]: " + vessel.vesselName + " - " + resourceName + " depleted!");
                        status = VesselInfo.Status.CRITICAL;
                    }
                }
            }
            else if (resourceRemaining < (max * warningLevel))
            {
                if (status != VesselInfo.Status.LOW)
                {
                    if (currentWarpRateIndex > 0)
                    {
                        Debug.Log("TAC Life Support (LifeSupportController) [" + this.GetInstanceID().ToString("X") + "][" + Time.time + "]: @LOW, warp rate: " + currentWarpRate);
                        TimeWarp.SetRate(currentWarpRateIndex - 1, false);
                    }
                    else
                    {
                        ScreenMessages.PostScreenMessage(vessel.vesselName + " - " + resourceName + " is running out!", 15.0f, ScreenMessageStyle.UPPER_CENTER);
                        Debug.Log("TAC Life Support (LifeSupportController) [" + this.GetInstanceID().ToString("X") + "][" + Time.time + "]: " + vessel.vesselName + " - " + resourceName + " is running out!");
                        status = VesselInfo.Status.LOW;
                    }
                }
            }
            else
            {
                status = VesselInfo.Status.GOOD;
            }
        }
コード例 #3
0
        private void ShowWarnings(Vessel vessel, double resourceRemaining, double max, double rate, string resourceName, ref VesselInfo.Status status)
        {
            double criticalLevel = rate;       // 1 second of resources
            double warningLevel  = max * 0.10; // 10% full

            if (resourceRemaining < criticalLevel)
            {
                if (status != VesselInfo.Status.CRITICAL)
                {
                    ScreenMessages.PostScreenMessage(vessel.vesselName + " - " + resourceName + " depleted!", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                    this.Log(vessel.vesselName + " - " + resourceName + " depleted!");
                    status = VesselInfo.Status.CRITICAL;
                    TimeWarp.SetRate(0, false);
                }
            }
            else if (resourceRemaining < warningLevel)
            {
                if (status == VesselInfo.Status.CRITICAL)
                {
                    status = VesselInfo.Status.LOW;
                }
                else if (status != VesselInfo.Status.LOW)
                {
                    ScreenMessages.PostScreenMessage(vessel.vesselName + " - " + resourceName + " is running out!", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                    this.Log(vessel.vesselName + " - " + resourceName + " is running out!");
                    status = VesselInfo.Status.LOW;
                    TimeWarp.SetRate(0, false);
                }
            }
            else
            {
                status = VesselInfo.Status.GOOD;
            }
        }