Пример #1
0
        public bool ContributeResearch(TieredResource source, string atBody, double timespentInKerbalSeconds)
        {
            if (!this.categoryToBodyToProgressMap.TryGetValue(source.ResearchCategory, out Dictionary <string, TechProgress> bodyToProgressMap))
            {
                bodyToProgressMap = new Dictionary <string, TechProgress>();
                this.categoryToBodyToProgressMap.Add(source.ResearchCategory, bodyToProgressMap);
            }

            string bodyName = source.ProductionRestriction == ProductionRestriction.Space ? "" : atBody;

            if (!bodyToProgressMap.TryGetValue(bodyName, out TechProgress progress))
            {
                progress = new TechProgress()
                {
                    ProgressInKerbalSeconds = 0, Tier = TechTier.Tier0
                };
                bodyToProgressMap.Add(bodyName, progress);
            }

            progress.ProgressInKerbalSeconds += timespentInKerbalSeconds;
            if (progress.ProgressInKerbalSeconds > KerbalTime.KerbalYearsToSeconds(source.ResearchCategory.KerbalYearsToNextTier(progress.Tier)))
            {
                progress.ProgressInKerbalSeconds = 0;
                ++progress.Tier;
                if (progress.Tier == TechTier.Tier1 && this.EligibleToSkipTier1(source.ResearchCategory))
                {
                    ++progress.Tier;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        internal ResearchData GetResearchProgress(TieredResource forResource, string atBody)
        {
            double   kerbalSecondsSoFar = 0;
            TechTier currentTier        = TechTier.Tier0;

            if (this.categoryToBodyToProgressMap.TryGetValue(forResource.ResearchCategory, out Dictionary <string, TechProgress> bodyToProgressMap))
            {
                string bodyName = forResource.ProductionRestriction == ProductionRestriction.Space ? "" : atBody;
                if (bodyToProgressMap.TryGetValue(bodyName, out TechProgress progress))
                {
                    currentTier        = progress.Tier;
                    kerbalSecondsSoFar = progress.ProgressInKerbalSeconds;
                }
            }

            return(new ResearchData(forResource.ResearchCategory, currentTier, KerbalTime.KerbalSecondsToDays(kerbalSecondsSoFar), KerbalTime.KerbalYearsToDays(forResource.ResearchCategory.KerbalYearsToNextTier(currentTier))));
        }
Пример #3
0
        public bool TryGetStatus(ProtoCrewMember crew, out double daysSinceMeal, out double daysToGrouchy, out bool isGrouchy)
        {
            double now = Planetarium.GetUniversalTime();

            if (this.knownKerbals.TryGetValue(crew.name, out LifeSupportStatus lifeSupportStatus))
            {
                daysSinceMeal = KerbalTime.SecondsToKerbalDays(now - lifeSupportStatus.LastMeal);
                isGrouchy     = lifeSupportStatus.IsGrouchy;
                daysToGrouchy = KerbalTime.SecondsToKerbalDays(lifeSupportStatus.LastMeal + secondsBeforeKerbalStarves - now);
                return(true);
            }
            else
            {
                daysSinceMeal = 0;
                daysToGrouchy = KerbalTime.SecondsToKerbalDays(secondsBeforeKerbalStarves);
                isGrouchy     = false;
                return(false);
            }
        }