This commit is contained in:
p.tychinin
2024-04-22 20:57:33 +03:00
parent 83d3e2f6c5
commit 323b82bdc4
5 changed files with 78 additions and 9 deletions

View File

Binary file not shown.

View File

@@ -8,9 +8,9 @@ using Verse.Sound;
namespace ResearchWhatever.Patches
{
[HarmonyPatch(typeof(ResearchManager), "FinishProject")]
public static class ResearchManager_FinishProject_ResearchWhateverPatch
static class ResearchManager_FinishProject_ResearchWhateverPatch
{
public static void Prefix(ResearchManager __instance, ref bool doCompletionDialog)
internal static void Prefix(ResearchProjectDef proj, ref bool doCompletionDialog)
{
if (doCompletionDialog)
{
@@ -20,14 +20,14 @@ namespace ResearchWhatever.Patches
doCompletionDialog = false;
var currentProj = __instance.GetProject();
//var currentProj = __instance.GetProject();
switch (comp.NotifyMode)
{
case ResearchWhateverNotifyMode.rwnLetter:
Find.LetterStack.ReceiveLetter("ResearchFinished".Translate(currentProj.LabelCap), currentProj.description, LetterDefOf.PositiveEvent, null, null, null, null, null);
Find.LetterStack.ReceiveLetter("ResearchFinished".Translate(proj.LabelCap), proj.description, LetterDefOf.PositiveEvent, null, null, null, null, null);
break;
case ResearchWhateverNotifyMode.rwnNotice:
Messages.Message("ResearchFinished".Translate(currentProj.LabelCap).CapitalizeFirst(), MessageTypeDefOf.SilentInput);
Messages.Message("ResearchFinished".Translate(proj.LabelCap).CapitalizeFirst(), MessageTypeDefOf.SilentInput);
break;
default:
break;

View File

@@ -0,0 +1,61 @@
using HarmonyLib;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Verse;
using Verse.Sound;
namespace ResearchWhatever.Patches
{
[HarmonyPatch(typeof(StudyManager), "StudyAnomaly")]
static class StudyManager_StudyAnomaly_ResearchWhateverPatch
{
internal static void Prefix(Thing studiedThing, Pawn studier, float knowledgeAmount, KnowledgeCategoryDef knowledgeCategory)
{
if (!ModsConfig.AnomalyActive)
{
return;
}
if (knowledgeAmount <= 0f)
{
return;
}
//
var researchManager = Find.ResearchManager;
var proj = researchManager.GetProject(knowledgeCategory);
if (proj != null)
return;
if (knowledgeCategory.overflowCategory != null)
proj = researchManager.GetProject(knowledgeCategory.overflowCategory);
//
if (proj != null)
return;
proj = DefDatabase<ResearchProjectDef>.AllDefsListForReading.FirstOrDefault((ResearchProjectDef x) => x.CanStartNow && x.knowledgeCategory == knowledgeCategory);
if (proj == null && knowledgeCategory.overflowCategory != null)
proj = DefDatabase<ResearchProjectDef>.AllDefsListForReading.FirstOrDefault((ResearchProjectDef x) => x.CanStartNow && x.knowledgeCategory == knowledgeCategory.overflowCategory);
if (proj == null)
{
//CompStudiable compStudiable = studiedThing.TryGetComp<CompStudiable>();
//if (compStudiable == null)
// return;
//
//if (compStudiable.Completed) ;
return;
}
SoundDefOf.ResearchStart.PlayOneShotOnCamera(null);
researchManager.SetCurrentProject(proj);
Thing thing = studiedThing;
if (thing.Map == null) thing = thing.ParentHolder as Thing;
TutorSystem.Notify_Event("StartResearchProject");
Messages.Message("ResearchWhateverNewResearch".Translate(studier.Name.ToStringFull, proj.label).CapitalizeFirst(), new TargetInfo(thing.Position, thing.Map, false), MessageTypeDefOf.SilentInput);
}
}
}

View File

@@ -63,6 +63,7 @@
<ItemGroup>
<Compile Include="Patches\ResearchManagerPatch.cs" />
<Compile Include="Patches\StaticConstructorOnStartupUtilityPatch.cs" />
<Compile Include="Patches\StudyManagerPatch.cs" />
<Compile Include="Patches\WorkGiver_ResearcherPatch.cs" />
<Compile Include="ResearchWhatever.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -1,11 +1,18 @@
1.1.0
1.1.2
- added sound notification when new anomaly project picked;
1.1.1
- fixed notification messages for anomaly projects showing that "current normal project" is finished;
- anomaly researchers now automatically start anomaly projects when possible;
1.1.0
- 1.5 be like;
1.0.7
- made a minor change that probably should improve cases when mods add their own requirements for research (thanks @Taranchuk);
other
- little hint to put this mod before "research re-invenred" mod.
- little hint to put this mod before "research re-invenred" mod;
1.0.6
- added checking for new prerequisites;