Files
RimWorld_ResearchWhatever/Source/ResearchWhatever15/Patches/ResearchManagerPatch.cs
p.tychinin 323b82bdc4 1.1.2
2024-04-22 20:57:33 +03:00

39 lines
1.4 KiB
C#

using System.Linq;
using System.Collections.Generic;
using HarmonyLib;
using RimWorld;
using Verse;
using Verse.Sound;
namespace ResearchWhatever.Patches
{
[HarmonyPatch(typeof(ResearchManager), "FinishProject")]
static class ResearchManager_FinishProject_ResearchWhateverPatch
{
internal static void Prefix(ResearchProjectDef proj, ref bool doCompletionDialog)
{
if (doCompletionDialog)
{
var comp = Current.Game.GetComponent<ResearchWhateverGameComp>();
if (comp.NotifyMode == ResearchWhateverNotifyMode.rwnDefault)
return;
doCompletionDialog = false;
//var currentProj = __instance.GetProject();
switch (comp.NotifyMode)
{
case ResearchWhateverNotifyMode.rwnLetter:
Find.LetterStack.ReceiveLetter("ResearchFinished".Translate(proj.LabelCap), proj.description, LetterDefOf.PositiveEvent, null, null, null, null, null);
break;
case ResearchWhateverNotifyMode.rwnNotice:
Messages.Message("ResearchFinished".Translate(proj.LabelCap).CapitalizeFirst(), MessageTypeDefOf.SilentInput);
break;
default:
break;
}
}
}
}
}