Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
using System ;
using RimWorld ;
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
using RimWorld.Planet ;
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
using UnityEngine ;
using Verse ;
namespace BlaxLaws
{
/// <summary>
/// Serving the sentence (design: "Jail for N days"). Hook K (Patch_Pawn_GuestTracker_CapturedBy) moves a
/// case to Jailed at the capture and starts the sentence there, not at filing; "Maintain only" lands two
/// ticks later, after any next-tick default from Blax Castes or a prison mod. Every 2500 ticks Check sets
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
/// "Release" once the sentence is served, releases in place a day later if no colonist did, and closes the
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
/// case when the pawn is out (served, released early, escaped, dead). Laws writes the prisoner
/// interaction mode only on pawns it jailed itself.
/// </summary>
public static class Sentences
{
/// <summary>A day after the release tick without a release, Laws releases the pawn in place.</summary>
public const int FallbackTicks = GenDate . TicksPerDay ;
private static int Now = > Find . TickManager ? . TicksGame ? ? 0 ;
/// <summary>
/// Writes "Maintain only" on a pawn Laws jailed, two ticks after the capture
/// (Pawn_GuestTracker.cs:304), and sets maintainOnlyDone. Two ticks win over Castes' next-tick default
/// and Prison Labor's default in any component order (GameComponentUtility.cs:24-31; Game.cs:472-489).
/// </summary>
public static void WriteMaintainOnly ( LawCase c )
{
if ( c = = null | | c . IsClosed | | c . status ! = CaseStatus . Jailed | | c . maintainOnlyDone )
return ;
Pawn p = c . offender ;
if ( p ? . guest = = null | | ! p . IsPrisonerOfColony )
return ;
p . guest . SetExclusiveInteraction ( PrisonerInteractionModeDefOf . MaintainOnly ) ;
c . maintainOnlyDone = true ;
}
/// <summary>
/// Every 2500 ticks for a jailed case: the early end, the "Maintain only" backstop, "Release" at the
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
/// release tick (wardens, and in 1.7 any colonist on Basic work, take it through WorkGiver_Warden_ReleasePrisoner, which calls
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
/// GenGuest.PrisonerRelease: WasImprisoned, unclaim, free again, GenGuest.cs:8-21), and the fallback.
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
/// An escape is told apart only by the note the escape hook leaves (LawCase.escapedTick), never by the
/// pawn being off the map: a pawn sold, given away, kidnapped or lost with a map is off the map too.
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
/// </summary>
public static void Check ( LawCase c )
{
if ( c = = null | | c . IsClosed | | c . status ! = CaseStatus . Jailed )
return ;
GameComponent_BlaxLaws comp = GameComponent_BlaxLaws . Instance ;
if ( comp = = null )
return ;
Pawn p = c . offender ;
int now = Now ;
if ( p = = null | | LawCase . IsGone ( p ) )
{
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
// Escaped, and the world discarded the escapee (WorldPawnGC, every 15000 ticks: RimWorld.Planet/
// WorldPawnGC.cs:20, 28-30) before this check saw it off the map. A save in between nulls the
// reference (LawCase.DropGoneReferences), so only the saved note counts. A pawn destroyed in place
// (another mod, a dev tool) passes to the world too (Pawn.Destroy, Pawn.cs:2349-2397) and the GC may
2026-12-03 15:32:47 +00:00
// discard it just the same, but it never escaped: offender gone. A discarded pawn is on no map, so an
// escapee that died off the map before the GC took it closes as escaped too, as below.
if ( c . escapedTick > = 0 )
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
{
CloseEscaped ( c , comp ) ;
return ;
}
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
comp . CloseCase ( c , CaseOutcomes . OffenderGone ) ;
return ;
}
if ( p . Dead )
{
2026-12-03 15:32:47 +00:00
// An escapee stays a prisoner of the colony off the map (Pawn.ExitMap clears the guest status only for
// a released prisoner, Pawn.cs:2556-2589) and world pawns keep ticking (WorldPawns.cs:73-101), so it can
// bleed out there before this sweep. A world pawn dies with no corpse (Pawn.cs:2221-2224): the escape
// ended the sentence, and the death came after it. A corpse on a map means it came back and died there.
if ( c . escapedTick > = 0 & & ! p . SpawnedOrAnyParentSpawned )
{
CloseEscaped ( c , comp ) ;
return ;
}
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
CaseMessages . Post ( c , "BlaxLaws_MsgDiedInJail" . Translate ( c . OffenderLabel ) ) ;
comp . CloseCase ( c , EnforcementOutcomes . Died ) ;
return ;
}
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
if ( p . Spawned & & c . escapedTick > = 0 )
c . escapedTick = - 1 ;
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
if ( c . releaseTick < 0 )
c . releaseTick = ( c . captureTick > = 0 ? c . captureTick : now ) + JailFlow . SentenceTicks ( c ) ;
bool served = now > = c . releaseTick ;
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
if ( ! p . Spawned & & c . escapedTick > = 0 )
{
// Escaped off the map, before or after the release tick: a prisoner on "Release" can still break out
// (PrisonBreakUtility.cs:149-176 has no release check).
CloseEscaped ( c , comp ) ;
return ;
}
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
if ( ! p . IsPrisonerOfColony )
{
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
if ( LeftCustody ( p ) )
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
{
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
// Sold, given away, kidnapped, or lost with a map: not an escape, and not free in the colony.
CaseMessages . Post ( c , "BlaxLaws_MsgLeftCustody" . Translate ( c . OffenderLabel ) ) ;
comp . CloseCase ( c , CaseOutcomes . OffenderGone ) ;
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
}
else if ( served )
{
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
// Released by a colonist after the sentence.
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
CaseMessages . Post ( c , "BlaxLaws_MsgBackAtWork" . Translate ( c . OffenderLabel ) ) ;
comp . CloseCase ( c , CaseOutcomes . Served ) ;
}
else
{
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
// Recruited, released by hand or by another mod, maybe off on a caravan since.
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
CaseMessages . Post ( c , "BlaxLaws_MsgReleasedEarly" . Translate ( c . OffenderLabel ) ) ;
comp . CloseCase ( c , CaseOutcomes . ReleasedEarly ) ;
}
return ;
}
if ( ! c . maintainOnlyDone & & ! Enforcement . IsQueued ( c , CaseTask . MaintainOnly ) )
WriteMaintainOnly ( c ) ;
if ( ! served )
return ;
if ( p . guest . ExclusiveInteractionMode ! = PrisonerInteractionModeDefOf . Release )
{
p . guest . SetExclusiveInteraction ( PrisonerInteractionModeDefOf . Release ) ;
CaseMessages . Post ( c , "BlaxLaws_MsgSentenceServed" . Translate ( c . OffenderLabel ) ) ;
}
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
// A prisoner taken along in a caravan keeps its guest status (Pawn.cs:2520-2524) and nobody there can
// carry out "Release"; GenGuest.PrisonerRelease needs no map for a colonist (GenGuest.cs:33-80). A pawn
// in a transporter or shuttle in flight waits until it lands.
if ( now > = c . releaseTick + FallbackTicks & & ( p . Spawned | | p . IsCaravanMember ( ) ) )
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
{
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
// Nobody released it (nobody free, unreachable, a break, away in a caravan): Laws releases it where it is.
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
GenGuest . PrisonerRelease ( p ) ;
CaseMessages . Post ( c , "BlaxLaws_MsgReleasedInPlace" . Translate ( c . OffenderLabel ) ) ;
comp . CloseCase ( c , CaseOutcomes . Served ) ;
}
}
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
private static void CloseEscaped ( LawCase c , GameComponent_BlaxLaws comp )
{
CaseMessages . Post ( c , "BlaxLaws_MsgEscaped" . Translate ( c . OffenderLabel ) ) ;
comp . CloseCase ( c , EnforcementOutcomes . Escaped ) ;
}
/// <summary>
/// A jailed colonist that is no prisoner any more and not in the colony's hands: another faction or none
/// (sold, Pawn.cs:2640-2643; given away; lost with a map, Pawn.cs:1859-1888), or off the map in no caravan,
/// transporter or container of the colony (kidnapped, KidnappedPawnsTracker.Kidnap). A colonist released
/// in the colony keeps the player faction (GenGuest.cs:33-43).
/// </summary>
private static bool LeftCustody ( Pawn p )
{
if ( p . Faction ! = Faction . OfPlayer )
return true ;
if ( p . SpawnedOrAnyParentSpawned | | p . IsCaravanMember ( ) )
return false ;
return ! ThingOwnerUtility . AnyParentIs < ActiveTransporterInfo > ( p ) & & ! ThingOwnerUtility . AnyParentIs < TravellingTransporters > ( p ) ;
}
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
/// <summary>The Cases tab's "Arrest now" applies: a jail case held for a role holder or mechanitor.</summary>
public static bool CanArrestNow ( LawCase c ) = >
c ? . offender ! = null & & ! c . IsClosed & & c . status = = CaseStatus . Open & & c . waitReason = = WaitReasons . Hold ;
/// <summary>"Arrest now" on a held case: lifts the hold, renews guilt and starts the arrest (or leaves it waiting for a bed or an enforcer).</summary>
public static void ArrestNow ( LawCase c )
{
if ( ! CanArrestNow ( c ) )
return ;
JailFlow . LiftHold ( c ) ;
JailFlow . Become ( c ) ;
JailFlow . TryArrest ( c , ignoreHold : true ) ;
}
/// <summary>Ticks of the sentence left for a jailed case, or -1. The Cases tab counts down with it.</summary>
public static int TicksLeft ( LawCase c ) = >
c ! = null & & c . status = = CaseStatus . Jailed & & c . releaseTick > = 0 ? Math . Max ( 0 , c . releaseTick - Now ) : - 1 ;
/// <summary>This capture is the one Laws sent: the case's own enforcer took the offender for a jail case.</summary>
public static bool IsOurCapture ( LawCase c , Pawn byPawn )
{
if ( c = = null | | c . IsClosed | | c . status ! = CaseStatus . Enforcing | | byPawn = = null | | c . enforcer ! = byPawn )
return false ;
string p = c . activePunishment ;
return p ! = null & & ( p = = BlaxLawsDefOf . Jail ? . defName | | p = = BlaxLawsDefOf . SubdueThenJail ? . defName ) ;
}
/// <summary>
/// Hook K's postfix: the sentence starts at the capture. Records the capture and release ticks, queues
/// "Maintain only" two ticks on, and sends the jail letter.
/// </summary>
internal static void OnCaptured ( LawCase c )
{
int now = Now ;
c . activePunishment = BlaxLawsDefOf . Jail ? . defName ? ? "Jail" ;
c . status = CaseStatus . Jailed ;
c . waitReason = null ;
c . captureTick = now ;
c . releaseTick = now + JailFlow . SentenceTicks ( c ) ;
c . maintainOnlyDone = false ;
Enforcement . Schedule ( c , CaseTask . MaintainOnly , c . activeStage , Enforcement . MaintainOnlyDelay ) ;
CaseLetters . Jailed ( c ) ;
}
/// <summary>
/// The law of a jailed case was repealed (Lawbook.Delete stops the case): Laws sets "Release" on the
Blax Laws 1.0.0: tests for every shipped claim, escape and custody fixes
- Tests for the end-to-end subdue and jail, halved pain, the role hold,
every way a sentence ends, pruning, the nobody-to-enforce letter and
performance; each fails when its feature is broken.
- A jailed colonist that escapes closes as Escaped, also when the world
deletes it before the sentence check or a save falls in between. One
sold, given away, kidnapped or lost with a map closes with its own
message instead of "escaped".
- The release fallback also frees a prisoner on a caravan.
- An arrest waits while the offender carries someone, and ends an
offender job that holds reservations, so no reservation errors.
- Release text says a colonist, not a warden: Basic work also releases
prisoners.
- Test harness: test order, fixture hardening, roof cleanup and logging.
2026-12-03 14:46:28 +00:00
/// pawn it jailed, so a colonist lets it go.
Blax Laws 1.0.0: lawbook, act catalogue, enforcement and jail
- Laws tab with the lawbook and the case log; the book starts empty and
the mod watches nothing until a law exists.
- Act catalogue built from the game's defs (breaks, food, drugs, usables,
interactions, recorded acts, records, bills) plus special acts, with
groups, break links and a starter lawbook.
- Enforcement: warn, guilty, subdue, jail for N days and subdue then jail,
one case per incident, danger waits, role holders and mechanitors held
for Arrest now.
- Headless test suite green in every DLC combination, core only and with
the compat mods.
2026-12-02 20:07:17 +00:00
/// </summary>
internal static void ReleaseOnRepeal ( LawCase c )
{
Pawn p = c ? . offender ;
if ( p ? . guest = = null | | ! p . IsPrisonerOfColony )
return ;
p . guest . SetExclusiveInteraction ( PrisonerInteractionModeDefOf . Release ) ;
CaseMessages . Post ( c , "BlaxLaws_MsgRepealedRelease" . Translate ( c . OffenderLabel ) ) ;
}
/// <summary>The release day as a date at the offender's map.</summary>
public static string ReleaseDate ( LawCase c )
{
if ( c = = null | | c . releaseTick < 0 )
return "" ;
Map map = c . offender ? . MapHeld ;
Vector2 at = map ! = null ? Find . WorldGrid . LongLatOf ( map . Tile ) : Vector2 . zero ;
return GenDate . DateFullStringAt ( GenDate . TickGameToAbs ( c . releaseTick ) , at ) ;
}
}
}