using Verse; namespace BlaxLaws { /// /// Subdue (design: "Subdue"): the BlaxLaws_Subdue job while the offender is still in its break. After the /// break a did-it Subdue row warns and a planning one closes as "break ended". A child (Biotech) is never /// beaten: it is warned (a Subdue row has no days). A break hostile to the colony (berserk, checked on /// the live state) never gets it: the pawn fights back, so it is warned. A slave is subdued like a /// colonist. A subdue that meets danger is called off; the sweep starts it again after the fight. /// public class PunishmentWorker_Subdue : PunishmentWorker { public override void Start(LawCase c, Law law, LawStage stage) { Pawn o = c?.offender; if (o == null || c.IsClosed || o.Dead || SubdueFlow.Runs(c)) return; if (DlcSupport.IsChild(o)) { SubdueFlow.WarnInstead(c, "BlaxLaws_MsgWarnedChild"); return; } if (o.Downed && c.status == CaseStatus.Enforcing) { // The earlier stage's subdue downed it: this stage's subdue is done too. GameComponent_BlaxLaws.Instance?.CloseCase(c, CaseOutcomes.Subdued); return; } if (o.Downed || !SubdueFlow.InBreak(c)) { SubdueFlow.BreakOver(c); return; } if (Enforcers.FightsBack(o)) { SubdueFlow.WarnInstead(c, "BlaxLaws_MsgWarnedFightsBack"); return; } SubdueFlow.TryIssue(c, EnforcerNeed.Subdue); } public override void Sweep(LawCase c) { if (c == null || c.IsClosed) return; GameComponent_BlaxLaws comp = GameComponent_BlaxLaws.Instance; if (!BlaxLawsMod.S.enforceLaws) { Stop(c); comp?.CloseCase(c, CaseOutcomes.NotEnforced); return; } Pawn o = c.offender; if (o == null || o.Dead) { Stop(c); comp?.CloseCase(c, CaseOutcomes.OffenderGone); return; } if (SubdueFlow.Runs(c)) { // A raid or a berserk colonist since the start: the warden is called off and the case waits. SubdueFlow.CallOffInDanger(c); return; } // A did-it Warn, Guilty or Subdue queued for next tick runs now, before anything below closes the case. SubdueFlow.RunQueuedAlongside(c, sameToo: true); if (c.IsClosed || SubdueFlow.Runs(c)) return; // A later stage with another punishment dispatches next tick and takes over (as Enforcement.Sweep's // break-ended close waits for it). if (SubdueFlow.HandOverDue(c)) return; if (o.Downed && c.status == CaseStatus.Enforcing) { // Downed while the enforcer was on it, by a hit or anything else: the break is over. comp?.CloseCase(c, CaseOutcomes.Subdued); return; } if (o.Downed || !SubdueFlow.InBreak(c)) { SubdueFlow.BreakOver(c); return; } if (Enforcers.FightsBack(o)) { SubdueFlow.WarnInstead(c, "BlaxLaws_MsgWarnedFightsBack"); return; } // A lost subdue (the enforcer got hungry, drafted, downed, or the game was loaded) starts again. SubdueFlow.TryIssue(c, EnforcerNeed.Subdue); } public override void Stop(LawCase c) { SubdueFlow.End(c); if (c != null && !c.IsClosed) c.status = CaseStatus.Open; } } }