diff --git a/1.5/Assemblies/ResearchWhatever.dll b/1.5/Assemblies/ResearchWhatever.dll index e8577df..d99a55e 100644 Binary files a/1.5/Assemblies/ResearchWhatever.dll and b/1.5/Assemblies/ResearchWhatever.dll differ diff --git a/About/ModIcon.png b/About/ModIcon.png new file mode 100644 index 0000000..36a3e4f Binary files /dev/null and b/About/ModIcon.png differ diff --git a/Source/ResearchWhatever15/Patches/StudyManagerPatch.cs b/Source/ResearchWhatever15/Patches/StudyManagerPatch.cs index 3c222bb..1099bcb 100644 --- a/Source/ResearchWhatever15/Patches/StudyManagerPatch.cs +++ b/Source/ResearchWhatever15/Patches/StudyManagerPatch.cs @@ -37,19 +37,36 @@ namespace ResearchWhatever.Patches if (proj != null) return; - proj = DefDatabase.AllDefsListForReading.FirstOrDefault((ResearchProjectDef x) => x.CanStartNow && x.knowledgeCategory == knowledgeCategory); - if (proj == null && knowledgeCategory.overflowCategory != null) - proj = DefDatabase.AllDefsListForReading.FirstOrDefault((ResearchProjectDef x) => x.CanStartNow && x.knowledgeCategory == knowledgeCategory.overflowCategory); - - if (proj == null) + var projs = DefDatabase.AllDefsListForReading.Where((ResearchProjectDef x) => x.CanStartNow && x.knowledgeCategory == knowledgeCategory).ToList(); + if (projs.NullOrEmpty() && knowledgeCategory.overflowCategory != null) + projs = DefDatabase.AllDefsListForReading.Where((ResearchProjectDef x) => x.CanStartNow && x.knowledgeCategory == knowledgeCategory.overflowCategory).ToList(); + + if (projs.NullOrEmpty()) { - //CompStudiable compStudiable = studiedThing.TryGetComp(); - //if (compStudiable == null) - // return; + CompStudiable compStudiable = studiedThing.TryGetComp(); + CompHoldingPlatformTarget compHoldingPlatformTarget = studiedThing.TryGetComp(); + + bool b = false; + if (compStudiable != null && compStudiable.Completed) + { + compStudiable.studyEnabled = false; + b = true; + } // - //if (compStudiable.Completed) ; + if (compHoldingPlatformTarget != null) + { + compHoldingPlatformTarget.containmentMode = EntityContainmentMode.MaintainOnly; + b = b || compStudiable != null; + } + + if (b) Messages.Message("ResearchWhateverNothingLeftToResearch".Translate(studiedThing.Label).CapitalizeFirst(), new TargetInfo(studiedThing.PositionHeld, studiedThing.MapHeld, false), MessageTypeDefOf.NeutralEvent); + return; } + projs.SortBy(x => x.CostApparent - x.ProgressApparent); + proj = projs.First(); + projs.TryRandomElementByWeight(x => x.CostApparent == proj.CostApparent ? 1f : 0f, out proj); + SoundDefOf.ResearchStart.PlayOneShotOnCamera(null); researchManager.SetCurrentProject(proj); Thing thing = studiedThing; diff --git a/Source/ResearchWhatever15/Patches/WorkGiver_ResearcherPatch.cs b/Source/ResearchWhatever15/Patches/WorkGiver_ResearcherPatch.cs index 392ac64..ce922f1 100644 --- a/Source/ResearchWhatever15/Patches/WorkGiver_ResearcherPatch.cs +++ b/Source/ResearchWhatever15/Patches/WorkGiver_ResearcherPatch.cs @@ -73,7 +73,7 @@ namespace ResearchWhatever.Patches Messages.Message("ResearchWhateverNothingLeftToResearch".Translate(bench.Label).CapitalizeFirst(), new TargetInfo(bench.Position, bench.Map, false), MessageTypeDefOf.NeutralEvent); return; } - projects.SortBy(x => x.GetModExtension()?.lowPriority == true ? 100000000f + x.CostApparent : x.CostApparent); + projects.SortBy(x => x.GetModExtension()?.lowPriority == true ? 100000000f + x.CostApparent - x.ProgressApparent : x.CostApparent - x.ProgressApparent); ResearchProjectDef def = projects.First(); projects.TryRandomElementByWeight(x => x.CostApparent == def.CostApparent ? 1f : 0f, out def); diff --git a/change.log b/change.log index 36bb802..d698694 100644 --- a/change.log +++ b/change.log @@ -1,4 +1,9 @@ -1.1.2 +1.1.3 +- mod now automatically picks CHEAPEST anomaly research; +- if anomly is fully studied and nothing left to research, study will be automatically toggled off; +- cheapest project now takes into account already made progress; + +1.1.2 - added sound notification when new anomaly project picked; 1.1.1