docs: work rule areas (1.6), status and ownership lines

Named areas painted over anything with per-area rules: No cleaning, No firefighting, No repairs, Don't haul from here, Clean first, Haul first. Kept in Zones' own save-safe grids, never as vanilla areas.
This commit is contained in:
Fabian @ Blax Software 2026-11-29 20:49:46 +01:00
parent d8d7e3d3c0
commit 8c401b3f04
1 changed files with 177 additions and 12 deletions

View File

@ -1,8 +1,8 @@
# Blax Zones
Drag a delivery zone and everything you buy from orbital or caravan traders, plus quest rewards, lands in it, sorted by item filter: medicine by the hospital, steel by the workshop. Drag a sleeping zone over the barn and every chicken and duck has a bed, so you stop placing sleeping spots one at a time.
Drag a delivery zone and everything you buy from orbital or caravan traders, plus quest rewards, lands in it, sorted by item filter: medicine by the hospital, steel by the workshop. Drag a sleeping zone over the barn and every chicken and duck has a bed, so you stop placing sleeping spots one at a time. Paint a work rule area and colonists stop cleaning the barn without giving up its fire watch, leave the killbox's loot alone until you untick the rule, and clean the hospital first.
Status: design ready to build, no code yet. Checked against the RimWorld 1.7.5021 game code on 2026-11-29. RimWorld 1.7, package id `blax.zones`. From the first release a plain unsubscribe leaves a loadable save with vanilla zones intact; from 1.2 a button removes it with no errors.
Status: 1.0 is built; 1.1 to 1.6 are designed, no code yet. Checked against the RimWorld 1.7.5021 game code on 2026-11-29. RimWorld 1.7, package id `blax.zones`. From the first release a plain unsubscribe leaves a loadable save with vanilla zones intact; from 1.2 a button removes it with no errors.
Changes on 2026-11-29, after two review rounds:
@ -16,8 +16,10 @@ Changes on 2026-11-29, after two review rounds:
- New: the zone list follows `ZoneManager`, the drop-pod reach rule no longer counts zone beds as colony, notes for Blax Defaults and Prisoner Realism, corrected Hospitality and RimFridge notes, and tests with numbers instead of screenshots.
- Every routed path falls back to vanilla in a catch, so a Zones bug never loses an item.
- DLC support: Zones works with any DLC combination, core only included, and About.xml names no DLC. Slave sleeping zones (1.4) are the one part that needs a DLC (Ideology). Their guard is now `ModsConfig.IdeologyActive` instead of the setter's install check, the option shows disabled with "Needs Ideology", and a slave zone from a save made with Ideology keeps its type without it. The Wastepack refusal is null-checked for runs without Biotech. A release runs the tests in all 8 combinations of Royalty, Ideology and Biotech. No day count changes: each guard is a null or `Active` check inside work already budgeted.
- The Blax Defaults notes match its final scope: the ownership sentence adds what the game forbids when pawns drop gear or die, and the hooks name the Defaults release they arrive in.
- The Blax Defaults notes match its reworked forbid rules: the ownership sentence reads "go down, die or are stripped", and the hooks name the Defaults releases after its re-cut (forbid rules 1.1, build scope 1.2, growing zones 1.4).
- Matched with the Castes and Defaults docs: At a glance gains a Needs column in the shared format. The ownership line lists every Castes slot, work priorities and weapon loadout included, and Defaults' sentence now says its forbid rules write outside creation.
- New release 1.6, work rule areas, from Fabian's request for "No cleaning" and "Priority zones" (2026-11-29): one painted layer of named areas, each with rule checkboxes (no cleaning, no firefighting, no repairs, don't haul from here, clean first, haul first). Kept in the component, not as vanilla Areas or Zones; seven postfixes and two work givers that need no patch. Construction and plant work first went to the Backlog.
- 1.6 after review: CleaningArea, Cleaning Area Relaunched and Cleaning Priority (Continued) don't reorder vanilla cleaning, they replace CleanFilth's work giver class. The "No cleaning" postfixes now also go on the class the CleanFilth def names, and "Clean first" stands down for Cleaning Priority (Continued). "Haul first" hands a pawn to Pick Up And Haul only when Pick Up And Haul's own `ShouldSkip` lets it through, so guests, working prisoners and quest lodgers never get inventory hauls. Hospitality guests do help with colony work and follow all six rules. The Defaults notes follow its forbid rework. The ownership line gains per-cell work rules, and Castes, Slaves and Defaults now carry the same Zones sentence; all four docs say "allowed area" for Castes' area slot, so it isn't read as a work rule area. The performance test runs 60 colonists. 1.6 takes 8 days, so the plan takes 37.
## At a glance
@ -29,11 +31,12 @@ Changes on 2026-11-29, after two review rounds:
| 1.3 | Goods go straight into stockpiles, shelves, racks and fridges, and under roofs; orbital traders buy from flagged storage; cargo pods land in a zone | Covers the use of Map Wide Orbital Trade Beacon (51k) and Wall-Mounted Orbital Trade Beacon (16k), both alive on 1.7. Replaces 3 small pod mods with no 1.7 build (6.5k combined) | None | 6 |
| 1.4 | People sleeping zones for colonists, slaves (Ideology) and prisoners; medical and shared zones | None directly; extends 1.2 to people | None (slaves: Ideology) | 6 |
| 1.5 | With Blax Castes, sleeping zones limited by caste | None | None | 2 |
| Total | | | | 29 |
| 1.6 | Work rule areas, painted over anything: a barn nobody cleans that still gets its fires fought, a killbox where nobody fights fires, repairs or hauls until you untick it, a hospital cleaned first, a landing pad hauled first | Covers the use of CleaningArea (114k, last 1.4), Cleaning Area Relaunched (23k, 1.6 only) and Cleaning Priority - 1.0 (1.8k, dead). Overlaps Cleaning Priority (Continued) (23k, 1.7), for which "Clean first" stands down, and the per-item "haul urgently" of Allow Tool (1.4M, last 1.6) and Keyz' Allow Utilities (91k, 1.7) | None | 8 |
| Total | | | | 37 |
Effort: S = 0.5 days, M = 2, L = 5, summed per release and rounded up. Subscriber counts were read from the Workshop on 2026-11-29. Needs: "None" means the release runs on the core game, and a DLC in brackets marks the parts that switch off without it (see "DLC support").
Total: 29 working days, up from 28: the removal button, plus the test work of shipping sleeping zones in two releases. 1.0 takes 6 working days, so it doesn't fit in a five-day week. If it slips, caravan camps move to 1.0.1 and orbital routing ships first.
Total: 37 working days: 29 for 1.0 to 1.5 (up from 28: the removal button, plus the test work of shipping sleeping zones in two releases), 6 of them for 1.0, which is built, and 8 for work rule areas (1.6). 1.6 needs only the 1.0 component and the 1.2 removal button, so it can move ahead of 1.3 to 1.5 without changes; if it slips, Clean first and Haul first move to 1.6.1 and the four "No" rules ship first.
## Defaults I picked
@ -59,6 +62,18 @@ Change if you disagree.
- Odyssey gravships leave Blax zones and their beds behind. Zone beds never fly.
- Caste limits (1.5) apply to medical zones too, so a medical zone can be kept for the Miner caste.
- A Zones error never costs an item: every routed path falls back to vanilla.
- Work rules (1.6) are named areas with checkboxes, not one layer per rule: a killbox gets "No firefighting", "No repairs" and "Don't haul from here" in one drag, and unticking "Don't haul from here" after the raid lets haulers empty it without repainting. Up to 10 per map, like allowed areas.
- A new work rule area has no rule ticked, so painting alone changes nothing.
- "No" beats "first": a cell in a "No cleaning" area and a "Clean first" area isn't cleaned automatically.
- Player orders win over every "No" rule: right-click cleaning and repairing, the right-click extinguish order and the vanilla Haul designation work in every area. Like a forbidden item, an item in a "Don't haul from here" cell has no right-click "Prioritize hauling"; the Haul designation or unticking the rule brings it in.
- A burning pawn is always put out, also in a "No firefighting" area. The "Fire in home area" alert still shows fires there.
- "No repairs" covers repairing and replacing broken components, the two jobs the home area gates. Auto-rebuild and trap rearming stay with the home area.
- "Clean first" works inside the home area only, as all cleaning does; the manage dialog counts an area's cells outside it.
- "First" rules cover cleaning and hauling only. "Build first" and plant work first are in the Backlog: frame order has build-order effects, and growing zones already split fields.
- With Cleaning Priority (Continued) active, "Clean first" stands down and its checkbox says why: that mod already orders cleaning by area. The four "No" rules still work with it.
- "Clean first" comes before snow clearing: priority 15 within Cleaning, above "clear snow" (10) and "clean filth" (5). "Haul first" sits at 21 within Hauling: after corpses, caravans, transporters and refuelling, before filling fermenting barrels and emptying egg boxes (19, 20), Pick Up And Haul (18) and general hauling (15).
- Work rules never change work priorities: a pawn cleans first only when it reaches Cleaning in its own order, hauls first only within Hauling, and never leaves its allowed area for either.
- Work rule areas don't touch the home area, which keeps everything else it does: forbidding what pawns drop outside it, auto-rebuild, trap rearming.
Everything below is for the modder building it.
@ -68,7 +83,7 @@ Three parts carry everything. Build them first, in 1.0 and 1.2. The rules and th
### Zone store, safe to remove from a save
All Blax state lives in one `MapComponent_BlaxZones` per map: our zones while saving and loading (1.0), the zone beds (1.2), the stockpile and shelf flags (1.3), and every cache (cell lists, reachability, pending respawns). No Blax zone or Blax field ever enters a vanilla save list.
All Blax state lives in one `MapComponent_BlaxZones` per map: our zones while saving and loading (1.0), the zone beds (1.2), the stockpile and shelf flags (1.3), the work rule areas (1.6), and every cache (cell lists, reachability, pending respawns, the work-rule mask and filth lists). No Blax zone, area or field ever enters a vanilla save list.
- Why: `ZoneManager.ExposeData` (ZoneManager.cs:21) deep-saves the private `allZones` (ZoneManager.cs:9). An unknown zone class falls back to the abstract `Zone`, throws and loads as null (ScribeExtractor.cs:105-118, 146-150). `UpdateZoneManagerLinks` (ZoneManager.cs:31) then throws an NRE in the same load. `Scribe_Deep` catches it in `SaveableFromNode` and leaves `map.zoneManager` null (Scribe_Deep.cs:84; Map.cs:873), so the map loses every zone and every later zone access throws. A MapComponent with a missing class also loads as null, but `Map.FillComponents` removes nulls (Map.cs:712, called again after loading at Map.cs:929), so nothing breaks.
- Save: a prefix on `ZoneManager.ExposeData`, only when `Scribe.mode == Saving`, swaps `allZones` for a filtered copy without our zones. A finalizer puts the original list object back, even if saving throws.
@ -77,6 +92,7 @@ All Blax state lives in one `MapComponent_BlaxZones` per map: our zones while sa
- Plain unsubscribe: the save loads. In 1.0 and 1.1 the log shows exactly 2 errors per map: "Could not find class BlaxZones.MapComponent_BlaxZones" and "SaveableFromNode exception: ... Can't load abstract class Verse.MapComponent" (ScribeExtractor.cs:111, 116; MapComponent.cs:3). From 1.2 the zone beds go with the component node, which adds:
- one "Could not resolve reference" warning per bed owner, job target and reservation that pointed at a zone bed;
- about two "tried to get CurToil with curToilIndex=2" errors (JobDriver.cs:52-66) per pawn that lay in a zone bed when the game was saved. Its `JobDriver_LayDown` had 3 toils with the bed (JobDriver_LayDown.cs:55-60). With the target unresolved, `SetupToils` on PostLoadInit (JobDriver.cs:268-271) builds 2 toils, or 1 for a pawn that can't move (JobDriver_LayDown.cs:61-69). The error comes at spawn, when `Pawn_RotationTracker.Notify_Spawned` reads `HandlingFacing` (Pawn_RotationTracker.cs:14-31; JobDriver.cs:122-131), and on the first tick in `DriverTick` (JobDriver.cs:350); the job then runs out of toils and ends. Saves made at night have many sleepers.
- From 1.6, one "Could not load reference to RimWorld.WorkGiverDef named BlaxZones_CleanFirst" (or `BlaxZones_HaulFirst`) error per current or queued job that one of Zones' two work givers handed out. `Job.ExposeData` saves the giver as a def reference (Job.cs:553), a missing def logs that error and loads as null (ScribeExtractor.cs:44-63, error at :56), and every vanilla reader of `job.workGiverDef` checks for null (Pawn_JobTracker.cs:116, JobQueue.cs:152, LearningGiver_Workwatching.cs:43, JobDriver_Workwatching.cs:65), so the job runs on. The work rule areas go with the component node and add no error.
- The removal button (1.2) avoids all of these.
- Removal flag (1.2): vanilla re-creates a missing MapComponent. `Map.FillComponents` (Map.cs:710-726) adds every missing MapComponent subclass on new maps (Map.cs:617) and at the end of every `ExposeComponents`, saving included (Map.cs:929, after the components list is written at :898). So after the button, a postfix on the private `Map.FillComponents` removes `MapComponent_BlaxZones` again while the removal flag, a weak reference to the current `Game`, names the current game. That covers every later save, autosave and new map in that game. The component is never removed inside a `FinalizeInit`: `MapComponentUtility.FinalizeInit` loops by index (MapComponentUtility.cs:72-84), so removing an entry would skip the next component's `FinalizeInit`. Zones' own code never creates the component, and every patch reads `map.GetComponent<MapComponent_BlaxZones>()` and routes to vanilla on null.
- Map removal: a `MapRemoved` override (MapComponent.cs:40, called from Game.cs:766) only drops caches. It never calls `Zone.Delete` or `Deregister` on a removed map. Vanilla doesn't either: it unclaims the map's pawns and only notifies things (MapDeiniter.cs:218-254).
@ -133,7 +149,7 @@ From the three Castes review rounds.
Every Blax mod works with any DLC combination, core only included (rule of 2026-11-29). For Zones:
- About.xml names no DLC, neither as a dependency nor in loadAfter.
- Every feature runs on the core game. The one part that needs a DLC is slave sleeping zones (Ideology, 1.4). Tribute collectors and Empire quests exist only with Royalty, but they reach Zones through core code (the caravan incident's base class, `QuestPart_DropPods`), so camping and reward routing have no Royalty code.
- Every feature runs on the core game. The one part that needs a DLC is slave sleeping zones (Ideology, 1.4). Work rule areas (1.6) name no DLC def; with Biotech, cleansweepers and lifters follow the rules through the same work givers (`canBeDoneByMechs` defaults to true, WorkGiverDef.cs:50; `IsColonyMech` passes `PawnCanUseWorkGiver`, JobGiver_Work.cs:270). Biotech's pollution clearing (`CleanClearPollution`, Biotech WorkGiverDefs/WorkGivers.xml:347) and Odyssey's sand clearing (the snow clear area and `WorkGiver_ClearSnowOrSand`) have their own areas and aren't touched. Tribute collectors and Empire quests exist only with Royalty, but they reach Zones through core code (the caravan incident's base class, `QuestPart_DropPods`), so camping and reward routing have no Royalty code.
- DLC defs only through `MayRequire` in XML and null-checked DefOf members in code. Zones' defs and patches name no DLC def: the designator patch anchors on Growing because the Fishing entry carries `MayRequire` Odyssey (Core Misc/Designations/DesignationCategories.xml:40-41), and the bed defs' `artificialForMeditationPurposes` and `bringAlongOnGravship` are core fields (BuildingProperties.cs:334, set by Core's own sleeping spots at Buildings_Furniture.xml:71 and :490; ThingDef.cs:167). The only DLC def the code reads is Biotech's Wastepack (Biotech ThingDefs_Items/Items_Resource_Manufactured.xml:280) through `ThingDefOf.Wastepack`, which is `[MayRequireBiotech]` (ThingDefOf.cs:235-236) and null without Biotech; every use checks for null.
- DLC code only behind `ModsConfig.<DLC>Active`. `ModLister.Check<DLC>` is no guard: it checks that the DLC is installed, not active (ModLister.cs:283-287, 347-364), so it passes in a run that leaves an installed DLC out and logs an error for a player who doesn't own it. Vanilla's `ForOwnerType` setter relies on it for slave beds (Building_Bed.cs:100), hence the 1.4 guard.
- Settings and gizmos: no global setting needs a DLC. A per-zone choice that does shows disabled with a "Needs <DLC>" note instead of hiding: the owner-type gizmo's "Slaves" shows "Needs Ideology".
@ -159,6 +175,7 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
| People sleeping zones for colonists and prisoners; medical, shared and comfort; zone tints | 1.4 | None | Unchanged |
| Slave sleeping zones | 1.4 | Ideology | "Slaves" shows disabled with "Needs Ideology"; a slave zone from a save made with Ideology stays one and can be switched to colonists or prisoners |
| Caste filter | 1.5 | None (Blax Castes is a mod) | Unchanged |
| Work rule areas: no cleaning, firefighting, repairs or hauling; clean first, haul first | 1.6 | None | Unchanged; without Biotech there are no mechs to follow the rules |
| Royal title rewards | Backlog | Royalty | Not offered |
| Age limits on people zones | Backlog | Biotech | Shown disabled with "Needs Biotech" |
| Blax zones fly with gravships | Backlog | Odyssey | Zones stay behind, as today |
@ -245,7 +262,7 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Compat runs:** `-Compat` adds Hospitality, Pick Up And Haul, Haul to Stack, RimFridge, Weapon Racks, Prison Labor, Prisoner Realism, Replace Stuff, VEF with VFE Core and VFE Medical, Dubs Skylights, Vanilla Events Expanded, Blax Castes, Blax Slaves, and Blax Defaults once it has code. Mods that change `TradeDropSpot` or `AllLaunchableThingsForTrade` stay out of `-Compat`, so they can't hide Zones' own path (the Castes spec review found Trade as Slave or Colonist hiding Blax Slaves' buy mode). None of the replaced mods is installed; compose with them through test-only prefixes.
- **Stand-down tests:** inject package ids into a `SimulatedActive` set, the Castes overlap-warning pattern. One per trading-spot id in Compat.cs.
- **Fixtures to add**, only those 1.0 uses; later releases list their own:
- `TestArea(w, h)` carves a deterministic area on the quick-test map: clears things, sets soil, removes roofs, unfogs, keeps away from colonists and beacons, and wraps random calls in `Rand.PushState(seed)`. Quick-test maps vary; Castes never needed this because it tests pawns, not terrain.
- `TestArea(w, h)` carves a deterministic area on the quick-test map: clears things, sets soil, removes roofs, unfogs, keeps away from colonists and beacons, and wraps random calls in `Rand.PushState(seed)`. Quick-test maps vary; Castes never needed this because it tests pawns, not terrain. The suite hands out about 55 areas, more than a hilly 250x250 map holds, so the test mod's `QuickTestMap` makes the quick-test map 325x325 on a flat or small-hills tile while `-blaxzonestests` is on. When nothing fits, `TestArea` fails with the reasons it turned candidates down.
- `Roof(rect)`, `Wall(cell)`, `Water(cell)`, `FenceRing(rect)` with a pen marker, `PoweredBeacon(cell)`, `Stockpile(rect)`.
- `DeliveryZone(rect, filter, priority, sources)`.
- `OrbitalTrader(kind)`, `TraderCaravan()` (forced incident).
@ -369,7 +386,8 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Players get:** Click "Remove Blax Zones from this game" in the mod settings, save, then disable the mod, and the save loads with no errors and no warnings from Zones. Without the button the save still loads, with the warnings and errors listed in the data model.
- **How:**
- Needs a loaded game and a confirmation dialog that names the counts (zones, zone beds; from 1.3 flagged storage).
- Needs a loaded game and a confirmation dialog that names the counts (zones, zone beds; from 1.3 flagged storage; from 1.6 work rule areas).
- From 1.6 it also ends every current job and drops every queued job whose `workGiverDef` is `BlaxZones_CleanFirst` or `BlaxZones_HaulFirst`, then deletes the work rule areas through the component's own delete, which calls `ListerHaulables.RecalcAllInCell` (ListerHaulables.cs:146-153) on every cell that had "Don't haul from here" once the rule is gone, so those items are hauled again in the same game.
- On every map: unclaim owners of zone beds silently, end every job whose target is a zone bed (`jobs.EndCurrentJob(JobCondition.InterruptForced)`), destroy the beds with the choke point told that Zones started it, deregister our zones, then remove the component from `map.components`.
- Set the removal flag from the data model; the `Map.FillComponents` postfix keeps the component off every map of this game from then on.
- It ends with the message "Save now, then disable the mod". A dev debug action does the same.
@ -571,6 +589,136 @@ Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 i
- Castes joins the default `-Compat` set; the caste tests skip in plain runs.
- A test helper builds castes through reflection only, so the test mod compiles without Castes.
### 1.6 Work rule areas (8 days)
From Fabian's request of 2026-11-29: a "No cleaning zone", "Priority zones (colonists should prefer work in that zone)", or one "Restrict" zone for firefighting, hauling and cleaning. What vanilla gives today:
- The home area gates four jobs at once: cleaning (only filth in the home area is listed and accepted, ListerFilthInHomeArea.cs:29-35; WorkGiver_CleanFilth.cs:17-20, 33), firefighting (WorkGiver_FightFires.cs:55), repairs (WorkGiver_Repair.cs:35) and broken components (WorkGiver_FixBrokenDownBuilding.cs:56). Taking a barn out of the home area to stop the cleaning also stops fire fighting and repairs there, and makes what pawns drop there forbidden (ForbidUtility.cs:48-58).
- An allowed area restricts a pawn for every job, not one job everywhere. Forbidding items stops hauling, but also every other use of them.
- Nothing orders work by place. `JobGiver_Work` walks the pawn's work givers by work type priority, then by `priorityInType` (Pawn_WorkSettings.cs:207-256; WorkTypeDef.cs:101-111), moves to the next `priorityInType` only when the current one found nothing (JobGiver_Work.cs:85-88), and each giver takes the closest reachable target (JobGiver_Work.cs:150; GenClosest.cs:40-85). Cleaning searches 4 regions around the pawn first, then the home filth list (WorkGiver_CleanFilth.cs:15; GenClosest.cs:58-72). Hauling searches the map's haulables set (WorkGiver_Haul.cs:14-22; ListerHaulables.cs:29-32).
Why this shape:
- Not a Zone. One zone per cell (Designator_ZoneAdd.cs:72-76), so a rule couldn't lie on the barn's hay stockpile and animal sleeping zone, the classic "don't clean here" place, or on a growing field.
- Not a vanilla `Area`. `AreaManager.ExposeData` deep-saves every area by class (AreaManager.cs:50). With the mod gone, a work rule area loads as null (ScribeExtractor.cs:111, 116, 146-150; Scribe_Collections.cs:240-247), `UpdateAllAreasLinks` throws on it in the same load (AreaManager.cs:51-54, 115-121), and the catch leaves `map.areaManager` null (ScribeExtractor.cs:146-150; Scribe_Deep.cs:84; Map.cs:879): the map loses its home area and every allowed area, and every home lookup throws (WorkGiver_CleanFilth.cs:33 and about 30 more). The `ZoneManager` save swap would fix that, but then nothing of vanilla's Area remains useful: `AreaManager.GetLabeled` matches any area by label (AreaManager.cs:86-96), which Blax Castes uses to find a caste's allowed area, so a work rule area named like an allowed area could hide it; and every painted cell notifies the path finder and regions (Area.cs:120-135), which rules don't need.
- Our own grids in `MapComponent_BlaxZones`, with our own designators and vanilla's `CellBoolDrawer` for the overlay. Save-safe like every other Zones state, and they overlap anything.
- Named areas with checkboxes, not one layer per rule. A layer per rule needs 12 designators in the Zone menu (expand and clear for six rules), and switching the killbox's "Don't haul from here" off after a raid would mean erasing and repainting.
- The four "No" rules are postfixes that make a cell count as outside the home area for one job. The two "first" rules are extra work givers in the same work type, the vanilla way to order work within a type, so they need no patch and can't override a pawn's work priorities.
#### Work rule areas
- **Players get:** "Expand work rule area" and "Clear work rule area" in the Zone menu, after the snow clear designators, painted like an allowed area. Clicking one picks an area from a list that also offers "New work rule area" and "Manage work rule areas". An area lies over anything: stockpiles, growing zones, delivery and sleeping zones, other work rule areas. The manage window renames and deletes areas and holds each area's checkboxes: "No cleaning", "No firefighting", "No repairs", "Don't haul from here", "Clean first", "Haul first". A new area has none ticked. Up to 10 per map. While a work rule designator or the manage window is open, the selected area is drawn in its color.
- **How:**
- Data: `WorkRuleArea : IExposable, ICellBoolGiver` with an int id from the component's own counter, a label, a color from a fixed palette, a vanilla `BoolGrid` (scribed with `Scribe_Deep`, as `Area` does, Area.cs:99-103) and the ticked rules as a list of rule names, so a rule dropped in a later version leaves nothing unresolved. The component deep-saves the list.
- Rule mask: one `byte[]` per map, one bit per rule, the OR of the rules of every area covering the cell, plus a cell count per rule. Unsaved. A paint or clear recomputes the touched cells, a checkbox change or delete the area's cells, and the first lookup after loading builds it in full. `Scribe.loader.FinalizeLoading` runs before maps spawn their things (Game.cs:611, 619), so the haulables postfix already sees the mask in the load spawn loop.
- Designators: `Designator_WorkRuleAreaExpand` and `_Clear`, `Designator_Cells` subclasses built like vanilla's snow clear pair (Designator_AreaSnowClear.cs:23-54), with the area picker of the allowed-area designator (Designator_AreaAllowed.cs:37-51). The selected area is kept as its id in the component, not as a static reference like vanilla's `selectedArea` (Designator_AreaAllowed.cs:8). A namespace-qualified `PatchOperationInsert` adds both after `Designator_AreaSnowClearClear` in DesignationCategoryDef Zone (Core Misc/Designations/DesignationCategories.xml:51), which carries no `MayRequire`. `Visible` reads the master toggle live.
- Overlay: each area owns a `CellBoolDrawer` like `Area` (Area.cs:72-82, 142-153), render queue 3650, marked for draw from `MapComponentUpdate` while one of our designators or the manage window is open.
- Manage window: one row per area with color, label, the six checkboxes with tooltips, the cell count, "N cells outside the home area" when "Clean first" is ticked, and delete, which asks first and names the cell count. "New work rule area" is disabled at 10.
- After any change the component updates the mask, calls `ListerHaulables.RecalcAllInCell` (ListerHaulables.cs:146-153) on every cell whose "Don't haul from here" bit changed, and marks the "Haul first" list stale.
- The removal button (1.2) gains the two steps listed there.
- **Settings:** Global "Work rule areas" (on): off hides both designators; areas and rules stay. Global "Apply work rules" (on): off makes every rule postfix and both work givers stand aside at once, to check whether Zones causes a work problem; areas stay. Per area: six rules, all off.
- **Save and removal:** Areas save in the component as a `BoolGrid` and names. A plain unsubscribe drops them with the component node, with no extra error. Cleaning, firefighting, repairs and hauling go back to vanilla, and the haulables set rebuilds itself, because vanilla never saves it and every thing re-registers when it spawns (ListerHaulables.cs:34-37). Jobs from the two work givers log one error each (see the data model); the removal button avoids that.
- **Overlaps:** Mods that list or edit vanilla areas never see work rule areas, which aren't in `AreaManager.AllAreas`. With Zones' own zones they stack: "Haul first" over a delivery zone brings arrivals in before other hauling, "No cleaning" over an animal sleeping zone keeps cleaners out of the barn. Replace Stuff has nothing to compose with: its frames are construction, which no rule touches. Hospitality guests who help with work follow all six rules, because the rules sit on the vanilla givers, the haulables set and our two givers. Its prefix on `JobGiver_Work.PawnCanUseWorkGiver` lets a guest take any work giver it is skilled and keen enough for, ignoring `nonColonistsCanDo`, with a bonus for emergency work such as firefighting, and asks the giver's `ShouldSkip` first (its Source/Source/Patches/JobGiver_Work_Patch.cs:14-43, `ShouldSkip` at :22, Workshop copy with the 1.6 tag). So guests use "Clean first" and "Haul first" too; see "Haul first" for why Pick Up And Haul never serves them there.
- **Replaces:** Nothing by itself; the rules below do.
- **Effort:** M plus S, 2.5 days. The S is the manage window and the removal-button steps.
- **Tests:**
- A 5x5 area with no rule ticked: the home filth list, the haulables set and a colonist's next work job are the same as without it.
- An area painted over a stockpile, an animal sleeping zone and a second work rule area leaves all four cell sets intact. An 11th area can't be made.
- Rename an area, tick "No cleaning", save: phase 2 has the same id, label, color, cells and rules, and the mask agrees on 3 sampled cells.
- 50 steel in a "Don't haul from here" area: unticking the rule puts it in `ThingsPotentiallyNeedingHauling()` within the same call; deleting the area does too.
- A stored rule name that doesn't resolve stays stored and changes nothing.
- Removal button: with a pawn on a "Clean first" job, afterwards no current or queued job names either giver, the steel on a former "Don't haul" cell is in the haulables set, and two saves contain no "BlaxZones".
- Phase 3: see "Headless tests in 1.6".
- **Risks:** Gravships leave work rule areas behind, as they leave Blax zones (Backlog). Seeing the areas needs a designator selected, as with vanilla allowed areas.
#### No cleaning, firefighting, repairs or hauling
- **Players get:**
- "No cleaning": cleaners leave the area's filth alone, but still fight its fires and repair it, which taking it out of the home area would stop. The barn, the pens, an outdoor workshop.
- "No firefighting": nobody runs in to beat fires there, for a killbox or a fire trap. A burning pawn is still put out.
- "No repairs": nobody repairs buildings or replaces broken components there, so nobody walks into the killbox to fix barricades during a raid.
- "Don't haul from here": nothing lying there is carried to storage, by haulers, mechs, Pick Up And Haul or opportunistic hauling. Colonists still take it for bills, construction and refuelling. Untick it after the raid and haulers empty the killbox.
- Right-click orders still work in every area, and so does the vanilla Haul designation.
- **How:**
- No cleaning, three postfixes on `WorkGiver_CleanFilth` and, when a mod replaces it, on the class the CleanFilth def names (see "Giver class" below):
- `HasJobOnThing` (WorkGiver_CleanFilth.cs:27-46): when `__result` is true, the call isn't forced and the filth's cell has the bit, false. The region search validator (JobGiver_Work.cs:150, 219-226) and the up to 15 neighbours a Clean job queues (WorkGiver_CleanFilth.cs:55-75, check at :66) both pass through it. Forced calls pass, so right-click cleaning still works (FloatMenuOptionProvider_WorkGivers.cs:126).
- `PotentialWorkThingsGlobal` (:17-20): swaps `__result` for the component's copy without no-clean filth, built at most once per tick per map from the list that came in. Without it the barn's filth stays in the global search set, where reachability and then the validator run on every candidate closer than the best so far (GenClosest.cs:64-85, 195-202): a barn with 300 filth would cost every cleaner 300 reach checks per search. Building from the incoming list keeps a replacing class's own list, such as Cleaning Area Relaunched's cleaning-area filth, working.
- `ShouldSkip` (:22-25): when not forced and the filtered list is empty, true, as vanilla skips when the home filth list is empty. Forced calls are left alone, because the right-click menu asks `ShouldSkip(pawn, forced: true)` (FloatMenuOptionProvider_WorkGivers.cs:248-255).
- The two one-line overrides are virtual, and every caller reaches them through a virtual call on a `WorkGiver` reference (JobGiver_Work.cs:115, 282; FloatMenuOptionProvider_WorkGivers.cs:250-252); Zones' own givers call the vanilla worker the same way. No call site can inline them.
- A pawn already cleaning when the area is painted finishes its queue: the job driver only skips targets outside the home area (JobDriver_CleanFilth.cs:31, 70).
- Giver class: Cleaning Priority (Continued), Cleaning Area Relaunched and CleaningArea swap CleanFilth's `giverClass` for their own `WorkGiver_Scanner` subclass that declares all four methods (see Overlaps). `WorkGiverDef.Worker` builds the worker from `giverClass` (WorkGiverDef.cs:77-88), so while one of them is active no `WorkGiver_CleanFilth` exists and postfixes on it alone never run. The patcher always patches `WorkGiver_CleanFilth`, then reads `DefDatabase<WorkGiverDef>.GetNamed("CleanFilth").giverClass`. When that class differs, it also patches its `HasJobOnThing`, `PotentialWorkThingsGlobal` and `ShouldSkip`, each found with `AccessTools.DeclaredMethod`, with the same three postfixes. A method the class doesn't declare is skipped with one log line naming it: it is inherited, from `WorkGiver_CleanFilth` (already patched) or from `WorkGiver_Scanner`. The postfixes take their arguments by position (`__0` to `__2`), so another class's parameter names don't matter. The replacing classes queue neighbours through their own `HasJobOnThing` (Cleaning Priority's Source/CleaningPriority/WorkGiver_CleanFilthPrioritized.cs:96, Cleaning Area Relaunched's Source/WorkGiver_CleanFilth_CleaningAreaRelaunched.cs:100), so the patched method filters their queues too.
- No firefighting: a postfix on `HasJobOnThing` of the internal `WorkGiver_FightFires` (WorkGiver_FightFires.cs:23-70), found with `AccessTools.TypeByName("RimWorld.WorkGiver_FightFires")`. False when `__result` is true, the call isn't forced, the fire isn't on a pawn (the `fire.parent is Pawn` branch, :29-47, is left alone) and its cell has the bit. FightFires is emergency work and not direct-orderable (Core WorkGiverDefs/WorkGivers.xml:7-17); the right-click extinguish order builds its own job without the work giver (FloatMenuOptionProvider_ExtinguishFires.cs:37-49), so player orders are untouched. Fires that lords and Gauranlen trees fight (JobGiver_FightFiresNearPoint, JobGiver_FightFiresNearConnectedTree) aren't colony work and stay as they are.
- No repairs: the same postfix on `WorkGiver_Repair.HasJobOnThing` (WorkGiver_Repair.cs:28-61, home check at :35) and `WorkGiver_FixBrokenDownBuilding.HasJobOnThing` (WorkGiver_FixBrokenDownBuilding.cs:38, home check at :56). Forced calls pass.
- Don't haul from here: a postfix on the private `ListerHaulables.ShouldBeHaulable` (ListerHaulables.cs:194-220). False when `__result` is true, the thing is spawned, its cell has the bit and it carries no Haul designation (the designation vanilla checks at :206). Every vanilla hauler reads that set: `WorkGiver_Haul` (WorkGiver_Haul.cs:14-22), `JobGiver_Haul` (JobGiver_Haul.cs:10), the built-in opportunistic hauling (Pawn_JobTracker.cs:649, set read at :697) and haul sources (HaulSourceUtility.cs:14). So do Pick Up And Haul (its Source/PickUpAndHaul/WorkGiver_HaulToInventory.cs:33, 146) and While You're Up (its Source/OpportunityDetour.cs:143). Spawning, unforbidding and adding the Haul designation re-run the check (ListerHaulables.cs:34-67); our own changes call `RecalcAllInCell`. Things in containers aren't spawned and are left alone. Bills, construction and refuelling search for ingredients, not haulables, so they still take the items. The method is 27 lines with five branches, too large to inline.
- Every postfix checks `__result` and `forced` first, then gets the component (null means vanilla), then the rule's cell count, then the mask byte. None allocates.
- Not patched: `ListerFilthInHomeArea.Notify_FilthSpawned` (ListerFilthInHomeArea.cs:29-35), four lines the JIT may inline, and the home area itself.
- **Settings:** Per area: the four rules (off). Global "Apply work rules".
- **Save and removal:** Nothing beyond the areas. Without the mod, the home area alone decides again.
- **Overlaps:**
- CleaningArea (870089952, 113,806 subs, last 1.4) and Cleaning Area Relaunched (3586697885, 23,066, 1.6 tag; a commenter reports it runs on 1.7): a separate area that replaces the home area for cleaning. Both replace the clean giver; neither hands vanilla's giver a different list. Cleaning Area Relaunched redefines CleanFilth with giverClass `CleaningAreaRelaunched.WorkGiver_CleanFilth_CleaningAreaRelaunched`, a `WorkGiver_Scanner` subclass with its own four methods (its 1.6/Defs/WorkGiverDefs/WorkGivers.xml and Source/WorkGiver_CleanFilth_CleaningAreaRelaunched.cs:11-53 on GitHub), and fills the home filth list with cleaning-area filth through prefixes on `ListerFilthInHomeArea` (its Source/Patch_ListerFilthInHomeArea.cs); its other patches cover areas, gravships and the play settings button. CleaningArea's source isn't public; Prison Labor's 1.7 compat assembly for it patches a `WorkGiver_CleanFilth_CleaningArea.HasJobOnThing`, so it brings its own giver class too. Both compose through the giver-class step: the four "No" rules hold, and "Clean first" wraps their worker, so it works inside their cleaning area instead of the home area; the manage window then leaves out its count of cells outside the home area. Package ids: `Cerule.CleaningAreaRelaunched` (its About/About.xml, which marks the other two incompatible), `hatti.cleaningarea`, and `s1.cleaningareatemp`, an earlier 1.6 update of CleaningArea; Prison Labor's LoadFolders.xml names the last two. One overlap warning while any of them is active, the Castes pattern. Before shipping, list CleaningArea's defs and Harmony patches in a dev run if a copy can be had.
- Cleaning Priority (Continued) (2018316486, 23,162, 1.7, package id `Mlie.CleaningPriority`): its 1.7/Patches/WorkGiverPatch.xml swaps CleanFilth's giverClass for `CleaningPriority.WorkGiver_CleanFilthPrioritized`, a `WorkGiver_Scanner` subclass that declares all four methods (its Source/CleaningPriority/WorkGiver_CleanFilthPrioritized.cs:9-114 on GitHub). The giver-class step puts the "No cleaning" postfixes on it, so no-clean filth stays out of its prioritized list too. "Clean first" stands down for it (see there).
- Dubs Bad Hygiene (836308268, 663,623, 1.7): its "prioritise cleaning indoors" option changes how cleaners pick, and cleaning-area mods report conflicts with it. It isn't installed here: before shipping, list its patches on `WorkGiver_CleanFilth` with Harmony's patch info in a dev run, and test with it if it patches `PotentialWorkThingsGlobal` or `ShouldSkip`.
- Common Sense (1561769193, 1,094,882, last 1.6): cleans rooms before cooking and surgery through its own jobs; untested, no 1.7 build.
- Pick Up And Haul (1279012058, 1,784,600, last 1.6) and While You're Up (2034960453, 154,914, last 1.5; its 1.6 patch 3516529053, 15,503): covered through the haulables set, see How.
- Prison Labor (1899474310, 174,952, 1.7): its assembly names `PawnCanUseWorkGiver` and `nonColonistsCanDo`, so it lets prisoners use colonist work givers. The four rules sit on the vanilla givers and the haulables set, so they hold for working prisoners too.
- Hospitality (753498552, 768,405, last 1.6): guests who help with work clean, haul and fight fires through the vanilla givers (see "Work rule areas"), so the four rules hold for them too.
- **Replaces:** FuelBurning (1498128603, 216, 1.0) for its no-firefighting area; nothing alive on 1.7 does this. Covers the reason players install CleaningArea and Cleaning Area Relaunched: stopping the cleaning somewhere without losing fire fighting and repairs there.
- **Effort:** M plus S, 2.5 days. The S is the giver-class step and its test.
- **Tests:**
- No cleaning: a 20x20 home area with 10 filth in a no-clean area and 5 outside. A colonist with only Cleaning enabled: `JobGiver_Work.TryIssueJobPackage` gives a Clean job whose target and queue all lie outside the area. With those 5 destroyed, `ShouldSkip(pawn)` is true, `ShouldSkip(pawn, forced: true)` false, and `HasJobOnThing(pawn, areaFilth, forced: true)` true. Two `PotentialWorkThingsGlobal` calls in one tick return the same list object; with no area the vanilla list object comes back. `GC.GetAllocatedBytesForCurrentThread` across 1,000 `HasJobOnThing` calls stays below 1 KB.
- Giver class: the test mod carries `TestCleanGiver : WorkGiver_Scanner`, which declares the four methods as vanilla does. The test sets CleanFilth's `giverClass` to it, clears the def's cached worker (`workerInt`, WorkGiverDef.cs:75) and the test pawns' giver lists (`Notify_UseWorkPrioritiesChanged`, Pawn_WorkSettings.cs:190-193), and runs Zones' giver-class step again. The no-cleaning case above then holds unchanged: the Clean job leaves the area's filth alone, `ShouldSkip(pawn)` is true once the outside filth is gone, and a forced `HasJobOnThing` is true. A second test class without `ShouldSkip` gets two patches and one log line. The test restores the def afterwards. It swaps at runtime instead of through a test Patches XML, so every other test still runs against vanilla's class.
- No firefighting: a fire on a home cell in the area: `HasJobOnThing` false for a colonist, true outside the area. A colonist set burning inside the area: another colonist's `HasJobOnThing` on that fire is true.
- No repairs: a damaged wall in the area: false, forced true. A broken-down cooler in the area: `WorkGiver_FixBrokenDownBuilding.HasJobOnThing` false.
- Don't haul from here: 50 steel spawned on an area cell isn't in `ThingsPotentiallyNeedingHauling()`. Wood a colonist drops there isn't either. Unforbidding a forbidden stack there keeps it out; a Haul designation puts it in. A colonist with only Hauling gets no job that targets the area.
- `-Compat`: a Pick Up And Haul job started next to the area never queues an area item. A Prison Labor prisoner set to clean leaves the no-clean filth alone. A Hospitality guest made to help through a test-only prefix and set to clean leaves the no-clean filth alone.
- **Risks:** The fire alert still lists fires in a "No firefighting" area inside the home area (Alert_FireInHomeArea.cs:19); the player sees them burn on purpose. A mod that cleans or hauls through its own search, without the vanilla givers or the haulables set, ignores the rules.
#### Clean first and haul first
- **Players get:**
- "Clean first": cleaners clean the area before other filth: the hospital, the kitchen, the lab. Inside the home area only, as all cleaning is.
- "Haul first": haulers take what lies in the area to storage before other loose items: a harvested field, the delivery zone, the gate after a raid.
- Work priorities stay as they are: a pawn cleans first only when it gets to Cleaning in its own order, hauls first only within Hauling, and never leaves its allowed area for it.
- **How:**
- Two WorkGiverDefs and no Harmony patch: `BlaxZones_CleanFirst` (Cleaning, `priorityInType` 15, `BlaxZones.WorkGiver_CleanFirst`) and `BlaxZones_HaulFirst` (Hauling, 21, `BlaxZones.WorkGiver_HaulFirst`). They copy verb, gerund and `requiredCapacities` from CleanFilth and HaulGeneral (Core WorkGiverDefs/WorkGivers.xml:1453-1464, 1365-1376), keep `nonColonistsCanDo` false like them, and set `directOrderable` false, so the right-click menu keeps only vanilla's options (FloatMenuOptionProvider_WorkGivers.cs:106) and no player order stores our def (Pawn_JobTracker.cs:875-886). `WorkTypeDef.ResolveReferences` sorts givers by `priorityInType`, highest first (WorkTypeDef.cs:101-111); `JobGiver_Work` tries the lower ones only when ours found nothing (JobGiver_Work.cs:85-88). Cleaning has clear snow at 10 and clean filth at 5 (WorkGivers.xml:1439-1464); Hauling has egg boxes and beer at 20, fermenting barrels at 19, Pick Up And Haul at 18 (its Defs/JobDefs/WorkGiver.xml:11) and general hauling at 15 (WorkGivers.xml:1337-1376, 1423-1434).
- Both classes derive from `WorkGiver_Scanner` directly and wrap a worker resolved once at startup (`DefDatabase<WorkGiverDef>.GetNamed("CleanFilth").Worker`, `"HaulGeneral"`), calling it through virtual calls. That is the worker of whatever class the def names, so every patch on it applies, ours ("No" rules, also on a replacing class) and other mods' alike, and there is no `base.` call for the JIT to inline past Harmony. With Cleaning Area Relaunched or CleaningArea the CleanFilth worker is theirs (see Overlaps of "No cleaning").
- `PotentialWorkThingRequest` stays Undefined (WorkGiver_Scanner.cs:10), so `JobGiver_Work` skips the region search and searches only the giver's own list, with reachability (GenClosest.cs:33, 58-72). `PathEndMode` and `MaxPathDanger` come from the wrapped worker.
- Clean first: `PotentialWorkThingsGlobal` is the wrapped worker's list (no-clean filth already gone) filtered to clean-first cells, cached once per tick per map. `ShouldSkip` is true when the map has no clean-first cells, "Apply work rules" is off or the list is empty. `HasJobOnThing` is the cell check plus the wrapped worker's (vanilla: home area, fog, reservation, the 600-tick wait, WorkGiver_CleanFilth.cs:27-46). `JobOnThing` is the wrapped worker's; vanilla's queues up to 15 more filth in the same room (:48-80), so a cleaner finishes the room it stands in even past the area's edge.
- Clean first stands down while Cleaning Priority (Continued) (`Mlie.CleaningPriority`) is active: our `ShouldSkip` is always true, the checkbox shows disabled with "Cleaning Priority (Continued) sets the cleaning order", and the overlap message says so once. Its worker refuses unforced filth outside the priority area it is working through, unless the pawn's own allowed area holds it (its Source/CleaningPriority/WorkGiver_CleanFilthPrioritized.cs:53-58), so wrapping it would mostly give nothing, and it already ranks areas.
- Haul first: the wrapped worker is Pick Up And Haul's when def `HaulToInventory` exists with giverClass `PickUpAndHaul.WorkGiver_HaulToInventory` (its Defs/JobDefs/WorkGiver.xml:4-15), otherwise vanilla HaulGeneral. With Pick Up And Haul the inventory run starts at the area's item and gathers nearby items as it always does; without it, a vanilla haul job (WorkGiver_Haul.cs:24-31). When Pick Up And Haul returns no job, the vanilla HaulGeneral worker is asked. `PotentialWorkThingsGlobal` holds the haulables on haul-first cells, corpses left out (HaulCorpses at 90 takes them first), rebuilt every 30 ticks or right after a change, from the area's cells or the haulables set, whichever is smaller. A stale entry is harmless: the global search skips despawned things (GenClosest.cs:197) and `HasJobOnThing` checks the cell again.
- Haul first asks Pick Up And Haul's `ShouldSkip` per pawn. That method is the only place Pick Up And Haul keeps out pawns of another faction, races its settings leave out (animals and mechs, each a setting that is on by default), quest lodgers and pawns over its gear limit (its Source/PickUpAndHaul/WorkGiver_HaulToInventory.cs:11-17; Settings.cs:6-7, 15). Its `JobOnThing` repeats none of the faction, race and lodger checks (:58-120), and its comp sits on every ThingDef with thingClass Pawn (its Patches/PickUpAndHaul.xml), so the inventory path would run for anyone who gets that far. Hospitality guests (see "Work rule areas"), Prison Labor's working prisoners and quest lodgers, who count as colonists (Pawn.cs:518-526; QuestUtility.cs:524-530), all reach our giver. So our `ShouldSkip`, which `JobGiver_Work` asks before it scans (JobGiver_Work.cs:282), calls the wrapped worker's `ShouldSkip(pawn)` through a virtual call and keeps the answer in a one-entry cache of pawn and tick. When it is true, `HasJobOnThing` and `JobOnThing` use the vanilla HaulGeneral worker for that pawn, and a cache miss asks again. Without this, guests and lodgers could leave the map with colony items in their inventory, and a lifter would haul to inventory with Pick Up And Haul's mechanoid setting off.
- Allowed areas: the work search refuses forbidden things, and that includes things outside the pawn's allowed area (JobGiver_Work.cs:219-226; ForbidUtility.cs:111-118, 157-165), so neither giver pulls a pawn out of its area, also when Blax Castes sets the area per caste.
- Cost: with no clean-first or haul-first cells on the map, one component lookup in `ShouldSkip` per work search. With cells, one filtered list per tick for cleaning or per 30 ticks for hauling, and the search over that short list.
- **Settings:** Per area: "Clean first", "Haul first" (off). Global "Apply work rules".
- **Save and removal:** The two defs reach a save only through jobs (see the data model). Without the mod, cleaning and hauling go back to closest first.
- **Overlaps:**
- Cleaning Priority (Continued) (2018316486, 23,162 subs, 1.7, package id `Mlie.CleaningPriority` from its About/About.xml): ranks allowed areas for cleaning, with the home area first; its author warns that removing it mid-save can cause errors (its Workshop page, read 2026-11-29). It doesn't reorder vanilla cleaning: it replaces CleanFilth's giver class (see "No cleaning"), so "Clean first" stands down while it is active, with one overlap message, and the four "No" rules work on its giver.
- Cleaning Area Relaunched and CleaningArea: "Clean first" wraps their giver and works inside their cleaning area (see "No cleaning").
- Allow Tool (761421485, 1,388,717, last 1.6): "Haul urgently" marks single items, hauled through its own work type HaulingUrgent with natural priority 1180 (its Mods/AllowTool/Defs/WorkTypeDefs/AllowToolWorkTypes.xml), so urgent items come before all of Hauling, "Haul first" included. Keyz' Allow Utilities (3524716849, 91,139, 1.7) carries "haul urgently" on 1.7; check its defs before shipping.
- Please Haul Perishables (Continued) (2807630952, 6,111, 1.7): hauls perishables early, a different axis.
- Pick Up And Haul: wrapped, see How. Dubs Bad Hygiene: as for "No cleaning".
- **Replaces:** Cleaning Priority - 1.0 (1543157124, 1,839, 1.0).
- **Effort:** M plus S, 2.5 days. The S is the per-pawn Pick Up And Haul check, the Cleaning Priority stand-down and their `-Compat` tests.
- **Tests:**
- Cleaning's `workGiversByPriority[0]` is `BlaxZones_CleanFirst`. In Hauling, `BlaxZones_HaulFirst` comes after DoBillsHaulCampfire (30) and before every giver at 20 or less.
- Clean first: 3 filth in a clean-first area 30 cells away and 3 next to the pawn: the Clean job's first target lies in the area. With "No cleaning" on the same cells, our giver gives nothing. An area outside the home area gives nothing, and the manage window counts its cells outside. A pawn whose allowed area leaves out the clean-first area gets a vanilla Clean job inside its own area.
- Haul first: steel in a haul-first area 40 cells away and wood next to the hauler, storage for both: the haul job targets the steel. With no storage that takes steel, it targets the wood.
- `-Compat` with Pick Up And Haul: the job is a `HaulToInventory` job whose first target is the steel, and the steel is in storage within 2500 ticks.
- `-Compat` with Pick Up And Haul and Hospitality: a guest made to help through a test-only prefix and set to haul, and a quest lodger, each next to a haul-first area, never get a `HaulToInventory` job from Haul first, and the guest gets a vanilla haul job that targets the area's steel.
- A Biotech lifter hauls first the same way; skipped without Biotech. In `-Compat`, with Pick Up And Haul's mechanoid setting switched off through its settings, the lifter gets a vanilla haul job from Haul first.
- Clean first with `Mlie.CleaningPriority` in `SimulatedActive`: our giver's `ShouldSkip` is true and the overlap message is logged once.
- With "Apply work rules" off, both givers give nothing and log nothing.
- **Risks:** A pawn may walk across the map for one old filth in a "Clean first" area; that is what the rule asks. `JobGiver_Work` stamps our def on the job Pick Up And Haul builds (JobGiver_Work.cs:240); if its driver reads `workGiverDef`, the `-Compat` test shows it, and the fallback is vanilla jobs only when it is active. Mods that show work givers one by one list ours as their own rows, so a player can set them apart.
#### Headless tests in 1.6
- Fixtures: `WorkRuleArea(rect, rules)`, `Filth(cell)` thickened past 600 ticks, `Fire(cell)`, `DamagedWall(cell)`, `BrokenDown(building)`, `OnlyWorkType(pawn, workType)`.
- Phase 3: the runner also renames `BlaxZones_CleanFirst` and `BlaxZones_HaulFirst` in the save, as it renames the component class, and expects exactly one "Could not load reference" error per job a pawn had from them, and no NRE.
- Performance in `-Compat`, with Pick Up And Haul active: time 2500 ticks with 60 colonists, the colony size Zones is built for (20 with only Cleaning, 20 with only Hauling, 20 with the quick-test colony's work settings), 300 filth in "No cleaning" areas, 200 filth elsewhere and 500 loose items, half of them in "Don't haul from here" and "Haul first" areas, with and without the areas; median of three runs each. Every rule hook runs inside each pawn's work search, so the cost grows with the number of cleaners and haulers, and 60 pawns measure that. The test fails when the areas add more than 5%, tighter than the beds' 10%.
- Compat: Pick Up And Haul, Prison Labor, Hospitality and Blax Castes (a caste area that leaves out a clean-first area, once Castes' area slot, its 1.2, has code) join the 1.6 tests; Blax Defaults once its forbid rules (its 1.1) have code.
- `docs/ingame-check.md` gains: the overlay color and the picker, the manage window, the tooltips.
- Effort: S, half a day.
## Works with the other Blax mods
- Package ids: `blax.slaves`, `blax.castes`, `blax.zones`, `blax.defaults`. No hard dependencies. About.xml has one sibling entry, loadAfter `blax.castes`. Load order is Castes, Zones, Slaves. Slaves lists `blax.zones`, so Zones doesn't list Slaves back, which would form a loadAfter cycle. Defaults lists no sibling and no sibling lists Defaults, so its position doesn't matter.
@ -591,12 +739,13 @@ Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 i
| `PrePick(Pawn, string casteId)` | not used by Zones; takes the token-prefixed id | 3 (Castes 1.4) |
Castes needs no Zones code. Zones reads nothing from Blax Slaves.
- Ownership: Zones owns sleeping spots, beds by zone and every friendly drop location. Castes owns every per-pawn policy default (apparel, food, drug, reading, medical care, schedule, work priorities, weapon loadout, area, hostility, self-tend, carried medicine, fire at will, prisoner interaction); Zones never touches policies. Slaves owns slave status, trade, prices, suppression, rebellion, slave medicine and slave economy. Defaults: starting settings of vanilla stockpiles and growing zones, storage buildings, production bills, workbenches, buildings, animals and mechs, and what the game forbids when pawns drop gear or die. It writes when something is made or joins, and through its opt-in forbid rules when a pawn drops gear or dies. It keeps nothing in the save.
- Ownership: Zones owns sleeping spots, beds by zone, every friendly drop location and per-cell work rules (work rule areas); it never changes a pawn's work priorities or allowed area. Castes owns every per-pawn policy default (apparel, food, drug, reading, medical care, schedule, work priorities, weapon loadout, allowed area, hostility, self-tend, carried medicine, fire at will, prisoner interaction); Zones never touches policies. Slaves owns slave status, trade, prices, suppression, rebellion, slave medicine and the slave economy. Defaults: starting settings of vanilla stockpiles and growing zones, storage buildings, production bills, workbenches, buildings, animals and mechs, and what the game forbids when pawns go down, die or are stripped. It writes when something is made or joins, and through its opt-in forbid rules when a pawn goes down, dies or is stripped. It keeps nothing in the save.
- Slaves routes its silver payouts through `ZonesApi.TryFindDropSpot` and spawns the pod at the returned cell with `TradeUtility.SpawnDropPod`, with `DropCellFinder.TradeDropSpot` and `DropThingsNear` as fallback (Blax Slaves docs/roadmap.md, purchase ledger and payouts). Pawns are never routed into zones. Payouts follow the zone's orbital checkbox, and its tooltip says so while Slaves is active.
- Buying: Zones never routes bought people. Slaves' buy-mode sets `guest.joinStatus` before vanilla `Pawn.PreTraded`, and Castes classifies by the final status in its own PreTraded scope. Zones touches neither.
- Slave sleeping zones (1.4) use vanilla `BedOwnerType.Slave`, so `Alert_NeedSlaveBeds` counts them with no patch (Alert_NeedSlaveBeds.cs:43). The alert runs only with Ideology (`requireIdeology`, Alert_NeedSlaveBeds.cs:14).
- Blax Slaves' shared infirmary (its 1.5) lets slaves use colonist medical beds, so a colonist sleeping zone set to medical takes slaves too. Zone filters and caste limits still apply, because the `CanUseBedNow` postfix runs at `Priority.Low`.
- Blax Defaults ("Starting settings for storage, bills, crops, buildings, animals and mechs"): it hooks only `Designator_ZoneAddStockpile` (its 1.0) and `Designator_ZoneAdd_Growing` (its 1.3), and Zones' zones subclass `Zone` and `Designator_ZoneAdd` directly with their own tabs (`ITab_Delivery`, the animal-zone and people-zone tabs), so no Defaults hook or button reaches a delivery or sleeping zone. A new stockpile or shelf starts unflagged; "Make default" never copies Zones' flags, which live in Zones' component. Defaults' button sits inside the storage tab and Zones' 1.3 gizmos on the gizmo bar. Zone beds come from `AddCell`, not a frame, so Defaults' build scope (its 1.1) never sees them. Neither mod touches the home area. Defaults' forbid rules (corpses in its 1.2, dropped gear in its 1.3) act only inside `Pawn.Kill` and `Pawn.DropAndForbidEverything`, never on goods Zones delivers, so arriving goods keep the forbid flag of the vanilla call. If Defaults ever adds a rule for them, it must act where Zones' routed groups also pass, because routed reward groups drop through `MakeDropPodAt` and orbital goods through `SpawnDropPod`, never through `DropThingsNear`.
- Blax Defaults ("Starting settings for storage, bills, crops, buildings, animals and mechs"): it hooks only `Designator_ZoneAddStockpile` (its 1.0) and `Designator_ZoneAdd_Growing` (its 1.4), and Zones' zones subclass `Zone` and `Designator_ZoneAdd` directly with their own tabs (`ITab_Delivery`, the animal-zone and people-zone tabs), so no Defaults hook or button reaches a delivery or sleeping zone. A new stockpile or shelf starts unflagged; "Make default" never copies Zones' flags, which live in Zones' component. Defaults' button sits inside the storage tab and Zones' 1.3 gizmos on the gizmo bar. Zone beds come from `AddCell`, not a frame, so Defaults' build scope (its 1.2) never sees them. Neither mod touches the home area. Defaults' forbid rules (its 1.1) act only inside `Pawn.Kill`, `Pawn_HealthTracker.MakeDowned` and `Pawn.Strip` (Pawn.cs:3895; Pawn_HealthTracker.cs:837), never on goods Zones delivers, so arriving goods keep the forbid flag of the vanilla call. If Defaults ever adds a rule for them, it must act where Zones' routed groups also pass, because routed reward groups drop through `MakeDropPodAt` and orbital goods through `SpawnDropPod`, never through `DropThingsNear`.
- Work rule areas (1.6) are per cell and never touch a pawn: Castes keeps the allowed area (its 1.2), and the work search already refuses things outside it (JobGiver_Work.cs:219-226; ForbidUtility.cs:111-118, 157-165), so a caste kept to the fields never walks to a "Clean first" hospital and Zones needs no CastesApi member. They aren't vanilla Areas, so they never show in Castes' area picker or match its area labels (`AreaManager.GetLabeled`, AreaManager.cs:86-96). Slaves are colonists for the work search and follow the rules like anyone. With Defaults the two compose: its forbid rules decide whether dropped gear is forbidden (its 1.1), and allow matched gear only once no enemy that can still fight is on the map; work rule areas decide whether haulers fetch it, so a killbox with "Don't haul from here" keeps allowed loot lying until the rule is unticked, and "Haul first" brings it in before other hauling. Neither mod hooks the other's code.
- Each mod keeps its state in its own Map or Game components, or none (Defaults), so removing one leaves the others' saves intact.
- Shared conventions: patches applied one class at a time from a `[StaticConstructorOnStartup]` class, logging "[Blax Zones] N patches applied"; a ModSettings toggle for every feature (zone storage has none, it is the save format); any DLC combination, core only included (see "DLC support"); every hook body in try/catch with a one-time log; the headless in-game test mod copied from blax-castes/Tests (BlaxCastesTests harness, run-tests.ps1) as Tests/BlaxZonesTests, plus a phase 3 that simulates removing the mod.
@ -613,7 +762,13 @@ Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 i
- Ally drop pods and aid land next to a chosen zone (Allies Spot 2067847359, 3,678 subs): needs a faction check so hostile drops are never affected; small demand.
- Vanilla Events Expanded's apparel and weapon pods in the cargo-pod context (S): the same context on those two incident workers, bound by reflection.
- A full removal test (`-Removal`, S): relaunch the game without blax.zones in ModsConfig plus a small verifier mod that loads the phase-3 save at the main menu and writes the error and warning counts.
- Blax zones fly with Odyssey gravships (`GravshipPlacementUtility`): Odyssey isn't installed on the test machine to build or test it. If built, behind `ModsConfig.OdysseyActive`.
- Blax zones fly with Odyssey gravships (`GravshipPlacementUtility`): Odyssey isn't installed on the test machine to build or test it. If built, behind `ModsConfig.OdysseyActive`. Work rule areas (1.6) would move with the same code, as vanilla moves the home area (GravshipPlacementUtility.cs:388).
- Construction first (M): a work rule "Build first" needs one wrapped giver per construction giver (finish frames, deliver to frames, deliver to blueprints; Core WorkGiverDefs/WorkGivers.xml:689-736), and frame order has build-order effects (roofs, walls closing a room). Smarter Construction (2202185773, 1,023,962 subs, 1.7) already reorders construction. Build it when players ask.
- Plant work first (M): sowing and harvesting first by area, wrapping `GrowerSow` and `GrowerHarvest`. Growing zones already split fields, and Growing Zone Priorities (Continued) (2026571920, 4,639, 1.7) ranks them.
- "Don't haul from here" with an item filter (S), for example leave weapons and apparel but haul corpses and food: a vanilla `ThingFilter` per area, checked in the same `ShouldBeHaulable` postfix. Wait for players to ask; Defaults' forbid rules cover what enemies drop.
- "No auto-rebuild" (S): auto-rebuild checks the home area before it places a blueprint (Verse/ThingUtility.cs:159, 168). A killbox player may want broken barricades left alone; nobody asked yet.
- Hide the "Fire in home area" alert for fires in "No firefighting" areas (S): a postfix on the alert's culprit list.
- Clean here even outside the home area (M): the inverse of "No cleaning". Needs filth outside the home area in the list, a way past the home check in `HasJobOnThing` (WorkGiver_CleanFilth.cs:33) and past the job driver's home jumps (JobDriver_CleanFilth.cs:31, 70). Extending the home area does the same today.
## Cut
@ -640,3 +795,13 @@ Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 i
- Trading Control's marketplace stall and trading buffs: outside zones, and it needs new art.
- Per-cell spot graphics and owner labels in sleeping zones: clutter, the reason Hidden Spots exists. The zone tint and inspect pane carry the state.
- Routing visitor and trader parting gifts: rare, and harmless next to the giver.
- Work rules as a Zone: one zone per cell, so a rule couldn't lie on a stockpile, a growing field or a delivery or sleeping zone, and the barn holds all of those.
- Work rules as vanilla `Area` subclasses: a plain unsubscribe would leave `map.areaManager` null, taking the home area and every allowed area with it (see "Why this shape" in 1.6), and a work rule area could shadow an allowed area of the same name for Blax Castes.
- One layer per rule with its own designators: 12 designators in the Zone menu, and switching a rule off for a while means erasing and repainting.
- "Clean first" by making vanilla cleaning prioritized with a `GetPriority` from the area: the prioritized path validates every candidate on the map with a reachability check (JobGiver_Work.cs:118-121) instead of the 4-region search, for every cleaner, even on maps with no area, and switching it on means patching the `Prioritized` getter every scanner shares.
- "Clean first" by sorting the filth list: the search picks by distance, not list order (GenClosest.cs:149-232), so a sort changes nothing.
- Firefighting first and repair first: fires are already an emergency handled closest first, and nobody asked for repair order.
- Doctor, warden or other work types first: their targets are pawns and beds, not places.
- Blocking right-click orders in "No" areas: a right-click is the player's explicit order.
- Standing down entirely for CleaningArea, Cleaning Area Relaunched or Cleaning Priority (Continued): the four "No" rules work on their giver class through the giver-class step, and so does "Clean first" except with Cleaning Priority (Continued), whose worker only takes its current priority area. Only "Clean first" stands down, and only for that one.
- Patching only `WorkGiver_CleanFilth`: all three cleaning mods replace CleanFilth's giver class, so no instance of it exists while one is active.