docs: plan Blax Zones by area in docs/features.md

features.md is the plan of record for what Zones covers: arrivals
(deliveries and caravan camps), work rule areas, sleeping zones, zone
tools and removal, and the API, each with steps in dependency order,
status per feature, the build order and four open questions.

design.md follows it: the At a glance table goes by area, unshipped
releases became area and step headings with their specs grouped
together, day counts and effort sums are gone, unshipped version
references name the feature, the Backlog gains three proposals (home
area work outside the home area, path rules, visitors gather here)
and the sibling section notes Blax Laws. README and the Workshop text
list the planned areas without version numbers.
This commit is contained in:
Timothy 2026-12-01 17:18:30 +01:00
parent 199a1e65ca
commit 8df6498102
4 changed files with 413 additions and 247 deletions

View File

@ -41,13 +41,12 @@ RimWorld mod (1.7) by Blax Gaming. Drag a delivery zone and what you buy from or
## Planned ## Planned
Later releases, in order (details in `docs/design.md`): Grouped by area. What each area covers, its steps and the build order are in `docs/features.md`, the specs in `docs/design.md`.
- 🐔 **1.2 Animal sleeping zones.** Every cell is a sleeping spot, with species and body-size filters, so big stalls stay free of chickens. A button in the mod settings strips Blax Zones from a save first, for a removal with no errors. - 🧹 **Work rule areas.** Paint named areas over anything, stockpiles and fields included, and tick rules per area: No cleaning, No firefighting, No repairs, Don't haul from here, Clean first, Haul first. A barn nobody cleans still gets its fires fought, and a hospital is cleaned first. Work rules never change work priorities or allowed areas, and right-click orders work in every area.
- 🧹 **1.3 Work rule areas.** Paint named areas over anything, stockpiles and fields included, and tick rules per area: No cleaning, No firefighting, No repairs, Don't haul from here, Clean first, Haul first. A barn nobody cleans still gets its fires fought, and a hospital is cleaned first. Work rules never change work priorities or allowed areas, and right-click orders work in every area. - 🛏️ **Sleeping zones.** Animal sleeping zones where every cell is a sleeping spot, with species and body-size filters, so big stalls stay free of chickens. Dorms and prisons for colonists, slaves (needs Ideology) and prisoners, one cell per sleeper, plus medical and shared zones. With Blax Castes, a zone can be limited to castes.
- 🗄️ **1.4 Storage, roofs and selling.** Stockpiles, shelves, racks and fridges receive deliveries directly, also under a roof. Orbital traders buy from flagged storage (needs a powered trade beacon). Random cargo pod events land in a zone you pick. All optional, off by default. - 🗄️ **More arrivals.** Stockpiles, shelves, racks and fridges receive deliveries directly, also under a roof. Orbital traders buy from flagged storage (needs a powered trade beacon). Random cargo pod events land in a zone you pick. All optional, off by default.
- 🛏️ **1.5 People sleeping zones.** Dorms and prisons for colonists, slaves (needs Ideology) and prisoners, one cell per sleeper. Medical and shared zones. - 🧰 **Zone tools.** A button in the mod settings strips Blax Zones from a save first, for a removal with no errors.
- 🏷️ **1.6 Castes.** With Blax Castes, people sleeping zones can be limited by caste.
## DLC support ## DLC support
@ -55,7 +54,7 @@ Blax Zones works with any combination of DLCs, core only included, and lists non
- **Royalty** adds tribute collectors, who camp at the zone like trader caravans, and Empire quests, whose item rewards land in the zone like any other. - **Royalty** adds tribute collectors, who camp at the zone like trader caravans, and Empire quests, whose item rewards land in the zone like any other.
- **Biotech** adds Wastepack, which never lands in a zone and is hidden from the filter. - **Biotech** adds Wastepack, which never lands in a zone and is hidden from the filter.
- **Ideology**, **Anomaly** and **Odyssey**: Blax Zones uses none of their content. Slave sleeping zones (planned for 1.5) will need Ideology. - **Ideology**, **Anomaly** and **Odyssey**: Blax Zones uses none of their content. Slave sleeping zones (planned) will need Ideology.
- **A save made with a DLC** loads without it. Delivery zone filters drop the missing items, with the same "Could not load reference" error per missing def that vanilla stockpile filters log, and the zone keeps working. - **A save made with a DLC** loads without it. Delivery zone filters drop the missing items, with the same "Could not load reference" error per missing def that vanilla stockpile filters log, and the zone keeps working.
## Compatibility ## Compatibility

View File

@ -2,7 +2,16 @@
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. 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: 1.0 and 1.1 are built; 1.2 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. Status: 1.0 and 1.1 are built and on the Workshop; sleeping zones, work rule areas, storage deliveries, cargo pods and the removal button are designed, no code yet. What the mod covers and the build order: [features.md](features.md). 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; once the removal button ships, it removes the mod with no errors.
Changes on 2026-12-01, the plan by area (Fabian: chunk by what belongs together, never by time or size):
- [features.md](features.md) is now the plan of record for what Zones covers and in which order it gets built. This doc keeps the specs.
- Releases after 1.1 became areas with steps: Arrivals (1.0, 1.1, storage as a delivery target, more arrival sources), Work rule areas, Sleeping zones (animals, people, by caste) and Zone tools and removal. The specs of the old 1.4 sit next to 1.0 and 1.1, people zones and the caste filter next to animal zones, and the removal button under Zone tools. Spec text is unchanged except where it named an unshipped version number; it names the feature now. Version numbers in the dated notes below belong to the old cut.
- The Days column, the day totals and the effort sums are gone. Per-feature S, M and L marks stay, without day counts.
- The Backlog gains three proposals, not checked against the code: "Repair here" and "Fight fires here" outside the home area next to "Clean here", path rules ("Walk around"), and "Visitors gather here". Repair first stays cut; its reason now names Repairing Priority.
- "Works with the other Blax mods" notes Blax Laws: its jail takes prisoner zone beds like any prisoner bed, and its court places are never zones. Sibling features are named instead of their unshipped version numbers.
- The README's Planned section and the Workshop description's planned list follow the areas, without version numbers.
Changes on 2026-11-29, after two review rounds: Changes on 2026-11-29, after two review rounds:
@ -10,46 +19,40 @@ Changes on 2026-11-29, after two review rounds:
- Fixed what would have broken features or tests: prisoner zones refresh their room so it becomes a prison cell; zone beds never fly on gravships; the overflow radius starts at 5, because a smaller one can hang the game; zone beds can't be deconstructed and draw the sleeper's body; zone tints change at once instead of after a reload. - Fixed what would have broken features or tests: prisoner zones refresh their room so it becomes a prison cell; zone beds never fly on gravships; the overflow radius starts at 5, because a smaller one can hang the game; zone beds can't be deconstructed and draw the sleeper's body; zone tints change at once instead of after a reload.
- Owner types: vanilla can no longer change a zone bed's owner type through either setter, and a prisoner zone never turns vanilla colonist or slave beds into prisoner beds without asking. - Owner types: vanilla can no longer change a zone bed's owner type through either setter, and a prisoner zone never turns vanilla colonist or slave beds into prisoner beds without asking.
- Removal: vanilla re-creates a missing MapComponent on every save, load and new map, so the button now strips it there instead of inside `FinalizeInit`. The button moved to 1.2, where zone beds make a plain unsubscribe noisy, and the plain-unsubscribe error counts are corrected. - Removal: vanilla re-creates a missing MapComponent on every save, load and new map, so the button now strips it there instead of inside `FinalizeInit`. The button moved to 1.2, where zone beds make a plain unsubscribe noisy, and the plain-unsubscribe error counts are corrected.
- Releases re-cut: caravan camps ship in 1.0 and caravan purchase routing in 1.1; sleeping zones split into animals (1.2) and people (1.4); royal title rewards, the age filter and the unusable-cell breakdown moved to the Backlog. 1.0 takes 6 days, the plan 29 instead of 28. - Releases re-cut: caravan camps ship in 1.0 and caravan purchase routing in 1.1; sleeping zones split into animals (1.2) and people (1.4); royal title rewards, the age filter and the unusable-cell breakdown moved to the Backlog.
- Sell zones offer only items, never the shelves themselves, and flags on linked shelves follow the group. - Sell zones offer only items, never the shelves themselves, and flags on linked shelves follow the group.
- `ZonesApi` version 1 is `TryFindDropSpot` only, and callers spawn the pod exactly at the returned cell. `CastesApi` version 1 moves to Castes 1.1 with token-prefixed ids in both members; Castes' design carries the same table. - `ZonesApi` version 1 is `TryFindDropSpot` only, and callers spawn the pod exactly at the returned cell. `CastesApi` version 1 moves to Castes 1.1 with token-prefixed ids in both members; Castes' design carries the same table.
- 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. - 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. - 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. - 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.
- 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). - 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. - 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. - 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. - 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.
- 2026-11-30: Work rule areas moved up to 1.3, the later releases shift by one; name confirmed. - 2026-11-30: Work rule areas moved up to 1.3, the later releases shift by one; name confirmed.
- 2026-11-30: 1.1 built as specified, with these differences. Caravan overflow follows "Overflow lands next to the zone" and needs a colony-reachable overflow center, as orbital overflow does. A reward group also stays with vanilla when a thing in it is already spawned, sits in a container or carries a pawn inside (a casket). A group that fails while dropping goes back to vanilla with every later group, its things taken out of the pod that never fell; only a failed plan hands vanilla the original list. The delivery tab is 528 high, two rows taller than the stockpile tab, for the two new checkboxes. The Trade Ships Drop Spot hint shows on the first map tick of a game, as a message and a log line; its marker def `DropSpotTradeShip` was read from SmashPhil/TradeShips-Drop-Spot, Defs/DropSpotIndicator.xml. Tests put a known stack on a pack animal instead of picking from the caravan's random stock, and the `dropAllInSamePod` test has a refugee in the shared group (a shared group of items only routes as one pod). - 2026-11-30: 1.1 built as specified, with these differences. Caravan overflow follows "Overflow lands next to the zone" and needs a colony-reachable overflow center, as orbital overflow does. A reward group also stays with vanilla when a thing in it is already spawned, sits in a container or carries a pawn inside (a casket). A group that fails while dropping goes back to vanilla with every later group, its things taken out of the pod that never fell; only a failed plan hands vanilla the original list. The delivery tab is 528 high, two rows taller than the stockpile tab, for the two new checkboxes. The Trade Ships Drop Spot hint shows on the first map tick of a game, as a message and a log line; its marker def `DropSpotTradeShip` was read from SmashPhil/TradeShips-Drop-Spot, Defs/DropSpotIndicator.xml. Tests put a known stack on a pack animal instead of picking from the caravan's random stock, and the `dropAllInSamePod` test has a refugee in the shared group (a shared group of items only routes as one pod).
## At a glance ## At a glance
| Version | What players get | Replaces | Needs | Days | | Area | What players get | Replaces | Needs |
|---|---|---|---|---| |---|---|---|---|
| 1.0 | Delivery zones: orbital buys land in them, by item filter and priority. Trader caravans camp next to a zone you pick | The orbital half of Trade Ships Drop Spot (206k, no official 1.7) and of Trading Control (111k, no 1.7); [KV] Trading Spot (126k) and [GMT] Trading Spot (118k), both dead; Trading Spot (44k), 1.6 only. Stands down for Trading Spot Rewritten (2.2k), which has a 1.7 build | None | 6 | | Arrivals: deliveries and caravan camps | Shipped in 1.0 and 1.1: delivery zones where orbital buys, quest rewards and caravan purchases land, by item filter and priority, and trader caravans that camp next to a zone you pick. Designed: stockpiles, shelves, racks and fridges receive deliveries, also under a roof; orbital traders buy from flagged storage; cargo pod events land in a zone | Trade Ships Drop Spot (206k, no official 1.7) and the orbital, reward and caravan-spot parts of Trading Control (111k, no 1.7); [KV] Trading Spot (126k) and [GMT] Trading Spot (118k), both dead; Trading Spot (44k), 1.6 only. Stands down for Trading Spot Rewritten (2.2k), which has a 1.7 build. Covers the use of Map Wide Orbital Trade Beacon (51k) and Wall-Mounted Orbital Trade Beacon (16k), both alive on 1.7, and replaces 3 small pod mods with no 1.7 build (6.5k combined) | None |
| 1.1 | Quest rewards land in delivery zones. Goods bought from trader caravans and Hospitality guests appear in them | The quest-reward half of Trade Ships Drop Spot and Trading Control | None | 3 | | Work rule areas | Named areas painted over anything, with rules per area: no cleaning, no firefighting, no repairs, don't haul from here, clean first, haul first. A barn nobody cleans that still gets its fires fought, a killbox nobody fights fires, repairs or hauls in 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 |
| 1.2 | Animal sleeping zones: every cell is a sleeping spot, with species and body-size filters. A button removes Zones from a save with no errors | Covers the spot-grid use of Designator Shapes (332k, a general shape tool, so not a demand count), Barn Stall's size filter (29k) and Hidden Spots (13k), all alive on 1.7 | None | 6 | | Sleeping zones | Animal sleeping zones where every cell is a sleeping spot, with species and body-size filters; people sleeping zones for colonists, slaves and prisoners, medical and shared; with Blax Castes, zones limited by caste | Covers the spot-grid use of Designator Shapes (332k, a general shape tool, so not a demand count), Barn Stall's size filter (29k) and Hidden Spots (13k), all alive on 1.7 | None (slaves: Ideology) |
| 1.3 | 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 | | Zone tools and removal | Save-safe zone storage (shipped in 1.0) and a button that removes Blax Zones from a save with no errors | Nothing | None |
| 1.4 | 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.5 | 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.6 | With Blax Castes, sleeping zones limited by caste | None | None | 2 |
| 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"). Order, steps, new proposals and open questions: [features.md](features.md). Subscriber counts were read from the Workshop on 2026-11-29. Needs: "None" means the area runs on the core game, and a DLC in brackets marks the parts that switch off without it (see "DLC support"). Effort marks on features (S, M, L for small, medium, large) are information only; the plan is grouped by area, not by effort.
Total: 37 working days: 29 for the other six releases (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.3). 1.3 needs only the 1.0 component and the 1.2 removal button, so it ships right after 1.2 without changes; if it slips, Clean first and Haul first move to 1.3.1 and the four "No" rules ship first.
## Defaults I picked ## Defaults I picked
Change if you disagree. Change if you disagree.
- Caravan camps ship in 1.0 and caravan purchase routing in 1.1. Camping fills a 1.7 gap (the trading-spot mods are dead or 1.6 only), and with the caravan camped by the zone, vanilla's drops at the pack animal's feet already land near it. - Caravan camps ship in 1.0 and caravan purchase routing in 1.1. Camping fills a 1.7 gap (the trading-spot mods are dead or 1.6 only), and with the caravan camped by the zone, vanilla's drops at the pack animal's feet already land near it.
- Deliveries get their own zone type in 1.0, not a flag on stockpiles. Most stockpiles are roofed, where pods can't land, and a landing pad keeps pods out of the warehouse. Flagged stockpiles and shelves come in 1.4 together with roofed delivery. - Deliveries get their own zone type in 1.0, not a flag on stockpiles. Most stockpiles are roofed, where pods can't land, and a landing pad keeps pods out of the warehouse. Flagged stockpiles and shelves come with storage deliveries, together with roofed delivery.
- Goods bought from Hospitality guests land in delivery zones too (1.1), because guests sell through the same caravan code. The caravan checkbox's tooltip says so. - Goods bought from Hospitality guests land in delivery zones too (1.1), because guests sell through the same caravan code. The caravan checkbox's tooltip says so.
- When every zone cell is taken, pods land within 16 cells of the top zone. The radius goes from 5 to 30, because the game's search can hang below 5. A setting sends overflow to the vanilla spot instead. - When every zone cell is taken, pods land within 16 cells of the top zone. The radius goes from 5 to 30, because the game's search can hang below 5. A setting sends overflow to the vanilla spot instead.
- Blax Slaves payouts (ransom, buy-back, wages) follow a zone's orbital checkbox. Its tooltip says so while Slaves is active. - Blax Slaves payouts (ransom, buy-back, wages) follow a zone's orbital checkbox. Its tooltip says so while Slaves is active.
- Roofed delivery (goods appear, no drop pod) exists, per zone, off by default, from 1.4. - Roofed delivery (goods appear, no drop pod) exists, per zone, off by default, with storage deliveries.
- Sleeping-zone cells match vanilla sleeping spots: 80% rest, "slept on ground" -4 mood, comfort 0.4, count for barracks, sleeper drawn lying on the ground. - Sleeping-zone cells match vanilla sleeping spots: 80% rest, "slept on ground" -4 mood, comfort 0.4, count for barracks, sleeper drawn lying on the ground.
- Sleeping zones don't extend the home area. Delivery zones do, like every vanilla zone. - Sleeping zones don't extend the home area. Delivery zones do, like every vanilla zone.
- A zone's owner type wins. Vanilla turns every bed in a prison cell into a prisoner bed; a colonist or slave zone in such a room stays as it is, and the inspect pane warns. - A zone's owner type wins. Vanilla turns every bed in a prison cell into a prisoner bed; a colonist or slave zone in such a room stays as it is, and the inspect pane warns.
@ -62,9 +65,9 @@ Change if you disagree.
- Caravan goods appear in the zone. Pack animals don't walk them over; I cut that. - Caravan goods appear in the zone. Pack animals don't walk them over; I cut that.
- Trader caravans and tribute collectors camp at a "Caravans camp here" zone. Visitor groups don't. - Trader caravans and tribute collectors camp at a "Caravans camp here" zone. Visitor groups don't.
- Odyssey gravships leave Blax zones and their beds behind. Zone beds never fly. - Odyssey gravships leave Blax zones and their beds behind. Zone beds never fly.
- Caste limits (1.6) apply to medical zones too, so a medical zone can be kept for the Miner caste. - Caste limits 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. - A Zones error never costs an item: every routed path falls back to vanilla.
- Work rules (1.3) 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. - Work rules 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. - 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. - "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. - 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.
@ -81,22 +84,22 @@ Everything below is for the modder building it.
## Data model ## Data model
Three parts carry everything. Build them first, in 1.0 and 1.2. The rules and the DLC support after them apply to every feature. Three parts carry everything. The zone store and the router came with 1.0; zone beds come with the first sleeping zones. The rules and the DLC support after them apply to every feature.
### Zone store, safe to remove from a save ### 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 work rule areas (1.3), the stockpile and shelf flags (1.4), 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. All Blax state lives in one `MapComponent_BlaxZones` per map: our zones while saving and loading (1.0), the zone beds (sleeping zones), the work rule areas, the stockpile and shelf flags (storage deliveries), 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. - 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. - 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.
- Zone list: `ZoneManager` stays the only registry while the game runs; the component keeps no list of zones. Vanilla registers and deregisters zones without calling Zones: the designators register new zones (Designator_ZoneAdd.cs:149-151, 182-184), and `Zone.RemoveCell` deregisters a zone when its last cell goes (Zone.cs:248-251). That covers `Zone.Delete` (Zone.cs:259-277), walls spawning on cells, also in the load spawn loop (ZoneManager.cs:97-112), and gravship landings (GravshipPlacementUtility.cs:313). When saving, the component writes the Blax zones it finds in `zoneManager.AllZones`; the map saves `zoneManager` before the components (Map.cs:873, 898), and the finalizer has restored the list by then. After loading, the component holds the loaded zones only until the load prefix has registered them. A deleted zone is never saved again. Caches keyed by zone are dropped in our zone classes' `PostDeregister` override (ZoneManager.cs:58-62). - Zone list: `ZoneManager` stays the only registry while the game runs; the component keeps no list of zones. Vanilla registers and deregisters zones without calling Zones: the designators register new zones (Designator_ZoneAdd.cs:149-151, 182-184), and `Zone.RemoveCell` deregisters a zone when its last cell goes (Zone.cs:248-251). That covers `Zone.Delete` (Zone.cs:259-277), walls spawning on cells, also in the load spawn loop (ZoneManager.cs:97-112), and gravship landings (GravshipPlacementUtility.cs:313). When saving, the component writes the Blax zones it finds in `zoneManager.AllZones`; the map saves `zoneManager` before the components (Map.cs:873, 898), and the finalizer has restored the list by then. After loading, the component holds the loaded zones only until the load prefix has registered them. A deleted zone is never saved again. Caches keyed by zone are dropped in our zone classes' `PostDeregister` override (ZoneManager.cs:58-62).
- Load: a prefix on `Map.FinalizeLoading` (Map.cs:750) re-registers our zones and appends zone beds to the private `loadedFullThings` (Map.cs:17), so vanilla spawns them and their references resolve. - Load: a prefix on `Map.FinalizeLoading` (Map.cs:750) re-registers our zones and appends zone beds to the private `loadedFullThings` (Map.cs:17), so vanilla spawns them and their references resolve.
- 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: - 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). With sleeping zones, 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; - 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. - 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.3, 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. - With work rule areas, 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. - The removal button 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. - Removal flag (removal button): 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). - 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).
### DeliveryRouter, shared by every delivery path ### DeliveryRouter, shared by every delivery path
@ -104,12 +107,12 @@ All Blax state lives in one `MapComponent_BlaxZones` per map: our zones while sa
One static class that orbital trade, rewards, caravans, cargo pods, direct delivery and `ZonesApi.TryFindDropSpot` all call. Its build counts in the delivery zone's effort, so each routing feature stays small. One static class that orbital trade, rewards, caravans, cargo pods, direct delivery and `ZonesApi.TryFindDropSpot` all call. Its build counts in the delivery zone's effort, so each routing feature stays small.
- Refuses: `Pawn`, `Corpse`, Wastepack (Biotech; the check skips a null `ThingDefOf.Wastepack`), maps with no zones, and maps without the component (after the removal button). - Refuses: `Pawn`, `Corpse`, Wastepack (Biotech; the check skips a null `ThingDefOf.Wastepack`), maps with no zones, and maps without the component (after the removal button).
- Candidates: delivery zones (from 1.4 also flagged stockpiles and shelves) that accept the source and pass the filter, ordered by priority, then zone ID (shelves: ThingID). - Candidates: delivery zones (with storage deliveries also flagged stockpiles and shelves) that accept the source and pass the filter, ordered by priority, then zone ID (shelves: ThingID).
- Cells: sorted by distance to the zone centroid, cached in the component and rebuilt in `AddCell`/`RemoveCell`. Delivery zones: pass 1 takes empty valid cells, pass 2 cells with a mergeable stack, because pods spread out. Storage targets (1.4): mergeable stacks first, then empty cells, the order Haul to Stack uses. At most 400 checks per stack. - Cells: sorted by distance to the zone centroid, cached in the component and rebuilt in `AddCell`/`RemoveCell`. Delivery zones: pass 1 takes empty valid cells, pass 2 cells with a mergeable stack, because pods spread out. Storage targets (storage deliveries): mergeable stacks first, then empty cells, the order Haul to Stack uses. At most 400 checks per stack.
- Reach rule: a spawned free colonist (`map.mapPawns.FreeColonistsSpawned`) can reach the cell, with `PathEndMode.OnCell` for pods and placement and `Touch` for storage. Checked once per district and cached in the component; with no free colonist on the map, `Reachability.CanReachColony` decides. Not `CanReachColony` first: it returns true for any cell that reaches any colony building (Reachability.cs:387-435), so a walled-off area holding a sleeping zone (1.2), or player walls, would count as colony. - Reach rule: a spawned free colonist (`map.mapPawns.FreeColonistsSpawned`) can reach the cell, with `PathEndMode.OnCell` for pods and placement and `Touch` for storage. Checked once per district and cached in the component; with no free colonist on the map, `Reachability.CanReachColony` decides. Not `CanReachColony` first: it returns true for any cell that reaches any colony building (Reachability.cs:387-435), so a walled-off area holding a sleeping zone, or player walls, would count as colony.
- Pod rule: `DropCellFinder.IsGoodDropSpot(c, map, allowFogged: false, canRoofPunch: false)` (DropCellFinder.cs:319-362) plus the reach rule. It refuses unwalkable cells, water and vacuum terrain (DropCellFinder.cs:509-516), any roof (:518-527), districts with an enclosed animal pen marker (:537-549), skyfallers and active transporters, and edifices that aren't clearable free buildings (:338-358). Shelves are edifices, so they fail it roofed or not. - Pod rule: `DropCellFinder.IsGoodDropSpot(c, map, allowFogged: false, canRoofPunch: false)` (DropCellFinder.cs:319-362) plus the reach rule. It refuses unwalkable cells, water and vacuum terrain (DropCellFinder.cs:509-516), any roof (:518-527), districts with an enclosed animal pen marker (:537-549), skyfallers and active transporters, and edifices that aren't clearable free buildings (:338-358). Shelves are edifices, so they fail it roofed or not.
- Placement rule (caravan goods, direct delivery into delivery zones): standable, unfogged, the reach rule, roof ignored. - Placement rule (caravan goods, direct delivery into delivery zones): standable, unfogged, the reach rule, roof ignored.
- Storage rule (1.4 storage targets): `StoreUtility.IsValidStorageFor(c, map, thing)` (StoreUtility.cs:103-115: the slot group accepts the thing, no storage blockers, items per cell respected) and `StoreUtility.IsGoodStoreCell(c, map, thing, null, Faction.OfPlayer)` (StoreUtility.cs:327: no player reservation, no fire, no blocking frame), unfogged, and the reach rule with `Touch`. Not standable: vanilla shelves and RimFridge fridges are PassThroughOnly, RimFridge wall fridges Impassable, and `Standable` (GenGrid.cs:144-159) refuses both. - Storage rule (storage targets): `StoreUtility.IsValidStorageFor(c, map, thing)` (StoreUtility.cs:103-115: the slot group accepts the thing, no storage blockers, items per cell respected) and `StoreUtility.IsGoodStoreCell(c, map, thing, null, Faction.OfPlayer)` (StoreUtility.cs:327: no player reservation, no fire, no blocking frame), unfogged, and the reach rule with `Touch`. Not standable: vanilla shelves and RimFridge fridges are PassThroughOnly, RimFridge wall fridges Impassable, and `Standable` (GenGrid.cs:144-159) refuses both.
- Overflow center: the top zone's cell nearest its centroid, not the raw centroid. `TryFindDropSpotNear` needs reachability from its center (DropCellFinder.cs:309-312), and the centroid of an L-shaped zone can be a wall. - Overflow center: the top zone's cell nearest its centroid, not the raw centroid. `TryFindDropSpotNear` needs reachability from its center (DropCellFinder.cs:309-312), and the centroid of an L-shaped zone can be a wall.
- Overflow: `DropCellFinder.TryFindDropSpotNear(center, map, out cell, allowFogged: false, canRoofPunch: false, maxRadius)` (DropCellFinder.cs:229) with the radius setting, never below 5. The search grows by `Mathf.Min(maxRadius / 5, 1)` (DropCellFinder.cs:272), which is 0 below 5, so a failed search never ends. Then the vanilla spot. - Overflow: `DropCellFinder.TryFindDropSpotNear(center, map, out cell, allowFogged: false, canRoofPunch: false, maxRadius)` (DropCellFinder.cs:229) with the radius setting, never below 5. The search grows by `Mathf.Min(maxRadius / 5, 1)` (DropCellFinder.cs:272), which is 0 below 5, so a failed search never ends. Then the vanilla spot.
- Context (from 1.1): callers that can't pass a source set a `[ThreadStatic] DeliveryContext` in a prefix, keep the previous value in `__state` and restore it in a finalizer. The `DropPodUtility.DropThingGroupsNear` prefix reads it. A prefix on `SignalManager.SendSignal` (SignalManager.cs:38) saves and clears the context and its finalizer restores it: signals are delivered inside the same call (SignalManager.cs:38-60), so quest parts chained through `outSignalResult` (QuestPart_DropPods.cs:239-251, QuestPart_GiveNearPawn.cs:224-238) never see a context that wasn't set for them. - Context (from 1.1): callers that can't pass a source set a `[ThreadStatic] DeliveryContext` in a prefix, keep the previous value in `__state` and restore it in a finalizer. The `DropPodUtility.DropThingGroupsNear` prefix reads it. A prefix on `SignalManager.SendSignal` (SignalManager.cs:38) saves and clears the context and its finalizer restores it: signals are delivered inside the same call (SignalManager.cs:38-60), so quest parts chained through `outSignalResult` (QuestPart_DropPods.cs:239-251, QuestPart_GiveNearPawn.cs:224-238) never see a context that wasn't set for them.
@ -117,19 +120,19 @@ One static class that orbital trade, rewards, caravans, cargo pods, direct deliv
### Zone beds ### Zone beds
One invisible bed per sleeping-zone cell: `Building_ZoneBed : Building_Bed`, player faction, not an edifice, def `isSaveable` false. Animal zones use them from 1.2, people zones from 1.5. One invisible bed per sleeping-zone cell: `Building_ZoneBed : Building_Bed`, player faction, not an edifice, def `isSaveable` false. Animal zones use them first, people zones after.
- Why real beds: ownership, prisoner capture, slave beds, patients, rescue, babies and `Alert_NeedColonistBeds` keep working with no extra patches. Ground sleep without beds covers voluntary sleep only (see Cut). - Why real beds: ownership, prisoner capture, slave beds, patients, rescue, babies and `Alert_NeedColonistBeds` keep working with no extra patches. Ground sleep without beds covers voluntary sleep only (see Cut).
- Not an edifice: an edifice without a `sowTag` blocks planting and wipes the pasture grass under it (ThingDef.cs:625-655, 1360-1387; GenSpawn.cs:445-447). - Not an edifice: an edifice without a `sowTag` blocks planting and wipes the pasture grass under it (ThingDef.cs:625-655, 1360-1387; GenSpawn.cs:445-447).
- Saving: `Map.ExposeData` skips things whose def has `isSaveable` false (Map.cs:652, the only check in the code), so the component deep-saves the beds instead and the load prefix hands them to vanilla. Without the mod they vanish with the component node, and the vanilla things list never holds a missing def. Before saving, the component drops destroyed and despawned beds from its list; a destroyed bed left there would come back next to its replacement. - Saving: `Map.ExposeData` skips things whose def has `isSaveable` false (Map.cs:652, the only check in the code), so the component deep-saves the beds instead and the load prefix hands them to vanilla. Without the mod they vanish with the component node, and the vanilla things list never holds a missing def. Before saving, the component drops destroyed and despawned beds from its list; a destroyed bed left there would come back next to its replacement.
- Spawning: make the bed, `SetFaction(Faction.OfPlayer)` (`IsValidBedFor` needs it, RestUtility.cs:185), set `ForOwnerType` and `Medical` while it is unspawned and the bypass flag below is set, then `GenSpawn.Spawn`. On an unspawned bed the setters find no owners and no room (Building_Bed.cs:92-131, 753-756). `Building_Bed.SpawnSetup` then recomputes the district and room with the bed already the right type (Building_Bed.cs:274-282), so a prisoner zone in a closed room becomes a prison cell. The bed never wipes anything: a cell holding a skyfaller, an active transporter or another bed waits for the next sweep. - Spawning: make the bed, `SetFaction(Faction.OfPlayer)` (`IsValidBedFor` needs it, RestUtility.cs:185), set `ForOwnerType` and `Medical` while it is unspawned and the bypass flag below is set, then `GenSpawn.Spawn`. On an unspawned bed the setters find no owners and no room (Building_Bed.cs:92-131, 753-756). `Building_Bed.SpawnSetup` then recomputes the district and room with the bed already the right type (Building_Bed.cs:274-282), so a prisoner zone in a closed room becomes a prison cell. The bed never wipes anything: a cell holding a skyfaller, an active transporter or another bed waits for the next sweep.
- Owner type comes from the zone (people zones, 1.5): prefixes on the `ForPrisoners` setter (Building_Bed.cs:44-73) and the `ForOwnerType` setter (Building_Bed.cs:92-108) refuse any change to a zone bed unless Zones' own `[ThreadStatic]` bypass flag is set. Vanilla changes owner types behind the zone's back in three places, and each flip posts one message per owner (`RemoveAllOwners`, Building_Bed.cs:738-751): - Owner type comes from the zone (people zones): prefixes on the `ForPrisoners` setter (Building_Bed.cs:44-73) and the `ForOwnerType` setter (Building_Bed.cs:92-108) refuse any change to a zone bed unless Zones' own `[ThreadStatic]` bypass flag is set. Vanilla changes owner types behind the zone's back in three places, and each flip posts one message per owner (`RemoveAllOwners`, Building_Bed.cs:738-751):
- at spawn in a prison cell (Building_Bed.cs:272-276); - at spawn in a prison cell (Building_Bed.cs:272-276);
- on every room recalculation of a prison cell, through `ForPrisoners` (Room.cs:721-727); - on every room recalculation of a prison cell, through `ForPrisoners` (Room.cs:721-727);
- through the bed gizmo: `SetBedOwnerTypeByInterface` collects every bed in the room, all of them when switching to Prisoner in a room that can be a prison cell and every prisoner bed when switching away, and sets them through `ForOwnerType` (Building_Bed.cs:395-473, collected at :419-436, set at :448, :452). - through the bed gizmo: `SetBedOwnerTypeByInterface` collects every bed in the room, all of them when switching to Prisoner in a room that can be a prison cell and every prisoner bed when switching away, and sets them through `ForOwnerType` (Building_Bed.cs:395-473, collected at :419-436, set at :448, :452).
- Zones sets the flag around its own owner-type changes and around `base.DeSpawn` in `Building_ZoneBed`, where vanilla resets the type to Colonist (Building_Bed.cs:301). Vanilla's confirm for the gizmo (:475-480) may still count zone-bed owners who keep their cells; accepted. - Zones sets the flag around its own owner-type changes and around `base.DeSpawn` in `Building_ZoneBed`, where vanilla resets the type to Colonist (Building_Bed.cs:301). Vanilla's confirm for the gizmo (:475-480) may still count zone-bed owners who keep their cells; accepted.
- Choke point: `Building_ZoneBed.DeSpawn` is our own override, no Harmony. If Zones didn't start the removal, the mode isn't `WillReplace` and the cell is still a sleeping-zone cell, it unclaims the owners silently and queues a respawn for the next tick with the zone's flags. - Choke point: `Building_ZoneBed.DeSpawn` is our own override, no Harmony. If Zones didn't start the removal, the mode isn't `WillReplace` and the cell is still a sleeping-zone cell, it unclaims the owners silently and queues a respawn for the next tick with the zone's flags.
- Sweep: every 250 ticks the component trims sleeping-zone cells that hold an edifice (backstop for the 1.2 edifice postfix), and from 1.5 it also runs the shared-zone and caste checks. - Sweep: every 250 ticks the component trims sleeping-zone cells that hold an edifice (backstop for the animal zones' edifice postfix), and with people zones it also runs the shared-zone and caste checks.
- Reconcile: `MapComponent.FinalizeInit` (MapComponent.cs:32, called from Map.cs:851) drops sleeping-zone cells that hold an edifice, destroys beds whose cell is no longer in a sleeping zone and spawns missing beds. It never resets the owners, medical flag or owner type of a bed that still exists. - Reconcile: `MapComponent.FinalizeInit` (MapComponent.cs:32, called from Map.cs:851) drops sleeping-zone cells that hold an edifice, destroys beds whose cell is no longer in a sleeping zone and spawns missing beds. It never resets the owners, medical flag or owner type of a bed that still exists.
### Rules every feature follows ### Rules every feature follows
@ -152,9 +155,9 @@ From the three Castes review rounds.
Every Blax mod works with any DLC combination, core only included (rule of 2026-11-29). For Zones: 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. - 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.5). Work rule areas (1.3) 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. - Every feature runs on the core game. The one part that needs a DLC is slave sleeping zones (Ideology). Work rule areas 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 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.5 guard. - 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 guard on slave sleeping zones.
- 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". - 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".
- A save made with a DLC loads without it: - A save made with a DLC loads without it:
- A slave zone keeps its owner type, as vanilla keeps a slave bed's (`forOwnerType` loads with no DLC check, Building_Bed.cs:319), and can still be switched to colonists or prisoners. With Ideology back it works as a slave zone again. - A slave zone keeps its owner type, as vanilla keeps a slave bed's (`forOwnerType` loads with no DLC check, Building_Bed.cs:319), and can still be switched to colonists or prisoners. With Ideology back it works as a slave zone again.
@ -166,30 +169,32 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- A test that needs a DLC names it and skips without. Each feature's DLC-off test runs in every combination that lacks its DLC. - A test that needs a DLC names it and skips without. Each feature's DLC-off test runs in every combination that lacks its DLC.
- Anomaly and Odyssey paths are not tested. - Anomaly and Odyssey paths are not tested.
| Feature | Release | Needs | Without it | | Feature | Shipped in, or area | Needs | Without it |
|---|---|---|---| |---|---|---|---|
| Save-safe zone storage | 1.0 | None | Unchanged | | Save-safe zone storage | 1.0 | None | Unchanged |
| Delivery zones, orbital purchases | 1.0 | None | Unchanged; the Wastepack refusal is skipped, since the def doesn't exist | | Delivery zones, orbital purchases | 1.0 | None | Unchanged; the Wastepack refusal is skipped, since the def doesn't exist |
| Caravans camp at a zone | 1.0 | None | Trader caravans camp; tribute collectors exist only with Royalty | | Caravans camp at a zone | 1.0 | None | Trader caravans camp; tribute collectors exist only with Royalty |
| Quest rewards land in the zone | 1.1 | None | Every item reward routes; Empire quests exist only with Royalty | | Quest rewards land in the zone | 1.1 | None | Every item reward routes; Empire quests exist only with Royalty |
| Caravan purchases | 1.1 | None | Unchanged | | Caravan purchases | 1.1 | None | Unchanged |
| Animal sleeping zones, animal filters, removal button | 1.2 | None | Unchanged | | Animal sleeping zones, animal filters, removal button | Sleeping zones, zone tools | None | Unchanged |
| Work rule areas: no cleaning, firefighting, repairs or hauling; clean first, haul first | 1.3 | None | Unchanged; without Biotech there are no mechs to follow the rules | | Work rule areas: no cleaning, firefighting, repairs or hauling; clean first, haul first | Work rule areas | None | Unchanged; without Biotech there are no mechs to follow the rules |
| Stockpile and shelf deliveries, delivery under a roof, sell zones, cargo pods | 1.4 | None | Unchanged | | Stockpile and shelf deliveries, delivery under a roof, sell zones, cargo pods | Arrivals | None | Unchanged |
| People sleeping zones for colonists and prisoners; medical, shared and comfort; zone tints | 1.5 | None | Unchanged | | People sleeping zones for colonists and prisoners; medical, shared and comfort; zone tints | Sleeping zones | None | Unchanged |
| Slave sleeping zones | 1.5 | 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 | | Slave sleeping zones | Sleeping zones | 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.6 | None (Blax Castes is a mod) | Unchanged | | Caste filter | Sleeping zones | None (Blax Castes is a mod) | Unchanged |
| Royal title rewards | Backlog | Royalty | Not offered | | Royal title rewards | Backlog | Royalty | Not offered |
| Age limits on people zones | Backlog | Biotech | Shown disabled with "Needs Biotech" | | Age limits on people zones | Backlog | Biotech | Shown disabled with "Needs Biotech" |
| Blax zones fly with gravships | Backlog | Odyssey | Zones stay behind, as today | | Blax zones fly with gravships | Backlog | Odyssey | Zones stay behind, as today |
## Releases ## Arrivals: deliveries and caravan camps
### 1.0 Delivery zones and caravan camps (6 days) Shipped in 1.0 and 1.1, then two designed steps. Order and status: [features.md](features.md), "Arrivals".
### 1.0 Delivery zones and caravan camps
#### Save-safe zone storage #### Save-safe zone storage
- **Players get:** Nothing to see. Zones survive save and load. Removing the mod mid-game with a plain unsubscribe leaves a save that loads: the Blax zones are gone, vanilla zones stay, and the log shows the 2 errors per map named in the data model. The button that removes even those comes in 1.2. - **Players get:** Nothing to see. Zones survive save and load. Removing the mod mid-game with a plain unsubscribe leaves a save that loads: the Blax zones are gone, vanilla zones stay, and the log shows the 2 errors per map named in the data model. The removal button (Zone tools) removes even those.
- **How:** - **How:**
- Save: the prefix and finalizer from the data model, with `AccessTools.FieldRefAccess` for `allZones`; the component writes the Blax zones from `AllZones` as the data model's zone-list rule says. - Save: the prefix and finalizer from the data model, with `AccessTools.FieldRefAccess` for `allZones`; the component writes the Blax zones from `AllZones` as the data model's zone-list rule says.
- Load: the `Map.FinalizeLoading` prefix runs while `zoneGrid` exists and nothing has spawned yet. Its whole body sits in try/catch, because vanilla catches an exception there as "Error in Map.FinalizeLoading()" and skips the rest of that map's load (Game.cs:619-623). On an exception it logs once and leaves our zones out of this load. It sets each zone's `zoneManager` link, calls the public `ZoneManager.RegisterZone` (ZoneManager.cs:52), then the internal `AddZoneGridCell` (ZoneManager.cs:68) per cell through an `AccessTools` delegate, and then clears the component's loaded-zone list. - Load: the `Map.FinalizeLoading` prefix runs while `zoneGrid` exists and nothing has spawned yet. Its whole body sits in try/catch, because vanilla catches an exception there as "Error in Map.FinalizeLoading()" and skips the rest of that map's load (Game.cs:619-623). On an exception it logs once and leaves our zones out of this load. It sets each zone's `zoneManager` link, calls the public `ZoneManager.RegisterZone` (ZoneManager.cs:52), then the internal `AddZoneGridCell` (ZoneManager.cs:68) per cell through an `AccessTools` delegate, and then clears the component's loaded-zone list.
@ -198,7 +203,7 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Settings:** None. This is the save format, not a feature. - **Settings:** None. This is the save format, not a feature.
- **Save and removal:** This is the save format. Zones that vanilla saved would need a migration later, so it ships in 1.0. Adding the mod mid-save gives every map an empty component. - **Save and removal:** This is the save format. Zones that vanilla saved would need a migration later, so it ships in 1.0. Adding the mod mid-save gives every map an empty component.
- **Replaces:** Nothing. - **Replaces:** Nothing.
- **Effort:** M, 2 days. - **Effort:** M.
- **Tests:** - **Tests:**
- Phase 1: create two delivery zones with different filters and priorities, save, parse the .rws. No "BlaxZones." inside `<zoneManager>` or `<things>`; both zones sit under the `MapComponent_BlaxZones` node. After an autosave without a reload, our zones are still in `AllZones`, the list is the same object (`ReferenceEquals`) and `zoneGrid` is intact. A test-only zone whose ExposeData throws while saving: the finalizer still restores the list. Delete a third zone before saving: the .rws doesn't contain it. A fourth zone whose only cell gets a wall before saving is not in the .rws either. - Phase 1: create two delivery zones with different filters and priorities, save, parse the .rws. No "BlaxZones." inside `<zoneManager>` or `<things>`; both zones sit under the `MapComponent_BlaxZones` node. After an autosave without a reload, our zones are still in `AllZones`, the list is the same object (`ReferenceEquals`) and `zoneGrid` is intact. A test-only zone whose ExposeData throws while saving: the finalizer still restores the list. Delete a third zone before saving: the .rws doesn't contain it. A fourth zone whose only cell gets a wall before saving is not in the .rws either.
- Phase 2: both zones are in `map.zoneManager.AllZones` with the same ID, label, cells, filter, priority and sources, and `ZoneAt(cell)` returns them. The deleted and walled-over zones stay gone. `Zone.ID` comes from `UniqueIDsManager` (Zone.cs:192), so a new vanilla zone never reuses it. A wall built on a zone cell before saving leaves that cell out. - Phase 2: both zones are in `map.zoneManager.AllZones` with the same ID, label, cells, filter, priority and sources, and `ZoneAt(cell)` returns them. The deleted and walled-over zones stay gone. `Zone.ID` comes from `UniqueIDsManager` (Zone.cs:192), so a new vanilla zone never reuses it. A wall built on a zone cell before saving leaves that cell out.
@ -210,7 +215,7 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Players get:** A new "Delivery zone" in the Zone menu, dragged like a stockpile. Its tab has an item filter (what may land here), a priority from Low to Critical, and source checkboxes (orbital traders now, quest rewards and caravan traders in 1.1). While the zone is selected, red outlines mark cells drop pods can't use (roofed, inside an enclosed pen, water or vacuum, a building in the way, blocked, fogged, unreachable), and the inspect pane gives their total. Like every vanilla zone, it extends the home area 4 cells around itself; the tooltip says so. - **Players get:** A new "Delivery zone" in the Zone menu, dragged like a stockpile. Its tab has an item filter (what may land here), a priority from Low to Critical, and source checkboxes (orbital traders now, quest rewards and caravan traders in 1.1). While the zone is selected, red outlines mark cells drop pods can't use (roofed, inside an enclosed pen, water or vacuum, a building in the way, blocked, fogged, unreachable), and the inspect pane gives their total. Like every vanilla zone, it extends the home area 4 cells around itself; the tooltip says so.
- **How:** - **How:**
- `Zone_Delivery : Verse.Zone` with `ThingFilter filter` (all items allowed; corpses and, with Biotech, Wastepack hidden and always refused; a null `ThingDefOf.Wastepack` is skipped), `StoragePriority priority = Normal`, `acceptOrbital` (true) and `campHere` (false), each scribed with its default. 1.1 adds `acceptRewards` and `acceptCaravan`, 1.4 `acceptCargoPods` and `directDelivery`, the same way. - `Zone_Delivery : Verse.Zone` with `ThingFilter filter` (all items allowed; corpses and, with Biotech, Wastepack hidden and always refused; a null `ThingDefOf.Wastepack` is skipped), `StoragePriority priority = Normal`, `acceptOrbital` (true) and `campHere` (false), each scribed with its default. 1.1 adds `acceptRewards` and `acceptCaravan`, cargo pods `acceptCargoPods` and delivery under a roof `directDelivery`, the same way.
- Designators: `Designator_ZoneAdd_Delivery` plus an `_Expand` subclass reached through `DesignatorUtility.FindAllowedDesignator` (DesignatorUtility.cs:25-46), as `Zone_Fishing` does (Zone_Fishing.cs:196-199). `Designator_ZoneAdd` compares the exact zone type and refuses cells in other zones (Designator_ZoneAdd.cs:46, 73, 114, 127). Expanding over the zone only adds new cells. A namespace-qualified `PatchOperationInsert` adds the designator after the `Designator_ZoneAdd_Growing` entry in DesignationCategoryDef Zone `specialDesignatorClasses` (Core Misc/Designations/DesignationCategories.xml:40); anchor on Growing, because the Fishing entry (:41) carries `MayRequire`. `Visible` reads the master toggle live. - Designators: `Designator_ZoneAdd_Delivery` plus an `_Expand` subclass reached through `DesignatorUtility.FindAllowedDesignator` (DesignatorUtility.cs:25-46), as `Zone_Fishing` does (Zone_Fishing.cs:196-199). `Designator_ZoneAdd` compares the exact zone type and refuses cells in other zones (Designator_ZoneAdd.cs:46, 73, 114, 127). Expanding over the zone only adds new cells. A namespace-qualified `PatchOperationInsert` adds the designator after the `Designator_ZoneAdd_Growing` entry in DesignationCategoryDef Zone `specialDesignatorClasses` (Core Misc/Designations/DesignationCategories.xml:40); anchor on Growing, because the Fishing entry (:41) carries `MayRequire`. `Visible` reads the master toggle live.
- Tab: `ITab_Delivery` holds the priority dropdown, the source checkboxes, the camp checkbox, `ThingFilterUI.DoThingFilterConfigWindow` and copy/paste gizmos with our own clipboard. - Tab: `ITab_Delivery` holds the priority dropdown, the source checkboxes, the camp checkbox, `ThingFilterUI.DoThingFilterConfigWindow` and copy/paste gizmos with our own clipboard.
- Cell validity uses the router's pod rule. `MapComponentUpdate` draws `GenDraw.DrawFieldEdges` over invalid cells while the zone is selected. `GetInspectString` adds "N cells drop pods can't use"; the breakdown by reason is in the Backlog. - Cell validity uses the router's pod rule. `MapComponentUpdate` draws `GenDraw.DrawFieldEdges` over invalid cells while the zone is selected. `GetInspectString` adds "N cells drop pods can't use"; the breakdown by reason is in the Backlog.
@ -221,9 +226,9 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Settings:** Global "Delivery zones" master toggle (on); off hides the designators, existing zones stay and the routing toggles still apply. Per zone: filter (all items), priority (Normal), orbital checkbox (on; 1.1 adds rewards and caravan, both on), "Caravans camp here" (off). - **Settings:** Global "Delivery zones" master toggle (on); off hides the designators, existing zones stay and the routing toggles still apply. Per zone: filter (all items), priority (Normal), orbital checkbox (on; 1.1 adds rewards and caravan, both on), "Caravans camp here" (off).
- **Save and removal:** The zone and its filter save inside the component, never in `ZoneManager`. Removal deletes them with the component and the cells become plain ground. - **Save and removal:** The zone and its filter save inside the component, never in `ZoneManager`. Removal deletes them with the component and the cells become plain ground.
- **Replaces:** Together with the routing below: Trade Ships Drop Spot (1969732297, 206,371 subs, official versions up to 1.6) and its unofficial 1.7 ports (3828260574, 127; 3837213962, 70), the orbital drop spot of Trading Control (2007107588, 111,091, up to 1.6), Orbital Trade Goods Landing Zone (3015945224, 161, 1.5). Quest rewards, the other half of what Trade Ships Drop Spot does, follow in 1.1. - **Replaces:** Together with the routing below: Trade Ships Drop Spot (1969732297, 206,371 subs, official versions up to 1.6) and its unofficial 1.7 ports (3828260574, 127; 3837213962, 70), the orbital drop spot of Trading Control (2007107588, 111,091, up to 1.6), Orbital Trade Goods Landing Zone (3015945224, 161, 1.5). Quest rewards, the other half of what Trade Ships Drop Spot does, follow in 1.1.
- **Effort:** M, 2 days, router included. - **Effort:** M, router included.
- **Tests:** Designating unroofed cells creates a `Zone_Delivery`; the expand gizmo grows it and only adds cells. The designator refuses cells in an existing stockpile. Roof 3 cells and `GetInspectString` reports 3 unusable cells; a water cell makes it 4. A fence ring with an animal pen marker around the zone makes every cell unusable. The default filter allows silver, medicine and steel and refuses Wastepack (Biotech); without Biotech it builds with no error. Filter, priority, orbital and camp flags persist in phase 2. `ZonesApi.TryFindDropSpot` returns a zone cell for steel and false for a pawn; with the zone's orbital checkbox off it returns false. The overflow radius setting can't go below 5. - **Tests:** Designating unroofed cells creates a `Zone_Delivery`; the expand gizmo grows it and only adds cells. The designator refuses cells in an existing stockpile. Roof 3 cells and `GetInspectString` reports 3 unusable cells; a water cell makes it 4. A fence ring with an animal pen marker around the zone makes every cell unusable. The default filter allows silver, medicine and steel and refuses Wastepack (Biotech); without Biotech it builds with no error. Filter, priority, orbital and camp flags persist in phase 2. `ZonesApi.TryFindDropSpot` returns a zone cell for steel and false for a pawn; with the zone's orbital checkbox off it returns false. The overflow radius setting can't go below 5.
- **Risks:** One zone per cell, so a delivery zone can't overlap a stockpile. Goods land and haulers store them; 1.4 lets stockpiles receive deliveries directly. Pods never land in an enclosed pen (vanilla rule). The red overlay shows this instead of failing silently like Trading Control's spot. Pick Up And Haul (1279012058, 1,784,752 subs) patches hauling only; it collects goods from the zone several stacks per trip, and nothing changes for us. - **Risks:** One zone per cell, so a delivery zone can't overlap a stockpile. Goods land and haulers store them; storage deliveries let stockpiles receive them directly. Pods never land in an enclosed pen (vanilla rule). The red overlay shows this instead of failing silently like Trading Control's spot. Pick Up And Haul (1279012058, 1,784,752 subs) patches hauling only; it collects goods from the zone several stacks per trip, and nothing changes for us.
#### Orbital purchases land in the zone #### Orbital purchases land in the zone
@ -236,7 +241,7 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Settings:** Global "Route orbital trade" (on), "Overflow lands next to the zone" (on; off sends overflow to vanilla), overflow radius 16 (5 to 30). Per zone: orbital checkbox; while Blax Slaves is active its tooltip adds "Also Blax Slaves payouts". - **Settings:** Global "Route orbital trade" (on), "Overflow lands next to the zone" (on; off sends overflow to vanilla), overflow radius 16 (5 to 30). Per zone: orbital checkbox; while Blax Slaves is active its tooltip adds "Also Blax Slaves payouts".
- **Save and removal:** Nothing saved. Without the mod, pods go to the vanilla spot. - **Save and removal:** Nothing saved. Without the mod, pods go to the vanilla spot.
- **Replaces:** With the delivery zone: the orbital half of Trade Ships Drop Spot (206k) and Trading Control's drop spot (111k). - **Replaces:** With the delivery zone: the orbital half of Trade Ships Drop Spot (206k) and Trading Control's drop spot (111k).
- **Effort:** S, half a day. - **Effort:** S.
- **Tests:** Build a `TradeShip` from an orbital TraderKindDef and call `GiveSoldThingToPlayer(steel, 50, negotiator)`. A `DropPodIncoming` skyfaller holding the steel sits on a zone cell, checked right after the call without ticking. With a medicine-only zone at Important plus a general zone, medicine lands in the first and steel in the second. Fully roofing the medicine zone sends medicine to the general zone. A 1-cell zone with 5 stacks gets 1 pod in the zone and 4 within 16 cells. An L-shaped zone whose centroid is a wall still overflows. With no zones, the pod lands near vanilla `TradeDropSpot`. A bought animal is not routed. With zones placed away from every beacon, 20 calls of `PawnsArrivalModeWorker_CenterDrop.TryResolveRaidSpawnCenter` never return a zone cell; a zone right next to a beacon can be picked by vanilla itself. Composition: a test-only prefix makes `TradeDropSpot` return a fixed cell. With no zone the pod lands there, with a zone it lands in the zone. After 300 ticks the item lies within 1 cell of the zone. The router throws (test hook): the steel still lands at the vanilla spot and the log shows one Zones error. - **Tests:** Build a `TradeShip` from an orbital TraderKindDef and call `GiveSoldThingToPlayer(steel, 50, negotiator)`. A `DropPodIncoming` skyfaller holding the steel sits on a zone cell, checked right after the call without ticking. With a medicine-only zone at Important plus a general zone, medicine lands in the first and steel in the second. Fully roofing the medicine zone sends medicine to the general zone. A 1-cell zone with 5 stacks gets 1 pod in the zone and 4 within 16 cells. An L-shaped zone whose centroid is a wall still overflows. With no zones, the pod lands near vanilla `TradeDropSpot`. A bought animal is not routed. With zones placed away from every beacon, 20 calls of `PawnsArrivalModeWorker_CenterDrop.TryResolveRaidSpawnCenter` never return a zone cell; a zone right next to a beacon can be picked by vanilla itself. Composition: a test-only prefix makes `TradeDropSpot` return a fixed cell. With no zone the pod lands there, with a zone it lands in the zone. After 300 ticks the item lies within 1 cell of the zone. The router throws (test hook): the steel still lands at the vanilla spot and the log shows one Zones error.
- **Risks:** The transpiler expects exactly one `SpawnDropPod` call. On a different count it logs an error and skips, and one-class-at-a-time patching keeps the rest alive. Mods that replace the trade-ship purchase entirely bypass us, which is fine; Realistic Orbital Trade (3236257897, 3,348 subs) uses shuttles. Pods spill with `ThingPlaceMode.Near` when they open (ActiveTransporter.cs:105), so a stack can land a cell or more past the zone edge, as vanilla pods do. - **Risks:** The transpiler expects exactly one `SpawnDropPod` call. On a different count it logs an error and skips, and one-class-at-a-time patching keeps the rest alive. Mods that replace the trade-ship purchase entirely bypass us, which is fine; Realistic Orbital Trade (3236257897, 3,348 subs) uses shuttles. Pods spill with `ThingPlaceMode.Near` when they open (ActiveTransporter.cs:105), so a stack can land a cell or more past the zone edge, as vanilla pods do.
@ -252,7 +257,7 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Settings:** Global "Caravans may camp at zones" (on). Per zone: off. - **Settings:** Global "Caravans may camp at zones" (on). Per zone: off.
- **Save and removal:** `campHere` saves with the zone. A caravan already on the map keeps its chill spot after removal. - **Save and removal:** `campHere` saves with the zone. A caravan already on the map keeps its chill spot after removal.
- **Replaces:** [KV] Trading Spot (1180719658, 125,658 subs, last version 1.3) and [GMT] Trading Spot (2874517333, 117,554, last 1.5), both dead; Trading Spot (3507108484, 44,236), 1.6 only; Trade Caravan Spot (3733234194, 2,770), 1.6 only; the trade-marker half of Trading Control (2007107588, 111,091). Trading Spot Rewritten (3780903689, 2,223) has had a 1.7 build since 2026-10-15 and re-targets the chill spot after the lord is made, so Zones stands down for it. - **Replaces:** [KV] Trading Spot (1180719658, 125,658 subs, last version 1.3) and [GMT] Trading Spot (2874517333, 117,554, last 1.5), both dead; Trading Spot (3507108484, 44,236), 1.6 only; Trade Caravan Spot (3733234194, 2,770), 1.6 only; the trade-marker half of Trading Control (2007107588, 111,091). Trading Spot Rewritten (3780903689, 2,223) has had a 1.7 build since 2026-10-15 and re-targets the chill spot after the lord is made, so Zones stands down for it.
- **Effort:** S, half a day. - **Effort:** S.
- **Tests:** Caravan arrival with a camp zone: the lord's chill spot is within 6 cells of the zone. A walled-off zone keeps the vanilla spot. Without the option, the vanilla spot. A visitor group ignores the zone; with Hospitality in `-Compat`, its guests do too. An exception thrown inside `TryExecuteWorker` (test hook) leaves `CampScope` unset. With `NachoToast.TradingSpot` in `SimulatedActive`, camping stands down and logs once. With Royalty, a forced tribute collector arrival camps within 6 cells of the zone; skipped without. - **Tests:** Caravan arrival with a camp zone: the lord's chill spot is within 6 cells of the zone. A walled-off zone keeps the vanilla spot. Without the option, the vanilla spot. A visitor group ignores the zone; with Hospitality in `-Compat`, its guests do too. An exception thrown inside `TryExecuteWorker` (test hook) leaves `CampScope` unset. With `NachoToast.TradingSpot` in `SimulatedActive`, camping stands down and logs once. With Royalty, a forced tribute collector arrival camps within 6 cells of the zone; skipped without.
- **Risks:** Traders still wander within the defend radius of 28 (LordToil_DefendPoint.cs:25). A zone deep inside the base brings visitors inside, which is the player's choice. - **Risks:** Traders still wander within the defend radius of 28 (LordToil_DefendPoint.cs:25). A zone deep inside the base brings visitors inside, which is the player's choice.
@ -260,8 +265,8 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Harness:** copy Castes' Tests/BlaxCastesTests to Tests/BlaxZonesTests. Command-line switch `-blaxzonestests`, data folder `%TEMP%\BlaxZonesTest`, results file `BlaxZonesTestResults.txt`. Keep from Castes' run-tests.ps1: the RimWorld path guard, the lock file and the junction check, `-AllowWhileRunning`, `-NoBuild`, `-NoDlc` and `-Dlc`, and deleting the settings files every run (renamed to `Mod_BlaxZones_*`). The game runs headless (run-tests.ps1:157), so no test asserts on a screenshot; what needs eyes goes into `docs/ingame-check.md`, as in Castes. A release runs all 8 DLC combinations (see "DLC support"). - **Harness:** copy Castes' Tests/BlaxCastesTests to Tests/BlaxZonesTests. Command-line switch `-blaxzonestests`, data folder `%TEMP%\BlaxZonesTest`, results file `BlaxZonesTestResults.txt`. Keep from Castes' run-tests.ps1: the RimWorld path guard, the lock file and the junction check, `-AllowWhileRunning`, `-NoBuild`, `-NoDlc` and `-Dlc`, and deleting the settings files every run (renamed to `Mod_BlaxZones_*`). The game runs headless (run-tests.ps1:157), so no test asserts on a screenshot; what needs eyes goes into `docs/ingame-check.md`, as in Castes. A release runs all 8 DLC combinations (see "DLC support").
- **Phase 3:** after phase 2 the runner saves as `BlaxZonesTest3` (saves are plain XML in 1.7, ScribeSaver.cs:45-49), replaces `Class="BlaxZones.MapComponent_BlaxZones"` with a type that doesn't exist, loads, and runs the `phase: 3` tests. Zones' assembly stays loaded, so `Map.FillComponents` adds a fresh, empty component: phase 3 proves the vanilla side of a removed-mod save loads cleanly, not that the game runs without the code (a full removal run is in the Backlog). - **Phase 3:** after phase 2 the runner saves as `BlaxZonesTest3` (saves are plain XML in 1.7, ScribeSaver.cs:45-49), replaces `Class="BlaxZones.MapComponent_BlaxZones"` with a type that doesn't exist, loads, and runs the `phase: 3` tests. Zones' assembly stays loaded, so `Map.FillComponents` adds a fresh, empty component: phase 3 proves the vanilla side of a removed-mod save loads cleanly, not that the game runs without the code (a full removal run is in the Backlog).
- **Expected errors:** add `T.ExpectErrors(fragment, count)`. Both removal errors include the node's OuterXml, so the harness's "ours" check would count them as Zones errors. Phase 3 allows exactly two per map. "Could not resolve reference" warnings are counted and reported as INFO (from 1.1 the phase-2 reload fails on them, see "Headless tests in 1.1"). From 1.2, `T.ExpectCurToilErrorsFor(pawns)` accepts "tried to get CurToil" errors only when they name a pawn the phase-2 run recorded as lying in a zone bed, and requires at least one per such pawn. - **Expected errors:** add `T.ExpectErrors(fragment, count)`. Both removal errors include the node's OuterXml, so the harness's "ours" check would count them as Zones errors. Phase 3 allows exactly two per map. "Could not resolve reference" warnings are counted and reported as INFO (from 1.1 the phase-2 reload fails on them, see "Headless tests in 1.1"). With zone beds, `T.ExpectCurToilErrorsFor(pawns)` accepts "tried to get CurToil" errors only when they name a pawn the phase-2 run recorded as lying in a zone bed, and requires at least one per such pawn.
- **KnownForeignErrors:** the `CanUseBedNow` postfix (1.2) and the `Toils_LayDown.ApplyBedRelatedEffects` postfix (1.5) sit in many stacks. Errors that Hospitality, Prison Labor or VEF log from their own code while a test ticks would name BlaxZones frames. Add each one with its text and frame, as Castes did for Weapons Tab Reborn. - **KnownForeignErrors:** the `CanUseBedNow` postfix (animal sleeping zones) and the `Toils_LayDown.ApplyBedRelatedEffects` postfix (people sleeping zones) sit in many stacks. Errors that Hospitality, Prison Labor or VEF log from their own code while a test ticks would name BlaxZones frames. Add each one with its text and frame, as Castes did for Weapons Tab Reborn.
- **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. - **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. - **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: - **Fixtures to add**, only those 1.0 uses; later releases list their own:
@ -272,15 +277,15 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- `Animal(def, tamed)` with chicken and muffalo (body size 2.4). - `Animal(def, tamed)` with chicken and muffalo (body size 2.4).
- Reused from Castes: Colonist, ColonySlave, Prisoner, Baby, `Tick`, `QuietStoryteller`, `SnapshotSettings` (Fixtures.cs:68, 71, 83, 114, 197, 243, 251). ColonySlave needs Ideology and Baby Biotech; tests that use them skip without, as in Castes. - Reused from Castes: Colonist, ColonySlave, Prisoner, Baby, `Tick`, `QuietStoryteller`, `SnapshotSettings` (Fixtures.cs:68, 71, 83, 114, 197, 243, 251). ColonySlave needs Ideology and Baby Biotech; tests that use them skip without, as in Castes.
- **Across features:** the orbital transpiler logged no "unexpected call count" error. - **Across features:** the orbital transpiler logged no "unexpected call count" error.
- **Effort:** S plus S, 1 day: the copy, phase 3, `ExpectErrors` and the map fixtures, which Castes never had. - **Effort:** S plus S: the copy, phase 3, `ExpectErrors` and the map fixtures, which Castes never had.
### 1.1 Quest rewards and caravan purchases (3 days) ### 1.1 Quest rewards and caravan purchases
#### Quest rewards land in the zone #### Quest rewards land in the zone
- **Players get:** Item rewards from quests (Empire quests included, with Royalty) drop into a delivery zone that has rewards ticked, and the quest letter points there. Refugees, prisoners, mechs, wastepacks, ransom returns and raids never come to the zone. - **Players get:** Item rewards from quests (Empire quests included, with Royalty) drop into a delivery zone that has rewards ticked, and the quest letter points there. Refugees, prisoners, mechs, wastepacks, ransom returns and raids never come to the zone.
- **How:** - **How:**
- This feature builds the DeliveryContext from the data model, which cargo pods (1.4) reuse. A context prefix and finalizer sit on two callers: - This feature builds the DeliveryContext from the data model, which cargo pods reuse. A context prefix and finalizer sit on two callers:
- `QuestPart_DropPods.Notify_QuestSignalReceived` (QuestPart_DropPods.cs:124), only when `useTradeDropSpot` is true and `dropSpot` is invalid (:165, 298-303): exactly the drops vanilla sends to the trade spot. `Reward_Items` creates these (Reward_Items.cs:180). - `QuestPart_DropPods.Notify_QuestSignalReceived` (QuestPart_DropPods.cs:124), only when `useTradeDropSpot` is true and `dropSpot` is invalid (:165, 298-303): exactly the drops vanilla sends to the trade spot. `Reward_Items` creates these (Reward_Items.cs:180).
- `QuestPart_GiveNearPawn.Notify_QuestSignalReceived` (QuestPart_GiveNearPawn.cs:107), which always uses the trade spot (:187-188). - `QuestPart_GiveNearPawn.Notify_QuestSignalReceived` (QuestPart_GiveNearPawn.cs:107), which always uses the trade spot (:187-188).
- While the context is set, a prefix on `DropPodUtility.DropThingGroupsNear` (DropPodUtility.cs:40) takes `thingsGroups` as a ref parameter. A group qualifies when it holds no Pawn and no Wastepack and all its things pass one zone (rewards ticked, filter). The prefix plans every group's target before it drops anything, so a failure halfway can't drop a group twice; on an exception vanilla gets the original list. - While the context is set, a prefix on `DropPodUtility.DropThingGroupsNear` (DropPodUtility.cs:40) takes `thingsGroups` as a ref parameter. A group qualifies when it holds no Pawn and no Wastepack and all its things pass one zone (rewards ticked, filter). The prefix plans every group's target before it drops anything, so a failure halfway can't drop a group twice; on an exception vanilla gets the original list.
@ -293,7 +298,7 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Settings:** Global "Route quest rewards" (on). Per zone: rewards checkbox (on). - **Settings:** Global "Route quest rewards" (on). Per zone: rewards checkbox (on).
- **Save and removal:** Nothing saved. The context lives for one call. - **Save and removal:** Nothing saved. The context lives for one call.
- **Replaces:** The quest-reward half of Trade Ships Drop Spot (206k) and Trading Control (111k). - **Replaces:** The quest-reward half of Trade Ships Drop Spot (206k) and Trading Control (111k).
- **Effort:** M, 2 days. - **Effort:** M.
- **Tests:** - **Tests:**
- `Quest.MakeRaw` plus a `QuestPart_DropPods` with `useTradeDropSpot = true`, things gold 50 and medicine 5, inSignal "blax.test". Call `Notify_QuestSignalReceived(new Signal("blax.test"))`. Both pods land on zone cells, split by filter, and the letter's look target lies in the zone. - `Quest.MakeRaw` plus a `QuestPart_DropPods` with `useTradeDropSpot = true`, things gold 50 and medicine 5, inSignal "blax.test". Call `Notify_QuestSignalReceived(new Signal("blax.test"))`. Both pods land on zone cells, split by filter, and the letter's look target lies in the zone.
- Add a refugee pawn: its pod is not in a zone, the items' pods are. A Wastepack is never routed (Biotech; skipped without). `dropAllInSamePod` routes nothing. - Add a refugee pawn: its pod is not in a zone, the items' pods are. A Wastepack is never routed (Biotech; skipped without). `dropAllInSamePod` routes nothing.
@ -319,7 +324,7 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- **Settings:** Global "Route caravan purchases" (on), "Message when goods arrive" (on). Per zone: caravan checkbox (on), tooltip "Trader caravans and guests". - **Settings:** Global "Route caravan purchases" (on), "Message when goods arrive" (on). Per zone: caravan checkbox (on), tooltip "Trader caravans and guests".
- **Save and removal:** Nothing saved. Goods already placed stay where they are. - **Save and removal:** Nothing saved. Goods already placed stay where they are.
- **Replaces:** Nothing directly. The trading-spot mods only move the caravan; 1.0 covers them. - **Replaces:** Nothing directly. The trading-spot mods only move the caravan; 1.0 covers them.
- **Effort:** S, half a day. - **Effort:** S.
- **Tests:** Force `IncidentWorker_TraderCaravanArrival`, take the trader pawn and a non-pawn Thing from `trader.Goods`, call `GiveSoldThingToPlayer(thing, 1, negotiator)`. The item is spawned in the zone and listed in the lord's `extraForbiddenThings`. A fully roofed zone still receives it. With every zone cell holding a different item, it lands near the zone and the message says "next to"; with overflow off, next to the carrier. Silver over the first zone's room splits over two zones, and the message counts both. With no zones, next to the carrier. A bought animal doesn't move. The router throws: the item lands next to the carrier, nothing is destroyed. Buying 3 stacks in one `TradeDeal.TryExecute` posts exactly 1 message that names the zone. With Hospitality (`-Compat`), a purchase from a guest lands in the zone. The transpiler logged no "unexpected call count" error. - **Tests:** Force `IncidentWorker_TraderCaravanArrival`, take the trader pawn and a non-pawn Thing from `trader.Goods`, call `GiveSoldThingToPlayer(thing, 1, negotiator)`. The item is spawned in the zone and listed in the lord's `extraForbiddenThings`. A fully roofed zone still receives it. With every zone cell holding a different item, it lands near the zone and the message says "next to"; with overflow off, next to the carrier. Silver over the first zone's room splits over two zones, and the message counts both. With no zones, next to the carrier. A bought animal doesn't move. The router throws: the item lands next to the carrier, nothing is destroyed. Buying 3 stacks in one `TradeDeal.TryExecute` posts exactly 1 message that names the zone. With Hospitality (`-Compat`), a purchase from a guest lands in the zone. The transpiler logged no "unexpected call count" error.
- **Risks:** Goods appear instead of being carried; carried delivery is cut. A mod that rewrites `Pawn_TraderTracker.GiveSoldThingToPlayer` would conflict; none in the active set. Hospitality (753498552, 768,480 subs, 1.6 build) only adds a pass-through prefix on `Pawn.GiveSoldThingToPlayer` (its Source/Patches/Pawn_Patch.cs), and its records don't depend on where the item lies. - **Risks:** Goods appear instead of being carried; carried delivery is cut. A mod that rewrites `Pawn_TraderTracker.GiveSoldThingToPlayer` would conflict; none in the active set. Hospitality (753498552, 768,480 subs, 1.6 build) only adds a pass-through prefix on `Pawn.GiveSoldThingToPlayer` (its Source/Patches/Pawn_Patch.cs), and its records don't depend on where the item lies.
@ -329,96 +334,84 @@ Every Blax mod works with any DLC combination, core only included (rule of 2026-
- `-NoDlc` and `-Dlc` runs: everything runs on the core game; only the Wastepack test needs Biotech. - `-NoDlc` and `-Dlc` runs: everything runs on the core game; only the Wastepack test needs Biotech.
- Reload check: the harness files the phase-2 load under its own tag and a phase-2 test fails on any "Could not resolve reference" warning, so a reference Zones saves but can't load turns the run red. After every test it notes each pawn relation whose other pawn no save holds, with who took that pawn out of the world pawns. One vanilla leak is excused by name: `TaleData_Pawn.GenerateRandom` (TaleData_Pawn.cs:110-115) makes a pawn for a book's text (Book.cs:235), also for every book in a trader caravan's stock, keeps only its tale data and never saves the pawn. PawnGenerator may hand it a world pawn or a new one with relations to existing pawns, so the forced caravans leave up to about 20 such warnings per run (none to 19 seen). With Hospitality (`-Compat`) also Lord warnings: its `CompGuest.PostSpawnSetup` stores `Pawn.GetLord()` on every humanlike pawn, saves it as a reference and never clears it when the pawn leaves the map, so the forced caravans' pawns keep their ended lord. Zones saves no Lord reference. - Reload check: the harness files the phase-2 load under its own tag and a phase-2 test fails on any "Could not resolve reference" warning, so a reference Zones saves but can't load turns the run red. After every test it notes each pawn relation whose other pawn no save holds, with who took that pawn out of the world pawns. One vanilla leak is excused by name: `TaleData_Pawn.GenerateRandom` (TaleData_Pawn.cs:110-115) makes a pawn for a book's text (Book.cs:235), also for every book in a trader caravan's stock, keeps only its tale data and never saves the pawn. PawnGenerator may hand it a world pawn or a new one with relations to existing pawns, so the forced caravans leave up to about 20 such warnings per run (none to 19 seen). With Hospitality (`-Compat`) also Lord warnings: its `CompGuest.PostSpawnSetup` stores `Pawn.GetLord()` on every humanlike pawn, saves it as a reference and never clears it when the pawn leaves the map, so the forced caravans' pawns keep their ended lord. Zones saves no Lord reference.
### 1.2 Animal sleeping zones (6 days) ### Storage as a delivery target
#### Animal sleeping zones Stockpile deliveries and direct delivery ship together: most freezers and hospital shelves are roofed, so the flag alone does little for orbital goods.
- **Players get:** A new "Animal sleeping zone" in the Zone menu. Every cell works like an animal sleeping spot, so one drag over the barn beds every chicken and duck. Shrinking or deleting the zone removes its cells. Sleeping zones don't extend the home area. #### Stockpiles and shelves receive deliveries
- **Players get:** A "Receive deliveries" gizmo on any stockpile, shelf, rack or fridge lets bought goods and rewards go straight into it, by its own filter and priority: medicine onto the hospital shelves, food into the freezer, no hauling. Delivery zones and flagged storage compete by priority.
- **How:** - **How:**
- Zone beds as in the data model. `Zone_SleepingBase : Zone` holds what both kinds share; `Zone_SleepingAnimals` ships now and `Zone_SleepingPeople` in 1.5. Separate types keep the designators from expanding each other's zones, since `Designator_ZoneAdd` compares the exact type. Animal zones get one fixed tint, brown at alpha 0.09. - Flags live in `MapComponent_BlaxZones` as a `HashSet<int>` of stockpile zone IDs and a `HashSet<int>` of storage building ThingIDs, never as fields on `Zone_Stockpile` or `Building_Storage`. Zone IDs and ThingIDs are never reused, so a stale flag can't land on a new storage.
- `AddCell` calls the base, then spawns a `Building_ZoneBed` as the data model describes. The designator refuses cells with an edifice or bed. - Gizmos come from postfixes on `Zone_Stockpile.GetGizmos` (Zone_Stockpile.cs:75) and `Building_Storage.GetGizmos` (Building_Storage.cs:227). RimFridge's and Weapon Racks' storage buildings call the base, so they get the gizmo.
- Cap: `Designator_ZoneAdd_SleepingBase` overrides `DesignateMultiCell` (Designator_ZoneAdd.cs:104). When the map's sleeping-zone cells plus the dragged cells exceed the cap, it passes only the first cells of the drag up to the cap to the base and posts one message naming the cap; at the cap it adds nothing and posts the same message. - Storage groups: shelves can be linked into a group (Building_Storage.cs:13), whose settings every member reads through `GetStoreSettings()` (Building_Storage.cs:100-107). Group membership changes through vanilla's link gizmos (Building_Storage.cs:241-244) without calling Zones. So a storage building counts as flagged when it or any member of its `StorageGroup` is flagged, and the gizmo on a grouped building sets or clears the flag on every member. A shelf linked into a flagged group later is flagged through the group. A shelf leaving a group keeps its own flag, as vanilla copies the group's settings onto it (StorageGroupUtility.cs:163-184); one that joined after the flag was set has none of its own and leaves unflagged.
- Home area: `Zone_SleepingBase.AddCell` sets `Find.PlaySettings.autoHomeArea` to false around `base.AddCell` and restores it in a `finally`. `AutoHomeAreaMaker.Notify_ZoneCellAdded` reads that setting first (AutoHomeAreaMaker.cs:9-16, 48-58), and the base `Zone.AddCell` always calls it (Zone.cs:232). No patch: a prefix on that 10-line static method could be inlined. `expandHomeArea` false on the bed def covers the bed's own spawn (AutoHomeAreaMaker.cs:18-24). - The router adds flagged storage as candidates, with accept from `StorageSettings.AllowedToAccept(thing)` and priority from `StorageSettings.Priority`, both through `GetStoreSettings()`; building cells come from `AllSlotCells()`. Storage targets use the storage rule from the data model and fill mergeable stacks first.
- Spawn cost: each bed spawn runs `District.Notify_RoomShapeOrContainedBedsChanged`, which walks regions only when the map has facilities (District.cs:235-247, FacilitiesUtility.cs:19-60), and `Room.Notify_RoomShapeChanged` with its temperature, auto roof area and prison-cell work (Room.cs:686-729). If a 500-cell drag takes more than 100 ms in the harness, spawn a drag's beds 50 per tick. - Pods use only stockpile cells that pass the pod rule. Shelves are edifices, so they get orbital goods only with direct delivery. Caravan placement and direct delivery put the thing on a storage cell with `GenPlace.TryPlaceThing(thing, cell, map, ThingPlaceMode.Direct)` and try the next cell on failure.
- `RemoveCell` and deregistration unclaim owners first with `pawn.ownership.UnclaimBed()`, then destroy, so there is no "lost assignment" spam; the loading flag skips this during load. - A deleted stockpile or storage building drops its ID on the next lookup. The gizmo tooltip says roofed targets need direct delivery for orbital goods and rewards.
- Def `BlaxZones_ZoneAnimalBed` (`bed_humanlike` false): 1x1, Standable, FloorEmplacement, no `sowTag` (so `CanOverlapZones` stays true), `building.isEdifice` false, `building.deconstructible` false, `building.bed_showSleeperBody` true, `building.expandHomeArea` false, `bringAlongOnGravship` false, `selectable` false, `drawGUIOverlay` false, `drawerType` None, `useHitPoints` false, WorkToBuild 0, Flammability 0, no cost list (no wealth), no designationCategory, `tickerType` Never, `isSaveable` false, `CompAssignableToPawn_Bed`. The uiIcon uses the vanilla AnimalSleepSpot texture. 1.5 adds the humanlike defs with the same flags. - **Settings:** Global "Stockpiles and shelves may receive deliveries" (on). Per stockpile and storage building: gizmo (off).
- Why those flags: - **Save and removal:** The flag sets save in the component. Without the mod they vanish with the component node; the stockpiles and shelves keep their own settings.
- `deconstructible` false: they are player buildings and `deconstructible` defaults to true (BuildingProperties.cs:21, 436-449). A deconstruct drag over a barn would destroy every bed at once, since work 0 destroys immediately (Designator_Deconstruct.cs:69-76). - **Replaces:** [DHM]Organized Trade Pod System (3490887589, 1,816 subs, no 1.7), Skipdoor Delivery (3233578663, 2,749, no 1.7) for trade goods.
- `bed_showSleeperBody` true: the default false hides a humanlike sleeper's body (BuildingProperties.cs:174; PawnRenderNodeWorker_Body.cs:29-31, PawnRenderer.cs:448), and with `drawerType` None there is no blanket either, so an adult would show as a floating head. Both vanilla spots set it (Core ThingDefs_Buildings/Buildings_Furniture.xml:64, :479). It matters for the 1.5 people defs; the animal def sets it to match. - **Effort:** M plus S. The S is the storage rule and storage groups.
- `bringAlongOnGravship` false (ThingDef.cs:167, checked in Gravship.cs:607-634): takeoff would otherwise despawn the beds with `WillReplace` (GravshipUtility.cs:389), keep their owners and, in a save made during flight, deep-save them inside `Gravship.things` (Gravship.cs:335). That bypasses `isSaveable`, which only `Map.ExposeData` checks, and would break the save after mod removal. Landing runs on a map that already exists (WorldComponent_GravshipController.cs:529-538), so reconcile never sees carried beds. It is a core `ThingDef` field (ThingDef.cs:167), so the def loads without Odyssey. - **Tests:** An unroofed flagged food stockpile at Important plus a general delivery zone at Normal: bought rice lands in the stockpile, steel in the zone. A flagged medicine shelf in a roofed hospital with direct delivery on: orbital medicine appears on the shelf. A vanilla shelf cell (PassThroughOnly) receives a direct delivery. Caravan rice goes into a roofed flagged freezer. A linked shelf group: flagging one shelf flags every member, and priority and filter come from the group. A new shelf linked into the flagged group receives a delivery; unlinked again, it doesn't. A shelf that was in the group when it was flagged keeps receiving after it is unlinked. Storage targets fill mergeable stacks before empty cells. Flags survive reload. A deleted stockpile is no longer a target. Phase 3 loads with no errors from the flag sets. `-Compat`: a RimFridge fridge (PassThroughOnly) and a RimFridge wall fridge (Impassable) each receive a delivery; a Weapon Racks rack holds no more than its items per cell.
- Copied from the vanilla spots: SurgerySuccessChanceFactor 0.7, `scatterableOnMapGen` false (needed for `IsClearableFreeBuilding`, Building.cs:64-74), `ai_chillDestination` false, `artificialForMeditationPurposes` false, `wakeDormantPawnsOnConstruction` false (Core Buildings_Furniture.xml:49-79, 459-491). Like the vanilla spots they leave `socialPropernessMatters` off. The vanilla spots carry `sowTag` SupportPlantsOnly, which is why ours can't copy it. - **Risks:** Without direct delivery, roofed freezers and shelves get only caravan goods; the tooltip says so. Overlapping mods:
- Bed search order: `RestUtility.Reset` (RestUtility.cs:25-44) builds the best-to-worst bed lists, sorted by `bed_maxBodySize`, then rest effectiveness, keeping definition order on ties. It runs before `[StaticConstructorOnStartup]` (PlayDataLoader.cs:207 vs 360). A postfix moves our animal def directly before AnimalSleepingSpot (1.5 adds the people defs before SleepingSpot), and the patch class calls `RestUtility.Reset()` once after patching. Otherwise unowned animals walk to any free vanilla spot first. - RimFridge: Now with Shelves! (2898411376, 282,094 subs, 1.6 build): `RimFridge_Building` is a `Building_Storage` (its Source/RimFridge_Building.cs:11) with its own items-per-cell setting, which the storage rule reads through `GetMaxItemsAllowedInCell`. Its fridges are PassThroughOnly and its wall fridge Impassable (its 1.6 Defs/ThingDefs_Buildings/Fridge_Base.xml:25, WallFridge_Building.xml:6), so neither is standable and both need the storage rule.
- Edifices: a postfix on `EdificeGrid.Register` (EdificeGrid.cs:21-33) queues the cell when any edifice spawns on a sleeping-zone cell, so no cell holds two beds. `Building.SpawnSetup` registers the edifice before the rest of its spawn (Building.cs:113-127), so destroying our bed inside the postfix would run mid-spawn. The component handles the queue on its next tick and before saving: `RemoveCell`, then `CheckContiguous`, as vanilla does for overlap (ZoneManager.cs:97-112). This replaces a hook on the hot virtual `Building.SpawnSetup`. If the JIT inlines `Register` into a caller and the postfix stops firing there, the 250-tick sweep from the data model trims the cell instead. Vanilla already trims zone cells for walls, storage and tables, which can't overlap zones (ThingDef.cs:625-655); beds and doors can, hence the postfix. - Weapon Racks (2788630748, 57,447 subs, 1.7): `Building_WeaponStorage` holds 1 to 4 items per cell (its 1.7/Defs/ThingDefs/ThingDefs_Buildings.xml); the storage rule respects that. Bought weapons can land on a flagged rack.
- Building over a zone bed needs no patch: `GenConstruct.CanPlaceBlueprintOver` already allows it over non-edifices (GenConstruct.cs:676-703), and `SpawnBuildingAsPossible` won't wipe a non-edifice zone bed on load (GenSpawn.cs:196-235). - Haul to Stack (949498803, 77,412 subs, 1.6 build) makes haulers fill stacks first; storage targets use the same order.
- Cutting the zone: a wall line across it removes the wall cells, and `Zone.CheckContiguous` keeps the part holding the zone's first cell and removes the rest (Zone.cs:345-397). The zone does not split in two. Removed cells lose their beds and owners silently. - Vanilla Furniture Expanded's storage furniture is `Building_Storage`, so it is covered.
- Gravship landing calls our `RemoveCell` through `GravshipPlacementUtility.ClearThingsAt` (GravshipPlacementUtility.cs:311-313); our own code handles it.
- **Settings:** Global "Sleeping zones" (on); "Max sleeping-zone cells per map" (500, 50 to 2000).
- **Save and removal:** Zones and beds save in the component, beds with their owners and flags. A plain unsubscribe drops the beds with the component and logs the warnings and CurToil errors listed in the data model; the button below avoids them.
- **Replaces:** Covers the spot-grid use of Designator Shapes (1235181370, 331,540 subs, alive on 1.7; a general shape tool, so its count says little about demand for zones); BuilderTweaksReplica (3521096349, 7,977, alive on 1.7) for drag-placing spots; Hidden Spots (3466316759, 13,301, alive on 1.7). Replaces Invisible Animal sleeping spot - Prettier Barn (2571118651, 397, up to 1.6).
- **Effort:** M plus S, 2.5 days. The S is the zone-bed safety work: the choke point, the queue and the sweep.
- **Tests:**
- Def: not an edifice, not deconstructible, flammability 0, no cost list, not selectable, `isSaveable` false, `bringAlongOnGravship` false. `Designator_Deconstruct.CanDesignateThing(zoneBed)` (Designator_Deconstruct.cs:84) is refused.
- A 4x4 animal zone holds 16 `BlaxZones_ZoneAnimalBed`, player faction; grass on those cells survives, and with auto home area on the home area doesn't grow and `Find.PlaySettings.autoHomeArea` is still true afterwards.
- A tamed chicken: `RestUtility.FindBedFor` returns a zone bed ahead of a free vanilla AnimalSleepingSpot; after it lies down, it owns the bed.
- Shrinking by 4 cells removes 4 beds and clears their owners with no messages. A wall on a zone cell removes the cell and the bed. A wall line across a 6x4 zone removes the cut-off part, its beds and owners, with no messages. A vanilla bed built on a zone cell removes that cell on the next tick; with the `Register` postfix switched off (test hook), within 250 ticks.
- Foreign destroy: `bed.Destroy()` from outside Zones respawns the bed on the next tick. Destroy a bed and save immediately: after the reload there is one bed per cell.
- Cap set to 50: a 60-cell drag adds 50 cells and posts one message naming the cap; a second drag adds nothing and posts the same message.
- A 500-cell drag fails the test above 500 ms.
- A delivery zone inside a walled-off area that also holds a sleeping zone gets no pods, although `CanReachColony` is true there.
- Phase 2: same bed count and ThingIDs, the chicken still owns its bed, no "Could not resolve reference" warnings.
- Phase 3, with a chicken asleep in a zone bed at save time: no beds, no zones, the chicken's owned bed is null, warnings only, and beyond the two expected errors per map only CurToil errors that name the chicken (`ExpectCurToilErrorsFor`), no NRE.
- If `GravshipPlacementUtility.ClearThingsAt` runs without Odyssey, call it by reflection on a zone cell: the cell and bed go, with no messages.
- **Risks:**
- Cost: hundreds of Building things add to `listerBuildings` loops and room recalculations; the cell cap, `drawerType` None and `tickerType` Never limit it. An unowned pawn's `FindBedFor` scans past owned beds, as with many vanilla spots. Other mods' bed lists will show zone beds.
- Heuristics: vanilla sleeping spots are colony buildings too, but zone beds come by the hundred. When no chill destination works, `RCellFinder.TryFindRandomSpotJustOutsideColony` falls back to random colony buildings (RCellFinder.cs:736-750); visitor groups (IncidentWorker_VisitorGroup.cs:24), waiting prisoners (JobGiver_PrisonerWaitInsteadOfEscaping.cs:22) and immediate-attack raids (RaidStrategyWorker_ImmediateAttack.cs:20) use it, so those spots drift toward a big barn. `TradeDropSpot` without a powered beacon or comms console picks random colony buildings too (DropCellFinder.cs:51-69). `JobGiver_AITrashBuildingsDistant` draws 75 random colony buildings (JobGiver_AITrashBuildingsDistant.cs:28-46) and zone beds never qualify (`IsClearableFreeBuilding`, TrashUtility.cs:64), so raiders trash a little less. The cell cap bounds all three; they aren't tested, because each is random by design. The reach rule keeps them out of Zones' own routing.
- Overflow pods may land on sleeping-zone cells, as on vanilla spots, because zone beds are clearable free buildings; a bed the pod wipes respawns through the choke point.
- Odyssey gravships move only stockpile and growing zones (Gravship.cs:396-440), so ours stay behind; untested, because Odyssey isn't installed on the test machine.
- Dubs Mint Minimap (1662119905, 655,557 subs): draws edifices only, so zone beds don't show. Delivery zones don't either; zones aren't drawn.
#### Which animals may sleep here #### Delivery under a roof
- **Players get:** The animal zone tab lists species with checkboxes and a body-size range, so big stalls stay free of chickens. The inspect pane warns when the filter leaves out every tamed animal on the map. - **Players get:** An option "No drop pods, goods appear here" on delivery zones, flagged stockpiles and flagged storage buildings. Roofed warehouses and rooms then receive orbital goods and rewards. Off by default.
- **How:** - **How:** For targets with direct delivery, orbital and reward routing skip the pod. Delivery zones use `GenPlace.TryPlaceThing(thing, cell, map, Near, null, validator)` with the placement rule, roof ignored; storage targets use Direct mode with the storage rule. For rewards, the `DropThingGroupsNear` prefix takes the group out of the list and places it, applying the call's forbid flag. A dust fleck marks the arrival. The stockpile and storage flags sit in the MapComponent next to the receive flags, and follow storage groups the same way. No roof punching: `Skyfaller.HitRoof` collapses a 3x3 roof (Skyfaller.cs:399-435).
- `Zone_SleepingAnimals` gets `HashSet<string> disallowedRaces`, a deny-list of race defNames resolved with `GetNamedSilentFail`, so new species are allowed by default and a removed animal mod leaves nothing unresolved. Plus `FloatRange bodySize` (0 to unlimited). - **Settings:** Global "Allow direct delivery" (on, makes the per-target option available). Per zone, stockpile and storage building: off.
- A postfix on `RestUtility.CanUseBedNow(Thing bedThing, Pawn sleeper, bool checkSocialProperness, bool allowMedBedEvenIfSetToNoCare, GuestStatus? guestStatusOverride)` (RestUtility.cs:72) at `Priority.Low` checks the bed type first. For a `Building_ZoneBed` whose zone rejects the sleeper it sets false. The zone comes from `zoneGrid` in O(1). This one patch covers `FindBedFor` (RestUtility.cs:235), `FindPatientBedFor` (:328), rescue, capture, `Toils_Bed.BedNoLongerUsable` and `FailOnBedNoLongerUsable` (Toils_Bed.cs:58-96), childcare and rituals. 1.6 adds the caste check to the same postfix. - **Save and removal:** The flags save in the component and vanish with it.
- Changing a filter, or pasting settings onto a zone, unclaims the owners that no longer pass, with one message naming the count. Vanilla's `FailOnBedNoLongerUsable` gets an animal already lying there out of bed.
- The tab has a search field, the species list (species tamed on this map first, then all animal races) and `Widgets.FloatRange` for size.
- **Settings:** Per animal zone: species deny-list (empty), body size (any). No global setting.
- **Save and removal:** Filters save with the zone in the component. A species whose mod is gone stays in the list and comes back with the mod.
- **Replaces:** Barn Stall (Continued) (2071768301, 29,391 subs, alive on 1.7): covers its size filter, which its author refused; Chicken nests Continued (3261309547, 5,715, up to 1.6), species-only nests. The vanilla animal spot has no size limit (`bed_maxBodySize` 9999, BuildingProperties.cs:178).
- **Effort:** M, 2 days.
- **Tests:** Chickens disallowed and only zone beds present: `FindBedFor(chicken)` returns null. Body size max 1.0: a muffalo (2.4) is refused, a chicken accepted. A filter change unclaims the now-refused owner, with one message naming the count. With every tamed species disallowed, the inspect string carries the warning. A species defName that doesn't resolve stays stored. Filters persist in phase 2.
- **Risks:** `CanUseBedNow` is hot; the postfix exits on the type check for every other bed. Ours only ever sets false, so it composes with other postfixes that set false. At `Priority.Low` it runs after postfixes that allow a bed, such as Blax Slaves' shared infirmary, so a zone filter has the last word.
#### Remove Blax Zones from a game
- **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 work rule areas; from 1.4 flagged storage).
- From 1.3 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.
- **Settings:** The button, enabled only while a game is loaded. No toggle.
- **Save and removal:** This is the removal.
- **Replaces:** Nothing. - **Replaces:** Nothing.
- **Effort:** S, half a day. - **Effort:** S.
- **Tests:** - **Tests:** In a fully roofed zone with the option on, orbital steel spawns on a zone cell the same tick with no pod. Without the option, it falls back. A quest reward goes to a roofed direct zone, forbid flag kept.
- The confirm names the counts. - **Risks:** Immersion only. Goods arrive either way, so balance is neutral. Dubs Skylights (833899765, 272,595 subs, 1.7): skylights sit in roofed cells, so pods can't land under them; the red overlay shows those cells and direct delivery covers them.
- Press the button with a chicken asleep in a zone bed, save, then save again (an autosave counts): neither file contains "BlaxZones", and `map.components` has no `MapComponent_BlaxZones` after either save.
- A map generated afterwards in the same game has no component, and a test-only MapComponent added after ours in the type list still had its `FinalizeInit` called.
- An orbital purchase and a caravan arrival behave like vanilla, log no error and don't bring the component back.
- Load the saved file (Zones' assembly is still loaded, so `FillComponents` adds a fresh, empty component for the new game): no errors, no "Could not resolve reference" warnings, and the chicken has no owned bed and no CurToil error.
- **Risks:** A mod that caches our component across saves would hold a dead object; none known.
#### Headless tests in 1.2 #### Sell zone
- Fixture `SleepingZone(rect, kind)`; 1.5 adds the owner type. - **Players get:** A gizmo "Orbital traders can buy from here" on stockpiles and storage buildings. While at least one powered trade beacon stands on the map, orbital traders see every item in flagged storage and can take payment silver from it, so goods don't have to be hauled to the beacon. The shelves themselves are never for sale. Off by default for balance.
- Performance in `-Compat`: time 2500 ticks with and without 500 animal zone beds, median of three runs each, written to the results file. The test fails when the zone beds add more than 10%. - **How:**
- KnownForeignErrors: add any foreign error found in these runs. - Flags (zone IDs and storage ThingIDs) in the MapComponent, with the storage-group rule from "Stockpiles and shelves receive deliveries".
- Effort: S, half a day for the performance and compat runs. - A postfix on `TradeUtility.AllLaunchableThingsForTrade(Map, ITrader)` (TradeUtility.cs:84, an iterator) at `Priority.Last` wraps the result. It yields everything, keeping a HashSet, then appends things on flagged cells whose `def.category` is `Item` and that pass `TradeUtility.PlayerSellableNow` (TradeUtility.cs:43) and aren't in the set. Only when `Building_OrbitalTradeBeacon.AllPowered(map)` is not empty. RimFridge's "fridges act as beacons" postfix appends without deduping (its 1.6 Source/HarmonyPatches.cs, `LaunchItemsFromFridges`), hence the late priority and the full set.
- Items only, as vanilla takes only `ThingCategory.Item` from beacon cells (TradeUtility.cs:134). `EverPlayerSellable` accepts minifiable buildings (TradeUtility.cs:32-39), vanilla shelves are minifiable and tradeable, so without the category check a flagged shelf or fridge, or a lamp standing on a flagged stockpile, would be offered, and selling it removes it from the map (TradeShip.cs:179-197). Pawns fail the check too, so prisoner and slave sales stay with vanilla and Blax Slaves. Bookcases and outfit stands aren't `Building_Storage` and get no gizmo.
- The trade dialog lists and pays from what `TradeShip.ColonyThingsWillingToBuy` collects through that method (TradeShip.cs:89-100; Tradeable.cs:463-471), so the postfix alone lets trades sell from and pay with flagged storage.
- `TradeUtility.LaunchThingsOfType(ThingDef resDef, int debt, Map map, TradeShip trader)` (TradeUtility.cs:185-222) searches beacon cells only. Its only vanilla callers are the ransom fee through `LaunchSilver` (:225) and the AI core information request (FactionDialogMaker.cs:196), and both check affordability through `AllLaunchableThingsForTrade`. A prefix with `ref int debt` (Harmony lets a prefix change a plain argument) pays from flagged cells first, the way vanilla pays from beacon cells, lowers `debt`, and lets vanilla pay the rest. Without it vanilla logs "Could not find any Silver" and underpays (:207-211).
- **Settings:** Global "Sell zones" (off). Per stockpile and storage building: off.
- **Save and removal:** The flags save in the component and vanish with it; trade goes back to beacon range.
- **Replaces:** Covers the use of Map Wide Orbital Trade Beacon (1839069104, 50,625 subs, alive on 1.7), Wall-Mounted Orbital Trade Beacon (3553078564, 15,875, alive on 1.7), Trade Beacon Shapes (3533891331, 610, a drawing shape for placing beacons; a weak overlap) and [DHM]Adjustable Trade Beacon Range (3823054506, 27).
- **Effort:** M. Two trade methods change.
- **Tests:** A flagged stockpile far from the beacon holds 100 steel. With a powered beacon the trade dialog lists the steel; with the beacon off it doesn't. Selling it removes it from the stockpile. Buying with silver that sits only in a flagged stockpile pays from it. A ransom fee paid from flagged silver logs no error and takes the full amount. A flagged shelf and a standing lamp on a flagged stockpile never show up in `ColonyThingsWillingToBuy`. A prisoner standing in a flagged stockpile isn't offered. `-Compat`: with RimFridge's beacon setting on and a fridge also flagged as a sell zone, the dialog lists each item once.
- **Risks:** Beacon mods also patch `AllLaunchableThingsForTrade`; our wrapper skips things already in the list, so running Map Wide Orbital Trade Beacon alongside doesn't list items twice. It removes hauling to the beacon, hence off by default. [RH2] Rimdeed (2411722784, 83,107 subs, 1.6 build) reads `AllLaunchableThingsForTrade`, so sell-zone silver may pay its fees, which is harmless.
### 1.3 Work rule areas (8 days) #### Headless tests for storage deliveries
- Fixtures: `Shelf(cell)`, `LinkShelves(a, b)`, `UnlinkShelf(a)`, a roofed `Stockpile(rect)`.
- Phase 2: every flag set survives. Phase 3: the flags vanish with no errors.
- `-Compat` adds the RimFridge and Weapon Racks tests above; RimFridge's beacon setting is switched on through its settings for the dedupe test.
### More arrival sources
Needs only the delivery context from 1.1. More sources wait in the Backlog (Vanilla Events Expanded pods, ally drops, returning caravans, royal title rewards).
#### Cargo pod events land in the zone
- **Players get:** Optional: random cargo pod events drop their goods into a delivery zone that has "Cargo pods" ticked, and the letter points there.
- **How:** A DeliveryContext prefix and finalizer on `IncidentWorker_ResourcePodCrash.TryExecuteWorker` (IncidentWorker_ResourcePodCrash.cs:8-16) with source CargoPod. While it is set, a prefix on `DropCellFinder.RandomDropSpot(Map, bool)` (DropCellFinder.cs:16) returns the top cargo-pod zone's overflow center, so the drop center and the letter target (IncidentWorker_ResourcePodCrash.cs:12-14) both point at the zone; with no such zone vanilla runs. The `DropThingGroupsNear` prefix from rewards routes the groups and keeps the call's forbid (default true) and `leaveSlag` (true, :13).
- **Settings:** Global "Route cargo pod events" (off). Per zone: "Cargo pods" (off).
- **Save and removal:** The per-zone flag saves with the zone.
- **Replaces:** Resource Drop Pod Redirection (2944180046, 1,984 subs, no 1.7).
- **Effort:** S.
- **Tests:** The incident with the toggle on puts forbidden pods in the zone, and the letter's target is a zone cell. With the toggle off, vanilla. Vanilla Events Expanded's ApparelPod and WeaponPod events (`-Compat`) stay vanilla.
- **Risks:** It takes the surprise out of cargo pods, hence off by default. Vanilla Events Expanded (1938420742, 836,672 subs, 1.7) drops apparel and weapon pods through `DropThingsNear` without our context; adding them is in the Backlog.
#### Headless tests for cargo pods
- `-Compat` adds the Vanilla Events Expanded test above.
## Work rule areas
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: 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:
@ -434,7 +427,9 @@ Why this shape:
- 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. - 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. - 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 ### Areas and the six rules
#### Paint and manage 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. - **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:** - **How:**
@ -444,12 +439,12 @@ Why this shape:
- 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. - 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. - 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. - 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. - The removal button 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. - **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. - **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. - **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. - **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. - **Effort:** M plus S. The S is the manage window and the removal-button steps.
- **Tests:** - **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. - 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. - 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.
@ -457,7 +452,7 @@ Why this shape:
- 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. - 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. - 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". - 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.3". - Phase 3: see "Headless tests for work rule areas".
- **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. - **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 #### No cleaning, firefighting, repairs or hauling
@ -492,7 +487,7 @@ Why this shape:
- 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. - 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. - 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. - **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. - **Effort:** M plus S. The S is the giver-class step and its test.
- **Tests:** - **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. - 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. - 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.
@ -527,7 +522,7 @@ Why this shape:
- Please Haul Perishables (Continued) (2807630952, 6,111, 1.7): hauls perishables early, a different axis. - 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". - Pick Up And Haul: wrapped, see How. Dubs Bad Hygiene: as for "No cleaning".
- **Replaces:** Cleaning Priority - 1.0 (1543157124, 1,839, 1.0). - **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. - **Effort:** M plus S. The S is the per-pawn Pick Up And Haul check, the Cleaning Priority stand-down and their `-Compat` tests.
- **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. - 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. - 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.
@ -539,85 +534,88 @@ Why this shape:
- With "Apply work rules" off, both givers give nothing and log nothing. - 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. - **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.3 #### Headless tests for work rule areas
- Fixtures: `WorkRuleArea(rect, rules)`, `Filth(cell)` thickened past 600 ticks, `Fire(cell)`, `DamagedWall(cell)`, `BrokenDown(building)`, `OnlyWorkType(pawn, workType)`. - 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. - 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%. - 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.3 tests; Blax Defaults once its forbid rules (its 1.1) have code. - Compat: Pick Up And Haul, Prison Labor, Hospitality and Blax Castes (a caste area that leaves out a clean-first area, once Castes' allowed-area slot has code) join the work rule tests; so does Blax Defaults with its forbid rules (its 1.1).
- `docs/ingame-check.md` gains: the overlay color and the picker, the manage window, the tooltips. - `docs/ingame-check.md` gains: the overlay color and the picker, the manage window, the tooltips.
- Effort: S, half a day. - Effort: S.
### 1.4 Stockpiles, shelves, roofs and selling (6 days) ## Sleeping zones
Stockpile deliveries and direct delivery ship together: most freezers and hospital shelves are roofed, so the flag alone does little for orbital goods. Three steps on one base, the zone beds from the data model: animals first, then people with owner types, then the caste filter once Blax Castes ships its read-only API.
#### Stockpiles and shelves receive deliveries ### Animals
- **Players get:** A "Receive deliveries" gizmo on any stockpile, shelf, rack or fridge lets bought goods and rewards go straight into it, by its own filter and priority: medicine onto the hospital shelves, food into the freezer, no hauling. Delivery zones and flagged storage compete by priority. #### Animal sleeping zones
- **Players get:** A new "Animal sleeping zone" in the Zone menu. Every cell works like an animal sleeping spot, so one drag over the barn beds every chicken and duck. Shrinking or deleting the zone removes its cells. Sleeping zones don't extend the home area.
- **How:** - **How:**
- Flags live in `MapComponent_BlaxZones` as a `HashSet<int>` of stockpile zone IDs and a `HashSet<int>` of storage building ThingIDs, never as fields on `Zone_Stockpile` or `Building_Storage`. Zone IDs and ThingIDs are never reused, so a stale flag can't land on a new storage. - Zone beds as in the data model. `Zone_SleepingBase : Zone` holds what both kinds share; `Zone_SleepingAnimals` ships first and `Zone_SleepingPeople` with people zones. Separate types keep the designators from expanding each other's zones, since `Designator_ZoneAdd` compares the exact type. Animal zones get one fixed tint, brown at alpha 0.09.
- Gizmos come from postfixes on `Zone_Stockpile.GetGizmos` (Zone_Stockpile.cs:75) and `Building_Storage.GetGizmos` (Building_Storage.cs:227). RimFridge's and Weapon Racks' storage buildings call the base, so they get the gizmo. - `AddCell` calls the base, then spawns a `Building_ZoneBed` as the data model describes. The designator refuses cells with an edifice or bed.
- Storage groups: shelves can be linked into a group (Building_Storage.cs:13), whose settings every member reads through `GetStoreSettings()` (Building_Storage.cs:100-107). Group membership changes through vanilla's link gizmos (Building_Storage.cs:241-244) without calling Zones. So a storage building counts as flagged when it or any member of its `StorageGroup` is flagged, and the gizmo on a grouped building sets or clears the flag on every member. A shelf linked into a flagged group later is flagged through the group. A shelf leaving a group keeps its own flag, as vanilla copies the group's settings onto it (StorageGroupUtility.cs:163-184); one that joined after the flag was set has none of its own and leaves unflagged. - Cap: `Designator_ZoneAdd_SleepingBase` overrides `DesignateMultiCell` (Designator_ZoneAdd.cs:104). When the map's sleeping-zone cells plus the dragged cells exceed the cap, it passes only the first cells of the drag up to the cap to the base and posts one message naming the cap; at the cap it adds nothing and posts the same message.
- The router adds flagged storage as candidates, with accept from `StorageSettings.AllowedToAccept(thing)` and priority from `StorageSettings.Priority`, both through `GetStoreSettings()`; building cells come from `AllSlotCells()`. Storage targets use the storage rule from the data model and fill mergeable stacks first. - Home area: `Zone_SleepingBase.AddCell` sets `Find.PlaySettings.autoHomeArea` to false around `base.AddCell` and restores it in a `finally`. `AutoHomeAreaMaker.Notify_ZoneCellAdded` reads that setting first (AutoHomeAreaMaker.cs:9-16, 48-58), and the base `Zone.AddCell` always calls it (Zone.cs:232). No patch: a prefix on that 10-line static method could be inlined. `expandHomeArea` false on the bed def covers the bed's own spawn (AutoHomeAreaMaker.cs:18-24).
- Pods use only stockpile cells that pass the pod rule. Shelves are edifices, so they get orbital goods only with direct delivery. Caravan placement and direct delivery put the thing on a storage cell with `GenPlace.TryPlaceThing(thing, cell, map, ThingPlaceMode.Direct)` and try the next cell on failure. - Spawn cost: each bed spawn runs `District.Notify_RoomShapeOrContainedBedsChanged`, which walks regions only when the map has facilities (District.cs:235-247, FacilitiesUtility.cs:19-60), and `Room.Notify_RoomShapeChanged` with its temperature, auto roof area and prison-cell work (Room.cs:686-729). If a 500-cell drag takes more than 100 ms in the harness, spawn a drag's beds 50 per tick.
- A deleted stockpile or storage building drops its ID on the next lookup. The gizmo tooltip says roofed targets need direct delivery for orbital goods and rewards. - `RemoveCell` and deregistration unclaim owners first with `pawn.ownership.UnclaimBed()`, then destroy, so there is no "lost assignment" spam; the loading flag skips this during load.
- **Settings:** Global "Stockpiles and shelves may receive deliveries" (on). Per stockpile and storage building: gizmo (off). - Def `BlaxZones_ZoneAnimalBed` (`bed_humanlike` false): 1x1, Standable, FloorEmplacement, no `sowTag` (so `CanOverlapZones` stays true), `building.isEdifice` false, `building.deconstructible` false, `building.bed_showSleeperBody` true, `building.expandHomeArea` false, `bringAlongOnGravship` false, `selectable` false, `drawGUIOverlay` false, `drawerType` None, `useHitPoints` false, WorkToBuild 0, Flammability 0, no cost list (no wealth), no designationCategory, `tickerType` Never, `isSaveable` false, `CompAssignableToPawn_Bed`. The uiIcon uses the vanilla AnimalSleepSpot texture. People zones add the humanlike defs with the same flags.
- **Save and removal:** The flag sets save in the component. Without the mod they vanish with the component node; the stockpiles and shelves keep their own settings. - Why those flags:
- **Replaces:** [DHM]Organized Trade Pod System (3490887589, 1,816 subs, no 1.7), Skipdoor Delivery (3233578663, 2,749, no 1.7) for trade goods. - `deconstructible` false: they are player buildings and `deconstructible` defaults to true (BuildingProperties.cs:21, 436-449). A deconstruct drag over a barn would destroy every bed at once, since work 0 destroys immediately (Designator_Deconstruct.cs:69-76).
- **Effort:** M plus S, 2.5 days. The S is the storage rule and storage groups. - `bed_showSleeperBody` true: the default false hides a humanlike sleeper's body (BuildingProperties.cs:174; PawnRenderNodeWorker_Body.cs:29-31, PawnRenderer.cs:448), and with `drawerType` None there is no blanket either, so an adult would show as a floating head. Both vanilla spots set it (Core ThingDefs_Buildings/Buildings_Furniture.xml:64, :479). It matters for the people defs; the animal def sets it to match.
- **Tests:** An unroofed flagged food stockpile at Important plus a general delivery zone at Normal: bought rice lands in the stockpile, steel in the zone. A flagged medicine shelf in a roofed hospital with direct delivery on: orbital medicine appears on the shelf. A vanilla shelf cell (PassThroughOnly) receives a direct delivery. Caravan rice goes into a roofed flagged freezer. A linked shelf group: flagging one shelf flags every member, and priority and filter come from the group. A new shelf linked into the flagged group receives a delivery; unlinked again, it doesn't. A shelf that was in the group when it was flagged keeps receiving after it is unlinked. Storage targets fill mergeable stacks before empty cells. Flags survive reload. A deleted stockpile is no longer a target. Phase 3 loads with no errors from the flag sets. `-Compat`: a RimFridge fridge (PassThroughOnly) and a RimFridge wall fridge (Impassable) each receive a delivery; a Weapon Racks rack holds no more than its items per cell. - `bringAlongOnGravship` false (ThingDef.cs:167, checked in Gravship.cs:607-634): takeoff would otherwise despawn the beds with `WillReplace` (GravshipUtility.cs:389), keep their owners and, in a save made during flight, deep-save them inside `Gravship.things` (Gravship.cs:335). That bypasses `isSaveable`, which only `Map.ExposeData` checks, and would break the save after mod removal. Landing runs on a map that already exists (WorldComponent_GravshipController.cs:529-538), so reconcile never sees carried beds. It is a core `ThingDef` field (ThingDef.cs:167), so the def loads without Odyssey.
- **Risks:** Without direct delivery, roofed freezers and shelves get only caravan goods; the tooltip says so. Overlapping mods: - Copied from the vanilla spots: SurgerySuccessChanceFactor 0.7, `scatterableOnMapGen` false (needed for `IsClearableFreeBuilding`, Building.cs:64-74), `ai_chillDestination` false, `artificialForMeditationPurposes` false, `wakeDormantPawnsOnConstruction` false (Core Buildings_Furniture.xml:49-79, 459-491). Like the vanilla spots they leave `socialPropernessMatters` off. The vanilla spots carry `sowTag` SupportPlantsOnly, which is why ours can't copy it.
- RimFridge: Now with Shelves! (2898411376, 282,094 subs, 1.6 build): `RimFridge_Building` is a `Building_Storage` (its Source/RimFridge_Building.cs:11) with its own items-per-cell setting, which the storage rule reads through `GetMaxItemsAllowedInCell`. Its fridges are PassThroughOnly and its wall fridge Impassable (its 1.6 Defs/ThingDefs_Buildings/Fridge_Base.xml:25, WallFridge_Building.xml:6), so neither is standable and both need the storage rule. - Bed search order: `RestUtility.Reset` (RestUtility.cs:25-44) builds the best-to-worst bed lists, sorted by `bed_maxBodySize`, then rest effectiveness, keeping definition order on ties. It runs before `[StaticConstructorOnStartup]` (PlayDataLoader.cs:207 vs 360). A postfix moves our animal def directly before AnimalSleepingSpot (people zones add their defs before SleepingSpot), and the patch class calls `RestUtility.Reset()` once after patching. Otherwise unowned animals walk to any free vanilla spot first.
- Weapon Racks (2788630748, 57,447 subs, 1.7): `Building_WeaponStorage` holds 1 to 4 items per cell (its 1.7/Defs/ThingDefs/ThingDefs_Buildings.xml); the storage rule respects that. Bought weapons can land on a flagged rack. - Edifices: a postfix on `EdificeGrid.Register` (EdificeGrid.cs:21-33) queues the cell when any edifice spawns on a sleeping-zone cell, so no cell holds two beds. `Building.SpawnSetup` registers the edifice before the rest of its spawn (Building.cs:113-127), so destroying our bed inside the postfix would run mid-spawn. The component handles the queue on its next tick and before saving: `RemoveCell`, then `CheckContiguous`, as vanilla does for overlap (ZoneManager.cs:97-112). This replaces a hook on the hot virtual `Building.SpawnSetup`. If the JIT inlines `Register` into a caller and the postfix stops firing there, the 250-tick sweep from the data model trims the cell instead. Vanilla already trims zone cells for walls, storage and tables, which can't overlap zones (ThingDef.cs:625-655); beds and doors can, hence the postfix.
- Haul to Stack (949498803, 77,412 subs, 1.6 build) makes haulers fill stacks first; storage targets use the same order. - Building over a zone bed needs no patch: `GenConstruct.CanPlaceBlueprintOver` already allows it over non-edifices (GenConstruct.cs:676-703), and `SpawnBuildingAsPossible` won't wipe a non-edifice zone bed on load (GenSpawn.cs:196-235).
- Vanilla Furniture Expanded's storage furniture is `Building_Storage`, so it is covered. - Cutting the zone: a wall line across it removes the wall cells, and `Zone.CheckContiguous` keeps the part holding the zone's first cell and removes the rest (Zone.cs:345-397). The zone does not split in two. Removed cells lose their beds and owners silently.
- Gravship landing calls our `RemoveCell` through `GravshipPlacementUtility.ClearThingsAt` (GravshipPlacementUtility.cs:311-313); our own code handles it.
- **Settings:** Global "Sleeping zones" (on); "Max sleeping-zone cells per map" (500, 50 to 2000).
- **Save and removal:** Zones and beds save in the component, beds with their owners and flags. A plain unsubscribe drops the beds with the component and logs the warnings and CurToil errors listed in the data model; the button below avoids them.
- **Replaces:** Covers the spot-grid use of Designator Shapes (1235181370, 331,540 subs, alive on 1.7; a general shape tool, so its count says little about demand for zones); BuilderTweaksReplica (3521096349, 7,977, alive on 1.7) for drag-placing spots; Hidden Spots (3466316759, 13,301, alive on 1.7). Replaces Invisible Animal sleeping spot - Prettier Barn (2571118651, 397, up to 1.6).
- **Effort:** M plus S. The S is the zone-bed safety work: the choke point, the queue and the sweep.
- **Tests:**
- Def: not an edifice, not deconstructible, flammability 0, no cost list, not selectable, `isSaveable` false, `bringAlongOnGravship` false. `Designator_Deconstruct.CanDesignateThing(zoneBed)` (Designator_Deconstruct.cs:84) is refused.
- A 4x4 animal zone holds 16 `BlaxZones_ZoneAnimalBed`, player faction; grass on those cells survives, and with auto home area on the home area doesn't grow and `Find.PlaySettings.autoHomeArea` is still true afterwards.
- A tamed chicken: `RestUtility.FindBedFor` returns a zone bed ahead of a free vanilla AnimalSleepingSpot; after it lies down, it owns the bed.
- Shrinking by 4 cells removes 4 beds and clears their owners with no messages. A wall on a zone cell removes the cell and the bed. A wall line across a 6x4 zone removes the cut-off part, its beds and owners, with no messages. A vanilla bed built on a zone cell removes that cell on the next tick; with the `Register` postfix switched off (test hook), within 250 ticks.
- Foreign destroy: `bed.Destroy()` from outside Zones respawns the bed on the next tick. Destroy a bed and save immediately: after the reload there is one bed per cell.
- Cap set to 50: a 60-cell drag adds 50 cells and posts one message naming the cap; a second drag adds nothing and posts the same message.
- A 500-cell drag fails the test above 500 ms.
- A delivery zone inside a walled-off area that also holds a sleeping zone gets no pods, although `CanReachColony` is true there.
- Phase 2: same bed count and ThingIDs, the chicken still owns its bed, no "Could not resolve reference" warnings.
- Phase 3, with a chicken asleep in a zone bed at save time: no beds, no zones, the chicken's owned bed is null, warnings only, and beyond the two expected errors per map only CurToil errors that name the chicken (`ExpectCurToilErrorsFor`), no NRE.
- If `GravshipPlacementUtility.ClearThingsAt` runs without Odyssey, call it by reflection on a zone cell: the cell and bed go, with no messages.
- **Risks:**
- Cost: hundreds of Building things add to `listerBuildings` loops and room recalculations; the cell cap, `drawerType` None and `tickerType` Never limit it. An unowned pawn's `FindBedFor` scans past owned beds, as with many vanilla spots. Other mods' bed lists will show zone beds.
- Heuristics: vanilla sleeping spots are colony buildings too, but zone beds come by the hundred. When no chill destination works, `RCellFinder.TryFindRandomSpotJustOutsideColony` falls back to random colony buildings (RCellFinder.cs:736-750); visitor groups (IncidentWorker_VisitorGroup.cs:24), waiting prisoners (JobGiver_PrisonerWaitInsteadOfEscaping.cs:22) and immediate-attack raids (RaidStrategyWorker_ImmediateAttack.cs:20) use it, so those spots drift toward a big barn. `TradeDropSpot` without a powered beacon or comms console picks random colony buildings too (DropCellFinder.cs:51-69). `JobGiver_AITrashBuildingsDistant` draws 75 random colony buildings (JobGiver_AITrashBuildingsDistant.cs:28-46) and zone beds never qualify (`IsClearableFreeBuilding`, TrashUtility.cs:64), so raiders trash a little less. The cell cap bounds all three; they aren't tested, because each is random by design. The reach rule keeps them out of Zones' own routing.
- Overflow pods may land on sleeping-zone cells, as on vanilla spots, because zone beds are clearable free buildings; a bed the pod wipes respawns through the choke point.
- Odyssey gravships move only stockpile and growing zones (Gravship.cs:396-440), so ours stay behind; untested, because Odyssey isn't installed on the test machine.
- Dubs Mint Minimap (1662119905, 655,557 subs): draws edifices only, so zone beds don't show. Delivery zones don't either; zones aren't drawn.
#### Delivery under a roof #### Which animals may sleep here
- **Players get:** An option "No drop pods, goods appear here" on delivery zones, flagged stockpiles and flagged storage buildings. Roofed warehouses and rooms then receive orbital goods and rewards. Off by default. - **Players get:** The animal zone tab lists species with checkboxes and a body-size range, so big stalls stay free of chickens. The inspect pane warns when the filter leaves out every tamed animal on the map.
- **How:** For targets with direct delivery, orbital and reward routing skip the pod. Delivery zones use `GenPlace.TryPlaceThing(thing, cell, map, Near, null, validator)` with the placement rule, roof ignored; storage targets use Direct mode with the storage rule. For rewards, the `DropThingGroupsNear` prefix takes the group out of the list and places it, applying the call's forbid flag. A dust fleck marks the arrival. The stockpile and storage flags sit in the MapComponent next to the receive flags, and follow storage groups the same way. No roof punching: `Skyfaller.HitRoof` collapses a 3x3 roof (Skyfaller.cs:399-435).
- **Settings:** Global "Allow direct delivery" (on, makes the per-target option available). Per zone, stockpile and storage building: off.
- **Save and removal:** The flags save in the component and vanish with it.
- **Replaces:** Nothing.
- **Effort:** S, half a day.
- **Tests:** In a fully roofed zone with the option on, orbital steel spawns on a zone cell the same tick with no pod. Without the option, it falls back. A quest reward goes to a roofed direct zone, forbid flag kept.
- **Risks:** Immersion only. Goods arrive either way, so balance is neutral. Dubs Skylights (833899765, 272,595 subs, 1.7): skylights sit in roofed cells, so pods can't land under them; the red overlay shows those cells and direct delivery covers them.
#### Sell zone
- **Players get:** A gizmo "Orbital traders can buy from here" on stockpiles and storage buildings. While at least one powered trade beacon stands on the map, orbital traders see every item in flagged storage and can take payment silver from it, so goods don't have to be hauled to the beacon. The shelves themselves are never for sale. Off by default for balance.
- **How:** - **How:**
- Flags (zone IDs and storage ThingIDs) in the MapComponent, with the storage-group rule from "Stockpiles and shelves receive deliveries". - `Zone_SleepingAnimals` gets `HashSet<string> disallowedRaces`, a deny-list of race defNames resolved with `GetNamedSilentFail`, so new species are allowed by default and a removed animal mod leaves nothing unresolved. Plus `FloatRange bodySize` (0 to unlimited).
- A postfix on `TradeUtility.AllLaunchableThingsForTrade(Map, ITrader)` (TradeUtility.cs:84, an iterator) at `Priority.Last` wraps the result. It yields everything, keeping a HashSet, then appends things on flagged cells whose `def.category` is `Item` and that pass `TradeUtility.PlayerSellableNow` (TradeUtility.cs:43) and aren't in the set. Only when `Building_OrbitalTradeBeacon.AllPowered(map)` is not empty. RimFridge's "fridges act as beacons" postfix appends without deduping (its 1.6 Source/HarmonyPatches.cs, `LaunchItemsFromFridges`), hence the late priority and the full set. - A postfix on `RestUtility.CanUseBedNow(Thing bedThing, Pawn sleeper, bool checkSocialProperness, bool allowMedBedEvenIfSetToNoCare, GuestStatus? guestStatusOverride)` (RestUtility.cs:72) at `Priority.Low` checks the bed type first. For a `Building_ZoneBed` whose zone rejects the sleeper it sets false. The zone comes from `zoneGrid` in O(1). This one patch covers `FindBedFor` (RestUtility.cs:235), `FindPatientBedFor` (:328), rescue, capture, `Toils_Bed.BedNoLongerUsable` and `FailOnBedNoLongerUsable` (Toils_Bed.cs:58-96), childcare and rituals. The caste filter adds its check to the same postfix.
- Items only, as vanilla takes only `ThingCategory.Item` from beacon cells (TradeUtility.cs:134). `EverPlayerSellable` accepts minifiable buildings (TradeUtility.cs:32-39), vanilla shelves are minifiable and tradeable, so without the category check a flagged shelf or fridge, or a lamp standing on a flagged stockpile, would be offered, and selling it removes it from the map (TradeShip.cs:179-197). Pawns fail the check too, so prisoner and slave sales stay with vanilla and Blax Slaves. Bookcases and outfit stands aren't `Building_Storage` and get no gizmo. - Changing a filter, or pasting settings onto a zone, unclaims the owners that no longer pass, with one message naming the count. Vanilla's `FailOnBedNoLongerUsable` gets an animal already lying there out of bed.
- The trade dialog lists and pays from what `TradeShip.ColonyThingsWillingToBuy` collects through that method (TradeShip.cs:89-100; Tradeable.cs:463-471), so the postfix alone lets trades sell from and pay with flagged storage. - The tab has a search field, the species list (species tamed on this map first, then all animal races) and `Widgets.FloatRange` for size.
- `TradeUtility.LaunchThingsOfType(ThingDef resDef, int debt, Map map, TradeShip trader)` (TradeUtility.cs:185-222) searches beacon cells only. Its only vanilla callers are the ransom fee through `LaunchSilver` (:225) and the AI core information request (FactionDialogMaker.cs:196), and both check affordability through `AllLaunchableThingsForTrade`. A prefix with `ref int debt` (Harmony lets a prefix change a plain argument) pays from flagged cells first, the way vanilla pays from beacon cells, lowers `debt`, and lets vanilla pay the rest. Without it vanilla logs "Could not find any Silver" and underpays (:207-211). - **Settings:** Per animal zone: species deny-list (empty), body size (any). No global setting.
- **Settings:** Global "Sell zones" (off). Per stockpile and storage building: off. - **Save and removal:** Filters save with the zone in the component. A species whose mod is gone stays in the list and comes back with the mod.
- **Save and removal:** The flags save in the component and vanish with it; trade goes back to beacon range. - **Replaces:** Barn Stall (Continued) (2071768301, 29,391 subs, alive on 1.7): covers its size filter, which its author refused; Chicken nests Continued (3261309547, 5,715, up to 1.6), species-only nests. The vanilla animal spot has no size limit (`bed_maxBodySize` 9999, BuildingProperties.cs:178).
- **Replaces:** Covers the use of Map Wide Orbital Trade Beacon (1839069104, 50,625 subs, alive on 1.7), Wall-Mounted Orbital Trade Beacon (3553078564, 15,875, alive on 1.7), Trade Beacon Shapes (3533891331, 610, a drawing shape for placing beacons; a weak overlap) and [DHM]Adjustable Trade Beacon Range (3823054506, 27). - **Effort:** M.
- **Effort:** M, 2 days. Two trade methods change. - **Tests:** Chickens disallowed and only zone beds present: `FindBedFor(chicken)` returns null. Body size max 1.0: a muffalo (2.4) is refused, a chicken accepted. A filter change unclaims the now-refused owner, with one message naming the count. With every tamed species disallowed, the inspect string carries the warning. A species defName that doesn't resolve stays stored. Filters persist in phase 2.
- **Tests:** A flagged stockpile far from the beacon holds 100 steel. With a powered beacon the trade dialog lists the steel; with the beacon off it doesn't. Selling it removes it from the stockpile. Buying with silver that sits only in a flagged stockpile pays from it. A ransom fee paid from flagged silver logs no error and takes the full amount. A flagged shelf and a standing lamp on a flagged stockpile never show up in `ColonyThingsWillingToBuy`. A prisoner standing in a flagged stockpile isn't offered. `-Compat`: with RimFridge's beacon setting on and a fridge also flagged as a sell zone, the dialog lists each item once. - **Risks:** `CanUseBedNow` is hot; the postfix exits on the type check for every other bed. Ours only ever sets false, so it composes with other postfixes that set false. At `Priority.Low` it runs after postfixes that allow a bed, such as Blax Slaves' shared infirmary, so a zone filter has the last word.
- **Risks:** Beacon mods also patch `AllLaunchableThingsForTrade`; our wrapper skips things already in the list, so running Map Wide Orbital Trade Beacon alongside doesn't list items twice. It removes hauling to the beacon, hence off by default. [RH2] Rimdeed (2411722784, 83,107 subs, 1.6 build) reads `AllLaunchableThingsForTrade`, so sell-zone silver may pay its fees, which is harmless.
#### Cargo pod events land in the zone #### Headless tests for animal sleeping zones
- **Players get:** Optional: random cargo pod events drop their goods into a delivery zone that has "Cargo pods" ticked, and the letter points there. - Fixture `SleepingZone(rect, kind)`; people zones add the owner type.
- **How:** A DeliveryContext prefix and finalizer on `IncidentWorker_ResourcePodCrash.TryExecuteWorker` (IncidentWorker_ResourcePodCrash.cs:8-16) with source CargoPod. While it is set, a prefix on `DropCellFinder.RandomDropSpot(Map, bool)` (DropCellFinder.cs:16) returns the top cargo-pod zone's overflow center, so the drop center and the letter target (IncidentWorker_ResourcePodCrash.cs:12-14) both point at the zone; with no such zone vanilla runs. The `DropThingGroupsNear` prefix from rewards routes the groups and keeps the call's forbid (default true) and `leaveSlag` (true, :13). - Performance in `-Compat`: time 2500 ticks with and without 500 animal zone beds, median of three runs each, written to the results file. The test fails when the zone beds add more than 10%.
- **Settings:** Global "Route cargo pod events" (off). Per zone: "Cargo pods" (off). - KnownForeignErrors: add any foreign error found in these runs.
- **Save and removal:** The per-zone flag saves with the zone. - Effort: S, for the performance and compat runs.
- **Replaces:** Resource Drop Pod Redirection (2944180046, 1,984 subs, no 1.7).
- **Effort:** S, half a day.
- **Tests:** The incident with the toggle on puts forbidden pods in the zone, and the letter's target is a zone cell. With the toggle off, vanilla. Vanilla Events Expanded's ApparelPod and WeaponPod events (`-Compat`) stay vanilla.
- **Risks:** It takes the surprise out of cargo pods, hence off by default. Vanilla Events Expanded (1938420742, 836,672 subs, 1.7) drops apparel and weapon pods through `DropThingsNear` without our context; adding them is in the Backlog.
#### Headless tests in 1.4 ### People
- Fixtures: `Shelf(cell)`, `LinkShelves(a, b)`, `UnlinkShelf(a)`, a roofed `Stockpile(rect)`.
- Phase 2: every flag set survives. Phase 3: the flags vanish with no errors.
- `-Compat` adds the RimFridge, Weapon Racks and Vanilla Events Expanded tests above; RimFridge's beacon setting is switched on through its settings for the dedupe test.
### 1.5 People sleeping zones (6 days)
#### Sleeping zones for colonists, slaves and prisoners #### Sleeping zones for colonists, slaves and prisoners
@ -635,9 +633,9 @@ Stockpile deliveries and direct delivery ship together: most freezers and hospit
- A closed room that holds a prisoner zone stays a prison cell, so vanilla beds there stay prisoner beds, as in any vanilla prison cell. The zone's owner type wins until the player switches the zone. - A closed room that holds a prisoner zone stays a prison cell, so vanilla beds there stay prisoner beds, as in any vanilla prison cell. The zone's owner type wins until the player switches the zone.
- New zones start as colonist zones. A new colonist zone in an existing prison cell keeps Colonist through the setter prefixes, and the inspect pane warns. - New zones start as colonist zones. A new colonist zone in an existing prison cell keeps Colonist through the setter prefixes, and the inspect pane warns.
- **Settings:** Per people zone: owner-type gizmo (colonists, slaves with Ideology, prisoners). Global: "Zone cells count for bedroom or barracks" (on, as vanilla spots; written to the people defs' `bed_countsForBedroomOrBarracks` at startup, tooltip "restart required"). - **Settings:** Per people zone: owner-type gizmo (colonists, slaves with Ideology, prisoners). Global: "Zone cells count for bedroom or barracks" (on, as vanilla spots; written to the people defs' `bed_countsForBedroomOrBarracks` at startup, tooltip "restart required").
- **Save and removal:** The owner type saves with the zone and on each bed. Removal as in 1.2. - **Save and removal:** The owner type saves with the zone and on each bed. Removal as for animal zones.
- **Replaces:** None directly. It extends 1.2's coverage of Designator Shapes and BuilderTweaksReplica spot grids to dorms and prisons. - **Replaces:** None directly. It extends the animal zones' coverage of Designator Shapes and BuilderTweaksReplica spot grids to dorms and prisons.
- **Effort:** M plus S, 2.5 days. The S is the owner-type protection and the prison-room rules. - **Effort:** M plus S. The S is the owner-type protection and the prison-room rules.
- **Tests:** - **Tests:**
- A colonist gets a bed in a people zone. Render inputs for the drawn body: once it lies down, `CurrentBed()` is the zone bed, its posture is `LayingInBed` and the bed's def has `bed_showSleeperBody` true. Seeing the body is a step in `docs/ingame-check.md`. - A colonist gets a bed in a people zone. Render inputs for the drawn body: once it lies down, `CurrentBed()` is the zone bed, its posture is `LayingInBed` and the bed's def has `bed_showSleeperBody` true. Seeing the body is a step in `docs/ingame-check.md`.
- Switched to slaves (Ideology, skipped without): the colonist is refused, a slave accepted, and zero `MessageBedLostAssignment` appear. - Switched to slaves (Ideology, skipped without): the colonist is refused, a slave accepted, and zero `MessageBedLostAssignment` appear.
@ -667,9 +665,9 @@ Stockpile deliveries and direct delivery ship together: most freezers and hospit
- Everything else already matches vanilla spots: rest effectiveness 0.8 (`BedRestEffectiveness` valueIfMissing, Toils_LayDown.cs:95-96; Stats_Building_Special.xml:36), SleptOnGround -4 when the cost list is empty, SleptOutside outdoors (Toils_LayDown.cs:208-215; Thoughts_Memory_Misc.xml:84-97). `Toils_LayDown.ApplyBedThoughts` (Toils_LayDown.cs:172) is private and not patched. Animals have no mood need, so for them only location, ownership and medical matter. - Everything else already matches vanilla spots: rest effectiveness 0.8 (`BedRestEffectiveness` valueIfMissing, Toils_LayDown.cs:95-96; Stats_Building_Special.xml:36), SleptOnGround -4 when the cost list is empty, SleptOutside outdoors (Toils_LayDown.cs:208-215; Thoughts_Memory_Misc.xml:84-97). `Toils_LayDown.ApplyBedThoughts` (Toils_LayDown.cs:172) is private and not patched. Animals have no mood need, so for them only location, ownership and medical matter.
- Switching medical or shared on a zone that has owners asks first and names the count. - Switching medical or shared on a zone that has owners asks first and names the count.
- **Settings:** Per zone: Medical (off); per people zone: Shared (off). Global: "Zone cells give sleeping-spot comfort" (on). - **Settings:** Per zone: Medical (off); per people zone: Shared (off). Global: "Zone cells give sleeping-spot comfort" (on).
- **Save and removal:** Both flags save with the zone; the medical flag also saves on each bed. Removal leaves owners without a bed, as in 1.2. - **Save and removal:** Both flags save with the zone; the medical flag also saves on each bed. Removal leaves owners without a bed, as for animal zones.
- **Replaces:** Nothing. - **Replaces:** Nothing.
- **Effort:** M, 2 days. - **Effort:** M.
- **Tests:** Medical zone: `RestUtility.FindPatientBedFor` returns a zone bed for an injured colonist, an injured tamed animal goes to a medical animal zone, and no lost-assignment messages appear. With Medical on, the Shared gizmo is disabled, and the reverse; animal zones show no Shared gizmo. Shared zone: a colonist sleeps a full night without `FailOnBedNoLongerUsable` ending the job; 250 ticks after waking, `ownership.OwnedBed` is null; a pawn whose LayDown job targets a shared bed it doesn't lie in yet keeps its claim through a sweep; no SleptInBarracks thought in a room with only shared cells. Comfort rises over 2500 ticks in a zone bed and stays flat on bare ground. SleptOnGround is present after waking. Toggles persist in phase 2. - **Tests:** Medical zone: `RestUtility.FindPatientBedFor` returns a zone bed for an injured colonist, an injured tamed animal goes to a medical animal zone, and no lost-assignment messages appear. With Medical on, the Shared gizmo is disabled, and the reverse; animal zones show no Shared gizmo. Shared zone: a colonist sleeps a full night without `FailOnBedNoLongerUsable` ending the job; 250 ticks after waking, `ownership.OwnedBed` is null; a pawn whose LayDown job targets a shared bed it doesn't lie in yet keeps its claim through a sweep; no SleptInBarracks thought in a room with only shared cells. Comfort rises over 2500 ticks in a zone bed and stays flat on bare ground. SleptOnGround is present after waking. Toggles persist in phase 2.
- **Risks:** A signature change of `ApplyBedRelatedEffects` breaks only this patch class. A medical prisoner zone still needs a prison cell, as in vanilla. A shared pawn owns its cell while asleep, so bed lists show it as claimed overnight. If the room also holds beds that count, it is still a barracks, and a shared sleeper gets SleptInBarracks, as on a vanilla spot (Toils_LayDown.cs:217-239; RoomRoleWorker_Barracks.cs:17). Priority Treatment Ressurected (3009738919, 135,928 subs, 1.7) carries downed colonists to bed first through the vanilla bed search, so medical zones help it. - **Risks:** A signature change of `ApplyBedRelatedEffects` breaks only this patch class. A medical prisoner zone still needs a prison cell, as in vanilla. A shared pawn owns its cell while asleep, so bed lists show it as claimed overnight. If the room also holds beds that count, it is still a barracks, and a shared sleeper gets SleptInBarracks, as on a vanilla spot (Toils_LayDown.cs:217-239; RoomRoleWorker_Barracks.cs:17). Priority Treatment Ressurected (3009738919, 135,928 subs, 1.7) carries downed colonists to bed first through the vanilla bed search, so medical zones help it.
@ -678,25 +676,25 @@ Stockpile deliveries and direct delivery ship together: most freezers and hospit
- **Players get:** The zone tint shows its type: colonist, slave, prisoner and medical zones each get their own color, and animal zones keep theirs. The inspect pane shows the owner type, claimed and free cells, and a warning when a prisoner zone isn't in a prison cell or a colonist or slave zone sits in one. - **Players get:** The zone tint shows its type: colonist, slave, prisoner and medical zones each get their own color, and animal zones keep theirs. The inspect pane shows the owner type, claimed and free cells, and a warning when a prisoner zone isn't in a prison cell or a colonist or slave zone sits in one.
- **How:** - **How:**
- Vanilla shows owner type and medical by sheet color, which `drawerType` None hides. The owner-type and medical gizmos set `Zone.color` from a fixed palette. `Zone.Material` builds its material once and caches it in the private `materialInt` (Zone.cs:26, 86-95), so after setting the color Zones nulls `materialInt` through `AccessTools.FieldRefAccess<Zone, Material>` and marks the zone mesh dirty on every cell (`MapMeshDirty(cell, MapMeshFlagDefOf.Zone)`, as `Zone.Hidden` does, Zone.cs:70-84). Without that the tint changes only after a reload. - Vanilla shows owner type and medical by sheet color, which `drawerType` None hides. The owner-type and medical gizmos set `Zone.color` from a fixed palette. `Zone.Material` builds its material once and caches it in the private `materialInt` (Zone.cs:26, 86-95), so after setting the color Zones nulls `materialInt` through `AccessTools.FieldRefAccess<Zone, Material>` and marks the zone mesh dirty on every cell (`MapMeshDirty(cell, MapMeshFlagDefOf.Zone)`, as `Zone.Hidden` does, Zone.cs:70-84). Without that the tint changes only after a reload.
- `GetInspectString` counts owners over the zone's beds. The prisoner-zone warning reads `IsPrisonCell` on the zone's rooms (GridsUtility.cs:475-485), the same check `CanUseBedNow` makes. The colonist or slave warning uses Zones' own test, `Building_Bed.RoomCanBePrisonCell(room)` plus a prisoner bed in `room.ContainedBeds`, so a room another mod counts as a prison cell, such as a Prisoner Realism commons, doesn't trigger it. It also shows the filter warning from "Which animals may sleep here" and, from 1.6, the caste warnings. - `GetInspectString` counts owners over the zone's beds. The prisoner-zone warning reads `IsPrisonCell` on the zone's rooms (GridsUtility.cs:475-485), the same check `CanUseBedNow` makes. The colonist or slave warning uses Zones' own test, `Building_Bed.RoomCanBePrisonCell(room)` plus a prisoner bed in `room.ContainedBeds`, so a room another mod counts as a prison cell, such as a Prisoner Realism commons, doesn't trigger it. It also shows the filter warning from "Which animals may sleep here" and, with the caste filter, the caste warnings.
- **Settings:** None. - **Settings:** None.
- **Save and removal:** The color saves with the zone, like any zone color. - **Save and removal:** The color saves with the zone, like any zone color.
- **Replaces:** Nothing. - **Replaces:** Nothing.
- **Effort:** S, half a day. - **Effort:** S.
- **Tests:** Switching a zone to prisoners changes `zone.Material.color`, not only `zone.color`. After 3 chickens sleep in a 16-cell zone, the inspect string says 3 claimed, 13 free. An outdoor prisoner zone shows the warning. A colonist zone in a room with a vanilla prisoner bed shows the prison-cell warning. - **Tests:** Switching a zone to prisoners changes `zone.Material.color`, not only `zone.color`. After 3 chickens sleep in a 16-cell zone, the inspect string says 3 claimed, 13 free. An outdoor prisoner zone shows the warning. A colonist zone in a room with a vanilla prisoner bed shows the prison-cell warning.
- **Risks:** Two colonist zones share a color; the zone label tells them apart. - **Risks:** Two colonist zones share a color; the zone label tells them apart.
#### Headless tests in 1.5 #### Headless tests for people sleeping zones
- Fixture `SleepingZone(rect, kind, ownerType)`. - Fixture `SleepingZone(rect, kind, ownerType)`.
- Performance: the 1.2 timing again with 500 people zone beds, same 10% limit. - Performance: the animal-zone timing again with 500 people zone beds, same 10% limit.
- Compat (`-Compat`): Replace Stuff builds a real bed blueprint on a zone cell, the cell leaves the zone and no error is logged. Prison Labor: `FindBedFor(prisoner, warden, false)` finds a prison zone bed. Hospitality: a healthy guest is refused a zone cell, a guest with a naturally healing injury who doesn't need medical rest may use a free non-medical colonist zone cell, and one that needs medical rest may use a medical zone cell. Prisoner Realism: a colonist zone spawned in a commons room keeps Colonist and shows no prison-cell warning. - Compat (`-Compat`): Replace Stuff builds a real bed blueprint on a zone cell, the cell leaves the zone and no error is logged. Prison Labor: `FindBedFor(prisoner, warden, false)` finds a prison zone bed. Hospitality: a healthy guest is refused a zone cell, a guest with a naturally healing injury who doesn't need medical rest may use a free non-medical colonist zone cell, and one that needs medical rest may use a medical zone cell. Prisoner Realism: a colonist zone spawned in a commons room keeps Colonist and shows no prison-cell warning.
- KnownForeignErrors: add any foreign error found in these runs. - KnownForeignErrors: add any foreign error found in these runs.
- Effort: S, half a day. - Effort: S.
### 1.6 Caste filter (2 days) ### By caste
Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 in both design docs. Ships once Blax Castes publishes its read-only API, `CastesApi` version 1, which both design docs describe.
#### Sleeping zones by caste #### Sleeping zones by caste
@ -705,7 +703,7 @@ Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 i
- Binding: in the `[StaticConstructorOnStartup]` patcher, only when `Compat.IsActive("blax.castes")` (`ignorePostfix: true`). `AccessTools.TypeByName("BlaxCastes.CastesApi")`, with `Bind<T>`, `ReadVersion` and `WarnOnce` copied from Blax Slaves' Siblings.cs (Siblings.cs:27, 61, 153-157). It needs Version 1 or higher and `Active`, `CasteIdOf` and `CasteLabels`, bound by exact delegate and return types; otherwise it stays unbound with one log line. A call that throws turns the link off until the next game, with one warning, the rule Castes uses for Weapons Tab Reborn. Calls run on the main thread only. - Binding: in the `[StaticConstructorOnStartup]` patcher, only when `Compat.IsActive("blax.castes")` (`ignorePostfix: true`). `AccessTools.TypeByName("BlaxCastes.CastesApi")`, with `Bind<T>`, `ReadVersion` and `WarnOnce` copied from Blax Slaves' Siblings.cs (Siblings.cs:27, 61, 153-157). It needs Version 1 or higher and `Active`, `CasteIdOf` and `CasteLabels`, bound by exact delegate and return types; otherwise it stays unbound with one log line. A call that throws turns the link off until the next game, with one warning, the rule Castes uses for Weapons Tab Reborn. Calls run on the main thread only.
- Ids: `CasteLabels()` and `CasteIdOf(Pawn)` both return the token-prefixed id `"<token>:<id>"`, so ids picked from the list compare directly with a pawn's id. - Ids: `CasteLabels()` and `CasteIdOf(Pawn)` both return the token-prefixed id `"<token>:<id>"`, so ids picked from the list compare directly with a pawn's id.
- Data on `Zone_SleepingPeople`: `HashSet<string> allowedCasteIds` (empty means any), `bool allowNoCaste` (only used while the set isn't empty) and `Dictionary<string, string> lastLabels`, so the UI can name a caste that has gone. All three are always scribed with `LookMode.Value`, kept while unbound, and never pruned in ExposeData, PostLoadInit or FinalizeInit: `CasteLabels()` can still be empty during map `FinalizeInit` (Game.cs:611-647), because Castes seeds its starter castes in `LoadedGame`. - Data on `Zone_SleepingPeople`: `HashSet<string> allowedCasteIds` (empty means any), `bool allowNoCaste` (only used while the set isn't empty) and `Dictionary<string, string> lastLabels`, so the UI can name a caste that has gone. All three are always scribed with `LookMode.Value`, kept while unbound, and never pruned in ExposeData, PostLoadInit or FinalizeInit: `CasteLabels()` can still be empty during map `FinalizeInit` (Game.cs:611-647), because Castes seeds its starter castes in `LoadedGame`.
- The check: in the 1.2 `CanUseBedNow` postfix, after the type and zone checks. It returns early when `__result` is already false, the zone has no caste limit, or the link isn't usable (bound and `Active`, read once per tick). Otherwise it gets the sleeper's id from a one-entry cache keyed by `(thingIDNumber, TicksGame)`. `FindBedFor` asks about one sleeper for hundreds of beds in a row through its `GenClosest` validators (RestUtility.cs:235 onwards), so the cache nearly always hits. It refuses when the id is null and `allowNoCaste` is off, or when the id isn't in the set. - The check: in the animal zones' `CanUseBedNow` postfix, after the type and zone checks. It returns early when `__result` is already false, the zone has no caste limit, or the link isn't usable (bound and `Active`, read once per tick). Otherwise it gets the sleeper's id from a one-entry cache keyed by `(thingIDNumber, TicksGame)`. `FindBedFor` asks about one sleeper for hundreds of beds in a row through its `GenClosest` validators (RestUtility.cs:235 onwards), so the cache nearly always hits. It refuses when the id is null and `allowNoCaste` is off, or when the id isn't in the set.
- Caste changes: Castes moves pawns one tick after a join and calls no other mod, so Zones polls. The 250-tick sweep also silently unclaims owners of caste-limited beds who no longer pass, while the link is usable. A pawn asleep at that moment is woken by `Toils_Bed.BedNoLongerUsable` through the same postfix (Toils_Bed.cs:58-69). A pawn with another valid bed re-claims it on its own through `FindBedFor`. - Caste changes: Castes moves pawns one tick after a join and calls no other mod, so Zones polls. The 250-tick sweep also silently unclaims owners of caste-limited beds who no longer pass, while the link is usable. A pawn asleep at that moment is woken by `Toils_Bed.BedNoLongerUsable` through the same postfix (Toils_Bed.cs:58-69). A pawn with another valid bed re-claims it on its own through `FindBedFor`.
- Filter edits unclaim owners that no longer pass, with one message naming the count. - Filter edits unclaim owners that no longer pass, with one message naming the count.
- UI: a "Castes" section in the people-zone tab, shown only while bound. One checkbox per caste from `CasteLabels()`, sorted by label to match Castes' pickers, plus "Pawns without a caste". Stored ids whose caste is gone show greyed as "Deleted caste (last label)" with a remove button. While unbound with ids stored, the inspect pane says the caste limit is inactive because Blax Castes isn't loaded. The inspect pane also warns when no current pawn of the zone's owner type fits. - UI: a "Castes" section in the people-zone tab, shown only while bound. One checkbox per caste from `CasteLabels()`, sorted by label to match Castes' pickers, plus "Pawns without a caste". Stored ids whose caste is gone show greyed as "Deleted caste (last label)" with a remove button. While unbound with ids stored, the inspect pane says the caste limit is inactive because Blax Castes isn't loaded. The inspect pane also warns when no current pawn of the zone's owner type fits.
@ -714,7 +712,7 @@ Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 i
- **Settings:** Per people zone: caste list (empty, any caste) and "Pawns without a caste" (off), hidden without Castes. No global setting. - **Settings:** Per people zone: caste list (empty, any caste) and "Pawns without a caste" (off), hidden without Castes. No global setting.
- **Save and removal:** Caste ids are strings in the zone, saved in the component. Removing Castes keeps them, unused. Removing Castes and adding it back creates a new caste token, so old ids match no new caste and show as deleted castes instead of silently matching a new caste with the same number. Removing Zones drops them with the component; Castes keeps nothing for Zones. - **Save and removal:** Caste ids are strings in the zone, saved in the component. Removing Castes keeps them, unused. Removing Castes and adding it back creates a new caste token, so old ids match no new caste and show as deleted castes instead of silently matching a new caste with the same number. Removing Zones drops them with the component; Castes keeps nothing for Zones.
- **Replaces:** Nothing. - **Replaces:** Nothing.
- **Effort:** M, 2 days: the token, the cache, the sweep and the deleted-caste UI. - **Effort:** M: the token, the cache, the sweep and the deleted-caste UI.
- **Tests:** Run with Castes in `-Compat`; create castes through reflection on `BlaxCastes.CasteManager`, so the test mod gets no assembly reference to Castes. Skip without Castes. - **Tests:** Run with Castes in `-Compat`; create castes through reflection on `BlaxCastes.CasteManager`, so the test mod gets no assembly reference to Castes. Skip without Castes.
- Phase 1, with Castes: a zone limited to caste A refuses a caste B pawn and accepts an A pawn. Every id from `CasteLabels()` has the same token prefix as `CasteIdOf` returns. A casteless pawn is refused until "Pawns without a caste" is ticked. A bought slave queued by Castes is refused before `Tick(1)` and accepted after it. Assigning the owner to caste B unclaims its zone bed within 250 ticks, and a sleeping owner is woken. A deleted caste's id stays stored and matches nobody. With Castes' API switched off, the limits are ignored and nobody is evicted. Ids from an older token (simulate a new component) match no new caste. `GC.GetAllocatedBytesForCurrentThread` across 1,000 `CanUseBedNow` calls on a caste-limited bed stays below 1 KB. `FindBedFor` across 500 caste-limited cells fails above 10 ms. - Phase 1, with Castes: a zone limited to caste A refuses a caste B pawn and accepts an A pawn. Every id from `CasteLabels()` has the same token prefix as `CasteIdOf` returns. A casteless pawn is refused until "Pawns without a caste" is ticked. A bought slave queued by Castes is refused before `Tick(1)` and accepted after it. Assigning the owner to caste B unclaims its zone bed within 250 ticks, and a sleeping owner is woken. A deleted caste's id stays stored and matches nobody. With Castes' API switched off, the limits are ignored and nobody is evicted. Ids from an older token (simulate a new component) match no new caste. `GC.GetAllocatedBytesForCurrentThread` across 1,000 `CanUseBedNow` calls on a caste-limited bed stays below 1 KB. `FindBedFor` across 500 caste-limited cells fails above 10 ms.
- Phase 1, without Castes: the section is hidden, stored ids are ignored but kept. - Phase 1, without Castes: the section is hidden, stored ids are ignored but kept.
@ -722,11 +720,38 @@ Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 i
- Load hook: a save loaded with Castes just added keeps every stored id, although `CasteLabels()` is empty during map `FinalizeInit`. - Load hook: a save loaded with Castes just added keeps every stored id, although `CasteLabels()` is empty during map `FinalizeInit`.
- **Risks:** It depends on Castes shipping API version 1 with `Active`, the token and `List<KeyValuePair<string, string>>`. An older or different API means unbound, with one log line. - **Risks:** It depends on Castes shipping API version 1 with `Active`, the token and `List<KeyValuePair<string, string>>`. An older or different API means unbound, with one log line.
#### Headless tests in 1.6 #### Headless tests for the caste filter
- Castes joins the default `-Compat` set; the caste tests skip in plain runs. - 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. - A test helper builds castes through reflection only, so the test mod compiles without Castes.
## Zone tools and removal
Save-safe zone storage shipped with 1.0; its spec stays there ("Save-safe zone storage"). The removal button ships with whichever of work rule areas or animal sleeping zones comes first.
### Removal button
#### Remove Blax Zones from a game
- **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, work rule areas and flagged storage, whichever exist).
- With work rule areas 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.
- **Settings:** The button, enabled only while a game is loaded. No toggle.
- **Save and removal:** This is the removal.
- **Replaces:** Nothing.
- **Effort:** S.
- **Tests:**
- The confirm names the counts.
- Press the button with a chicken asleep in a zone bed, save, then save again (an autosave counts): neither file contains "BlaxZones", and `map.components` has no `MapComponent_BlaxZones` after either save.
- A map generated afterwards in the same game has no component, and a test-only MapComponent added after ours in the type list still had its `FinalizeInit` called.
- An orbital purchase and a caravan arrival behave like vanilla, log no error and don't bring the component back.
- Load the saved file (Zones' assembly is still loaded, so `FillComponents` adds a fresh, empty component for the new game): no errors, no "Could not resolve reference" warnings, and the chicken has no owned bed and no CurToil error.
- **Risks:** A mod that caches our component across saves would hold a dead object; none known.
## Works with the other Blax mods ## 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. - 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.
@ -735,26 +760,27 @@ Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 i
- `Version` (static int property), 1. - `Version` (static int property), 1.
- `bool TryFindDropSpot(Map map, Thing thing, out IntVec3 cell)`: respects zone filters, priority and drop rules, false if no zone fits. It uses the orbital rules (orbital ticked, pod rule, overflow setting), always returns false for a Pawn, and returns false instead of throwing. The cell is for one pod holding that one thing: the caller spawns it exactly there with `TradeUtility.SpawnDropPod(cell, map, thing)` or `DropPodUtility.MakeDropPodAt`, and calls again per thing, after spawning the last pod, because a falling pod is what marks its cell as taken. `DropThingsNear` would not do: `DropThingGroupsNear` searches a new random cell around the center for every group (DropPodUtility.cs:44), starting within 5 cells (DropCellFinder.cs:271-276), so the pod would usually miss a small zone. - `bool TryFindDropSpot(Map map, Thing thing, out IntVec3 cell)`: respects zone filters, priority and drop rules, false if no zone fits. It uses the orbital rules (orbital ticked, pod rule, overflow setting), always returns false for a Pawn, and returns false instead of throwing. The cell is for one pod holding that one thing: the caller spawns it exactly there with `TradeUtility.SpawnDropPod(cell, map, thing)` or `DropPodUtility.MakeDropPodAt`, and calls again per thing, after spawning the last pod, because a falling pod is what marks its cell as taken. `DropThingsNear` would not do: `DropThingGroupsNear` searches a new random cell around the center for every group (DropPodUtility.cs:44), starting within 5 cells (DropCellFinder.cs:271-276), so the pod would usually miss a small zone.
- A member for sleeping zones is added once a sibling needs one, with its meaning written down then. - A member for sleeping zones is added once a sibling needs one, with its meaning written down then.
- Zones reads from Blax Castes, in 1.6 only, through `CastesApi` version 1, which Castes' design plans for its 1.1 with the same table: - Zones reads from Blax Castes, for the caste filter only, through `CastesApi` version 1, Castes' read-only API, which Castes' design carries with the same table:
| Member | What Zones expects | Castes version | | Member | What Zones expects | API version |
|---|---|---| |---|---|---|
| `Version` | static int property, 1 or higher | 1 (Castes 1.1) | | `Version` | static int property, 1 or higher | 1 (Castes' read-only API) |
| `Active` | static bool; false with no game loaded or with Castes' `enableApi` off | 1 | | `Active` | static bool; false with no game loaded or with Castes' `enableApi` off | 1 |
| `CasteIdOf(Pawn)` | `"<token>:<id>"`, or null (no record, casteless by choice, or not Active). The token is a random int made once per `GameComponent_BlaxCastes` and saved with it; the string is cached on the caste, so a call allocates nothing | 1 | | `CasteIdOf(Pawn)` | `"<token>:<id>"`, or null (no record, casteless by choice, or not Active). The token is a random int made once per `GameComponent_BlaxCastes` and saved with it; the string is cached on the caste, so a call allocates nothing | 1 |
| `CasteLabels()` | `List<KeyValuePair<string, string>>` of (id, label), ids in the same `"<token>:<id>"` form, sorted by label; null while not Active | 1 | | `CasteLabels()` | `List<KeyValuePair<string, string>>` of (id, label), ids in the same `"<token>:<id>"` form, sorted by label; null while not Active | 1 |
| `HintJoinReason`, `NotifyJoined` | not used by Zones; Blax Slaves binds them by name | 2 (Castes 1.3) | | `HintJoinReason`, `NotifyJoined` | not used by Zones; Blax Slaves binds them by name | 2 (Castes' join API) |
| `PrePick(Pawn, string casteId)` | not used by Zones; takes the token-prefixed id | 3 (Castes 1.4) | | `PrePick(Pawn, string casteId)` | not used by Zones; takes the token-prefixed id | 3 (Castes' trade-row pre-pick) |
Castes needs no Zones code. Zones reads nothing from Blax Slaves. Castes needs no Zones code. Zones reads nothing from Blax Slaves.
- 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. - 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. - 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. - 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.5) 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). - Slave sleeping zones 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 Slaves' shared infirmary 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.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.4 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`. - 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 growing-zone defaults), 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' storage-delivery gizmos on the gizmo bar. Zone beds come from `AddCell`, not a frame, so Defaults' build scope for more storage 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.3) 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. - Work rule areas are per cell and never touch a pawn: Castes keeps the allowed area (its allowed-area slot), 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. - Each mod keeps its state in its own Map or Game components, or none (Defaults), so removing one leaves the others' saves intact.
- Blax Laws (designed on branch `design/act-catalogue` of `rimworld-blax-laws`, not built): its jail takes any prisoner bed, so its arrests use prisoner zone beds like any vanilla prisoner bed, with no code on either side. Its court place and courtrooms are stored by ThingID in Laws' own component, never as a zone, and Zones adds no jail, court or courtroom zone. Its package id and ownership line join this section once its design is accepted.
- 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. - 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.
## Backlog ## Backlog
@ -770,18 +796,21 @@ 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. - 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. - 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. - 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`. Work rule areas (1.3) would move with the same code, as vanilla moves the home area (GravshipPlacementUtility.cs:388). - 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 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. - 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. - 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. - "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. - "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. - 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. - 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.
- "Repair here" and "Fight fires here" outside the home area (new 2026-12-01, not checked against the code), one step together with "Clean here" above: the same home checks gate them (WorkGiver_Repair.cs:35, WorkGiver_FixBrokenDownBuilding.cs:56, WorkGiver_FightFires.cs:55). A postfix can't tell why vanilla refused, so each likely needs a transpiler on its home check. Vanilla ignores fires outside the home area; Repair Outside the Home Area is a small mod for repairs.
- Path rules (new 2026-12-01, not checked against the code): "Walk around" per work rule area, a path cost that never blocks a path; the allowed area stays the hard limit. [KV] Path Avoid (1180719857, 44,501 subs) stopped at 1.5. RimWorld 1.7 builds path costs in `PathFinderMapData` from `IPathFinderDataSource` sources (both names read from the 1.7.5021 reference assembly), so a source fed from the area mask is the likely hook. Needs the shared ownership line to read "per-cell work and path rules".
- "Visitors gather here" on delivery zones (new 2026-12-01, not checked against the code): visitor groups call the same `TryFindRandomSpotJustOutsideColony` overload as caravans (see "Trader caravans camp at a zone"), so a second scope on `IncidentWorker_VisitorGroup.CreateLordJob` would bring them to the zone. Smarter Visitors (3012491521, 137,980 subs, 1.7) has a visitor spot building; stand down while it is active.
## Cut ## Cut
- Pack animals walk purchases to the zone (L): many exit paths (lord transitions, duty reassignment, `ExitMap`, death, hostility), owed items must be hidden from the next trade, and nobody asked. Goods appearing plus caravan camping covers it. - Pack animals walk purchases to the zone (L): many exit paths (lord transitions, duty reassignment, `ExitMap`, death, hostility), owed items must be hidden from the next trade, and nobody asked. Goods appearing plus caravan camping covers it.
- Stockpile flags instead of a delivery zone in 1.0: most stockpiles are roofed, so pods couldn't use them without direct delivery, and a flagged outdoor stockpile mixes landing pods with stored goods. The delivery zone is a landing pad with its own source checkboxes and the camp option. It wouldn't spare the zone save work either, which sleeping zones need in 1.2 anyway. Flags arrive in 1.4 together with direct delivery. - Stockpile flags instead of a delivery zone in 1.0: most stockpiles are roofed, so pods couldn't use them without direct delivery, and a flagged outdoor stockpile mixes landing pods with stored goods. The delivery zone is a landing pad with its own source checkboxes and the camp option. It wouldn't spare the zone save work either, which sleeping zones need anyway. Flags arrive with storage deliveries, together with direct delivery.
- Shared zones by blocking `Pawn_Ownership.ClaimBedIfNonMedical`: the unowned sleeper fails `CanUseBedNow` (RestUtility.cs:142-146) and gets kicked out of bed in a loop. - Shared zones by blocking `Pawn_Ownership.ClaimBedIfNonMedical`: the unowned sleeper fails `CanUseBedNow` (RestUtility.cs:142-146) and gets kicked out of bed in a loop.
- Letter-target postfix on `QuestPart_DropPods.GetRandomDropSpot`: vanilla already points the letter at the first dropped thing, and the postfix would pull refugees and quest prisoners next to the zone. - Letter-target postfix on `QuestPart_DropPods.GetRandomDropSpot`: vanilla already points the letter at the first dropped thing, and the postfix would pull refugees and quest prisoners next to the zone.
- Defeat-all-enemies rewards (`DefeatAllEnemiesQuestComp.GiveRewardsAndSendLetter`): nothing in vanilla 1.7 calls its `StartQuest`, so it never becomes active (RimWorld.Planet/DefeatAllEnemiesQuestComp.cs:25-55), and its letter would point at the trade spot (:74-81). - Defeat-all-enemies rewards (`DefeatAllEnemiesQuestComp.GiveRewardsAndSendLetter`): nothing in vanilla 1.7 calls its `StartQuest`, so it never becomes active (RimWorld.Planet/DefeatAllEnemiesQuestComp.cs:25-55), and its letter would point at the trade spot (:74-81).
@ -804,11 +833,11 @@ Ships once Blax Castes publishes `CastesApi` version 1, planned for Castes 1.1 i
- 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. - 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. - 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 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.3), and a work rule area could shadow an allowed area of the same name for Blax Castes. - 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" under Work rule areas), 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. - 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 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. - "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. - Firefighting first and repair first: fires are already an emergency handled closest first, and repair order has its own 1.7 mod, Repairing Priority (3229907892, 2,188 subs).
- Doctor, warden or other work types first: their targets are pawns and beds, not places. - 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. - 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. - 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.

138
docs/features.md Normal file
View File

@ -0,0 +1,138 @@
# Blax Zones feature plan
Blax Zones decides where things arrive, where animals and people sleep, and how colonists treat a place. Complete, it routes every friendly arrival (trade, quest rewards, cargo, aid) into zones and storage you pick, beds a whole barn, dorm or prison with one drag, and lets you paint areas where nobody cleans, everything is hauled first or pawns walk around. Every part has its own toggle, works with any DLC combination and leaves a loadable save when you unsubscribe.
Status: 1.0 (delivery zones, caravan camps) and 1.1 (quest rewards, caravan purchases) are on the Workshop as item 3848261160. Everything else below is designed or proposed, with no code yet.
Planned 2026-12-01. This file says what the mod covers, grouped by what belongs together, and in which order it gets built. How each feature works is in [design.md](design.md).
Status values:
- **Shipped x.y**: on the Workshop.
- **Designed**: specified in design.md and checked against the RimWorld 1.7.5021 code.
- **New**: proposed in this plan. Not checked against the code unless the line says so.
- **Idea**: kept on the list; it waits for player demand or for content that uses it.
## Scope
Zones covers three things:
- every friendly drop location: where bought goods, quest rewards, cargo and friendly aid land, and where trader caravans camp;
- sleeping spots and beds by zone, for animals and people;
- per-cell work rules (work rule areas).
What it leaves to the other Blax mods:
- **Blax Castes**: every per-pawn setting, including work priorities and the allowed area. Work rule areas apply to everyone on a cell and never change a pawn.
- **Blax Defaults**: starting settings of vanilla stockpiles, growing zones, storage, bills, animals and mechs, and what gets forbidden when pawns go down, die or are stripped. A new stockpile starts unflagged for deliveries; Zones' flags live in Zones.
- **Blax Slaves**: slave status, trade, prices and how much a payout is. Zones only hands Slaves a cell for its silver pods.
- **Blax Laws** (designed, not built): the lawbook, arrests, jail, court places and courtrooms. Laws' jail takes any prisoner bed, so prisoner sleeping zones serve it with no code on either side. Court places and courtrooms are Laws' own, stored by ThingID; Zones adds no jail, court or courtroom zone.
Pawns are never routed into zones. Bought people and animals, refugees, quest pawns, ransomed and lent colonists arrive as in vanilla.
## Arrivals: deliveries and caravan camps
Vanilla drops everything next to the first trade beacon, quest rewards included, and caravans camp at a random spot outside the base. The mods that fixed this (Trade Ships Drop Spot 206k, Trading Control 111k, the Trading Spot mods) are dead or stop at 1.6. Zones makes a delivery zone the landing pad and the meeting point, then extends it to storage and to every other friendly source.
1. **Delivery zones and caravan camps**: Shipped 1.0.
- Delivery zone with item filter, priority, source checkboxes and unusable cells marked red. Shipped 1.0 ([spec](design.md#delivery-zone)).
- Orbital purchases and sale silver land in the best zone, overflow next to it. Shipped 1.0 ([spec](design.md#orbital-purchases-land-in-the-zone)).
- Trader caravans and tribute collectors camp next to a zone you pick. Shipped 1.0 ([spec](design.md#trader-caravans-camp-at-a-zone)).
2. **Quest rewards and caravan purchases**: Shipped 1.1.
- Item rewards land in the zone and the letter points there. Shipped 1.1 ([spec](design.md#quest-rewards-land-in-the-zone)).
- Goods bought from caravans and Hospitality guests appear in the zone, roofed or not. Shipped 1.1 ([spec](design.md#caravan-purchases-appear-in-the-zone)).
3. **Storage as a delivery target**: Designed. These three share one flag set in the map component, one storage-group rule and one gizmo family. Most freezers and hospital shelves are roofed, so the delivery flag is worth little without delivery under a roof.
- A "Receive deliveries" gizmo on stockpiles, shelves, racks and fridges: medicine straight onto the hospital shelf, by the shelf's own filter and priority. Designed ([spec](design.md#stockpiles-and-shelves-receive-deliveries)).
- Delivery under a roof: goods appear in place, no drop pod, off by default. Designed ([spec](design.md#delivery-under-a-roof)).
- Sell zone: orbital traders buy from flagged storage and take payment from it while a powered beacon stands, off by default. Designed ([spec](design.md#sell-zone)).
4. **More arrival sources**: independent of step 3, it needs only the reward routing from 1.1.
- Random cargo pod events land in a zone with "Cargo pods" ticked, off by default. Designed ([spec](design.md#cargo-pod-events-land-in-the-zone)).
- Vanilla Events Expanded's apparel and weapon pods join the cargo pods. Idea ([backlog](design.md#backlog)). Needs that mod.
- Ally reinforcements and aid drop next to a chosen zone, never hostile drops. Idea; Allies Spot (2067847359, 3,678 subs) shows small demand.
- Returning player caravans unload into a delivery zone. Idea; UnloadHere (522) and Homecoming (207) show small demand.
- Royal title rewards land in the zone. Idea, waits for content: no vanilla title and no mod in the active list defines title rewards. Needs Royalty.
5. **Polish and small extensions**: each stands alone.
- Unusable cells counted by reason in the inspect pane (roof, water, pen, building). Idea.
- Fewer drop pods by batching stacks. Idea; the only such mod has 1.8k subscribers and nobody asked.
- "Visitors gather here" next to "Caravans camp here", for visitor groups. New, Idea. Smarter Visitors (3012491521, 137,980 subs, alive on 1.7) has a visitor spot building, so this would stand down while it is active. Hook: visitor groups already call the patched `TryFindRandomSpotJustOutsideColony` overload (design, "Trader caravans camp at a zone"); a second scope on `IncidentWorker_VisitorGroup.CreateLordJob`. Not checked against the code.
Why this order: 1.0 built the zone, the router and the API that everything else calls; 1.1 added the delivery context the reward, cargo and aid paths share. Storage targets come before more sources because they change where every existing source can land.
## Work rule areas
The home area switches cleaning, firefighting and repairs on and off together, an allowed area restricts a pawn for every job, and nothing orders work by place. CleaningArea (114k, last 1.4) and Cleaning Area Relaunched (23k, 1.6 only) were the usual fix, and neither runs on 1.7. Fabian asked for "No cleaning" and "Priority zones" on 2026-11-29. Work rule areas are one painted layer of named areas that lie over anything, up to 10 per map, each with rule checkboxes.
1. **Areas and the six rules**: Designed. One step: Fabian's request covers both kinds of rule, and they share the layer, the mask and the manage window.
- Paint, name and manage work rule areas over stockpiles, fields and other zones. Designed ([spec](design.md#paint-and-manage-work-rule-areas)).
- "No cleaning", "No firefighting", "No repairs", "Don't haul from here". Right-click orders still work everywhere. Designed ([spec](design.md#no-cleaning-firefighting-repairs-or-hauling)).
- "Clean first" and "Haul first", within the pawn's own work priorities and allowed area. Designed ([spec](design.md#clean-first-and-haul-first)).
2. **Home-area work outside the home area**: New. Three inverse rules, "Clean here", "Repair here" and "Fight fires here", for a field, a mine entrance or an outpost wall outside the home area, without growing the home area, which would also forbid what pawns drop there and auto-rebuild. The backlog had "Clean here" alone; repairs and firefighting sit behind the same home checks (design: WorkGiver_Repair.cs:35, WorkGiver_FightFires.cs:55, WorkGiver_FixBrokenDownBuilding.cs:56). Demand is thin so far: vanilla ignores fires outside the home area (RimWorld wiki, Firefighting), and a small mod, Repair Outside the Home Area, exists for repairs (subscriber count not read). Hook: a postfix can't tell why vanilla said no, so this likely needs a transpiler on the home check in each `HasJobOnThing`, plus the cleaning job driver's home jumps (JobDriver_CleanFilth.cs:31, 70). Not checked against the code. It comes after step 1 because it adds bits to the same mask and rows to the same window.
3. **Path rules**: New. "Walk around" per area, so pawns path around a killbox, a nursery or a freezer door unless there is no other way. It never blocks a path; the allowed area stays the hard limit. Demand: [KV] Path Avoid (1180719857, 44,501 subs) stopped at 1.5; Pathfinding Avoidance (1.6) does it by treating allowed areas with fixed names as costly, so those names also show up in every allowed-area picker. Hook: 1.7 builds path costs in `PathFinderMapData` from `IPathFinderDataSource` sources (both names are in the 1.7.5021 reference assembly), so a source fed from the area mask. Behaviour not checked against the code. Needs the ownership change in the open questions.
4. **More rules, each waiting for demand**: Ideas ([backlog](design.md#backlog)).
- "Build first": frame order has build-order effects, and Smarter Construction (1M subs, 1.7) already reorders construction.
- "Plant work first": growing zones already split fields, and Growing Zone Priorities (Continued) ranks them.
- "Don't haul from here" with an item filter, for example leave weapons, haul corpses.
- "No auto-rebuild", for killbox barricades the player wants left broken.
- Hide the "Fire in home area" alert for fires in "No firefighting" areas.
## Sleeping zones
Animal sleeping spots and dorm sleeping spots are placed one at a time. Designator Shapes and BuilderTweaksReplica help place them in bulk, and the spots then clutter the map (Hidden Spots exists for that). A zone whose every cell is a bed does both jobs. The beds are real but invisible, so ownership, prisoner capture, patients and the bed alerts keep working with vanilla code.
1. **Animals**: Designed. Zone beds are built on the simplest sleepers first: no owner types, no prison rules.
- Animal sleeping zone: one drag over the barn beds every chicken. Designed ([spec](design.md#animal-sleeping-zones)).
- Species checkboxes and a body-size range, so big stalls stay free of chickens. Designed ([spec](design.md#which-animals-may-sleep-here)).
- Needs the removal button (Zone tools) at the latest here, because zone beds make a plain unsubscribe noisy.
2. **People**: Designed. The same zone beds with an owner type.
- Sleeping zones for colonists, slaves (Ideology) and prisoners; a prisoner zone makes its room a prison cell, and vanilla beds are never flipped without asking. Designed ([spec](design.md#sleeping-zones-for-colonists-slaves-and-prisoners)).
- Medical zones (people and animals), shared zones where nobody keeps a cell, sleeping-spot comfort. Designed ([spec](design.md#medical-shared-and-comfort)).
- Zone tint by type and claimed and free counts in the inspect pane. Designed ([spec](design.md#visible-zone-state)).
3. **By caste**: Designed. With Blax Castes, a people zone can be limited to castes, medical zones included. Needs Castes' read-only API (CastesApi version 1) ([spec](design.md#sleeping-zones-by-caste)).
4. **Ideas**:
- Age limits on people zones, for example a nursery. Needs Biotech. Nobody asked yet.
- Animals sleep on a stockpile, so the barn's hay stockpile is also the sleeping area. Zone beds can't overlap zones today; two zones in one barn work.
Why this order: people zones reuse the animal zone beds and add owner types; the caste filter is one more check in the same bed postfix and waits for Castes' API, so it can move up as soon as Castes ships that.
## Zone tools and removal
What every zone, bed and area needs: a save that survives removing the mod, and setup that doesn't repeat.
- Save-safe zone storage: zones live in Zones' own map data, never in the game's zone list. Shipped 1.0 ([spec](design.md#save-safe-zone-storage)).
- "Remove Blax Zones from this game" button: strips zone beds, work rule jobs and areas, so the save loads with no errors after unsubscribing. Designed ([spec](design.md#remove-blax-zones-from-a-game)). Ships with whichever of work rule areas or animal sleeping zones comes first.
- "Make default" for new delivery and sleeping zones, kept in Zones' own file, as Blax Defaults does for vanilla zones. Idea.
- Blax zones and work rule areas fly with Odyssey gravships. Idea; Odyssey isn't on the test machine, so it can't be built or tested yet.
- A full removal test that relaunches the game without Zones. Idea, test-only.
## For other mods
- `ZonesApi` version 1, `TryFindDropSpot`: a cell for one drop pod in or next to a delivery zone. Shipped 1.0. Blax Slaves binds it for its silver payouts.
- Whether API drops follow the global "Route orbital trade" switch: open question below.
- A member for sleeping zones, added once a sibling needs one. Idea.
## Order
1. **Work rule areas, step 1, with the removal button.** Fabian's own request, no cleaning-area mod runs on 1.7, and it needs only the shipped map component. The removal button ships here because the two work givers leave one error per job after a plain unsubscribe.
2. **Sleeping zones, animals then people.** Zone beds are the base both share; people add owner types and the prison rules on top.
3. **Arrivals, storage as a delivery target, then cargo pods.** They extend paths that already work, so they matter less than the missing features above.
4. **Sleeping zones by caste** as soon as Castes ships its read-only API. It can jump ahead of step 3.
5. **The new steps** (home-area work outside the home area, path rules) and the ideas, as players ask.
## Left out
The reasons are in design.md's [Cut](design.md#cut). In short:
- pack animals walking purchases to the zone, roof-punching pods, and patching the vanilla trade drop spot globally, which would let raiders drop into the zone;
- sleeping zones without beds, and people and animals in one zone;
- work rules as vanilla zones or areas, one layer per rule, "first" rules for firefighting, repairs, doctors or wardens (Repairing Priority, 2,188 subs on 1.7, covers repair order for those who want it), and blocking right-click orders;
- routing ransom returns, lent colonists, quest pawns, wastepacks and royal permit drops;
- Trading Control's marketplace stall and per-cell spot graphics, which need art;
- anything Castes, Defaults, Slaves or Laws owns (see Scope);
- multiplayer, until a 1.7 build of the Multiplayer mod exists to test against.
## Open questions for Fabian
1. **Work rule areas before sleeping zones?** On 2026-11-30 animal sleeping zones stayed first and work rule areas moved up to second. Grouped by area, sleeping zones are now one chunk with people and castes, which would push work rule areas behind all of it. Recommendation: build work rule areas first, with the removal button.
2. **Do other mods' drops follow "Route orbital trade"?** Today `ZonesApi.TryFindDropSpot` follows each zone's orbital checkbox but ignores the global switch (`ZonesApi.cs` calls the router directly; only `DeliveryRouter.Orbital.cs:23` reads `routeOrbital`). Recommendation: follow it. One switch then means "orbital pods go to zones", and its tooltip names Blax Slaves' payouts while Slaves is active.
3. **Path rules widen Zones' ownership line** from "per-cell work rules" to "per-cell work and path rules", in all five docs. No sibling owns pathing, and Castes' allowed area stays the hard limit. Recommendation: yes, and build it after the home-area rules.
4. **Bought animals land in a zone**, for example outside the pen gate. It needs the shared rule "pawns are never routed into zones" narrowed to people. Recommendation: no for now; nobody asked, and that rule is what keeps refugees and raiders out of delivery zones.

View File

@ -34,10 +34,10 @@
[img]https://cdn.blax.at/blax-gaming/zones/planned.png[/img] [img]https://cdn.blax.at/blax-gaming/zones/planned.png[/img]
Not in this version yet. Planned for the next releases: Not in this version yet. Planned for the next releases:
[list] [list]
[*]🐔 Animal sleeping zones: every cell is a sleeping spot, with species and body-size filters.
[*]🧹 Work rule areas: paint areas where nobody cleans, fights fires, repairs or hauls from, or that get cleaned and hauled first. [*]🧹 Work rule areas: paint areas where nobody cleans, fights fires, repairs or hauls from, or that get cleaned and hauled first.
[*]🗄️ Deliveries straight into stockpiles and shelves, sell zones for orbital traders, cargo pods into a zone. [*]🛏️ Sleeping zones: every cell a sleeping spot, for animals with species and body-size filters, and for colonists, prisoners and slaves (slaves need Ideology). With Blax Castes, limited by caste.
[*]🛏️ Sleeping zones for colonists, prisoners and slaves (slaves need Ideology). [*]🗄️ More arrivals: deliveries straight into stockpiles and shelves, also under a roof, sell zones for orbital traders, cargo pods into a zone.
[*]🧰 A button that removes Blax Zones from a save with no errors.
[/list] [/list]
[img]https://cdn.blax.at/blax-gaming/zones/replaces.png[/img] [img]https://cdn.blax.at/blax-gaming/zones/replaces.png[/img]