rimworld-blax-laws/Source/BlaxLaws/Enforcement/CaseMessages.cs

32 lines
1.5 KiB
C#
Raw Normal View History

using RimWorld;
using Verse;
namespace BlaxLaws
{
/// <summary>
/// Messages for cases (setting "Messages for cases"). Letters are the punishment workers' own, only when
/// a colonist is jailed or the player has to act (setting "Letters for jailings"); Laws never sends a
/// second letter for a break, since the vanilla break letter already arrives.
/// </summary>
public static class CaseMessages
{
/// <summary>One message when a stage's punishment is dispatched: "Bob broke a law: Wake-up (Did it). Punishment: jail."</summary>
public static void Filed(LawCase c, Law law, LawStage stage, PunishmentDef punishment)
{
if (c == null || law == null || !BlaxLawsMod.S.caseMessages)
return;
string text = "BlaxLaws_CaseFiled".Translate(c.OffenderLabel, law.Label, LawLabels.Stage(stage), punishment?.label ?? law.punishment);
Post(c, text);
}
/// <summary>A message about the case, pointing at the offender while it is spawned. Does nothing with messages off.</summary>
public static void Post(LawCase c, string text, MessageTypeDef type = null)
{
if (!BlaxLawsMod.S.caseMessages || text.NullOrEmpty())
return;
LookTargets target = c?.offender != null && c.offender.Spawned ? new LookTargets(c.offender) : LookTargets.Invalid;
Messages.Message(text, target, type ?? MessageTypeDefOf.NeutralEvent, historical: true);
}
}
}