Beispiel #1
0
        public void KerbalsHadASnack(Vessel vessel, double lastMealTime)
        {
            this.CheckForNewLoadedVesselSet();

            var ungrounchedKerbals = new List <ProtoCrewMember>();
            var unhungryKerbals    = new List <ProtoCrewMember>();

            foreach (var crew in vessel.GetVesselCrew())
            {
                if (this.knownKerbals.TryGetValue(crew.name, out LifeSupportStatus crewStatus))
                {
                    if (crewStatus.IsGrouchy)
                    {
                        crew.type = ProtoCrewMember.KerbalType.Crew;
                        KerbalRoster.SetExperienceTrait(crew, crewStatus.OldTrait);
                        ungrounchedKerbals.Add(crew);
                    }
                    crewStatus.LastMeal  = lastMealTime;
                    crewStatus.IsGrouchy = false;
                    this.incapacitatedKerbals.Remove(crew);
                }
                else
                {
                    this.knownKerbals.Add(crew.name, new LifeSupportStatus
                    {
                        IsGrouchy  = false,
                        KerbalName = crew.name,
                        LastMeal   = Planetarium.GetUniversalTime(),
                        OldTrait   = null
                    });

                    if (this.hungryKerbals.Remove(crew))
                    {
                        unhungryKerbals.Add(crew);
                    }
                }
            }

            if (ungrounchedKerbals.Any())
            {
                ScreenMessages.PostScreenMessage(
                    message: CrewBlurbs.CreateMessage("#LOC_KPBS_KERBAL_NOT_INCAPACITATED", ungrounchedKerbals, new string[] { }, TechTier.Tier0),
                    duration: 15f,
                    style: ScreenMessageStyle.UPPER_CENTER);
            }
            if (unhungryKerbals.Any())
            {
                ScreenMessages.PostScreenMessage(
                    message: CrewBlurbs.CreateMessage("#LOC_KPBS_KERBAL_NOT_HUNGRY", unhungryKerbals, new string[] { }, TechTier.Tier0),
                    duration: 15f,
                    style: ScreenMessageStyle.UPPER_CENTER);
            }
        }
Beispiel #2
0
        public ResourceLode GetOrCreateResourceLoad(Vessel scannerVessel, Vessel nearVessel, TechTier tier, double scannerNetQuality)
        {
            // There's only allowed one resource load - you have to harvest it until it's gone
            // So find the thing first.
            var lode = this.activeLodes.FirstOrDefault(rl => rl.bodyName == nearVessel.mainBody.name && rl.Tier == tier);

            if (lode != null)
            {
                // Ensure that there's a waypoint
                if (Waypoints.TryFindWaypointById(lode.Identifier, out _))
                {
                    ScreenMessages.PostScreenMessage("A lode has already been identified - look for a waypoint on the surface");
                }
                else
                {
                    Waypoints.CreateWaypointAt($"Loose Crushins ({tier.DisplayName()})", nearVessel.mainBody, lode.Latitude, lode.Longitude);
                    ScreenMessages.PostScreenMessage("A lode has already been identified - the waypoint was recreated");
                }
            }
            else
            {
                var waypoint = Waypoints.CreateWaypointNear(
                    $"Loose Crushins ({tier.DisplayName()})", nearVessel, 10000, 500000,
                    scannerNetQuality, nearVessel.situation == Vessel.Situations.SPLASHED);
                lode = new ResourceLode(waypoint, tier);
                activeLodes.Add(lode);

                PopupMessageWithKerbal.ShowPopup(
                    "Lookie What I Found!",
                    CrewBlurbs.CreateMessage(
                        scannerNetQuality < PksScanner.BadScannerNetQualityThreshold ? "#LOC_KPBS_SCANNER_FIND_NOSATS" : "#LOC_KPBS_SCANNER_FIND_SATS",
                        scannerVessel.GetVesselCrew(),
                        new string[] { nameof(PksScanningSkill) }, tier),
                    "A waypoint has been created - you need to land a ship or drive a rover with a portable digger "
                    + "to within 150m of the waypoint, deploy the drill, fill your tanks with CrushIns, haul the "
                    + "load back to the base and unload it using the resource-transfer mechanism on the colony "
                    + "status screen (the cupcake button).  After you've dumped two loads with the same craft, "
                    + "the crew at the base will be able to automatically gather resources in the future."
                    + "\r\n\r\n"
                    + "The more scanner satellites you have in polar orbit, the more likely you are to get a location "
                    + "near your base.",
                    "On it");
            }

            return(lode);
        }
Beispiel #3
0
        private const double secondsBeforeKerbalStarves = DaysBeforeKerbalStarves * 6 * 60 * 60; // 7 kerban days

        public void KerbalsMissedAMeal(Vessel vessel, bool hasActiveProducers)
        {
            if (vessel.isEVA)
            {
                return;
            }

            this.CheckForNewLoadedVesselSet();

            List <ProtoCrewMember> crewThatBecameHungry        = new List <ProtoCrewMember>();
            List <ProtoCrewMember> crewThatBecameIncapacitated = new List <ProtoCrewMember>();

            double now = Planetarium.GetUniversalTime();

            foreach (var crew in vessel.GetVesselCrew())
            {
                if (!this.knownKerbals.TryGetValue(crew.name, out LifeSupportStatus crewStatus))
                {
                    crewStatus = new LifeSupportStatus
                    {
                        IsGrouchy  = false,
                        KerbalName = crew.name,
                        LastMeal   = now,
                        OldTrait   = null
                    };
                    this.knownKerbals.Add(crew.name, crewStatus);
                }

                if (!crewStatus.IsGrouchy &&
                    now > crewStatus.LastMeal + secondsBeforeKerbalStarves)
                {
                    crewStatus.IsGrouchy = true;
                    crewStatus.OldTrait  = crew.experienceTrait.Title;
                    crew.type            = ProtoCrewMember.KerbalType.Tourist;
                    KerbalRoster.SetExperienceTrait(crew, "Tourist");
                }

                if (crewStatus.IsGrouchy && !this.incapacitatedKerbals.Contains(crew))
                {
                    crewThatBecameIncapacitated.Add(crew);
                    this.incapacitatedKerbals.Add(crew);
                }
                else if (!crewStatus.IsGrouchy &&
                         (hasActiveProducers || now > crewStatus.LastMeal + .5 * secondsBeforeKerbalStarves) &&
                         !this.hungryKerbals.Contains(crew))
                {
                    crewThatBecameHungry.Add(crew);
                    this.hungryKerbals.Add(crew);
                }
            }

            if (crewThatBecameIncapacitated.Any())
            {
                ScreenMessages.PostScreenMessage(
                    message: CrewBlurbs.CreateMessage("#LOC_KPBS_KERBAL_INCAPACITATED", crewThatBecameIncapacitated, new string[] { }, TechTier.Tier0),
                    duration: 15f,
                    style: ScreenMessageStyle.UPPER_CENTER);
            }
            else if (crewThatBecameHungry.Any())
            {
                ScreenMessages.PostScreenMessage(
                    message: CrewBlurbs.CreateMessage(
                        (hasActiveProducers ? "#LOC_KPBS_KERBAL_HUNGRY_NO_PRODUCTION" : "#LOC_KPBS_KERBAL_HUNGRY"),
                        crewThatBecameHungry,
                        new string[] { },
                        TechTier.Tier0),
                    duration: 15f,
                    style: ScreenMessageStyle.UPPER_CENTER);
            }
        }
Beispiel #4
0
 public string BoringBreakthroughMessage(List <ProtoCrewMember> crew, TechTier newTier)
 => CrewBlurbs.CreateMessage(this.breakThroughExplanationTag, crew, this.crewSkills, newTier);