Beispiel #1
0
        public string TimeToCompleteLearning(ResearchProjectDef curProj, Pawn pawn = null)
        {
            float hoursToComplete = ((1 - Aux_HR.HRExpertise(pawn)[curProj]) * pawn.CurJob.bill.recipe.workAmount * Aux_HR.HRStuffCostFactor(curProj) /
                                     (ResearchSpeedForGivenProject(curProj, pawn) * Aux_HR.HRStudyPointsPerWorkTick * 2500f * (DebugSettings.fastResearch ? 500f : 1f)));
            TimeSpan time = TimeSpan.FromHours(hoursToComplete);

            return((time.Days > 0 ? $"{time.Days.ToString() + "LetterDay".Translate()} " : "") +
                   (time.Hours > 0 ? $"{time.Hours.ToString() + "LetterHour".Translate()} " : "") +
                   ($"{time.Minutes.ToString() + "LetterMinute".Translate()}"));
        }
Beispiel #2
0
        public string TimeToCompleteResearch(ResearchProjectDef curProj, Pawn pawn = null)
        {
            if (ResearchSpeedForGivenProject(curProj, pawn) <= 0)
            {
                return("-");
            }
            float hoursToComplete;

            if (ResearchInfo.ModHumanResources)
            {
                hoursToComplete = ((1 - Aux_HR.HRExpertise(pawn)[curProj]) * curProj.CostApparent /
                                   (ResearchSpeedForGivenProject(curProj, pawn) * curProj.CostFactor(pawn.Faction.def.techLevel) * Aux_HR.HRResearchPointsPerWorkTick * 2500f * (DebugSettings.fastResearch ? 500f : 1f)));
            }
            else
            {
                hoursToComplete = (curProj.CostApparent - curProj.ProgressApparent) /
                                  (ResearchSpeedForGivenProject(curProj, pawn) * 0.00825f * 2500f * Find.Storyteller.difficulty.researchSpeedFactor * (DebugSettings.fastResearch ? 500f : 1f));
            }
            TimeSpan time = TimeSpan.FromHours(hoursToComplete);

            return((time.Days > 0 ? $"{time.Days.ToString() + "LetterDay".Translate()} " : "") +
                   (time.Hours > 0 ? $"{time.Hours.ToString() + "LetterHour".Translate()} " : "") +
                   ($"{time.Minutes.ToString() + "LetterMinute".Translate()}"));
        }
Beispiel #3
0
        protected override void FillTab()
        {
            float curY = 5f;

            GUI.color = Color.white;

            /* Begin of Label */
            float labelY = 30f;

            Text.Font = GameFont.Medium;
            Rect rectProjectLabel = new Rect(7f, curY, size.x - 30f, labelY);

            GUI.BeginGroup(rectProjectLabel);
            Widgets.Label(new Rect(0f, 0f, rectProjectLabel.width, rectProjectLabel.height), _curProj.LabelCap.Truncate(rectProjectLabel.width));
            if (Mouse.IsOver(rectProjectLabel) && (_curProj.LabelCap.Truncate(rectProjectLabel.width) != _curProj.LabelCap))
            {
                GUI.DrawTexture(rectProjectLabel, TexUI.HighlightTex);
                TooltipHandler.TipRegion(rectProjectLabel, _curProj.LabelCap);
            }
            GUI.EndGroup();
            Text.Font = GameFont.Small;
            curY     += labelY;
            /* End of Label */

            /* Begin of Desc */
            float descY           = 120f;
            Rect  rectProjectDesc = new Rect(10f, curY, size.x - 20f, descY);

            GUI.BeginGroup(rectProjectDesc);
            Widgets.LabelScrollable(new Rect(0f, 0f, rectProjectDesc.width, rectProjectDesc.height), _curProj.description, ref _scrollPosition);
            GUI.EndGroup();
            curY += descY;
            /* End of Desc */

            Widgets.DrawLine(new Vector2(10f, curY + 5f), new Vector2(size.x - 20f, curY + 5f), Color.grey, 1f);
            curY += 10f;

            /* Begin of Details */
            float detailsY           = 164f;
            float stringPos          = 0f;
            float stringHeight       = 22f;
            Rect  rectProjectDetails = new Rect(10f, curY, size.x - 30f, detailsY);

            GUI.BeginGroup(rectProjectDetails);

            Rect rectProjectTechLevel = new Rect(0f, stringPos, rectProjectDetails.width, stringHeight);

            Text.Anchor = TextAnchor.MiddleLeft;
            if (_curProj.techLevel == Faction.OfPlayer.def.techLevel)
            {
                Widgets.Label(rectProjectTechLevel, "RqRI_ProjectTechLevel".Translate());
            }
            else
            {
                Text.CurFontStyle.fontStyle = FontStyle.Italic;
                Widgets.Label(rectProjectTechLevel, "RqRI_ProjectTechLevel".Translate());
                Text.CurFontStyle.fontStyle = FontStyle.Normal;
                if (Mouse.IsOver(rectProjectTechLevel))
                {
                    GUI.DrawTexture(rectProjectTechLevel, TexUI.HighlightTex);
                    TooltipHandler.TipRegion(rectProjectTechLevel, "RqRI_FactionTechLevel".Translate()
                                             + Faction.OfPlayer.def.techLevel.ToStringHuman().CapitalizeFirst());
                }
            }
            Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rectProjectTechLevel, _curProj.techLevel.ToStringHuman().CapitalizeFirst());
            stringPos += stringHeight;

            Rect rectProjectCost = new Rect(0f, stringPos, rectProjectDetails.width, stringHeight);

            Text.Anchor = TextAnchor.MiddleLeft;
            if (_curProj.CostFactor(Faction.OfPlayer.def.techLevel) == 1)
            {
                Widgets.Label(rectProjectCost, "RqRI_ProjectCost".Translate());
            }
            else
            {
                Text.CurFontStyle.fontStyle = FontStyle.Italic;
                Widgets.Label(rectProjectCost,
                              "RqRI_ProjectCostMultiplied".Translate((_curProj.CostFactor(Faction.OfPlayer.def.techLevel)).ToStringPercent()));
                Text.CurFontStyle.fontStyle = FontStyle.Normal;
                if (Mouse.IsOver(rectProjectCost))
                {
                    GUI.DrawTexture(rectProjectCost, TexUI.HighlightTex);
                    TooltipHandler.TipRegion(rectProjectCost,
                                             "ResearchCostComparison".Translate(_curProj.baseCost.ToString("F0"), _curProj.CostApparent.ToString("F0")));
                }
            }
            Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rectProjectCost, _curProj.CostApparent.ToString());
            stringPos += stringHeight + 10f;

            Rect rectResearchProgress = new Rect(0f, stringPos, rectProjectDetails.width, stringHeight);

            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rectResearchProgress, "RqRI_ResearchProgress".Translate());
            Text.Anchor = TextAnchor.MiddleRight;
            if (ResearchInfo.ModHumanResources)
            {
                Widgets.Label(rectResearchProgress, Aux_HR.HRExpertise(_userpawn)[_curProj].ToStringPercent("F1"));
            }
            else
            {
                Widgets.Label(rectResearchProgress, _curProj.ProgressApparent.ToString("F0")
                              + " / " + _curProj.CostApparent.ToString("F0") + $" ({_curProj.ProgressPercent.ToStringPercent("F1")})");
            }
            stringPos += stringHeight;

            if (_HR_TechLevelDifference)
            {
                Rect rectTechLevelDifference = new Rect(0f, stringPos, rectProjectDetails.width, stringHeight);
                Text.Anchor = TextAnchor.MiddleLeft;
                Text.CurFontStyle.fontStyle = FontStyle.Italic;
                Widgets.Label(rectTechLevelDifference, "RqRI_TechLevelDifference".Translate());
                Text.CurFontStyle.fontStyle = FontStyle.Normal;
                if (Mouse.IsOver(rectTechLevelDifference))
                {
                    GUI.DrawTexture(rectTechLevelDifference, TexUI.HighlightTex);
                    TooltipHandler.TipRegion(rectTechLevelDifference, "RqRI_TechLevelDifferenceDesc".Translate(_userpawn.NameShortColored,
                                                                                                               Aux_HR.HRTechLevel(_userpawn).ToStringHuman(), _curProj.techLevel.ToStringHuman()));
                }
                Text.Anchor = TextAnchor.MiddleRight;
                Widgets.Label(rectTechLevelDifference, (1 / _curProj.CostFactor(Aux_HR.HRTechLevel(_userpawn))).ToStringPercent("F0"));
                stringPos += stringHeight;
            }

            if (_HR_PrerequisiteMultiplier)
            {
                Rect rectPrerequisiteMultiplier = new Rect(0f, stringPos, rectProjectDetails.width, stringHeight);
                Text.Anchor = TextAnchor.MiddleLeft;
                Text.CurFontStyle.fontStyle = FontStyle.Italic;
                Widgets.Label(rectPrerequisiteMultiplier, "RqRI_PrerequisiteMultiplier".Translate());
                Text.CurFontStyle.fontStyle = FontStyle.Normal;
                if (Mouse.IsOver(rectPrerequisiteMultiplier))
                {
                    GUI.DrawTexture(rectPrerequisiteMultiplier, TexUI.HighlightTex);
                    TooltipHandler.TipRegion(rectPrerequisiteMultiplier, "RqRI_PrerequisiteMultiplierDesc".Translate(_userpawn.NameShortColored));
                }
                Text.Anchor = TextAnchor.MiddleRight;
                Widgets.Label(rectPrerequisiteMultiplier, (Aux_HR.HRPrerequisiteMultiplier(_curProj, _userpawn)).ToStringPercent("F0"));
                stringPos += stringHeight;
            }

            Rect rectResearchSpeed = new Rect(0f, stringPos, rectProjectDetails.width, stringHeight);

            Text.Anchor = TextAnchor.MiddleLeft;
            if (!ResearchInfo.ModHumanResources)
            {
                if (_util.NumberOfCurrentResearchersOfGivenProject(_curProj) > 0)
                {
                    Text.CurFontStyle.fontStyle = FontStyle.Italic;
                    Widgets.Label(rectResearchSpeed, "RqRI_ResearchSpeed".Translate());
                    Text.CurFontStyle.fontStyle = FontStyle.Normal;
                    if (_util.NumberOfCurrentResearchersOfGivenProject(_curProj) == 1 && Mouse.IsOver(rectResearchSpeed))
                    {
                        GUI.DrawTexture(rectResearchSpeed, TexUI.HighlightTex);
                        var user = ResearchInfo.ModPawnsChooseResearch ? _userpawn : _util.ListOfCurrentResearchers().First();
                        TooltipHandler.TipRegion(rectResearchSpeed, "RqRI_ResearchSpeedSoloDesc".Translate(user.NameShortColored)
                                                 + _util.ToolTipResearchSpeedDetails(_curProj, user));
                    }
                    if (_util.NumberOfCurrentResearchersOfGivenProject(_curProj) > 1 && Mouse.IsOver(rectResearchSpeed))
                    {
                        GUI.DrawTexture(rectResearchSpeed, TexUI.HighlightTex);
                        TooltipHandler.TipRegion(rectResearchSpeed, "RqRI_ResearchSpeedMultipleDesc".Translate() + _util.ToolTipNamesList(_curProj));
                    }
                }
                else
                {
                    Widgets.Label(rectResearchSpeed, "RqRI_ResearchSpeed".Translate());
                }
            }
            else
            {
                Text.CurFontStyle.fontStyle = FontStyle.Italic;
                Widgets.Label(rectResearchSpeed, "RqRI_ResearchSpeed".Translate());
                Text.CurFontStyle.fontStyle = FontStyle.Normal;
                if (Mouse.IsOver(rectResearchSpeed))
                {
                    GUI.DrawTexture(rectResearchSpeed, TexUI.HighlightTex);
                    TooltipHandler.TipRegion(rectResearchSpeed, "RqRI_ResearchSpeedSoloDesc".Translate(_userpawn.NameShortColored)
                                             + _util.ToolTipResearchSpeedDetails(_curProj, _userpawn));
                }
            }
            Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rectResearchSpeed, _util.ResearchSpeedForGivenProject(_curProj, _userpawn).ToStringPercent("F1"));
            stringPos += stringHeight;

            Rect rectTimeToComplete = new Rect(0f, stringPos, rectProjectDetails.width, stringHeight);

            Text.Anchor = TextAnchor.MiddleLeft;
            if (_util.ResearchSpeedForGivenProject(_curProj, _userpawn) > 0)
            {
                Text.CurFontStyle.fontStyle = FontStyle.Italic;
                Widgets.Label(rectTimeToComplete, "RqRI_TimeToComplete".Translate());
                Text.CurFontStyle.fontStyle = FontStyle.Normal;
                if (Mouse.IsOver(rectTimeToComplete))
                {
                    GUI.DrawTexture(rectTimeToComplete, TexUI.HighlightTex);
                    TooltipHandler.TipRegion(rectTimeToComplete, "RqRI_TimeToCompleteDesc".Translate());
                }
            }
            else
            {
                Widgets.Label(rectTimeToComplete, "RqRI_TimeToComplete".Translate());
            }
            Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(rectTimeToComplete, _util.TimeToCompleteResearch(_curProj, _userpawn));
            GUI.EndGroup();
            Text.Anchor = TextAnchor.UpperLeft;
            /* End of Details */
        }
Beispiel #4
0
        public string InspectStringInfo(Thing thing, bool study = false)
        {
            StringBuilder      sb = new StringBuilder();
            ResearchProjectDef curProj;

            if (study)
            {
                Pawn pawn = ListOfCurrentResearchers(study: true).Where(x => x.CurJob.targetA.Thing == thing).FirstOrDefault();
                if (pawn != null)
                {
                    curProj = Aux_HR.HRCurrentProject(pawn);
                    sb.AppendInNewLine(RI_Mod.settings.showCurrentProject ? $"{"RqRI_CurrentProject".Translate() + curProj.LabelCap}" : "");
                    sb.AppendInNewLine(RI_Mod.settings.showResearchProgress ? $"{"RqRI_LearningProgress".Translate() + Aux_HR.HRExpertise(pawn)[curProj].ToStringPercent("F0")}" : "");
                    sb.AppendInNewLine(RI_Mod.settings.showTimeToComplete ? $"{"RqRI_TimeToComplete".Translate() + TimeToCompleteLearning(curProj, pawn)}" : "");
                }
                return(sb.ToString());
            }
            if (ResearchInfo.Clean)
            {
                curProj = Find.ResearchManager.currentProj;
                sb.AppendInNewLine(RI_Mod.settings.showCurrentProject ? $"{"RqRI_CurrentProject".Translate() + (curProj != null ? curProj.LabelCap : "None".Translate())}" : "");
                if (curProj != null)
                {
                    sb.AppendInNewLine(RI_Mod.settings.showResearchProgress ? $"{"RqRI_ResearchProgress".Translate() + curProj.ProgressApparent.ToString("F0") + " / " + curProj.CostApparent.ToString("F0") + $" ({curProj.ProgressPercent.ToStringPercent("F1")})"}" : "");
                    sb.AppendInNewLine(RI_Mod.settings.showTimeToComplete && TimeToCompleteResearch(curProj) != "-" ? $"{"RqRI_TimeToComplete".Translate() + TimeToCompleteResearch(curProj)}" : "");
                }
                return(sb.ToString());
            }
            if (ResearchInfo.ModHumanResources)
            {
                Pawn pawn = ListOfCurrentResearchers().Where(x => x.CurJob.targetA.Thing == thing).FirstOrDefault();
                if (pawn != null)
                {
                    curProj = Aux_HR.HRCurrentProject(pawn);
                    sb.AppendInNewLine(RI_Mod.settings.showCurrentProject ? $"{"RqRI_CurrentProject".Translate() + curProj.LabelCap}" : "");
                    sb.AppendInNewLine(RI_Mod.settings.showResearchProgress ? $"{"RqRI_ResearchProgress".Translate() + Aux_HR.HRExpertise(pawn)[curProj].ToStringPercent("F1")}" : "");
                    sb.AppendInNewLine(RI_Mod.settings.showTimeToComplete ? $"{"RqRI_TimeToComplete".Translate() + TimeToCompleteResearch(curProj, pawn)}" : "");
                }
                else
                {
                    sb.Append("RqRI_NotCurrentlyInUse".Translate());
                }
                return(sb.ToString());
            }
            if (ResearchInfo.ModPawnsChooseResearch && !ResearchInfo.ModHumanResources)
            {
                if (Aux_PCR.VersionMismatch)
                {
                    sb.Append("You are using an incompatible version of the 'Pawns Choose Research' mod.");
                    return(sb.ToString());
                }
                Pawn pawn = ListOfCurrentResearchers().Where(x => x.CurJob.targetA.Thing == thing).FirstOrDefault();
                if (pawn != null)
                {
                    curProj = Aux_PCR.PCRCurrentProject(pawn);
                    if (curProj != null)
                    {
                        sb.AppendInNewLine(RI_Mod.settings.showCurrentProject ? $"{"RqRI_CurrentProject".Translate() + curProj.LabelCap}" : "");
                        sb.AppendInNewLine(RI_Mod.settings.showResearchProgress ? $"{"RqRI_ResearchProgress".Translate() + $"{curProj.ProgressApparent.ToString("F0")} / {curProj.CostApparent.ToString("F0")} ({curProj.ProgressPercent.ToStringPercent("F1")})"}" : "");
                        sb.AppendInNewLine(RI_Mod.settings.showTimeToComplete ? $"{"RqRI_TimeToComplete".Translate() + TimeToCompleteResearch(curProj)}" : "");
                    }
                }
                else
                {
                    sb.Append("RqRI_NotCurrentlyInUse".Translate());
                }
                return(sb.ToString());
            }
            return(string.Empty);
        }