public string ToolTipNamesList(ResearchProjectDef curProj) { Dictionary <Pawn, float> d = new Dictionary <Pawn, float>(); if (ResearchInfo.Clean) { d = ListOfCurrentResearchers(). OrderByDescending(p => p.GetStatValue(StatDefOf.ResearchSpeed) * p.CurJob.targetA.Thing.GetStatValue(StatDefOf.ResearchSpeedFactor)). ToDictionary(p => p, p => p.GetStatValue(StatDefOf.ResearchSpeed) * p.CurJob.targetA.Thing.GetStatValue(StatDefOf.ResearchSpeedFactor)); } if (ResearchInfo.ModPawnsChooseResearch && !ResearchInfo.ModHumanResources) { d = ListOfCurrentResearchers(). Where(p => Aux_PCR.PCRCurrentProject(p) == curProj). OrderByDescending(p => p.GetStatValue(StatDefOf.ResearchSpeed) * p.CurJob.targetA.Thing.GetStatValue(StatDefOf.ResearchSpeedFactor)). ToDictionary(p => p, p => p.GetStatValue(StatDefOf.ResearchSpeed) * p.CurJob.targetA.Thing.GetStatValue(StatDefOf.ResearchSpeedFactor)); } string names = string.Empty; for (int i = 0; i < d.Count; i++) { names += $"\n{d.Keys.ElementAt(i).NameShortColored}: {d.Values.ElementAt(i).ToStringPercent("F1")}"; } return(names); }
public float ResearchSpeedForGivenProject(ResearchProjectDef curProj, Pawn pawn) { if (ResearchInfo.Clean) { return(ListOfCurrentResearchers(). Select(p => p.GetStatValue(StatDefOf.ResearchSpeed) * p.CurJob.targetA.Thing.GetStatValue(StatDefOf.ResearchSpeedFactor)). Sum()); } if (ResearchInfo.ModHumanResources) { return(pawn.GetStatValue(StatDefOf.ResearchSpeed) * pawn.CurJob.targetA.Thing.GetStatValue(StatDefOf.ResearchSpeedFactor) * Aux_HR.HRPrerequisiteMultiplier(curProj, pawn) * pawn.GetStatValue(StatDefOf.GlobalLearningFactor) / curProj.CostFactor(Aux_HR.HRTechLevel(pawn))); } if (ResearchInfo.ModPawnsChooseResearch && !ResearchInfo.ModHumanResources) { return(ListOfCurrentResearchers(). Where(p => Aux_PCR.PCRCurrentProject(p) == curProj). Select(p => p.GetStatValue(StatDefOf.ResearchSpeed) * p.CurJob.targetA.Thing.GetStatValue(StatDefOf.ResearchSpeedFactor)). Sum()); } return(0f); }
public byte NumberOfCurrentResearchersOfGivenProject(ResearchProjectDef curProj) { if (ResearchInfo.Clean) { return((byte)ListOfCurrentResearchers().Count); } if (ResearchInfo.ModPawnsChooseResearch && !ResearchInfo.ModHumanResources) { return((byte)ListOfCurrentResearchers().Where(p => Aux_PCR.PCRCurrentProject(p) == curProj).Count()); } return(0); }
private ResearchProjectDef GetCurProj() { if (ResearchInfo.Clean) { return(Find.ResearchManager.currentProj); } if (_userpawn != null && ResearchInfo.ModHumanResources) { return(Aux_HR.HRCurrentProject(_userpawn)); } if (_userpawn != null && ResearchInfo.ModPawnsChooseResearch && !ResearchInfo.ModHumanResources && !Aux_PCR.VersionMismatch) { return(Aux_PCR.PCRCurrentProject(_userpawn)); } return(null); }
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); }