예제 #1
0
        private LifeSupportVesselDisplayStat GetEvaKerbalStats(Vessel kerbal)
        {
            var lblColor = "FFD966";
            var vstat    = new LifeSupportVesselDisplayStat();

            vstat.VesselName = String.Format("<color=#{0}>{1}</color>", lblColor, kerbal.vesselName);
            vstat.LastUpdate = kerbal.missionTime;
            var sitString = "(EVA)";

            var remEVATime = LifeSupportScenario.Instance.settings.GetSettings().EVATime - kerbal.missionTime;
            var timeString = LifeSupportUtilities.SmartDurationDisplay(Math.Max(0, remEVATime));

            if (remEVATime > 0)
            {
                vstat.SummaryLabel = String.Format(
                    "<color=#3DB1FF>{0}/{1} - </color><color=#9EE4FF>{2}</color><color=#3DB1FF> time remaining</color>"
                    , kerbal.mainBody.bodyName
                    , sitString
                    , timeString.Substring(timeString.IndexOf(':') + 1));
            }
            else
            {
                vstat.SummaryLabel = "<color=#FF8585>EVA Time Expired</color>";
            }

            vstat.crew = new List <LifeSupportCrewDisplayStat>();
            return(vstat);
        }
예제 #2
0
 private void DisplayVesselStats(LifeSupportVesselDisplayStat v)
 {
     GUILayout.BeginHorizontal();
     GUILayout.Label("", _labelStyle, GUILayout.Width(10));
     GUILayout.Label(v.VesselName, _labelStyle, GUILayout.Width(155));
     GUILayout.Label(v.SummaryLabel, _labelStyle, GUILayout.Width(570));
     GUILayout.EndHorizontal();
     foreach (var c in v.crew)
     {
         DisplayCrewStats(c);
     }
 }
예제 #3
0
        private List <LifeSupportVesselDisplayStat> UpdateGUIStats()
        {
            var secondsPerDay   = GameSettings.KERBIN_TIME ? (21600) : (86400);
            var useHabPenalties = (LifeSupportScenario.Instance.settings.GetSettings().NoHomeEffectVets +
                                   LifeSupportScenario.Instance.settings.GetSettings().NoHomeEffect > 0);

            LifeSupportManager.Instance.UpdateVesselStats();

            var statList = new List <LifeSupportVesselDisplayStat>();

            var checkVessels = new List <Guid>();

            foreach (var v in FlightGlobals.Vessels.Where(v => v.isEVA))
            {
                checkVessels.Add(v.id);
            }


            foreach (var vslId in checkVessels)
            {
                var vsl = FlightGlobals.Vessels.FirstOrDefault(v => v.id == vslId);
                if (vsl == null)
                {
                    continue;
                }

                var lblColor = "FFD966";
                var vstat    = new LifeSupportVesselDisplayStat();
                vstat.VesselName = String.Format("<color=#{0}>{1}</color>", lblColor, vsl.vesselName);
                vstat.LastUpdate = vsl.missionTime;
                var sitString = "(EVA)";

                var remEVATime = LifeSupportScenario.Instance.settings.GetSettings().EVATime - vsl.missionTime;
                var timeString = LifeSupportUtilities.SecondsToKerbinTime(Math.Max(0, remEVATime));

                if (remEVATime > 0)
                {
                    vstat.SummaryLabel = String.Format(
                        "<color=#3DB1FF>{0}/{1} - </color><color=#9EE4FF>{2}</color><color=#3DB1FF> time remaining</color>"
                        , vsl.mainBody.bodyName
                        , sitString
                        , timeString.Substring(timeString.IndexOf(':') + 1));
                }
                else
                {
                    vstat.SummaryLabel = "<color=#FF8585>EVA Time Expired</color>";
                }

                vstat.crew = new List <LifeSupportCrewDisplayStat>();
                statList.Add(vstat);
            }

            var vesselList = new List <VesselSupplyStatus>();

            vesselList.AddRange(LifeSupportManager.Instance.VesselSupplyInfo);


            foreach (var vsl in vesselList)
            {
                var    vstat      = new LifeSupportVesselDisplayStat();
                Vessel thisVessel = FlightGlobals.Vessels.First(v => v.id.ToString() == vsl.VesselId);
                double supmult    = LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount *Convert.ToDouble(vsl.NumCrew) * vsl.RecyclerMultiplier;
                var    supPerDay  = secondsPerDay * supmult;
                var    estFood    = supmult * (Planetarium.GetUniversalTime() - vsl.LastFeeding);

                double ecmult   = LifeSupportScenario.Instance.settings.GetSettings().ECAmount *Convert.ToDouble(vsl.NumCrew);
                var    ecPerDay = secondsPerDay * ecmult;
                var    estEC    = ecmult * (Planetarium.GetUniversalTime() - vsl.LastECCheck);

                int numSharedHabVessels = 0;
                var habTime             = LifeSupportManager.GetTotalHabTime(vsl, out numSharedHabVessels);

                var supAmount = GetResourceInVessel(thisVessel, "Supplies");
                if (supAmount == 0)
                {
                    supAmount = Math.Max(0, (vsl.SuppliesLeft * supmult) - estFood);
                }

                var ecAmount = GetResourceInVessel(thisVessel, "ElectricCharge");
                if (ecAmount == 0)
                {
                    ecAmount = Math.Max(0, (vsl.ECLeft * ecmult) - estEC);
                }

                bool isOldData = Planetarium.GetUniversalTime() - vsl.LastUpdate > 2;
                var  lblColor  = isOldData ? "C4C4C4" : "ACFF40";

                vstat.VesselName = String.Format("<color=#{0}>{1}</color>", lblColor, vsl.VesselName);
                vstat.VesselId   = vsl.VesselId;
                vstat.LastUpdate = vsl.LastUpdate;
                var sitString = "Orbiting";


                thisVessel.checkSplashed();
                if (thisVessel.Splashed)
                {
                    sitString = "Splashed";
                }
                thisVessel.checkLanded();
                if (thisVessel.Landed)
                {
                    sitString = "Landed";
                }

                var habString = "indefinite";
                if (useHabPenalties)
                {
                    habString = LifeSupportUtilities.SecondsToKerbinTime(habTime, true);
                }
                vstat.SummaryLabel = String.Format(
                    "<color=#3DB1FF>{0}/{1} - </color><color=#9EE4FF>{2:0}</color><color=#3DB1FF> supplies (</color><color=#9EE4FF>{3:0.0}</color><color=#3DB1FF>/day) hab for </color><color=#9EE4FF>{4}</color>"
                    , thisVessel.mainBody.bodyName
                    , sitString
                    , supAmount
                    , supPerDay
                    , habString);
                vstat.crew = new List <LifeSupportCrewDisplayStat>();
                if (useHabPenalties)
                {
                    vstat.SummaryLabel += String.Format(
                        "<color=#3DB1FF> (</color><color=#9EE4FF>{0}</color><color=#3DB1FF> {1} shared within </color><color=#9EE4FF>{2}</color><color=#3DB1FF>m)</color>",
                        isOldData ? "?" : numSharedHabVessels.ToString(),
                        numSharedHabVessels == 1 ? "vessel" : "vessels",
                        LifeSupportScenario.Instance.settings.GetSettings().HabRange);
                }

                foreach (var c in thisVessel.GetVesselCrew())
                {
                    var cStat = new LifeSupportCrewDisplayStat();
                    var cls   = LifeSupportManager.Instance.FetchKerbal(c);
                    cStat.CrewName = String.Format("<color=#FFFFFF>{0} ({1})</color>", c.name, c.experienceTrait.Title.Substring(0, 1));

                    var ecLeft = (ecAmount / ecPerDay * secondsPerDay) + LifeSupportScenario.Instance.settings.GetSettings().ECTime;
                    if (ecAmount <= LifeSupportScenario.Instance.settings.GetSettings().ECAmount&& !LifeSupportManager.IsOnKerbin(thisVessel))
                    {
                        ecLeft = cls.LastEC - Planetarium.GetUniversalTime() + LifeSupportScenario.Instance.settings.GetSettings().ECTime;
                    }
                    var lblECTime = LifeSupportUtilities.SecondsToKerbinTime(ecLeft);

                    var lblEC = "6FFF00";
                    if (ecLeft < LifeSupportScenario.Instance.settings.GetSettings().ECTime)
                    {
                        lblEC = "FFE100";
                    }
                    if (ecLeft < LifeSupportScenario.Instance.settings.GetSettings().ECTime / 2)
                    {
                        lblEC = "FFAE00";
                    }
                    if (ecLeft <= ResourceUtilities.FLOAT_TOLERANCE)
                    {
                        lblEC     = "FF5E5E";
                        lblECTime = "expired";
                    }
                    cStat.ECLabel = String.Format("<color=#{0}>{1}</color>", lblEC, lblECTime);


                    var snacksLeft = (supAmount / supPerDay * secondsPerDay) + LifeSupportScenario.Instance.settings.GetSettings().SupplyTime;
                    if (supAmount <= LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount&& !LifeSupportManager.IsOnKerbin(thisVessel))
                    {
                        snacksLeft = cls.LastMeal - Planetarium.GetUniversalTime() + LifeSupportScenario.Instance.settings.GetSettings().SupplyTime;
                    }

                    var lblSupTime = LifeSupportUtilities.SecondsToKerbinTime(snacksLeft);

                    var lblSup = "6FFF00";
                    if (snacksLeft < LifeSupportScenario.Instance.settings.GetSettings().SupplyTime)
                    {
                        lblSup = "FFE100";
                    }
                    if (snacksLeft < LifeSupportScenario.Instance.settings.GetSettings().SupplyTime / 2)
                    {
                        lblSup = "FFAE00";
                    }
                    if (snacksLeft <= ResourceUtilities.FLOAT_TOLERANCE)
                    {
                        lblSup     = "FF5E5E";
                        lblSupTime = "expired";
                    }
                    cStat.SupplyLabel = String.Format("<color=#{0}>{1}</color>", lblSup, lblSupTime);


                    var habTimeLeft  = habTime - (Planetarium.GetUniversalTime() - cls.TimeEnteredVessel);
                    var homeTimeLeft = cls.MaxOffKerbinTime - Planetarium.GetUniversalTime();

                    var crewHabString  = "indefinite";
                    var crewHomeString = "indefinite";
                    var lblHab         = "6FFF00";
                    var lblHome        = "6FFF00";

                    if (useHabPenalties)
                    {
                        crewHomeString = LifeSupportUtilities.SecondsToKerbinTime(homeTimeLeft);
                        crewHabString  = LifeSupportUtilities.SecondsToKerbinTime(habTimeLeft);
                    }



                    if (habTimeLeft < secondsPerDay * 30)
                    {
                        lblHab = "FFE100";
                    }
                    if (habTimeLeft < secondsPerDay * 15)
                    {
                        lblHab = "FFAE00";
                    }
                    if (habTimeLeft < 0)
                    {
                        lblHab        = "FF5E5E";
                        crewHabString = "expired";
                    }
                    cStat.HabLabel = String.Format("<color=#{0}>{1}</color>", lblHab, crewHabString);

                    if (homeTimeLeft < secondsPerDay * 30) //15 days
                    {
                        lblHome = "FFE100";
                    }
                    if (homeTimeLeft < secondsPerDay * 15)
                    {
                        lblHome = "FFAE00";
                    }
                    if (homeTimeLeft < 0)
                    {
                        lblHome        = "FF5E5E";
                        crewHomeString = "expired";
                    }
                    cStat.HomeLabel = String.Format("<color=#{0}>{1}</color>", lblHome, crewHomeString);


                    vstat.crew.Add(cStat);
                }
                statList.Add(vstat);
            }

            return(statList);
        }
예제 #4
0
        private List<LifeSupportVesselDisplayStat> UpdateGUIStats()
        {
            var secondsPerDay = GameSettings.KERBIN_TIME ? (21600) : (86400);
            var useHabPenalties = (LifeSupportScenario.Instance.settings.GetSettings().NoHomeEffectVets +
                                   LifeSupportScenario.Instance.settings.GetSettings().NoHomeEffect > 0);
            LifeSupportManager.Instance.UpdateVesselStats();

            var statList = new List<LifeSupportVesselDisplayStat>();

            var checkVessels = new List<Guid>();
                foreach (var v in FlightGlobals.Vessels.Where(v => v.isEVA))
                {
                    checkVessels.Add(v.id);
                }

            foreach (var vslId in checkVessels)
            {
                var vsl = FlightGlobals.Vessels.FirstOrDefault(v => v.id == vslId);
                if (vsl == null)
                    continue;

                var lblColor = "FFD966";
                var vstat = new LifeSupportVesselDisplayStat();
                vstat.VesselName = String.Format("<color=#{0}>{1}</color>", lblColor, vsl.vesselName);
                vstat.LastUpdate = vsl.missionTime;
                var sitString = "(EVA)";

                var remEVATime = LifeSupportScenario.Instance.settings.GetSettings().EVATime - vsl.missionTime;
                var timeString = LifeSupportUtilities.SecondsToKerbinTime(Math.Max(0,remEVATime));

                if (remEVATime > 0)
                {
                    vstat.SummaryLabel = String.Format(
                        "<color=#3DB1FF>{0}/{1} - </color><color=#9EE4FF>{2}</color><color=#3DB1FF> time remaining</color>"
                        , vsl.mainBody.bodyName
                        , sitString
                        , timeString.Substring(timeString.IndexOf(':') + 1));
                }
                else
                {
                    vstat.SummaryLabel = "<color=#FF8585>EVA Time Expired</color>";
                }

                vstat.crew = new List<LifeSupportCrewDisplayStat>();
                statList.Add(vstat);
            }

            var vesselList = new List<VesselSupplyStatus>();
            vesselList.AddRange(LifeSupportManager.Instance.VesselSupplyInfo);

            foreach (var vsl in vesselList)
            {
                var vstat = new LifeSupportVesselDisplayStat();
                Vessel thisVessel = FlightGlobals.Vessels.First(v => v.id.ToString() == vsl.VesselId);
                double supmult = LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount * Convert.ToDouble(vsl.NumCrew) * vsl.RecyclerMultiplier;
                var supPerDay = secondsPerDay*supmult;
                var estFood = supmult*(Planetarium.GetUniversalTime() - vsl.LastFeeding);

                double ecmult = LifeSupportScenario.Instance.settings.GetSettings().ECAmount * Convert.ToDouble(vsl.NumCrew);
                var ecPerDay = secondsPerDay* ecmult;
                var estEC = ecmult * (Planetarium.GetUniversalTime() - vsl.LastECCheck);

                int numSharedHabVessels = 0;
                var habTime = LifeSupportManager.GetTotalHabTime(vsl, out numSharedHabVessels);

                var supAmount = GetResourceInVessel(thisVessel,"Supplies");
                if(supAmount == 0)
                    supAmount = Math.Max(0, (vsl.SuppliesLeft * supmult) - estFood);

                var ecAmount = GetResourceInVessel(thisVessel,"ElectricCharge");
                if (ecAmount == 0)
                    ecAmount = Math.Max(0, (vsl.ECLeft * ecmult) - estEC);

                bool isOldData = Planetarium.GetUniversalTime() - vsl.LastUpdate > 2;
                var lblColor = isOldData ? "C4C4C4" : "ACFF40";

                vstat.VesselName = String.Format("<color=#{0}>{1}</color>", lblColor, vsl.VesselName);
                vstat.VesselId = vsl.VesselId;
                vstat.LastUpdate = vsl.LastUpdate;
                var sitString = "Orbiting";

                thisVessel.checkSplashed();
                if (thisVessel.Splashed)
                    sitString = "Splashed";
                thisVessel.checkLanded();
                if (thisVessel.Landed)
                    sitString = "Landed";

                var habString = "indefinite";
                if (useHabPenalties)
                {
                    habString = LifeSupportUtilities.SecondsToKerbinTime(habTime, true);
                }
                vstat.SummaryLabel = String.Format(
                    "<color=#3DB1FF>{0}/{1} - </color><color=#9EE4FF>{2:0}</color><color=#3DB1FF> supplies (</color><color=#9EE4FF>{3:0.0}</color><color=#3DB1FF>/day) hab for </color><color=#9EE4FF>{4}</color>"
                    ,thisVessel.mainBody.bodyName
                    ,sitString
                    , supAmount
                    , supPerDay
                    , habString);
                vstat.crew = new List<LifeSupportCrewDisplayStat>();
                if (useHabPenalties)
                {
                    vstat.SummaryLabel += String.Format(
                        "<color=#3DB1FF> (</color><color=#9EE4FF>{0}</color><color=#3DB1FF> {1} shared within </color><color=#9EE4FF>{2}</color><color=#3DB1FF>m)</color>",
                        isOldData ? "?" : numSharedHabVessels.ToString(),
                        numSharedHabVessels == 1 ? "vessel" : "vessels",
                        LifeSupportScenario.Instance.settings.GetSettings().HabRange);
                }

                foreach (var c in thisVessel.GetVesselCrew())
                {
                    var cStat = new LifeSupportCrewDisplayStat();
                    var cls = LifeSupportManager.Instance.FetchKerbal(c);
                    cStat.CrewName = String.Format("<color=#FFFFFF>{0} ({1})</color>", c.name,c.experienceTrait.Title.Substring(0,1));

                    var ecLeft = (ecAmount / ecPerDay * secondsPerDay) + LifeSupportScenario.Instance.settings.GetSettings().ECTime;
                    if (ecAmount <= LifeSupportScenario.Instance.settings.GetSettings().ECAmount && !LifeSupportManager.IsOnKerbin(thisVessel))
                    {
                       ecLeft = cls.LastEC - Planetarium.GetUniversalTime() + LifeSupportScenario.Instance.settings.GetSettings().ECTime;
                    }
                    var lblECTime = LifeSupportUtilities.SecondsToKerbinTime(ecLeft);

                    var lblEC = "6FFF00";
                    if (ecLeft < LifeSupportScenario.Instance.settings.GetSettings().ECTime)
                    {
                        lblEC = "FFE100";
                    }
                    if (ecLeft < LifeSupportScenario.Instance.settings.GetSettings().ECTime / 2)
                    {
                        lblEC = "FFAE00";
                    }
                    if (ecLeft <= ResourceUtilities.FLOAT_TOLERANCE)
                    {
                        lblEC = "FF5E5E";
                        lblECTime = "expired";
                    }
                    cStat.ECLabel = String.Format("<color=#{0}>{1}</color>",lblEC,lblECTime);

                    var snacksLeft = (supAmount / supPerDay * secondsPerDay) + LifeSupportScenario.Instance.settings.GetSettings().SupplyTime;
                    if (supAmount <= LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount && !LifeSupportManager.IsOnKerbin(thisVessel))
                    {
                        snacksLeft = cls.LastMeal - Planetarium.GetUniversalTime() + LifeSupportScenario.Instance.settings.GetSettings().SupplyTime;
                    }

                    var lblSupTime = LifeSupportUtilities.SecondsToKerbinTime(snacksLeft);

                    var lblSup = "6FFF00";
                    if (snacksLeft < LifeSupportScenario.Instance.settings.GetSettings().SupplyTime)
                    {
                        lblSup = "FFE100";
                    }
                    if (snacksLeft < LifeSupportScenario.Instance.settings.GetSettings().SupplyTime / 2)
                    {
                        lblSup = "FFAE00";
                    }
                    if (snacksLeft <= ResourceUtilities.FLOAT_TOLERANCE)
                    {
                        lblSup = "FF5E5E";
                        lblSupTime = "expired";
                    }
                    cStat.SupplyLabel = String.Format("<color=#{0}>{1}</color>", lblSup, lblSupTime);

                    var habTimeLeft = habTime - (Planetarium.GetUniversalTime() - cls.TimeEnteredVessel);
                    var homeTimeLeft = cls.MaxOffKerbinTime - Planetarium.GetUniversalTime();

                    var crewHabString = "indefinite";
                    var crewHomeString = "indefinite";
                    var lblHab = "6FFF00";
                    var lblHome = "6FFF00";

                    if (useHabPenalties)
                    {
                        crewHomeString = LifeSupportUtilities.SecondsToKerbinTime(homeTimeLeft);
                        crewHabString = LifeSupportUtilities.SecondsToKerbinTime(habTimeLeft);
                    }

                    if (habTimeLeft < secondsPerDay * 30)
                    {
                        lblHab = "FFE100";
                    }
                    if (habTimeLeft < secondsPerDay * 15)
                    {
                        lblHab = "FFAE00";
                    }
                    if (habTimeLeft < 0)
                    {
                        lblHab = "FF5E5E";
                        crewHabString = "expired";
                    }
                    cStat.HabLabel = String.Format("<color=#{0}>{1}</color>", lblHab, crewHabString);

                    if (homeTimeLeft < secondsPerDay * 30) //15 days
                    {
                        lblHome = "FFE100";
                    }
                    if (homeTimeLeft < secondsPerDay * 15)
                    {
                        lblHome = "FFAE00";
                    }
                    if (homeTimeLeft < 0)
                    {
                        lblHome = "FF5E5E";
                        crewHomeString = "expired";
                    }
                    cStat.HomeLabel = String.Format("<color=#{0}>{1}</color>", lblHome, crewHomeString);

                    vstat.crew.Add(cStat);
                }
                statList.Add(vstat);
            }

            return statList;
        }
예제 #5
0
        private LifeSupportVesselDisplayStat GetVesselStats(VesselSupplyStatus vsl)
        {
            var secondsPerDay   = GameSettings.KERBIN_TIME ? (21600) : (86400);
            var useHabPenalties = (LifeSupportScenario.Instance.settings.GetSettings().NoHomeEffectVets +
                                   LifeSupportScenario.Instance.settings.GetSettings().NoHomeEffect > 0);

            Vessel thisVessel = FlightGlobals.Vessels.Find(v => v.id.ToString() == vsl.VesselId);
            var    vstat      = new LifeSupportVesselDisplayStat();
            bool   isOldData  = Planetarium.GetUniversalTime() - vsl.LastUpdate > 2;
            var    lblColor   = isOldData ? "C4C4C4" : "ACFF40";

            vstat.VesselName = String.Format("<color=#{0}>{1}</color>", lblColor, vsl.VesselName);
            vstat.VesselId   = vsl.VesselId;
            vstat.LastUpdate = vsl.LastUpdate;
            var situationString = GetSituationString(thisVessel);

            double suppliesPerSecond = LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount *Convert.ToDouble(vsl.NumCrew) * vsl.RecyclerMultiplier;
            var    suppliesPerDay    = secondsPerDay * suppliesPerSecond;
            var    supAmount         = GetResourceInVessel(thisVessel, "Supplies");
            var    suppliesTimeLeft  = (suppliesPerSecond > ResourceUtilities.FLOAT_TOLERANCE) ? (supAmount / suppliesPerSecond) : 0;

            if (supAmount == 0)
            {
                var suppliesConsumedSinceLastCheck = suppliesPerSecond * (Planetarium.GetUniversalTime() - vsl.LastFeeding);
                supAmount        = Math.Max(0, (vsl.SuppliesLeft * suppliesPerSecond) - suppliesConsumedSinceLastCheck);
                suppliesTimeLeft = (vsl.SuppliesLeft - (Planetarium.GetUniversalTime() - vsl.LastFeeding));
            }

            double ecPerSecond = LifeSupportScenario.Instance.settings.GetSettings().ECAmount *Convert.ToDouble(vsl.NumCrew);
            var    ecAmount    = GetResourceInVessel(thisVessel, "ElectricCharge");
            var    ecTimeLeft  = (ecPerSecond > ResourceUtilities.FLOAT_TOLERANCE) ? (ecAmount / ecPerSecond) : 0;

            if (ecAmount == 0)
            {
                var ecConsumedSinceLastCheck = ecPerSecond * (Planetarium.GetUniversalTime() - vsl.LastECCheck);
                ecAmount   = Math.Max(0, (vsl.ECLeft * ecPerSecond) - ecConsumedSinceLastCheck);
                ecTimeLeft = (vsl.ECLeft - (Planetarium.GetUniversalTime() - vsl.LastECCheck));
            }

            int numSharedHabVessels = 0;
            var habTime             = LifeSupportManager.GetTotalHabTime(vsl, thisVessel, out numSharedHabVessels);

            var habString = "indefinite";

            if (useHabPenalties)
            {
                habString = LifeSupportUtilities.DurationDisplay(habTime, LifeSupportUtilities.TimeFormatLength.Short);
            }
            vstat.SummaryLabel = String.Format(
                "<color=#3DB1FF>{0}/{1} - </color><color=#9EE4FF>{2:0}</color><color=#3DB1FF> supplies (</color><color=#9EE4FF>{3:0.0}</color><color=#3DB1FF>/day) hab for </color><color=#9EE4FF>{4}</color>"
                , thisVessel.mainBody.bodyName
                , situationString
                , supAmount
                , suppliesPerDay
                , habString);
            vstat.crew = new List <LifeSupportCrewDisplayStat>();
            if (useHabPenalties)
            {
                vstat.SummaryLabel += String.Format(
                    "<color=#3DB1FF> (</color><color=#9EE4FF>{0}</color><color=#3DB1FF> {1} shared within </color><color=#9EE4FF>{2}</color><color=#3DB1FF>m)</color>",
                    isOldData ? "?" : numSharedHabVessels.ToString(),
                    numSharedHabVessels == 1 ? "vessel" : "vessels",
                    LifeSupportScenario.Instance.settings.GetSettings().HabRange);
            }

            foreach (var c in thisVessel.GetVesselCrew())
            {
                var crewStat = GetCrewStat(c, thisVessel, suppliesTimeLeft, ecTimeLeft, ecAmount, habTime);
                vstat.crew.Add(crewStat);
            }
            vstat.crew = vstat.crew.OrderBy(crewStat => crewStat.EarliestExpiration).ToList();
            if (vstat.crew.Any())
            {
                vstat.EarliestExpiration = vstat.crew.First().EarliestExpiration;
            }
            return(vstat);
        }
예제 #6
0
        private List <LifeSupportVesselDisplayStat> UpdateGUIStats()
        {
            var useHabPenalties = (LifeSupportSetup.Instance.LSConfig.NoHomeEffectVets +
                                   LifeSupportSetup.Instance.LSConfig.NoHomeEffect > 0);

            LifeSupportManager.Instance.UpdateVesselStats();

            var statList = new List <LifeSupportVesselDisplayStat>();

            var checkVessels = new List <Guid>();

            foreach (var v in FlightGlobals.Vessels.Where(v => v.isEVA))
            {
                checkVessels.Add(v.id);
            }


            foreach (var vslId in checkVessels)
            {
                var vsl = FlightGlobals.Vessels.FirstOrDefault(v => v.id == vslId);
                if (vsl == null)
                {
                    continue;
                }

                var lblColor = "FFD966";
                var vstat    = new LifeSupportVesselDisplayStat();
                vstat.VesselName = String.Format("<color=#{0}>{1}</color>", lblColor, vsl.vesselName);
                vstat.LastUpdate = vsl.missionTime;
                var sitString = "(EVA)";

                var remEVATime = LifeSupportSetup.Instance.LSConfig.EVATime - vsl.missionTime;
                var timeString = LifeSupportUtilities.SecondsToKerbinTime(Math.Max(0, remEVATime));

                if (remEVATime > 0)
                {
                    vstat.SummaryLabel = String.Format(
                        "<color=#3DB1FF>{0}/{1} - </color><color=#9EE4FF>{2}</color><color=#3DB1FF> time remaining</color>"
                        , vsl.mainBody.bodyName
                        , sitString
                        , timeString.Substring(timeString.IndexOf(':') + 1));
                }
                else
                {
                    vstat.SummaryLabel = "<color=#FF8585>EVA Time Expired</color>";
                }

                vstat.crew = new List <LifeSupportCrewDisplayStat>();
                statList.Add(vstat);
            }

            var vesselList = new List <VesselSupplyStatus>();

            vesselList.AddRange(LifeSupportManager.Instance.VesselSupplyInfo);


            foreach (var vsl in vesselList)
            {
                var    vstat      = new LifeSupportVesselDisplayStat();
                Vessel thisVessel = FlightGlobals.Vessels.First(v => v.id.ToString() == vsl.VesselId);
                double supmult    = LifeSupportSetup.Instance.LSConfig.SupplyAmount * Convert.ToDouble(vsl.NumCrew) * vsl.RecyclerMultiplier;
                var    supPerDay  = (21600 * supmult);
                var    estFood    = supmult * (Planetarium.GetUniversalTime() - vsl.LastFeeding);
                var    habTime    = LifeSupportManager.GetTotalHabTime(vsl);
                var    supAmount  = GetSuppliesInVessel(thisVessel);
                if (supAmount == 0)
                {
                    supAmount = Math.Max(0, (vsl.SuppliesLeft * supmult) - estFood);
                }

                var lblColor = "ACFF40";
                if (Planetarium.GetUniversalTime() - vsl.LastUpdate > 2)
                {
                    lblColor = "C4C4C4";
                }
                vstat.VesselName = String.Format("<color=#{0}>{1}</color>", lblColor, vsl.VesselName);
                vstat.LastUpdate = vsl.LastUpdate;
                var sitString = "Orbiting";
                if (thisVessel.Splashed || thisVessel.heightFromTerrain < 1000)
                {
                    sitString = "Splashed";
                }
                if (thisVessel.Landed || thisVessel.heightFromTerrain < 1000)
                {
                    sitString = "Landed";
                }

                var habString = "indefinite";
                if (useHabPenalties)
                {
                    habString = LifeSupportUtilities.SecondsToKerbinTime(habTime, true);
                }
                vstat.SummaryLabel = String.Format("<color=#3DB1FF>{0}/{1} - </color><color=#9EE4FF>{2:0}</color><color=#3DB1FF> supplies (</color><color=#9EE4FF>{3:0.0}</color><color=#3DB1FF>/day) hab for </color><color=#9EE4FF>{4}</color>"
                                                   , thisVessel.mainBody.bodyName
                                                   , sitString
                                                   , supAmount
                                                   , supPerDay
                                                   , habString);
                vstat.crew = new List <LifeSupportCrewDisplayStat>();

                foreach (var c in thisVessel.GetVesselCrew())
                {
                    var cStat = new LifeSupportCrewDisplayStat();
                    var cls   = LifeSupportManager.Instance.FetchKerbal(c);
                    cStat.CrewName = String.Format("<color=#FFFFFF>{0} ({1})</color>", c.name, c.experienceTrait.Title.Substring(0, 1));

                    var snacksLeft = supAmount / supPerDay * 60 * 60 * 6;
                    if (supAmount <= ResourceUtilities.FLOAT_TOLERANCE && !LifeSupportManager.IsOnKerbin(thisVessel))
                    {
                        snacksLeft = cls.LastMeal - Planetarium.GetUniversalTime();
                    }

                    var lblSup = "6FFF00";
                    if (snacksLeft < 60 * 60 * 6 * 15) //15 days
                    {
                        lblSup = "FFE100";
                    }
                    if (snacksLeft < 0)
                    {
                        lblSup = "FFAE00";
                    }
                    if (snacksLeft < -60 * 60 * 6 * 15)
                    {
                        lblSup = "FF5E5E";
                    }
                    cStat.SupplyLabel = String.Format("<color=#{0}>{1}</color>", lblSup, LifeSupportUtilities.SecondsToKerbinTime(snacksLeft));
                    var timeLeft = Math.Min(cls.MaxOffKerbinTime - Planetarium.GetUniversalTime(), habTime - (Planetarium.GetUniversalTime() - cls.TimeEnteredVessel));

                    var lblHab = "6FFF00";
                    if (timeLeft < 60 * 60 * 6 * 15) //15 days
                    {
                        lblHab = "FFE100";
                    }
                    if (timeLeft < 0)
                    {
                        lblHab = "FFAE00";
                    }
                    if (timeLeft < -60 * 60 * 6 * 15)
                    {
                        lblHab = "FF5E5E";
                    }
                    var crewHabString = "indefinite";
                    if (useHabPenalties)
                    {
                        crewHabString = LifeSupportUtilities.SecondsToKerbinTime(timeLeft);
                    }
                    cStat.HabLabel = String.Format("<color=#{0}>{1}</color>", lblHab, crewHabString);
                    vstat.crew.Add(cStat);
                }
                statList.Add(vstat);
            }

            return(statList);
        }