Compare commits

..

2 Commits

Author SHA1 Message Date
Fabian @ Blax Software 892062c54f feat: Blax Defaults 1.1: forbid rules
Rules for your colony and for enemies allow what the game forbids when their pawns go down or die if it matches a filter with hit point and quality ranges, once the fight is over. Stripping can forbid what doesn't match; three corpse switches. Overlap warnings for KilledEnemyAutoAllowed, Allow Everything, Non uno Pinata and Allow Dead Animals. The test runner fails on stray mod errors.
2026-11-30 22:33:42 +01:00
Fabian @ Blax Software 4f08c30f66 docs: forbid rules decision and 1.1 status
Ticking a rule without a filter applies its suggested setup.
2026-11-30 22:33:42 +01:00
25 changed files with 2660 additions and 66 deletions

Binary file not shown.

Binary file not shown.

View File

@ -3,7 +3,7 @@
<name>Blax Defaults</name>
<author>Blax Gaming</author>
<packageId>blax.defaults</packageId>
<modVersion>1.0.0</modVersion>
<modVersion>1.1.0</modVersion>
<supportedVersions>
<li>1.7</li>
</supportedVersions>
@ -18,7 +18,7 @@
<loadAfter>
<li>brrainz.harmony</li>
</loadAfter>
<description>Your own starting settings for new stockpiles, shelves and bills. Set up one shelf, click "Make default for new shelves", and every new shelf starts like it. Nothing changes until you save a default, and the things you already have keep their settings. Works with any DLC combination, core only included; 1.0 needs no DLC. Colonists, slaves and prisoners: Blax Castes.
<description>Your own starting settings for new stockpiles, shelves and bills, and rules for what stays forbidden when pawns go down, die or are stripped. Set up one shelf, click "Make default for new shelves", and every new shelf starts like it. Nothing changes until you save a default or turn a rule on, and the things you already have keep their settings. Works with any DLC combination, core only included; no feature needs a DLC. Colonists, slaves and prisoners: Blax Castes.
&lt;color=#19C63C&gt;Storage&lt;/color&gt;
- New stockpiles and dumping stockpiles start with the filter and priority you saved for that type.
@ -31,13 +31,20 @@
- Values for every new bill: repeat mode, count and target, pause when satisfied and resume at, ingredient radius, allowed skill range, where products go (best stockpile or drop on floor), and the counting options.
- Only the values you change are applied. Surgery, mech gestation, pasted bills and the bills you already have are left alone.
&lt;color=#19C63C&gt;Forbid rules&lt;/color&gt;
- Gear rules for your colony and for enemies: when a pawn goes down or dies, what the game forbids is allowed again if it matches your filter, with hit points and quality ranges. For example enemy weapons only at 50 to 100% and Normal or better, their food, medicine, drugs and silver always. The rest stays forbidden.
- Allowed things wait until no enemy that can still fight is on the map. A downed colonist's own weapon stays forbidden while the colonist lies where it fell, so it picks the weapon up again.
- Stripping can forbid what doesn't match, such as a Poor tuque. Butchering stays as it is.
- Animal, enemy and other corpses outside the home area can stay allowed.
- Every rule ships off. Ticking a rule uses a suggested setup you can edit. What neutral visitors, traders and quest lodgers drop keeps the game's flags.
&lt;color=#19C63C&gt;Your defaults stay&lt;/color&gt;
- Defaults live in their own file in the game's Config folder, shared by every save. Nothing goes into your save, so you can add or remove the mod in a running colony.
- Each write is checked before it replaces the file, with a backup that a broken file never overwrites.
- Items from a mod you removed are skipped, not lost, and work again when the mod comes back.
- The settings page lists every default with Edit and Forget, and names mods that set the same things.
- The settings page lists every default with Edit and Forget, and names mods that do the same things.
Planned for later releases: rules for what stays forbidden when pawns go down or die (1.1), more storage, recipe and workbench bills (1.2), animals (1.3), crops and building settings (1.4), mech work modes (1.5, needs Biotech).
Planned for later releases: more storage, recipe and workbench bills (1.2), animals (1.3), crops and building settings (1.4), mech work modes (1.5, needs Biotech).
Multiplayer: not supported yet.

View File

@ -1,5 +1,18 @@
# Changelog
## 1.1.0
- Forbid rules, a new section on the settings page. Every rule ships off, so nothing changes until you turn one on.
- Gear rules for your colony and for enemies: when one of the group's pawns goes down or dies, what the game forbids is allowed again if it matches the rule's filter, the vanilla item filter with hit points and quality ranges and the special filters (tainted, biocoded, rotten, smeltable). What doesn't match stays forbidden, and a rule never forbids a dropped thing the game left allowed. Your colony is colonists, slaves, colony mechs, colony animals and prisoners, also while they break out or rebel; enemies are everyone else hostile to you. Neutral visitors, traders and quest lodgers keep the game's rules.
- Each rule has Edit, Forget (which asks first and turns the rule off), "Where" (anywhere, or only inside the home area) and "Use the suggested setup" (which asks first). Ticking a rule that has no filter yet saves its suggested setup and says so. Suggested for enemies: every item, but hit points 50 to 100% and Normal or better, stripping on, so a Poor rifle or one below 50% stays forbidden while food, medicine, drugs and silver are allowed. Suggested for your colony: every item, any hit points and quality, stripping off.
- Wait until the fight is over: what a rule allows waits while an enemy that can still fight is on the map, and is allowed once none is left. Changing a waiting thing's flag yourself takes it off the list. A save and reload forgets the list, so things still waiting stay forbidden.
- A downed colonist's own weapon stays forbidden while the colonist lies where it fell, so it picks the weapon up after getting up, as in vanilla. Once the colonist is rescued, carried off or dies, the rule decides.
- "Stripping forbids what doesn't match", per rule: stripping one of the group's pawns or corpses forbids each dropped thing the filter refuses. Butchering strips too, but what a butcher strips stays allowed.
- Three corpse switches: animal, enemy and other corpses outside the home area stay allowed. Manhunters and predators count as animals. They wait for the fight to end like the gear rules.
- The filters live in the defaults file next to your other defaults; the switches are mod settings. Nothing goes into your save.
- Overlap warnings also name KilledEnemyAutoAllowed (Continued), Allow Everything, Non uno Pinata and Allow Dead Animals, and now say "do some of the same things" instead of "set the same starting settings".
- With Hospitality, a downed colonist doesn't remember its weapon (Hospitality drops it without that), so the colony rule decides the weapon once the fight is over instead of waiting for the colonist.
## 1.0.0
- Stockpile defaults: drag a stockpile or a dumping stockpile and it starts with the filter and priority you saved for that type. A modded stockpile designator that builds on the vanilla one is a type of its own. An Expand drag that grows a zone leaves its filter alone.

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<LanguageData>
<!-- Work package "forbid" (1.1 Forbid rules). Keys start with BlaxDefaults_. -->
<!-- Settings page section -->
<BlaxDefaults_ForbidSection>Forbid rules</BlaxDefaults_ForbidSection>
<BlaxDefaults_ForbidToggle>Forbid rules act when pawns go down, die or are stripped</BlaxDefaults_ForbidToggle>
<BlaxDefaults_ForbidToggleTip>Off: dropped gear, stripped things and corpses keep the game's forbidden flags. The rules and filters below stay saved.</BlaxDefaults_ForbidToggleTip>
<!-- The two gear rules -->
<BlaxDefaults_ForbidColonyRule>Gear your colony drops</BlaxDefaults_ForbidColonyRule>
<BlaxDefaults_ForbidColonyRuleTip>When a colonist, slave, colony mech, colony animal or prisoner goes down or dies, what the game forbids is allowed again when the filter allows it, once the fight is over. The rest stays forbidden. A downed colonist's own weapon stays forbidden while the colonist lies where it fell, so it picks the weapon up after getting up. Ticking the rule before it has a filter uses the suggested setup.</BlaxDefaults_ForbidColonyRuleTip>
<BlaxDefaults_ForbidEnemyRule>Gear enemies drop</BlaxDefaults_ForbidEnemyRule>
<BlaxDefaults_ForbidEnemyRuleTip>When anyone hostile to you goes down or dies, what the game forbids is allowed again when the filter allows it, once the fight is over. The rest stays forbidden. Ticking the rule before it has a filter uses the suggested setup.</BlaxDefaults_ForbidEnemyRuleTip>
<BlaxDefaults_ForbidNoFilter>No filter yet. Ticking the rule saves the suggested setup; Edit makes your own.</BlaxDefaults_ForbidNoFilter>
<BlaxDefaults_ForbidFilterMissing>The rule is on, but its filter is not loaded (the defaults file could not be read), so it acts as off.</BlaxDefaults_ForbidFilterMissing>
<BlaxDefaults_ForbidWhere>Where</BlaxDefaults_ForbidWhere>
<BlaxDefaults_ForbidWhereAnywhere>Anywhere</BlaxDefaults_ForbidWhereAnywhere>
<BlaxDefaults_ForbidWhereHome>Only inside the home area</BlaxDefaults_ForbidWhereHome>
<BlaxDefaults_ForbidWhereTip>Where a dropped or stripped thing must lie for the rule to act. Inside the home area the game already leaves dropped food and medicine allowed and forbids only weapons and what enemies carried.</BlaxDefaults_ForbidWhereTip>
<BlaxDefaults_ForbidStrip>Stripping forbids what doesn't match</BlaxDefaults_ForbidStrip>
<BlaxDefaults_ForbidStripTip>Stripping one of the group's pawns or corpses forbids each dropped thing the filter refuses; the rest stays allowed. Butchering strips too, but what a butcher strips stays allowed.</BlaxDefaults_ForbidStripTip>
<BlaxDefaults_ForbidStripNeedsFilter>Tick the rule or edit its filter first.</BlaxDefaults_ForbidStripNeedsFilter>
<BlaxDefaults_ForbidUseSuggested>Use the suggested setup</BlaxDefaults_ForbidUseSuggested>
<BlaxDefaults_ForbidUseSuggestedConfirm>Replace the filter of "{0}" with the suggested setup? {1}</BlaxDefaults_ForbidUseSuggestedConfirm>
<BlaxDefaults_ForbidSuggestedColony>Every item, any hit points and quality, anywhere, stripping off.</BlaxDefaults_ForbidSuggestedColony>
<BlaxDefaults_ForbidSuggestedEnemies>Every item, but hit points 50 to 100% and Normal or better, anywhere, stripping on. A Poor rifle or one below 50% stays forbidden; food, medicine, drugs and silver are allowed.</BlaxDefaults_ForbidSuggestedEnemies>
<BlaxDefaults_ForbidUsedSuggested>Using the suggested setup for "{0}": {1}. Edit changes it.</BlaxDefaults_ForbidUsedSuggested>
<BlaxDefaults_ForbidForgetConfirm>Forget the filter of "{0}"? The rule and its strip switch turn off, and dropped gear keeps the game's flags again.</BlaxDefaults_ForbidForgetConfirm>
<BlaxDefaults_ForbidNeutral>What neutral visitors, traders and quest lodgers drop keeps the game's flags.</BlaxDefaults_ForbidNeutral>
<!-- What a rule's filter allows, on its row -->
<BlaxDefaults_ForbidSummaryAll>all items</BlaxDefaults_ForbidSummaryAll>
<BlaxDefaults_ForbidSummaryNone>no items</BlaxDefaults_ForbidSummaryNone>
<BlaxDefaults_ForbidSummarySome>allows {0} of {1} items</BlaxDefaults_ForbidSummarySome>
<BlaxDefaults_ForbidSummaryHitPoints>hit points {0} to {1}%</BlaxDefaults_ForbidSummaryHitPoints>
<BlaxDefaults_ForbidSummaryQualityMin>{0} or better</BlaxDefaults_ForbidSummaryQualityMin>
<BlaxDefaults_ForbidSummaryQualityMax>up to {0}</BlaxDefaults_ForbidSummaryQualityMax>
<BlaxDefaults_ForbidSummaryQualityOnly>only {0}</BlaxDefaults_ForbidSummaryQualityOnly>
<BlaxDefaults_ForbidSummaryQualityRange>{0} to {1}</BlaxDefaults_ForbidSummaryQualityRange>
<BlaxDefaults_ForbidSummaryRefuses>refuses: {0}</BlaxDefaults_ForbidSummaryRefuses>
<!-- The filter's edit window -->
<BlaxDefaults_ForbidEditTitle>Filter: {0}</BlaxDefaults_ForbidEditTitle>
<BlaxDefaults_ForbidUnlistedTip>Items the filter lists neither as allowed nor as refused, such as items a mod adds later. "Refuse them" leaves them forbidden; "allow them" lets the hit points and quality ranges decide.</BlaxDefaults_ForbidUnlistedTip>
<!-- Corpse switches -->
<BlaxDefaults_ForbidCorpsesHeader>The game forbids new corpses outside the home area. These switches leave them allowed, once the fight is over:</BlaxDefaults_ForbidCorpsesHeader>
<BlaxDefaults_ForbidCorpsesAnimal>Animal corpses outside the home area are allowed</BlaxDefaults_ForbidCorpsesAnimal>
<BlaxDefaults_ForbidCorpsesAnimalTip>Any animal: wild ones, yours, manhunters and predators.</BlaxDefaults_ForbidCorpsesAnimalTip>
<BlaxDefaults_ForbidCorpsesEnemy>Enemy corpses outside the home area are allowed</BlaxDefaults_ForbidCorpsesEnemy>
<BlaxDefaults_ForbidCorpsesEnemyTip>Anyone hostile to you that is not an animal: raiders, hostile mechs and the like.</BlaxDefaults_ForbidCorpsesEnemyTip>
<BlaxDefaults_ForbidCorpsesOther>Other corpses outside the home area are allowed</BlaxDefaults_ForbidCorpsesOther>
<BlaxDefaults_ForbidCorpsesOtherTip>Everyone else: your own colonists and mechs, neutral visitors, traders.</BlaxDefaults_ForbidCorpsesOtherTip>
<!-- Overlap warnings: what each forbid mod does -->
<BlaxDefaults_OverlapWhatForbid>Leaves everything pawns drop when they go down or die allowed, corpses too</BlaxDefaults_OverlapWhatForbid>
<BlaxDefaults_OverlapWhatAllowEverything>Allows the items on the map, also what a forbid rule leaves forbidden</BlaxDefaults_OverlapWhatAllowEverything>
<BlaxDefaults_OverlapWhatPinata>Keeps gear on pawns that go down or die, so little drops for the forbid rules to sort</BlaxDefaults_OverlapWhatPinata>
<BlaxDefaults_OverlapWhatDeadAnimals>Allows animal corpses, like the animal corpse switch</BlaxDefaults_OverlapWhatDeadAnimals>
</LanguageData>

View File

@ -5,7 +5,7 @@
<!-- Settings page: master toggle and status -->
<BlaxDefaults_PageEnabled>Apply saved defaults to new things</BlaxDefaults_PageEnabled>
<BlaxDefaults_PageEnabledTip>Off: nothing new gets a default, and every new stockpile, storage building and bill starts with the game's settings. Your saved defaults stay in the file.</BlaxDefaults_PageEnabledTip>
<BlaxDefaults_PageEnabledTip>Off: nothing new gets a default, every new stockpile, storage building and bill starts with the game's settings, and the forbid rules act on nothing. Your saved defaults stay in the file.</BlaxDefaults_PageEnabledTip>
<BlaxDefaults_PageStatusNone>No defaults saved yet.</BlaxDefaults_PageStatusNone>
<BlaxDefaults_PageStatusOne>1 default.</BlaxDefaults_PageStatusOne>
<BlaxDefaults_PageStatusMany>{0} defaults.</BlaxDefaults_PageStatusMany>

View File

@ -18,17 +18,17 @@
<BlaxDefaults_QuickSetupSaved>Saved {0} empty defaults.</BlaxDefaults_QuickSetupSaved>
<!-- Overlap warnings -->
<BlaxDefaults_WarnOverlaps>Warn about mods that set the same defaults</BlaxDefaults_WarnOverlaps>
<BlaxDefaults_WarnOverlaps>Warn about mods that do the same things</BlaxDefaults_WarnOverlaps>
<BlaxDefaults_WarnOverlapsTip>Names them here and shows one window on the first game you load in a session. "Don't remind me" in that window hides a mod from the window, not from this page.</BlaxDefaults_WarnOverlapsTip>
<BlaxDefaults_OverlapSettingsIntro>These active mods set some of the same starting settings:</BlaxDefaults_OverlapSettingsIntro>
<BlaxDefaults_OverlapSettingsIntro>These active mods do some of the same things as Blax Defaults:</BlaxDefaults_OverlapSettingsIntro>
<BlaxDefaults_OverlapLine>{MOD}: {WHAT}</BlaxDefaults_OverlapLine>
<BlaxDefaults_OverlapAdvice>Set each of these in one mod only, or the two overwrite each other.</BlaxDefaults_OverlapAdvice>
<BlaxDefaults_OverlapTitle>Mods that set the same defaults</BlaxDefaults_OverlapTitle>
<BlaxDefaults_OverlapMessage>{MODS} set some of the same starting settings as Blax Defaults. Set each of these in one mod only, or the two overwrite each other. The Blax Defaults settings page lists them too.</BlaxDefaults_OverlapMessage>
<BlaxDefaults_OverlapAdvice>Use each of these features in one mod only, or the two work against each other.</BlaxDefaults_OverlapAdvice>
<BlaxDefaults_OverlapTitle>Mods that do the same things</BlaxDefaults_OverlapTitle>
<BlaxDefaults_OverlapMessage>Blax Defaults does some of the same things as {MODS}. Use each of those features in one mod only, or the two work against each other. The Blax Defaults settings page lists them too.</BlaxDefaults_OverlapMessage>
<BlaxDefaults_OverlapDontRemind>Don't remind me</BlaxDefaults_OverlapDontRemind>
<BlaxDefaults_OverlapDismissed>Not shown again</BlaxDefaults_OverlapDismissed>
<!-- What each overlapping mod sets -->
<!-- What each overlapping mod does -->
<BlaxDefaults_OverlapWhatDefaults>Starting settings for stockpiles, storage buildings and bills</BlaxDefaults_OverlapWhatDefaults>
<BlaxDefaults_OverlapWhatFsfShelves>Shelves start empty at Normal</BlaxDefaults_OverlapWhatFsfShelves>
<BlaxDefaults_OverlapWhatFsfTweaks>Its "No Default Storage Settings" option empties the starting filter of storage buildings</BlaxDefaults_OverlapWhatFsfTweaks>

View File

@ -6,9 +6,9 @@
[![Steam Workshop](https://img.shields.io/badge/Steam_Workshop-subscribe-1b2838?logo=steam)](https://steamcommunity.com/sharedfiles/filedetails/?id=3848261264)
[![Needs Harmony](https://img.shields.io/badge/needs-Harmony-050805)](https://steamcommunity.com/sharedfiles/filedetails/?id=2009463077)
[![Any DLC combination](https://img.shields.io/badge/DLCs-any_combination-5a6b5d)](#dlc-support)
[![Status: 1.0](https://img.shields.io/badge/status-1.0-CDCDCD)](CHANGELOG.md)
[![Status: 1.1](https://img.shields.io/badge/status-1.1-CDCDCD)](CHANGELOG.md)
RimWorld mod (1.7) from Blax Gaming: your own starting settings for new stockpiles, shelves and bills. Set up one shelf, click "Make default for new shelves", and every new shelf starts like it. Nothing changes until you save a default, the things you already have keep their settings, and nothing goes into your save, so the mod can be added to or removed from a running colony. Needs Harmony. Works with any DLC combination, core only included. Colonists, slaves and prisoners are Blax Castes' job; Blax Defaults never changes a pawn.
RimWorld mod (1.7) from Blax Gaming: your own starting settings for new stockpiles, shelves and bills, and rules for what stays forbidden when pawns go down, die or are stripped. Set up one shelf, click "Make default for new shelves", and every new shelf starts like it. Nothing changes until you save a default or turn a rule on, the things you already have keep their settings, and nothing goes into your save, so the mod can be added to or removed from a running colony. Needs Harmony. Works with any DLC combination, core only included. Colonists, slaves and prisoners are Blax Castes' job; Blax Defaults never changes a pawn.
## Features
@ -25,18 +25,29 @@ RimWorld mod (1.7) from Blax Gaming: your own starting settings for new stockpil
- 📜 **Values for every new bill:** repeat mode, count, target, pause when satisfied and resume at, ingredient radius, allowed skill range, where products go (best stockpile or drop on floor), count equipped, count tainted, and the hit points and quality ranges used for counting. Each value starts at "Game's default", and only values you change are applied. "Do until you have X" falls back to "do X times" where the bill can't count its products. `Source/BlaxDefaults/BillDefaults.cs`
- 🩺 Surgery, mech gestation, mech resurrection and forming bills, pasted bills and loaded bills are never touched.
### Forbid rules
A "Forbid rules" section on the settings page. Every rule ships off. `Source/BlaxDefaults/ForbidRules.cs`, `ForbidHooks.cs`, `ForbidRulesSection.cs`
- 🛡️ **Gear rules for your colony and for enemies.** When one of the group's pawns goes down or dies, what the game forbids is allowed again if it matches the rule's filter: the vanilla item filter with the hit points and quality ranges stockpiles have and the special filters (tainted, biocoded, rotten, smeltable). What doesn't match stays forbidden, and a rule never forbids a dropped thing the game left allowed. Your colony is colonists, slaves, colony mechs, colony animals and prisoners, also while they break out or rebel; enemies are everyone else hostile to you. Neutral visitors, traders and quest lodgers keep the game's rules.
- Each rule has Edit, Forget (asks first, turns the rule off), "Where" (anywhere, or only inside the home area) and "Use the suggested setup" (asks first). Ticking a rule that has no filter yet saves its suggested setup. Enemies: every item, but hit points 50 to 100% and Normal or better, stripping on, so a Poor rifle or one below 50% stays forbidden while food, medicine, drugs and silver are allowed. Your colony: every item, any hit points and quality, stripping off.
- ⚔️ **Once the fight is over.** What a rule allows waits while an enemy that can still fight is on the map. Changing a waiting thing's flag yourself takes it off the list; a save and reload forgets the list, so things still waiting stay forbidden.
- 🔫 **A downed colonist's own weapon** stays forbidden while the colonist lies where it fell, so it picks the weapon up after getting up, as in vanilla. Once the colonist is rescued, carried off or dies, the rule decides.
- 👕 **Stripping forbids what doesn't match**, a switch per rule: stripping one of the group's pawns or corpses forbids each dropped thing the filter refuses. This is how the rules reach apparel. Butchering strips too, but what a butcher strips stays allowed.
- 🦴 **Corpses outside the home area stay allowed**, with one switch each for animals (manhunters and predators included), enemies and everyone else. They wait for the fight to end too.
- Not reached: trading a pawn away, capturing it, and anything other mods forbid after the game's own drop.
### Your defaults stay
- 📁 **One file for every save.** Defaults live in `Config/BlaxDefaults/Defaults.xml` in the game's save data folder, shared by every save, never in a save or in the mod settings. Every write goes to a temporary file first, is read back and checked, and only then replaces the file, with the previous version kept as `Defaults.xml.bak`. A file that fails to load is kept as a broken copy under its own name and never rotated into the backup; the backup loads instead, and the settings page says so. A file from a newer version is read but never overwritten. `Source/BlaxDefaults/DefaultsFile.cs`
- 🔌 **Removed a mod?** Names from a mod or DLC that is not active stay in the file, are skipped and counted on the settings page, and work again when the mod comes back.
- 📋 **Settings page** (Mod settings > Blax Defaults): the master switch "Apply saved defaults to new things", a status line, and the sections Stockpiles, Storage buildings and Every new bill, each with its own switch. Every saved default has a row saying what it sets, with Edit and Forget; Forget asks first. Edit opens the item filter with the priority and the rule for unlisted items. It all works from the main menu. `Source/BlaxDefaults/SettingsPage.cs`
- ⚠️ **Overlap warnings.** The settings page names active mods that set the same starting settings, and the first game loaded in a session opens a window listing them, with "Don't remind me" per mod. `Source/BlaxDefaults/OverlapWarnings.cs`
- 📋 **Settings page** (Mod settings > Blax Defaults): the master switch "Apply saved defaults to new things", a status line, and the sections Stockpiles, Storage buildings, Every new bill and Forbid rules, each with its own switch. Every saved default has a row saying what it sets, with Edit and Forget; Forget asks first. Edit opens the item filter with the priority and the rule for unlisted items. It all works from the main menu. `Source/BlaxDefaults/SettingsPage.cs`
- ⚠️ **Overlap warnings.** The settings page names active mods that do some of the same things, and the first game loaded in a session opens a window listing them, with "Don't remind me" per mod. `Source/BlaxDefaults/OverlapWarnings.cs`
### Planned
Designed, not built yet (details and the release table in `docs/design.md`):
- 1.1: forbid rules. When your colonists, slaves, prisoners or enemies go down or die, what the game forbids is allowed again if it matches a filter with hit points and quality ranges, once the fight is over. For example enemy weapons and apparel only at 50 to 100% and Normal or better, their food, medicine, drugs and silver always. Stripping can forbid what doesn't match. Corpses outside the home area can stay allowed. Every rule ships off; neutral visitors and traders keep the game's rules.
- 1.2: graves, sarcophagi, mortars, growth vats (Biotech), biosculpter pods (Ideology) and other storage; defaults per recipe from the bill window; the bills a new workbench comes with.
- 1.3: animals per species (area, follow flags, training), born animals copy their mother, auto-slaughter limits; auto-repair for new mechs (Biotech).
- 1.4: crops for new growing zones and hydroponics basins; settings for new doors, tables, traps, heaters, coolers and lamps.
@ -44,7 +55,7 @@ Designed, not built yet (details and the release table in `docs/design.md`):
### DLC support
Blax Defaults works with any combination of DLCs, core only included, and lists none as a dependency. 1.0 needs no DLC for any feature.
Blax Defaults works with any combination of DLCs, core only included, and lists none as a dependency. No feature needs a DLC. The forbid rules count slaves (Ideology) and colony mechs (Biotech) with your colony when that DLC is loaded; mechs destroy their weapon instead of dropping it in any DLC set.
- The defaults file is shared by every DLC set. A DLC item inside a default, such as wastepack in a dumping stockpile default saved with Biotech, is skipped while that DLC is off, counted with the names from inactive mods, and works again when the DLC is back.
- A save made with a DLC loads without it: Blax Defaults keeps nothing in the save, and the vanilla fields it wrote are the game's to load.
@ -56,12 +67,16 @@ Replaces, so you can unsubscribe them (the settings page names them while they a
- ♻️ [FSF] No Default Shelf Storage: the quick setup empties new shelves per kind and leaves hoppers and single-purpose storage alone.
- ♻️ Default Ingredient Radius and Default Bill Ingredient Radius: "Ingredient radius" under Every new bill.
- ♻️ KilledEnemyAutoAllowed (Continued): both gear rules with every item, anywhere, and the corpse switches on. Neutral pawns' drops stay vanilla.
- ♻️ Allow Dead Animals: the animal corpse switch.
- ♻️ Allow Everything, for what pawns drop when they go down or die: both gear rules with every item. Everything else keeps the flag the player or the game gave it.
Overlaps, named by the overlap warning:
- ⚠️ 1trickPwnyta's Defaults and Set my Defaults set starting settings for stockpiles and shelves too, and 1trickPwnyta's sets values for every new bill. Blax Defaults 1.0 covers those, so set each in one mod. Their bill lists per recipe or per workbench are not in 1.0 (planned for 1.1), so keep those mods for that and for their other defaults. The unofficial Defaults 1.7 repack is not detected yet.
- ⚠️ 1trickPwnyta's Defaults and Set my Defaults set starting settings for stockpiles and shelves too, and 1trickPwnyta's sets values for every new bill. Blax Defaults covers those, so set each in one mod. Their bill lists per recipe or per workbench are not in Blax Defaults yet (planned for 1.2), so keep those mods for that and for their other defaults. The unofficial Defaults 1.7 repack is not detected yet.
- ⚠️ [FSF] FrozenSnowFox Tweaks: its "No Default Storage Settings" option empties the starting filter of storage buildings, like the quick setup. Use one of the two.
- ⚠️ Better Workbench Management sets where the products of new bills go. Set that in one mod only.
- ⚠️ Non uno Pinata keeps gear on pawns that go down or die, so little drops for the forbid rules to sort.
Works next to:
@ -69,6 +84,8 @@ Works next to:
- ✔️ RimFridge (no 1.7 build yet, loads its 1.6 files): its fridges are covered storage kinds. The quick setup leaves them unticked, because RimFridge makes fridges act as hoppers.
- ✔️ Replace Stuff: replacing a shelf's material keeps its settings.
- ✔️ Preset Filtered Zones: its zones keep their preset filters and show no Defaults button.
- ✔️ Hospitality: guests keep the game's rules, and with its option to keep friendly pawns' gear on them a downed visitor drops nothing. Hospitality drops a downed pawn's weapon without remembering it, so with Hospitality a downed colonist doesn't go back for its weapon and the colony rule decides it once the fight is over.
- ✔️ Pick Up And Haul: what a forbid rule allows gets hauled like anything else.
- 🧩 Other Blax mods: Blax Castes handles colonists, slaves and prisoners. Blax Slaves and Blax Zones don't overlap with Blax Defaults; Zones' delivery zones keep their own tab and get no Defaults button. Load order between them doesn't matter.
- ❌ Multiplayer: not supported yet (the defaults file differs per player).
@ -99,7 +116,7 @@ dotnet build Source\BlaxDefaults\BlaxDefaults.csproj -c Release
.\Tests\run-tests.ps1 -Compat
```
A release runs all 8 combinations of Royalty, Ideology and Biotech. Each run also leaves a copy of the results per DLC set next to the results file: `BlaxDefaultsTestResults.all.txt` (every installed DLC), `.nodlc.txt` or `.dlc-<names>.txt`. The Workshop upload checks the `all` and `nodlc` copies. `-Compat` also loads the installed mods Blax Defaults is tested next to (the list is at the top of `run-tests.ps1`). Exit code 0 means all passed, 1 failures, 2 the run didn't finish.
A release runs all 8 combinations of Royalty, Ideology and Biotech. Each run also leaves a copy of the results per DLC set next to the results file: `BlaxDefaultsTestResults.all.txt` (every installed DLC), `.nodlc.txt` or `.dlc-<names>.txt`. The Workshop upload checks the `all` and `nodlc` copies. `-Compat` also loads the installed mods Blax Defaults is tested next to (the list is at the top of `run-tests.ps1`). Exit code 0 means all passed, 1 failures or errors the mod logged between tests, 2 the run didn't finish.
### Workshop art
@ -120,7 +137,7 @@ Without `About/PublishedFileId.txt`, `-Publish` creates a new item. It writes th
It stages only what players need (About, 1.7, Defs, Patches, Languages, Textures, Sounds) in `%TEMP%`, sets the tags the game would (Mod plus the supported versions), and writes every CHANGELOG.md entry since the version in `Tools/workshop-published.txt` as the change note. The title is About.xml's name and the preview is `About/Preview.png`, set on every upload like the in-game uploader does. `-Publish` refuses unless the shipped files are committed and pushed, the top CHANGELOG entry matches `modVersion`, `About/Preview.png` is under 1 MB, and two test runs passed after the last build: one with every installed DLC and one with `-NoDlc` (the `all` and `nodlc` result copies, see Tests). `-Check` runs every `-Publish` check and the dry run and lists each problem; exit code 0 means none. The in-game route still works: `Tools/workshop-stage.ps1` swaps the junction for a clean copy, upload from Mods > Blax Defaults > Advanced... > Upload to Steam Workshop (dev mode), then `workshop-stage.ps1 -Done` copies `About/PublishedFileId.txt` back into the repo.
The Workshop description is `docs/workshop-description.txt` (Steam BBCode, at most 8000 bytes); `-DescriptionOnly -DescriptionFile docs\workshop-description.txt` replaces just the text, with no build, no content upload and no change note. Steam loads description images as cross-origin requests, so every `[img]` host must send an `Access-Control-Allow-Origin` header or the image shows broken; the script checks each one and `-Publish` refuses otherwise. Forgejo's raw URLs send no such header, so the Steam images are served from `cdn.blax.at/blax-gaming/`, which does. The section headers must be on `cdn.blax.at/blax-gaming/defaults/` before `-Publish` passes. Every forgejo.blax.at link in the description must also open without a login, so the repo has to be public first. `Source/Art/README.md` has the render commands.
The Workshop description is `docs/workshop-description.txt` (Steam BBCode, at most 8000 bytes). Once something was published from here, an update replaces the description only when `-DescriptionFile docs\workshop-description.txt` is passed, so pass it on every release that changed the file. `-DescriptionOnly -DescriptionFile docs\workshop-description.txt` replaces just the text, with no build, no content upload and no change note. Steam loads description images as cross-origin requests, so every `[img]` host must send an `Access-Control-Allow-Origin` header or the image shows broken; the script checks each one and `-Publish` refuses otherwise. Forgejo's raw URLs send no such header, so the Steam images are served from `cdn.blax.at/blax-gaming/`, which does. The section headers must be on `cdn.blax.at/blax-gaming/defaults/` before `-Publish` passes. Every forgejo.blax.at link in the description must also open without a login, so the repo has to be public first. `Source/Art/README.md` has the render commands.
---

View File

@ -30,6 +30,7 @@ The Steam description (`docs/workshop-description.txt`) shows one header per sec
& $edge --headless=new --disable-gpu --hide-scrollbars --user-data-dir="$edgeData" --virtual-time-budget=3000 --window-size=1600,254 --screenshot="$PWD\..\..\docs\art\blax-oss-banner.png" "file:///$here/oss-banner.html" | Out-Null
& $edge --headless=new --disable-gpu --hide-scrollbars --user-data-dir="$edgeData" --virtual-time-budget=3000 --window-size=1270,150 --screenshot="$PWD\..\..\docs\art\steam\storage.png" "file:///$here/header.html?t=Storage&s=New%20stockpiles%20and%20shelves%20start%20from%20your%20default&i=warehouse" | Out-Null
& $edge --headless=new --disable-gpu --hide-scrollbars --user-data-dir="$edgeData" --virtual-time-budget=3000 --window-size=1270,150 --screenshot="$PWD\..\..\docs\art\steam\bills.png" "file:///$here/header.html?t=Bills&s=Values%20every%20new%20bill%20starts%20with&i=scroll-text" | Out-Null
& $edge --headless=new --disable-gpu --hide-scrollbars --user-data-dir="$edgeData" --virtual-time-budget=3000 --window-size=1270,150 --screenshot="$PWD\..\..\docs\art\steam\forbid.png" "file:///$here/header.html?t=Forbid%20rules&s=What%20stays%20forbidden%20when%20pawns%20go%20down%2C%20die%20or%20are%20stripped&i=sliders" | Out-Null
& $edge --headless=new --disable-gpu --hide-scrollbars --user-data-dir="$edgeData" --virtual-time-budget=3000 --window-size=1270,150 --screenshot="$PWD\..\..\docs\art\steam\file.png" "file:///$here/header.html?t=Your%20defaults%20stay&s=Their%20own%20file%2C%20a%20backup%20and%20a%20settings%20page&i=save" | Out-Null
& $edge --headless=new --disable-gpu --hide-scrollbars --user-data-dir="$edgeData" --virtual-time-budget=3000 --window-size=1270,150 --screenshot="$PWD\..\..\docs\art\steam\planned.png" "file:///$here/header.html?t=Planned&s=Coming%20in%20later%20releases&i=milestone" | Out-Null
& $edge --headless=new --disable-gpu --hide-scrollbars --user-data-dir="$edgeData" --virtual-time-budget=3000 --window-size=1270,150 --screenshot="$PWD\..\..\docs\art\steam\replaces.png" "file:///$here/header.html?t=Replaces&s=Mods%20you%20can%20unsubscribe&i=replace" | Out-Null
@ -40,6 +41,7 @@ The Steam description (`docs/workshop-description.txt`) shows one header per sec
|---|---|---|---|
| `storage.png` | Storage | New stockpiles and shelves start from your default | warehouse |
| `bills.png` | Bills | Values every new bill starts with | scroll-text |
| `forbid.png` | Forbid rules | What stays forbidden when pawns go down, die or are stripped | sliders |
| `file.png` | Your defaults stay | Their own file, a backup and a settings page | save |
| `planned.png` | Planned | Coming in later releases | milestone |
| `replaces.png` | Replaces | Mods you can unsubscribe | replace |

View File

@ -24,6 +24,9 @@ namespace BlaxDefaults
/// <summary>New production bills get the values of "Every new bill".</summary>
public static bool BillsOn => Enabled && (Settings == null || Settings.billDefaults);
/// <summary>The forbid rules may act (each rule still needs its own switch and filter).</summary>
public static bool ForbidOn => Enabled && (Settings == null || Settings.forbidRules);
public override string SettingsCategory() => "Blax Defaults";
public override void DoSettingsWindowContents(Rect inRect) => SettingsPage.Draw(inRect);

View File

@ -18,7 +18,27 @@ namespace BlaxDefaults
public bool storageDefaults = true;
/// <summary>New production bills get the values of "Every new bill".</summary>
public bool billDefaults = true;
/// <summary>The settings page and one message per session name active mods that set the same defaults.</summary>
/// <summary>The forbid rules as a category: off, no gear rule, strip switch or corpse switch acts.</summary>
public bool forbidRules = true;
/// <summary>"Gear your colony drops". Acts only with a saved filter under forbid:colony.</summary>
public bool colonyGearRule;
/// <summary>The colony rule's "Where": anywhere (true) or only inside the home area.</summary>
public bool colonyGearAnywhere = true;
/// <summary>"Gear enemies drop". Acts only with a saved filter under forbid:enemies.</summary>
public bool enemyGearRule;
/// <summary>The enemy rule's "Where": anywhere (true) or only inside the home area.</summary>
public bool enemyGearAnywhere = true;
/// <summary>Stripping one of your colony's pawns or corpses forbids what the colony filter refuses.</summary>
public bool colonyStripRule;
/// <summary>Stripping an enemy or an enemy corpse forbids what the enemy filter refuses.</summary>
public bool enemyStripRule;
/// <summary>Animal corpses outside the home area are allowed.</summary>
public bool animalCorpsesAllowed;
/// <summary>Enemy corpses outside the home area are allowed.</summary>
public bool enemyCorpsesAllowed;
/// <summary>Other corpses outside the home area are allowed.</summary>
public bool otherCorpsesAllowed;
/// <summary>The settings page and one message per session name active mods that do some of the same things.</summary>
public bool warnOverlaps = true;
/// <summary>Package ids whose overlap message the player dismissed with "Don't remind me".</summary>
public List<string> dismissedOverlaps = new List<string>();
@ -30,6 +50,16 @@ namespace BlaxDefaults
Scribe_Values.Look(ref stockpileDefaults, "stockpileDefaults", true);
Scribe_Values.Look(ref storageDefaults, "storageDefaults", true);
Scribe_Values.Look(ref billDefaults, "billDefaults", true);
Scribe_Values.Look(ref forbidRules, "forbidRules", true);
Scribe_Values.Look(ref colonyGearRule, "colonyGearRule", false);
Scribe_Values.Look(ref colonyGearAnywhere, "colonyGearAnywhere", true);
Scribe_Values.Look(ref enemyGearRule, "enemyGearRule", false);
Scribe_Values.Look(ref enemyGearAnywhere, "enemyGearAnywhere", true);
Scribe_Values.Look(ref colonyStripRule, "colonyStripRule", false);
Scribe_Values.Look(ref enemyStripRule, "enemyStripRule", false);
Scribe_Values.Look(ref animalCorpsesAllowed, "animalCorpsesAllowed", false);
Scribe_Values.Look(ref enemyCorpsesAllowed, "enemyCorpsesAllowed", false);
Scribe_Values.Look(ref otherCorpsesAllowed, "otherCorpsesAllowed", false);
Scribe_Values.Look(ref warnOverlaps, "warnOverlaps", true);
Scribe_Collections.Look(ref dismissedOverlaps, "dismissedOverlaps", LookMode.Value);
if (Scribe.mode == LoadSaveMode.PostLoadInit || Scribe.mode == LoadSaveMode.LoadingVars)
@ -44,6 +74,16 @@ namespace BlaxDefaults
stockpileDefaults = d.stockpileDefaults;
storageDefaults = d.storageDefaults;
billDefaults = d.billDefaults;
forbidRules = d.forbidRules;
colonyGearRule = d.colonyGearRule;
colonyGearAnywhere = d.colonyGearAnywhere;
enemyGearRule = d.enemyGearRule;
enemyGearAnywhere = d.enemyGearAnywhere;
colonyStripRule = d.colonyStripRule;
enemyStripRule = d.enemyStripRule;
animalCorpsesAllowed = d.animalCorpsesAllowed;
enemyCorpsesAllowed = d.enemyCorpsesAllowed;
otherCorpsesAllowed = d.otherCorpsesAllowed;
warnOverlaps = d.warnOverlaps;
dismissedOverlaps = new List<string>();
}

View File

@ -52,7 +52,8 @@ namespace BlaxDefaults
/// <summary>
/// The library keys. One default per kind: "stockpile:Stockpile", "stockpile:Dumping",
/// "stockpile:&lt;designator type name&gt;", "storage:&lt;ThingDef&gt;" and "bill:*" in 1.0. Later releases
/// "stockpile:&lt;designator type name&gt;", "storage:&lt;ThingDef&gt;" and "bill:*" in 1.0, "forbid:colony" and
/// "forbid:enemies" (the forbid rules' filters) in 1.1. Later releases
/// add their own prefixes (bill:&lt;RecipeDef&gt;, bench:, animal:, slaughter:, mech:, grower:, building:).
/// </summary>
public static class DefaultsKeys
@ -60,6 +61,12 @@ namespace BlaxDefaults
public const string StockpilePrefix = "stockpile:";
public const string StoragePrefix = "storage:";
public const string BillPrefix = "bill:";
public const string ForbidPrefix = "forbid:";
/// <summary>The filter of "Gear your colony drops" (1.1).</summary>
public const string ForbidColony = "forbid:colony";
/// <summary>The filter of "Gear enemies drop" (1.1).</summary>
public const string ForbidEnemies = "forbid:enemies";
/// <summary>The vanilla stockpile (DefaultStockpile preset): Designator_ZoneAddStockpile_Resources and _Expand.</summary>
public const string Stockpile = "stockpile:Stockpile";
@ -81,6 +88,8 @@ namespace BlaxDefaults
public static bool IsBill(string key) => key != null && key.StartsWith(BillPrefix, StringComparison.Ordinal);
public static bool IsForbid(string key) => key != null && key.StartsWith(ForbidPrefix, StringComparison.Ordinal);
/// <summary>The part after the prefix: "Shelf" for "storage:Shelf".</summary>
public static string NameOf(string key)
{

View File

@ -18,6 +18,9 @@ namespace BlaxDefaults
/// template that don't resolve now (so nothing from an inactive mod is lost), and stores it with
/// DefaultsLibrary.Set. Needs defs only, not a running game: the places where the vanilla filter reads
/// the game are bridged by Patch_Listing_TreeThingFilter_MainMenu below.
///
/// For a forbid rule's filter (1.1, StorageKind.IsForbid) the same window has no priority, and the unlisted
/// rule offers only "refuse them" (stays forbidden) and "allow them".
/// </summary>
public class Dialog_EditStorageTemplate : Window
{
@ -40,7 +43,9 @@ namespace BlaxDefaults
Original = template?.CloneTemplate();
Scratch = new StorageSettings();
kind.LoadDefault(Scratch, template);
Unlisted = template?.unlisted ?? UnlistedRule.Game;
Unlisted = template?.unlisted ?? (kind.IsForbid ? UnlistedRule.Allow : UnlistedRule.Game);
if (kind.IsForbid && Unlisted == UnlistedRule.Game)
Unlisted = UnlistedRule.Allow;
doCloseX = true;
forcePause = true;
absorbInputAroundWindow = true;
@ -53,14 +58,18 @@ namespace BlaxDefaults
public override void DoWindowContents(Rect inRect)
{
Text.Font = GameFont.Medium;
Widgets.Label(new Rect(0f, 0f, inRect.width - 30f, TitleHeight), "BlaxDefaults_PageEditTitle".Translate(Kind.LabelPlural));
string title = Kind.IsForbid ? "BlaxDefaults_ForbidEditTitle".Translate(Kind.Label) : "BlaxDefaults_PageEditTitle".Translate(Kind.LabelPlural);
Widgets.Label(new Rect(0f, 0f, inRect.width - 30f, TitleHeight), title);
Text.Font = GameFont.Small;
float y = TitleHeight + 4f;
if (!Kind.IsForbid)
{
var priorityRect = new Rect(0f, y, Mathf.Min(220f, inRect.width), RowHeight);
if (Widgets.ButtonText(priorityRect, "BlaxDefaults_PagePriority".Translate(Scratch.Priority.Label().CapitalizeFirst())))
Find.WindowStack.Add(new FloatMenu(PriorityOptions()));
y += RowHeight + Gap;
}
float bottomHeight = RowHeight + Gap + RowHeight;
var filterRect = new Rect(0f, y, inRect.width, inRect.height - y - Gap - bottomHeight);
@ -80,7 +89,9 @@ namespace BlaxDefaults
var unlistedRect = new Rect(0f, y, inRect.width, RowHeight);
if (Widgets.ButtonText(unlistedRect, "BlaxDefaults_PageUnlisted".Translate(Unlisted.Label())))
Find.WindowStack.Add(new FloatMenu(UnlistedOptions()));
TooltipHandler.TipRegion(unlistedRect, "BlaxDefaults_PageUnlistedTip".Translate(Kind.LabelPlural).Resolve());
TooltipHandler.TipRegion(unlistedRect, Kind.IsForbid
? "BlaxDefaults_ForbidUnlistedTip".Translate().Resolve()
: "BlaxDefaults_PageUnlistedTip".Translate(Kind.LabelPlural).Resolve());
y += RowHeight + Gap;
float half = (inRect.width - Gap) / 2f;
@ -108,6 +119,8 @@ namespace BlaxDefaults
var list = new List<FloatMenuOption>();
foreach (UnlistedRule r in Enum.GetValues(typeof(UnlistedRule)))
{
if (Kind.IsForbid && r == UnlistedRule.Game)
continue;
UnlistedRule local = r;
list.Add(new FloatMenuOption(local.Label().CapitalizeFirst(), () => Unlisted = local));
}

View File

@ -0,0 +1,513 @@
using System;
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
using RimWorld;
using Verse;
using Verse.AI;
namespace BlaxDefaults
{
/// <summary>
/// One downing or death in progress: the pawn, its group read while it was alive, and every thing the game
/// forbade inside the call (allowed before, forbidden after). Never saved.
/// </summary>
public sealed class ForbidScope
{
public readonly Pawn Pawn;
public readonly ForbidGroup Group;
/// <summary>True for Pawn_HealthTracker.MakeDowned, false for Pawn.Kill.</summary>
public readonly bool Downing;
public readonly List<Thing> Recorded = new List<Thing>();
public ForbidScope(Pawn pawn, ForbidGroup group, bool downing)
{
Pawn = pawn;
Group = group;
Downing = downing;
}
}
/// <summary>
/// The forbid rules' hooks. Work package "forbid" (design.md, 1.1 "Gear rules for your colony and for
/// enemies", "Stripping forbids what doesn't match", "Corpses outside the home area stay allowed").
///
/// Scopes: prefixes on Pawn.Kill(DamageInfo?, Hediff) and the private Pawn_HealthTracker.MakeDowned(DamageInfo?,
/// Hediff) push the pawn and its group onto a [ThreadStatic] stack while the game is playing, no map is being
/// made and a rule or corpse switch could act; a finalizer pops it, even on an exception. Recorder: a prefix and
/// a postfix on the CompForbiddable.Forbidden setter add a thing that went from allowed to forbidden to the
/// innermost scope. So a scope holds exactly what the game forbade in that call. Apply, in the postfixes of
/// Kill and MakeDowned: a corpse goes to the corpse switches, any other thing is allowed when its group's rule
/// acts, its cell passes "Where" and the filter allows it: at once when the map has no active threat, else
/// through ForbidWaitList. A downed colonist's remembered weapon always waits (ForbidWaitList keeps it while
/// the colonist still remembers it). Strip: a prefix records what the pawn wears, holds and carries, and the
/// postfix forbids each of those now on a map, inside "Where", that the filter refuses; nothing while
/// butchering's ingredient step (Toils_Recipe.CalculateIngredients) runs. Never patched:
/// ForbidUtility.SetForbidden, which player designators use, and SetForbiddenIfOutsideHomeArea, five lines
/// the JIT may inline.
/// </summary>
public static class ForbidHooks
{
[ThreadStatic] private static List<ForbidScope> stack;
[ThreadStatic] private static int butchering;
/// <summary>True while a downing or death scope is open on this thread.</summary>
public static bool ScopeOpen
{
get
{
List<ForbidScope> s = stack;
return s != null && s.Count > 0;
}
}
/// <summary>True while butchering's ingredient step runs on this thread: stripping stays vanilla then.</summary>
public static bool Butchering => butchering > 0;
/// <summary>A scope opens while the game plays, no map is being made, and a rule or corpse switch could act.</summary>
public static bool ShouldOpen =>
Current.ProgramState == ProgramState.Playing && MapGenerator.mapBeingGenerated == null && ForbidRules.AnyDropRuleOn;
public static ForbidScope Push(Pawn pawn, bool downing)
{
var scope = new ForbidScope(pawn, ForbidRules.GroupOf(pawn), downing);
(stack ??= new List<ForbidScope>()).Add(scope);
return scope;
}
public static void Pop(ForbidScope scope)
{
List<ForbidScope> s = stack;
if (s == null || scope == null)
return;
int i = s.LastIndexOf(scope);
if (i >= 0)
s.RemoveAt(i);
}
/// <summary>The recorder: a thing the game just forbade inside a scope goes to the innermost one.</summary>
public static void Record(Thing t)
{
List<ForbidScope> s = stack;
if (t == null || s == null || s.Count == 0)
return;
List<Thing> recorded = s[s.Count - 1].Recorded;
if (!recorded.Contains(t))
recorded.Add(t);
}
internal static void EnterButchering() => butchering++;
internal static void LeaveButchering()
{
if (butchering > 0)
butchering--;
}
/// <summary>
/// What the postfix of Kill or MakeDowned does with the things its scope recorded. A thing no longer
/// spawned or no longer forbidden is skipped; a corpse goes to the corpse switches; any other thing to its
/// group's rule. A downed colonist's remembered weapon goes on the wait list with its owner.
/// </summary>
public static void Apply(ForbidScope scope)
{
if (scope == null || scope.Recorded.Count == 0)
return;
ForbidRule rule = ForbidRules.For(scope.Group);
Thing remembered = scope.Downing && scope.Group == ForbidGroup.Colony ? scope.Pawn?.mindState?.droppedWeapon : null;
foreach (Thing thing in scope.Recorded.ToList())
{
if (thing == null || thing.Destroyed || !thing.Spawned || !ForbidRules.IsForbiddenFlag(thing))
continue;
if (thing is Corpse corpse)
{
ApplyCorpse(corpse, scope);
continue;
}
if (rule == null || !rule.Active)
continue;
if (thing == remembered)
{
ForbidWaitList.Add(thing, rule, null, scope.Pawn);
continue;
}
if (rule.InsideWhere(thing) && rule.Allows(thing))
AllowOrWait(thing, rule, null);
}
}
private static void ApplyCorpse(Corpse corpse, ForbidScope scope)
{
Map map = corpse.Map;
if (map == null || map.areaManager.Home[corpse.Position])
return;
Pawn inner = corpse.InnerPawn;
CorpseKind kind = inner == scope.Pawn
? ForbidRules.CorpseKindOf(inner, scope.Group)
: ForbidRules.CorpseKindOf(inner, ForbidRules.GroupOfDead(inner));
if (ForbidRules.CorpseSwitch(kind))
AllowOrWait(corpse, null, kind);
}
/// <summary>Allows the thing now when its map has no active threat, else puts it on the wait list.</summary>
private static void AllowOrWait(Thing thing, ForbidRule rule, CorpseKind? corpse)
{
if (GenHostility.AnyHostileActiveThreatToPlayer(thing.Map))
ForbidWaitList.Add(thing, rule, corpse, null);
else
thing.SetForbidden(false, warnOnFail: false);
}
/// <summary>What the strip prefix recorded: the rule of the stripped pawn's group and what it had.</summary>
public sealed class StripRecord
{
public ForbidRule Rule;
public List<Thing> Things;
}
/// <summary>The strip prefix: null when the pawn's group has no strip switch acting.</summary>
public static StripRecord BeforeStrip(Pawn pawn)
{
if (pawn == null || Butchering || Current.ProgramState != ProgramState.Playing || !ForbidRules.On)
return null;
if (!ForbidRules.Colony.StripActive && !ForbidRules.Enemies.StripActive)
return null;
ForbidGroup group = pawn.Dead ? ForbidRules.GroupOfDead(pawn) : ForbidRules.GroupOf(pawn);
ForbidRule rule = ForbidRules.For(group);
if (rule == null || !rule.StripActive)
return null;
var things = new List<Thing>();
if (pawn.equipment != null)
things.AddRange(pawn.equipment.AllEquipmentListForReading);
if (pawn.apparel != null)
things.AddRange(pawn.apparel.WornApparel);
if (pawn.inventory != null)
things.AddRange(pawn.inventory.innerContainer);
return things.Count == 0 ? null : new StripRecord { Rule = rule, Things = things };
}
/// <summary>The strip postfix: forbids each recorded thing now on a map, inside "Where", that the filter refuses.</summary>
public static void AfterStrip(StripRecord record)
{
if (record?.Rule == null || !record.Rule.StripActive)
return;
foreach (Thing t in record.Things)
{
if (t == null || t.Destroyed || !t.Spawned || ForbidRules.IsForbiddenFlag(t))
continue;
if (record.Rule.InsideWhere(t) && !record.Rule.Allows(t))
t.SetForbidden(true, warnOnFail: false);
}
}
}
/// <summary>
/// Things a rule allows wait here while an enemy that can still fight is on their map. Work package "forbid"
/// (design.md, 1.1 "Wait until the fight is over"). An unsaved list of thing, rule (or corpse switch) and, for
/// a remembered weapon, its owner, with the Game it belongs to: a different Current.Game clears it, so a save
/// and reload forgets it and things still waiting stay forbidden, as in vanilla.
///
/// Every 250 ticks, per map with entries (Map.MapPostTick postfix, which returns at once while the list is
/// empty): an entry whose thing is no longer spawned on that map leaves; a remembered weapon stays while
/// owner.mindState.droppedWeapon is still that weapon; if any other entry is left and
/// GenHostility.AnyHostileActiveThreatToPlayer(map) is false, each whose rule still acts, that is still
/// forbidden, inside "Where" and allowed by the current filter is allowed, and all of them leave the list.
/// Changing a waiting thing's flag outside a scope (the player, a mod) takes it off the list.
/// </summary>
public static class ForbidWaitList
{
public const int CheckInterval = 250;
public sealed class Entry
{
public Thing Thing;
/// <summary>The gear rule, or null for a corpse.</summary>
public ForbidRule Rule;
/// <summary>The corpse switch, for a corpse.</summary>
public CorpseKind? Corpse;
/// <summary>The colonist that remembers this weapon, or null.</summary>
public Pawn Owner;
public Map Map;
}
private static readonly List<Entry> entries = new List<Entry>();
private static Game game;
/// <summary>No entries: the tick postfix returns at once.</summary>
public static bool IsEmpty => entries.Count == 0;
public static int Count
{
get
{
CheckGame();
return entries.Count;
}
}
/// <summary>True while the thing waits.</summary>
public static bool Contains(Thing t)
{
CheckGame();
return t != null && entries.Any(e => e.Thing == t);
}
/// <summary>The waiting entry of the thing, or null.</summary>
public static Entry EntryOf(Thing t)
{
CheckGame();
return t == null ? null : entries.FirstOrDefault(e => e.Thing == t);
}
public static void Add(Thing thing, ForbidRule rule, CorpseKind? corpse, Pawn owner)
{
if (thing == null || thing.Map == null)
return;
CheckGame();
game = Current.Game;
entries.RemoveAll(e => e.Thing == thing);
entries.Add(new Entry { Thing = thing, Rule = rule, Corpse = corpse, Owner = owner, Map = thing.Map });
}
public static void Remove(Thing thing)
{
if (thing == null || entries.Count == 0)
return;
entries.RemoveAll(e => e.Thing == thing);
}
/// <summary>Empties the list. Tests only (and a game change).</summary>
public static void Clear()
{
entries.Clear();
game = null;
}
private static void CheckGame()
{
if (entries.Count > 0 && game != Current.Game)
Clear();
}
/// <summary>The tick postfix: every CheckInterval ticks, the check for this map.</summary>
public static void MapTick(Map map)
{
if (entries.Count == 0 || map == null)
return;
CheckGame();
if (entries.Count == 0 || Find.TickManager.TicksGame % CheckInterval != 0)
return;
Check(map);
}
/// <summary>The check for one map, as described above.</summary>
public static void Check(Map map)
{
CheckGame();
List<Map> maps = Find.Maps;
entries.RemoveAll(e => e.Map == null || !maps.Contains(e.Map));
var ready = new List<Entry>();
foreach (Entry e in entries.Where(x => x.Map == map).ToList())
{
if (e.Thing == null || e.Thing.Destroyed || !e.Thing.Spawned || e.Thing.Map != map)
{
entries.Remove(e);
continue;
}
if (e.Owner != null && e.Owner.mindState != null && e.Owner.mindState.droppedWeapon == e.Thing)
continue;
ready.Add(e);
}
if (ready.Count == 0 || GenHostility.AnyHostileActiveThreatToPlayer(map))
return;
foreach (Entry e in ready)
{
entries.Remove(e);
if (ShouldAllow(e))
e.Thing.SetForbidden(false, warnOnFail: false);
}
}
private static bool ShouldAllow(Entry e)
{
if (!ForbidRules.IsForbiddenFlag(e.Thing))
return false;
if (e.Corpse.HasValue)
return ForbidRules.CorpseSwitch(e.Corpse.Value);
ForbidRule rule = e.Rule;
return rule != null && rule.Active && rule.InsideWhere(e.Thing) && rule.Allows(e.Thing);
}
}
// ---- patches ---------------------------------------------------------------------
[HarmonyPatch(typeof(Pawn), nameof(Pawn.Kill), new[] { typeof(DamageInfo?), typeof(Hediff) })]
public static class Patch_Pawn_Kill
{
public static void Prefix(Pawn __instance, out ForbidScope __state)
{
__state = null;
try
{
if (ForbidHooks.ShouldOpen)
__state = ForbidHooks.Push(__instance, downing: false);
}
catch (Exception e)
{
HookGuard.Report("Pawn.Kill prefix", e);
}
}
public static void Postfix(ForbidScope __state)
{
if (__state == null)
return;
try
{
ForbidHooks.Apply(__state);
}
catch (Exception e)
{
HookGuard.Report("Pawn.Kill", e);
}
}
public static void Finalizer(ForbidScope __state)
{
if (__state != null)
ForbidHooks.Pop(__state);
}
}
[HarmonyPatch(typeof(Pawn_HealthTracker), "MakeDowned", new[] { typeof(DamageInfo?), typeof(Hediff) })]
public static class Patch_Pawn_HealthTracker_MakeDowned
{
public static void Prefix(Pawn ___pawn, out ForbidScope __state)
{
__state = null;
try
{
if (ForbidHooks.ShouldOpen)
__state = ForbidHooks.Push(___pawn, downing: true);
}
catch (Exception e)
{
HookGuard.Report("Pawn_HealthTracker.MakeDowned prefix", e);
}
}
public static void Postfix(ForbidScope __state)
{
if (__state == null)
return;
try
{
ForbidHooks.Apply(__state);
}
catch (Exception e)
{
HookGuard.Report("Pawn_HealthTracker.MakeDowned", e);
}
}
public static void Finalizer(ForbidScope __state)
{
if (__state != null)
ForbidHooks.Pop(__state);
}
}
/// <summary>The recorder. It never changes a flag: it only reads the old value and notes the change.</summary>
[HarmonyPatch(typeof(CompForbiddable), nameof(CompForbiddable.Forbidden), MethodType.Setter)]
public static class Patch_CompForbiddable_Forbidden
{
public static void Prefix(CompForbiddable __instance, out bool __state)
{
__state = false;
if (!ForbidHooks.ScopeOpen && ForbidWaitList.IsEmpty)
return;
__state = __instance.Forbidden;
}
public static void Postfix(CompForbiddable __instance, bool __state)
{
if (!ForbidHooks.ScopeOpen && ForbidWaitList.IsEmpty)
return;
try
{
bool now = __instance.Forbidden;
if (ForbidHooks.ScopeOpen)
{
if (!__state && now)
ForbidHooks.Record(__instance.parent);
}
else if (__state != now)
{
ForbidWaitList.Remove(__instance.parent);
}
}
catch (Exception e)
{
HookGuard.Report("CompForbiddable.Forbidden", e);
}
}
}
[HarmonyPatch(typeof(Pawn), nameof(Pawn.Strip))]
public static class Patch_Pawn_Strip
{
public static void Prefix(Pawn __instance, out ForbidHooks.StripRecord __state)
{
__state = null;
try
{
__state = ForbidHooks.BeforeStrip(__instance);
}
catch (Exception e)
{
HookGuard.Report("Pawn.Strip prefix", e);
}
}
public static void Postfix(ForbidHooks.StripRecord __state)
{
if (__state == null)
return;
try
{
ForbidHooks.AfterStrip(__state);
}
catch (Exception e)
{
HookGuard.Report("Pawn.Strip", e);
}
}
}
/// <summary>Butchering's ingredient step strips corpses (autoStripCorpses); the strip switch leaves that vanilla.</summary>
[HarmonyPatch(typeof(Toils_Recipe), "CalculateIngredients")]
public static class Patch_Toils_Recipe_CalculateIngredients
{
public static void Prefix() => ForbidHooks.EnterButchering();
public static void Finalizer() => ForbidHooks.LeaveButchering();
}
[HarmonyPatch(typeof(Map), nameof(Map.MapPostTick))]
public static class Patch_Map_MapPostTick
{
public static void Postfix(Map __instance)
{
if (ForbidWaitList.IsEmpty)
return;
try
{
ForbidWaitList.MapTick(__instance);
}
catch (Exception e)
{
HookGuard.Report("Map.MapPostTick", e);
}
}
}
}

View File

@ -0,0 +1,382 @@
using System;
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;
namespace BlaxDefaults
{
/// <summary>Who a pawn that goes down, dies or is stripped belongs to, for the forbid rules.</summary>
public enum ForbidGroup
{
/// <summary>Neutral visitors, traders, quest lodgers and anyone else: the game's rules.</summary>
None,
/// <summary>Colonists, slaves, colony mechs, colony animals and prisoners, breaking out or rebelling included.</summary>
Colony,
/// <summary>Everyone else hostile to the player.</summary>
Enemies,
}
/// <summary>Which corpse switch a corpse falls under; the first kind that fits decides.</summary>
public enum CorpseKind
{
Animal,
Enemy,
Other,
}
/// <summary>
/// One forbid rule: "Gear your colony drops" or "Gear enemies drop". Work package "forbid" (design.md, 1.1
/// "Gear rules for your colony and for enemies"). Its filter is a StorageTemplate in the defaults library under
/// forbid:colony or forbid:enemies (priority unused, unlisted Refuse or Allow); its switches live in mod
/// settings. The rule acts only when it is ticked and has a filter: a ticked rule whose filter is missing (the
/// defaults file failed to load) acts as off, and the settings page says why.
/// </summary>
public sealed class ForbidRule
{
public readonly ForbidGroup Group;
public readonly string Key;
private StorageTemplate filterFor;
private ThingFilter filter;
public ForbidRule(ForbidGroup group, string key)
{
Group = group;
Key = key;
}
private static BlaxDefaultsSettings S => BlaxDefaultsMod.Settings;
/// <summary>The rule's checkbox: colonyGearRule or enemyGearRule.</summary>
public bool Ticked
{
get => S != null && (Group == ForbidGroup.Colony ? S.colonyGearRule : S.enemyGearRule);
set
{
if (S == null) return;
if (Group == ForbidGroup.Colony) S.colonyGearRule = value;
else S.enemyGearRule = value;
}
}
/// <summary>"Where": true for anywhere (the default), false for only inside the home area.</summary>
public bool Anywhere
{
get => S == null || (Group == ForbidGroup.Colony ? S.colonyGearAnywhere : S.enemyGearAnywhere);
set
{
if (S == null) return;
if (Group == ForbidGroup.Colony) S.colonyGearAnywhere = value;
else S.enemyGearAnywhere = value;
}
}
/// <summary>"Stripping forbids what doesn't match": colonyStripRule or enemyStripRule.</summary>
public bool StripTicked
{
get => S != null && (Group == ForbidGroup.Colony ? S.colonyStripRule : S.enemyStripRule);
set
{
if (S == null) return;
if (Group == ForbidGroup.Colony) S.colonyStripRule = value;
else S.enemyStripRule = value;
}
}
/// <summary>The saved filter, or null.</summary>
public StorageTemplate Template => DefaultsLibrary.Get<StorageTemplate>(Key);
public bool HasFilter => Template != null;
/// <summary>The gear rule acts: the forbid rules are on, the rule is ticked and it has a filter.</summary>
public bool Active => ForbidRules.On && Ticked && HasFilter;
/// <summary>The strip switch acts: the forbid rules are on, the switch is ticked and the rule has a filter.</summary>
public bool StripActive => ForbidRules.On && StripTicked && HasFilter;
/// <summary>"Gear your colony drops" or "Gear enemies drop".</summary>
public string Label => (Group == ForbidGroup.Colony ? "BlaxDefaults_ForbidColonyRule" : "BlaxDefaults_ForbidEnemyRule").Translate();
/// <summary>
/// The filter built from the saved template, kept until the template changes (the library replaces an entry
/// on every change, so the reference tells). Null without a saved template.
/// </summary>
public ThingFilter Filter
{
get
{
StorageTemplate t = Template;
if (t == null)
{
filterFor = null;
filter = null;
return null;
}
if (!ReferenceEquals(t, filterFor) || filter == null)
{
filter = ForbidRules.BuildFilter(t);
filterFor = t;
}
return filter;
}
}
/// <summary>The filter allows the thing (def, hit points, quality, special filters). False without a filter.</summary>
public bool Allows(Thing t)
{
ThingFilter f = Filter;
return f != null && t != null && f.Allows(t);
}
/// <summary>The thing's cell passes "Where": anywhere, or inside the home area of its map.</summary>
public bool InsideWhere(Thing t)
{
if (Anywhere)
return true;
Map map = t?.MapHeld;
if (map == null)
return false;
IntVec3 c = t.PositionHeld;
return c.InBounds(map) && map.areaManager.Home[c];
}
/// <summary>
/// The suggested setup, applied only when the player asks (or ticks a rule without a filter). Enemies:
/// every item, hit points 50 to 100%, Normal or better, stripping on. Your colony: every item, full ranges,
/// stripping off. Both anywhere, with unlisted items allowed, so items a mod adds later follow the ranges.
/// </summary>
public StorageTemplate Suggested()
{
var t = new StorageTemplate(Key) { unlisted = UnlistedRule.Allow };
if (Group == ForbidGroup.Enemies)
{
t.hitPoints = new FloatRange(0.5f, 1f);
t.quality = new QualityRange(QualityCategory.Normal, QualityCategory.Legendary);
}
return t;
}
/// <summary>The strip switch the suggested setup sets.</summary>
public bool SuggestedStrip => Group == ForbidGroup.Enemies;
/// <summary>
/// Saves the suggested setup as the filter and sets "Where" to anywhere and the strip switch as the setup
/// says. Leaves the rule's checkbox as it is. Returns whether the defaults file was written.
/// </summary>
public bool UseSuggested()
{
bool ok = DefaultsLibrary.Set(Suggested());
Anywhere = true;
StripTicked = SuggestedStrip;
return ok;
}
/// <summary>
/// Ticks or unticks the rule from the settings page. Ticking a rule that has no filter yet saves the
/// suggested setup first (strip switch included) and returns true, so the page can say so (decided
/// 2026-11-30, design.md "Defaults I picked").
/// </summary>
public bool SetTicked(bool on)
{
bool usedSuggested = false;
if (on && !HasFilter)
{
UseSuggested();
usedSuggested = true;
}
Ticked = on;
return usedSuggested;
}
/// <summary>Forget: deletes the filter and turns the rule and its strip switch off.</summary>
public void Forget()
{
DefaultsLibrary.Forget(Key);
Ticked = false;
StripTicked = false;
}
public override string ToString() => Key;
}
/// <summary>
/// The two forbid rules, the corpse switches and the shared pieces: groups, the parent filter, filters built
/// from templates and the row summary. Work package "forbid" (design.md, 1.1 Forbid rules).
/// </summary>
public static class ForbidRules
{
public static readonly ForbidRule Colony = new ForbidRule(ForbidGroup.Colony, DefaultsKeys.ForbidColony);
public static readonly ForbidRule Enemies = new ForbidRule(ForbidGroup.Enemies, DefaultsKeys.ForbidEnemies);
public static readonly ForbidRule[] All = { Colony, Enemies };
private static ThingFilter parentFilter;
/// <summary>The forbid rules category is on (and the master switch).</summary>
public static bool On => BlaxDefaultsMod.ForbidOn;
public static ForbidRule For(ForbidGroup group) =>
group == ForbidGroup.Colony ? Colony : group == ForbidGroup.Enemies ? Enemies : null;
public static ForbidRule ForKey(string key) => All.FirstOrDefault(r => r.Key == key);
/// <summary>Anything a downing or a death could change: a gear rule acting or a corpse switch on.</summary>
public static bool AnyDropRuleOn =>
On && (Colony.Active || Enemies.Active || CorpseSwitch(CorpseKind.Animal) || CorpseSwitch(CorpseKind.Enemy) || CorpseSwitch(CorpseKind.Other));
/// <summary>
/// The group of a living pawn: your colony when its faction is the player's and it is not a quest lodger,
/// or it is a prisoner of the colony (a prison break leaves it one); otherwise enemies when it is hostile
/// to the player; otherwise none. Read before death: HostileTo is false for anything destroyed.
/// </summary>
public static ForbidGroup GroupOf(Pawn p)
{
Faction player = Faction.OfPlayerSilentFail;
if (p == null || player == null)
return ForbidGroup.None;
if (p.Faction == player && !p.IsQuestLodger())
return ForbidGroup.Colony;
if (p.IsPrisonerOfColony)
return ForbidGroup.Colony;
if (p.HostileTo(player))
return ForbidGroup.Enemies;
return ForbidGroup.None;
}
/// <summary>
/// The group of a dead pawn, from its faction alone: your faction (not a lodger) is your colony, a faction
/// hostile to yours is enemies. A dead prisoner counts by the faction it came from.
/// </summary>
public static ForbidGroup GroupOfDead(Pawn p)
{
Faction player = Faction.OfPlayerSilentFail;
if (p == null || player == null || p.Faction == null)
return ForbidGroup.None;
if (p.Faction == player)
return p.IsQuestLodger() ? ForbidGroup.None : ForbidGroup.Colony;
return p.Faction.HostileTo(player) ? ForbidGroup.Enemies : ForbidGroup.None;
}
/// <summary>
/// The corpse switch a pawn's corpse falls under: animal (any RaceProps.Animal), then enemy (the group read
/// while it was alive), then other.
/// </summary>
public static CorpseKind CorpseKindOf(Pawn p, ForbidGroup group)
{
if (p?.RaceProps != null && p.RaceProps.Animal)
return CorpseKind.Animal;
return group == ForbidGroup.Enemies ? CorpseKind.Enemy : CorpseKind.Other;
}
/// <summary>The corpse switch for this kind is on (and the forbid rules).</summary>
public static bool CorpseSwitch(CorpseKind kind)
{
BlaxDefaultsSettings s = BlaxDefaultsMod.Settings;
if (s == null || !On)
return false;
switch (kind)
{
case CorpseKind.Animal: return s.animalCorpsesAllowed;
case CorpseKind.Enemy: return s.enemyCorpsesAllowed;
default: return s.otherCorpsesAllowed;
}
}
/// <summary>
/// What a forbid filter may ever allow: every storable item (StorageSettings.EverStorableFixedSettings)
/// without the Corpses category, which the corpse switches cover. Built once.
/// </summary>
public static ThingFilter ParentFilter
{
get
{
if (parentFilter == null)
{
var f = new ThingFilter();
f.CopyAllowancesFrom(StorageSettings.EverStorableFixedSettings().filter);
if (ThingCategoryDefOf.Corpses != null)
f.SetAllow(ThingCategoryDefOf.Corpses, false);
f.RecalculateDisplayRootCategory();
parentFilter = f;
}
return parentFilter;
}
}
/// <summary>
/// A base the template goes on: every item of the parent filter, every special filter, full ranges. The
/// edit window's "game's default" for a forbid rule.
/// </summary>
public static StorageSettings BaseSettings()
{
var s = new StorageSettings();
s.filter.SetAllowAll(ParentFilter);
s.filter.AllowedHitPointsPercents = FloatRange.ZeroToOne;
s.filter.AllowedQualityLevels = QualityRange.All;
s.Priority = StoragePriority.Normal;
return s;
}
/// <summary>The ThingFilter a template stands for: the base with the template applied on top.</summary>
public static ThingFilter BuildFilter(StorageTemplate t)
{
StorageSettings s = BaseSettings();
t?.ApplyTo(s, ParentFilter);
return s.filter;
}
/// <summary>
/// What a rule's row says: "all items, hit points 50 to 100%, Normal or better", "allows 120 of 1,903 items,
/// refuses tainted apparel". Counts only names that resolve.
/// </summary>
public static string Summary(StorageTemplate t)
{
if (t == null)
return null;
ThingFilter f = BuildFilter(t);
List<ThingDef> storable = StorageKinds.StorableDefs(ParentFilter).ToList();
int allows = storable.Count(d => f.Allows(d));
var parts = new List<string>();
if (allows == storable.Count)
parts.Add("BlaxDefaults_ForbidSummaryAll".Translate());
else if (allows == 0)
parts.Add("BlaxDefaults_ForbidSummaryNone".Translate());
else
parts.Add("BlaxDefaults_ForbidSummarySome".Translate(allows.ToString("N0", System.Globalization.CultureInfo.InvariantCulture),
storable.Count.ToString("N0", System.Globalization.CultureInfo.InvariantCulture)));
if (t.hitPoints != FloatRange.ZeroToOne)
parts.Add("BlaxDefaults_ForbidSummaryHitPoints".Translate(Percent(t.hitPoints.min), Percent(t.hitPoints.max)));
string quality = QualityText(t.quality);
if (quality != null)
parts.Add(quality);
List<string> refusedSpecial = t.refusedSpecial
.Select(n => DefDatabase<SpecialThingFilterDef>.GetNamedSilentFail(n))
.Where(sf => sf != null && sf.configurable)
.Select(sf => sf.label)
.ToList();
if (refusedSpecial.Count > 0)
parts.Add("BlaxDefaults_ForbidSummaryRefuses".Translate(string.Join(", ", refusedSpecial)));
return string.Join(", ", parts);
}
private static string Percent(float f) => UnityEngine.Mathf.RoundToInt(f * 100f).ToString(System.Globalization.CultureInfo.InvariantCulture);
/// <summary>"Normal or better", "up to Normal", "Normal to Excellent", or null for every quality.</summary>
public static string QualityText(QualityRange q)
{
if (q == QualityRange.All)
return null;
if (q.max == QualityCategory.Legendary)
return "BlaxDefaults_ForbidSummaryQualityMin".Translate(q.min.GetLabel().CapitalizeFirst());
if (q.min == QualityCategory.Awful)
return "BlaxDefaults_ForbidSummaryQualityMax".Translate(q.max.GetLabel().CapitalizeFirst());
if (q.min == q.max)
return "BlaxDefaults_ForbidSummaryQualityOnly".Translate(q.min.GetLabel().CapitalizeFirst());
return "BlaxDefaults_ForbidSummaryQualityRange".Translate(q.min.GetLabel().CapitalizeFirst(), q.max.GetLabel().CapitalizeFirst());
}
/// <summary>The thing's forbidden flag, false for things that can't be forbidden.</summary>
public static bool IsForbiddenFlag(Thing t) => t is ThingWithComps twc && twc.GetComp<CompForbiddable>() is CompForbiddable c && c.Forbidden;
}
}

View File

@ -0,0 +1,153 @@
using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
namespace BlaxDefaults
{
/// <summary>
/// The "Forbid rules" section of the settings page. Work package "forbid" (design.md, 1.1). Order: the
/// category toggle (forbidRules); per rule its checkbox ("Gear your colony drops", "Gear enemies drop"), a row
/// saying what its filter allows with Edit and Forget (Forget asks first), "Where", the strip switch (disabled
/// until the rule has a filter) and "Use the suggested setup" (asks first); a line saying what neutral pawns drop keeps
/// the game's flags; the three corpse switches. Ticking a rule without a filter saves its suggested setup and
/// says so in a message. Works from the main menu: nothing here needs a running game.
/// </summary>
public static class ForbidRulesSection
{
private const float ButtonWidth = 90f;
private const float ButtonHeight = 28f;
private const float RowPad = 4f;
/// <summary>The summary row per rule, cached by template reference (library entries are replaced, never edited).</summary>
private static readonly Dictionary<ForbidRule, (StorageTemplate template, string summary)> summaries =
new Dictionary<ForbidRule, (StorageTemplate, string)>();
public static void Draw(Listing_Standard l)
{
BlaxDefaultsSettings s = BlaxDefaultsMod.Settings;
if (s == null)
return;
l.CheckboxLabeled("BlaxDefaults_ForbidToggle".Translate(), ref s.forbidRules, "BlaxDefaults_ForbidToggleTip".Translate());
foreach (ForbidRule rule in ForbidRules.All)
DrawRule(l, rule);
using (new TextBlock(Color.gray))
l.Label("BlaxDefaults_ForbidNeutral".Translate());
l.Gap(6f);
l.Label("BlaxDefaults_ForbidCorpsesHeader".Translate());
l.CheckboxLabeled("BlaxDefaults_ForbidCorpsesAnimal".Translate(), ref s.animalCorpsesAllowed, "BlaxDefaults_ForbidCorpsesAnimalTip".Translate());
l.CheckboxLabeled("BlaxDefaults_ForbidCorpsesEnemy".Translate(), ref s.enemyCorpsesAllowed, "BlaxDefaults_ForbidCorpsesEnemyTip".Translate());
l.CheckboxLabeled("BlaxDefaults_ForbidCorpsesOther".Translate(), ref s.otherCorpsesAllowed, "BlaxDefaults_ForbidCorpsesOtherTip".Translate());
}
private static void DrawRule(Listing_Standard l, ForbidRule rule)
{
l.Gap(6f);
bool ticked = rule.Ticked;
bool was = ticked;
l.CheckboxLabeled(rule.Label, ref ticked, (rule.Group == ForbidGroup.Colony ? "BlaxDefaults_ForbidColonyRuleTip" : "BlaxDefaults_ForbidEnemyRuleTip").Translate());
if (ticked != was)
Tick(rule, ticked);
DrawFilterRow(l, rule);
string where = rule.Anywhere ? "BlaxDefaults_ForbidWhereAnywhere".Translate() : "BlaxDefaults_ForbidWhereHome".Translate();
if (l.ButtonTextLabeledPct("BlaxDefaults_ForbidWhere".Translate(), where, 0.6f, tooltip: "BlaxDefaults_ForbidWhereTip".Translate()))
{
Find.WindowStack.Add(new FloatMenu(new List<FloatMenuOption>
{
new FloatMenuOption("BlaxDefaults_ForbidWhereAnywhere".Translate(), () => rule.Anywhere = true),
new FloatMenuOption("BlaxDefaults_ForbidWhereHome".Translate(), () => rule.Anywhere = false),
}));
}
bool strip = rule.StripTicked;
Rect stripRect = l.GetRect(Text.LineHeight);
bool hasFilter = rule.HasFilter;
Widgets.CheckboxLabeled(stripRect, "BlaxDefaults_ForbidStrip".Translate(), ref strip, disabled: !hasFilter);
TooltipHandler.TipRegion(stripRect, hasFilter ? "BlaxDefaults_ForbidStripTip".Translate() : "BlaxDefaults_ForbidStripNeedsFilter".Translate());
if (hasFilter)
rule.StripTicked = strip;
l.Gap(2f);
if (l.ButtonText("BlaxDefaults_ForbidUseSuggested".Translate(), widthPct: 0.6f))
ConfirmSuggested(rule);
}
/// <summary>The checkbox: ticking a rule without a filter saves the suggested setup and says so.</summary>
public static void Tick(ForbidRule rule, bool on)
{
if (rule.SetTicked(on))
Messages.Message("BlaxDefaults_ForbidUsedSuggested".Translate(rule.Label, ForbidRules.Summary(rule.Template) ?? ""), MessageTypeDefOf.NeutralEvent, historical: false);
}
private static void DrawFilterRow(Listing_Standard l, ForbidRule rule)
{
StorageTemplate t = rule.Template;
string text;
Color color = Color.white;
if (t != null)
{
text = Summary(rule, t);
}
else if (rule.Ticked && ForbidRules.On)
{
text = "BlaxDefaults_ForbidFilterMissing".Translate();
color = ColorLibrary.RedReadable;
}
else
{
text = "BlaxDefaults_ForbidNoFilter".Translate();
color = Color.gray;
}
float textWidth = l.ColumnWidth - 2f * ButtonWidth - 3f * 6f;
float height = Mathf.Max(ButtonHeight + 2f * RowPad, Text.CalcHeight(text, textWidth) + 2f * RowPad);
Rect row = l.GetRect(height);
Widgets.DrawHighlightIfMouseover(row);
using (new TextBlock(color))
Widgets.Label(new Rect(row.x + 6f, row.y + RowPad, textWidth, height - 2f * RowPad), text);
float buttonY = row.y + (height - ButtonHeight) / 2f;
var forgetRect = new Rect(row.xMax - ButtonWidth, buttonY, ButtonWidth, ButtonHeight);
var editRect = new Rect(forgetRect.x - 6f - ButtonWidth, buttonY, ButtonWidth, ButtonHeight);
if (Widgets.ButtonText(editRect, "BlaxDefaults_PageEdit".Translate()))
OpenEditor(rule);
if (t != null && Widgets.ButtonText(forgetRect, "BlaxDefaults_PageForget".Translate()))
ConfirmForget(rule);
l.Gap(2f);
}
private static string Summary(ForbidRule rule, StorageTemplate t)
{
if (summaries.TryGetValue(rule, out var cached) && ReferenceEquals(cached.template, t))
return cached.summary;
string summary = ForbidRules.Summary(t);
summaries[rule] = (t, summary);
return summary;
}
/// <summary>Edit: the storage editor on the saved filter, or on the suggested setup when there is none yet.</summary>
public static Dialog_EditStorageTemplate Editor(ForbidRule rule) =>
new Dialog_EditStorageTemplate(StorageKinds.ForForbid(rule), (rule.Template ?? rule.Suggested()).CloneTemplate());
private static void OpenEditor(ForbidRule rule) => Find.WindowStack.Add(Editor(rule));
private static void ConfirmForget(ForbidRule rule)
{
Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(
"BlaxDefaults_ForbidForgetConfirm".Translate(rule.Label),
rule.Forget,
destructive: true));
}
private static void ConfirmSuggested(ForbidRule rule)
{
Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(
"BlaxDefaults_ForbidUseSuggestedConfirm".Translate(rule.Label,
(rule.Group == ForbidGroup.Colony ? "BlaxDefaults_ForbidSuggestedColony" : "BlaxDefaults_ForbidSuggestedEnemies").Translate()),
() => rule.UseSuggested()));
}
}
}

View File

@ -9,7 +9,7 @@ using Verse;
namespace BlaxDefaults
{
/// <summary>A mod that sets the same defaults: its package id, name and a keyed string naming what it sets.</summary>
/// <summary>A mod that does some of the same things: its package id, name and a keyed string naming what it does.</summary>
public sealed class OverlapMod
{
public readonly string PackageId;
@ -29,12 +29,14 @@ namespace BlaxDefaults
}
/// <summary>
/// Names active mods that set the same defaults. Work package "setup" (design.md: "Overlap warnings").
/// Names active mods that do some of the same things. Work package "setup" (design.md: "Overlap warnings").
/// Detection only, through Compat.IsActive; no patches against those mods. 1.0 detects for storage
/// 1trickPwnyta's Defaults (defaults.1trickPwnyta), the unofficial Defaults 1.7 repack, Set my Defaults,
/// [FSF] No Default Shelf Storage, [FSF] FrozenSnowFox Tweaks and Default Normal Empty Storage, and for the
/// bill values Better Workbench Management, Default Ingredient Radius, Default Bill Ingredient Radius and
/// Default Until X. Dismissed ids live in BlaxDefaultsSettings.dismissedOverlaps, never in a save.
/// Default Until X. 1.1 adds, for the forbid rules, KilledEnemyAutoAllowed (Continued), Allow Everything and
/// Non uno Pinata, and for the corpse switches Allow Dead Animals. Dismissed ids live in
/// BlaxDefaultsSettings.dismissedOverlaps, never in a save.
///
/// Package ids, each read from the mod's own About/About.xml in its public source repository, with its
/// About/PublishedFileId.txt matching the Workshop item (checked 2026-11-29):
@ -47,11 +49,21 @@ namespace BlaxDefaults
/// mod-structure/About/About.xml.
/// - Default Ingredient Radius (2909706985): github.com/emipa606/DefaultIngredientRadius, branch main.
/// - Default Bill Ingredient Radius (3789671048): github.com/benpbmith/DefaultBillIngredientRadius, branch main.
/// - KilledEnemyAutoAllowed (Continued) (2159090973): github.com/emipa606/KilledEnemyAutoAllowed, branch main
/// (read 2026-11-30).
/// - Allow Everything (2592726874): github.com/andrew-raphael-lukasik/rimworld-mod_allow-everything, branch
/// master (read 2026-11-30).
/// - Allow Dead Animals (2403873031): github.com/andrew-raphael-lukasik/rimworld-mod_allow-dead-animals, branch
/// master (read 2026-11-30).
/// - Non uno Pinata (1778821244): github.com/catgirlfighter/RimWorld_NonUnoPinata, branch master, the source its
/// Workshop page links (it has no PublishedFileId.txt; read 2026-11-30).
/// Not listed yet, because no public About.xml could be read; add each once its id is read from the mod files:
/// - the unofficial Defaults 1.7 repack (3836680679): its Workshop description says its packageId differs
/// from the original's, without naming it (what: BlaxDefaults_OverlapWhatDefaults).
/// - Default Normal Empty Storage (3779351608): no public source; Nexus mod 758 (BlaxDefaults_OverlapWhatEmptyStorage).
/// - Default Until X (3554414830): no public source (BlaxDefaults_OverlapWhatRepeat).
/// Not listed at all: KilledEnemyAutoAllowed's 1.0 original (1858219355). It supports RimWorld 1.0 only, whose
/// About.xml had no packageId, and the id the game makes up for such a mod hashes its description.
/// None of these mods is installed on the test machine, so detection is tested with a simulated id.
/// </summary>
public static class OverlapWarnings
@ -63,8 +75,12 @@ namespace BlaxDefaults
public const string BetterWorkbenchManagement = "falconne.BWM";
public const string DefaultIngredientRadius = "Mlie.DefaultIngredientRadius";
public const string DefaultBillIngredientRadius = "pkthxbai.defaultbillingredientradius";
public const string KilledEnemyAutoAllowed = "Mlie.KilledEnemyAutoAllowed";
public const string AllowEverything = "AndrewRaphaelLukasik.AllowEverything";
public const string NonUnoPinata = "avilmask.NonUnoPinata";
public const string AllowDeadAnimals = "AndrewRaphaelLukasik.AllowDeadAnimals";
/// <summary>Every overlapping mod Defaults knows, in the order the page lists them: storage, then bills.</summary>
/// <summary>Every overlapping mod Defaults knows, in the order the page lists them: storage, bills, forbid rules.</summary>
public static readonly OverlapMod[] Mods =
{
new OverlapMod(Defaults1trickPwnyta, "1trickPwnyta's Defaults", "BlaxDefaults_OverlapWhatDefaults"),
@ -74,6 +90,10 @@ namespace BlaxDefaults
new OverlapMod(BetterWorkbenchManagement, "Better Workbench Management", "BlaxDefaults_OverlapWhatStoreMode"),
new OverlapMod(DefaultIngredientRadius, "Default Ingredient Radius", "BlaxDefaults_OverlapWhatRadius"),
new OverlapMod(DefaultBillIngredientRadius, "Default Bill Ingredient Radius", "BlaxDefaults_OverlapWhatRadius"),
new OverlapMod(KilledEnemyAutoAllowed, "KilledEnemyAutoAllowed (Continued)", "BlaxDefaults_OverlapWhatForbid"),
new OverlapMod(AllowEverything, "Allow Everything", "BlaxDefaults_OverlapWhatAllowEverything"),
new OverlapMod(NonUnoPinata, "Non uno Pinata", "BlaxDefaults_OverlapWhatPinata"),
new OverlapMod(AllowDeadAnimals, "Allow Dead Animals", "BlaxDefaults_OverlapWhatDeadAnimals"),
};
/// <summary>Package ids treated as active on top of the real mod list. For tests only.</summary>
@ -198,8 +218,8 @@ namespace BlaxDefaults
}
/// <summary>
/// The window on the first game loaded in a session: which active mods set the same defaults, each with
/// what it sets and "Don't remind me". Work package "setup".
/// The window on the first game loaded in a session: which active mods do some of the same things, each with
/// what it does and "Don't remind me". Work package "setup".
/// </summary>
public class Dialog_OverlapWarnings : Window
{

View File

@ -17,7 +17,8 @@ namespace BlaxDefaults
/// from inactive mods); the red BrokenFilesLine when the startup load found broken files; then one section
/// per category, each with its toggle: Stockpiles (stockpileDefaults, one row per stockpile entry),
/// Storage buildings (storageDefaults, one row per storage entry, then QuickSetup.DrawButton), Every new
/// bill (billDefaults, then BillValuesSection.Draw); last OverlapWarnings.DrawSettings. Each storage row
/// bill (billDefaults, then BillValuesSection.Draw), Forbid rules (ForbidRulesSection.Draw, 1.1: the
/// forbid:colony and forbid:enemies rows live there); last OverlapWarnings.DrawSettings. Each storage row
/// shows RowSummary with Edit (Dialog_EditStorageTemplate) and Forget (asks first). A row whose kind
/// needs a DLC that is off is drawn disabled with DisabledReason; a row whose kind is not loaded for
/// another reason (a removed mod) shows its inactive names and can't be edited. It all works from the
@ -105,6 +106,10 @@ namespace BlaxDefaults
l.CheckboxLabeled("BlaxDefaults_PageBillsToggle".Translate(), ref s.billDefaults, "BlaxDefaults_PageBillsToggleTip".Translate());
Guarded("BillValuesSection.Draw", () => BillValuesSection.Draw(l));
// Forbid rules
SectionHeader(l, "BlaxDefaults_ForbidSection".Translate());
Guarded("ForbidRulesSection.Draw", () => ForbidRulesSection.Draw(l));
l.GapLine();
Guarded("OverlapWarnings.DrawSettings", () => OverlapWarnings.DrawSettings(l));
}
@ -273,6 +278,9 @@ namespace BlaxDefaults
return null;
if (entry.key == DefaultsKeys.EveryBill)
return "BlaxDefaults_PageSectionBills".Translate();
ForbidRule rule = ForbidRules.ForKey(entry.key);
if (rule != null)
return rule.Label;
StorageKind kind = StorageKinds.ForKey(entry.key);
string label = kind?.Label;
return label.NullOrEmpty() ? DefaultsKeys.NameOf(entry.key) : label.CapitalizeFirst();

View File

@ -55,8 +55,9 @@ namespace BlaxDefaults
}
/// <summary>
/// One kind that has its own storage default: a stockpile type or a storage building def. Knows its
/// key, label, parent filter and the game's default, and loads a default onto settings.
/// One kind that has its own storage default: a stockpile type, a storage building def, or (1.1) a forbid
/// rule, whose filter is a template too. Knows its key, label, parent filter and the game's default, and
/// loads a default onto settings.
/// </summary>
public sealed class StorageKind
{
@ -65,6 +66,8 @@ namespace BlaxDefaults
public readonly ThingDef Def;
/// <summary>The stockpile type, or null for a building.</summary>
public readonly StockpileType Stockpile;
/// <summary>The forbid rule whose filter this is, or null for storage.</summary>
public readonly ForbidRule Forbid;
public StorageKind(ThingDef def)
{
@ -78,10 +81,19 @@ namespace BlaxDefaults
Key = stockpile.Key;
}
public StorageKind(ForbidRule rule)
{
Forbid = rule;
Key = rule.Key;
}
public bool IsStockpile => Stockpile != null;
/// <summary>"shelf", "stockpile".</summary>
public string Label => Def != null ? Def.label : Stockpile.Label;
/// <summary>A forbid rule's filter: no priority, the unlisted rule is Refuse or Allow.</summary>
public bool IsForbid => Forbid != null;
/// <summary>"shelf", "stockpile", "gear enemies drop".</summary>
public string Label => Def != null ? Def.label : Forbid != null ? Forbid.Label : Stockpile.Label;
/// <summary>
/// "shelves", "stockpiles". A key BlaxDefaults_Plural_&lt;defName&gt; in the active language wins over
@ -91,6 +103,8 @@ namespace BlaxDefaults
{
get
{
if (Forbid != null)
return Forbid.Label;
if (Def == null)
return Stockpile.LabelPlural;
string key = "BlaxDefaults_Plural_" + Def.defName;
@ -99,13 +113,15 @@ namespace BlaxDefaults
}
/// <summary>What settings of this kind may ever allow: the building's fixedStorageSettings, else every storable item.</summary>
public ThingFilter ParentFilter => Def != null ? StorageKinds.ParentFilterFor(Def) : StorageKinds.StockpileParentFilter;
public ThingFilter ParentFilter =>
Def != null ? StorageKinds.ParentFilterFor(Def) : Forbid != null ? ForbidRules.ParentFilter : StorageKinds.StockpileParentFilter;
/// <summary>The saved default, or null.</summary>
public StorageTemplate Saved => DefaultsLibrary.Get<StorageTemplate>(Key);
/// <summary>A fresh scratch StorageSettings holding the game's default for this kind.</summary>
public StorageSettings GameDefault() => Def != null ? StorageKinds.GameDefaultFor(Def) : StorageKinds.GameDefaultFor(Stockpile);
public StorageSettings GameDefault() =>
Def != null ? StorageKinds.GameDefaultFor(Def) : Forbid != null ? ForbidRules.BaseSettings() : StorageKinds.GameDefaultFor(Stockpile);
/// <summary>Replaces the target's priority, filter, special filters and ranges with the game's default.</summary>
public void LoadGameDefault(StorageSettings target) => target.CopyFrom(GameDefault());
@ -261,6 +277,8 @@ namespace BlaxDefaults
public static StorageKind ForStockpile(StockpileType type) => type == null ? null : new StorageKind(type);
public static StorageKind ForForbid(ForbidRule rule) => rule == null ? null : new StorageKind(rule);
/// <summary>The kind for a library key, or null when its def or designator is not loaded.</summary>
public static StorageKind ForKey(string key)
{
@ -268,6 +286,8 @@ namespace BlaxDefaults
return ForDef(DefDatabase<ThingDef>.GetNamedSilentFail(DefaultsKeys.NameOf(key)));
if (DefaultsKeys.IsStockpile(key))
return ForStockpile(StockpileTypeForKey(key));
if (DefaultsKeys.IsForbid(key))
return ForForbid(ForbidRules.ForKey(key));
return null;
}

View File

@ -1,15 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using BlaxDefaults;
using RimWorld;
using RimWorld.Planet;
using Verse;
namespace BlaxDefaultsTests
{
/// <summary>
/// Shared helpers for tests. Things, zones and areas made here are removed after each test unless passed
/// to Keep() or KeepZone(). Mod settings and the defaults library are restored after each test (the
/// Shared helpers for tests. Things, pawns, zones and areas made here are removed after each test unless
/// passed to Keep() or KeepZone(). Mod settings and the defaults library are restored after each test (the
/// library in memory only, the file is not rewritten), so tests may change them freely. Feature-specific
/// helpers belong in the feature's own test file.
/// </summary>
@ -20,6 +22,8 @@ namespace BlaxDefaultsTests
private static readonly List<Zone> madeZones = new List<Zone>();
private static readonly HashSet<Zone> keptZones = new HashSet<Zone>();
private static readonly List<CellRect> areas = new List<CellRect>();
private static readonly List<Pawn> madePawns = new List<Pawn>();
private static readonly List<Action> afterTest = new List<Action>();
private static List<DefaultsEntry> librarySnapshot;
private static bool keepLibrary;
@ -79,13 +83,17 @@ namespace BlaxDefaultsTests
/// <summary>
/// A free area of this size near the map centre: in bounds, away from the edge, unfogged, standable,
/// heavy-supporting terrain, no zone, nothing but grass or filth, which is removed. Tracked: buildings,
/// blueprints, frames, items and zones in it are removed after the test (kept ones stay).
/// inside a district (pawns spawned there can walk and work as in vanilla; the map centre can be rock), heavy-supporting
/// terrain, no zone, nothing but grass or filth, which is removed. Searches 40 cells around the centre,
/// then the whole map by distance. Tracked: buildings, blueprints, frames, items and zones in it are
/// removed after the test (kept ones stay).
/// </summary>
public static CellRect EmptyArea(int width, int height)
{
Map map = Map;
foreach (IntVec3 origin in GenRadial.RadialCellsAround(map.Center, 40f, useCenter: true))
IEnumerable<IntVec3> near = GenRadial.RadialCellsAround(map.Center, 40f, useCenter: true);
IEnumerable<IntVec3> rest = map.AllCells.OrderBy(c => (c - map.Center).LengthHorizontalSquared);
foreach (IntVec3 origin in near.Concat(rest))
{
var rect = new CellRect(origin.x, origin.z, width, height);
if (rect.Cells.All(c => Free(c, map)))
@ -97,12 +105,12 @@ namespace BlaxDefaultsTests
return rect;
}
}
T.Fail("no empty " + width + "x" + height + " area near the map centre");
T.Fail("no empty " + width + "x" + height + " area on the map");
return default;
}
private static bool Free(IntVec3 c, Map map) =>
c.InBounds(map) && !c.CloseToEdge(map, 5) && !c.Fogged(map) && c.Standable(map)
c.InBounds(map) && !c.CloseToEdge(map, 5) && !c.Fogged(map) && c.Standable(map) && c.GetDistrict(map) != null
&& c.SupportsStructureType(map, TerrainAffordanceDefOf.Heavy) && c.GetZone(map) == null
&& map.thingGrid.ThingsListAt(c).All(t => (t is Plant plant && !plant.def.plant.IsTree) || t is Filth)
&& !areas.Any(r => r.Contains(c));
@ -133,6 +141,31 @@ namespace BlaxDefaultsTests
return zone;
}
/// <summary>Destroys the pawn (or its corpse) after the test unless kept.</summary>
public static Pawn TrackPawn(Pawn p)
{
if (p != null) madePawns.Add(p);
return p;
}
/// <summary>Runs after the test, last added first, before the things and zones are removed (restore a value the test changed).</summary>
public static void AfterTest(Action undo)
{
if (undo != null) afterTest.Add(undo);
}
/// <summary>A visible, non-player, humanlike faction that is not hostile to the player, or null.</summary>
public static Faction FriendlyFaction() =>
Find.FactionManager.AllFactionsVisible
.Where(f => !f.IsPlayer && !f.defeated && f.def.humanlikeFaction && !f.HostileTo(Faction.OfPlayer))
.OrderBy(f => f.loadID).FirstOrDefault();
/// <summary>A visible, non-player, humanlike faction hostile to the player, or null.</summary>
public static Faction HostileFaction() =>
Find.FactionManager.AllFactionsVisible
.Where(f => !f.IsPlayer && !f.defeated && f.def.humanlikeFaction && f.HostileTo(Faction.OfPlayer))
.OrderBy(f => f.loadID).FirstOrDefault();
/// <summary>A spawned free colonist of the quick-test colony, to complete frames with.</summary>
public static Pawn Worker()
{
@ -201,6 +234,27 @@ namespace BlaxDefaultsTests
public static void Cleanup()
{
for (int i = afterTest.Count - 1; i >= 0; i--)
{
try { afterTest[i](); }
catch (Exception e) { T.Info("after-test step threw: " + e.Message); }
}
afterTest.Clear();
foreach (Pawn p in madePawns)
{
if (p == null || kept.Contains(p)) continue;
if (p.Corpse != null && !kept.Contains(p.Corpse) && !p.Corpse.Destroyed)
p.Corpse.Destroy(DestroyMode.Vanish);
else if (p.Spawned)
p.Destroy(DestroyMode.Vanish);
else if (!p.Destroyed && p.ParentHolder is Pawn_CarryTracker carrier)
carrier.innerContainer.Remove(p);
if (!p.Destroyed && !p.Spawned && p.IsWorldPawn())
Find.WorldPawns.RemoveAndDiscardPawnViaGC(p);
}
madePawns.Clear();
foreach (Thing t in made)
{
if (t != null && !kept.Contains(t) && !t.Destroyed && t.Spawned)

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,9 @@
<#
Runs the in-game test suite. RimWorld 1.7 starts headless (no window, no focus change) with its
own save data folder, so your mod list, saves, settings and defaults file stay untouched. Needs Steam
running and the Harmony mod from the Workshop. Exit code: 0 all passed, 1 failures, 2 the run didn't finish.
running and the Harmony mod from the Workshop. Exit code: 0 all passed, 1 failures or errors the mod logged
between tests (MODERR lines, strayModErrors on the SUMMARY line; the Workshop upload refuses those too),
2 the run didn't finish.
.\Tests\run-tests.ps1 Harmony, the installed DLCs, Blax Defaults
.\Tests\run-tests.ps1 -Compat also the installed mods Defaults is tested next to: RimFridge, Weapon Racks,
@ -214,4 +216,7 @@ $lines = Get-Content -LiteralPath $results -Encoding UTF8
$lines | ForEach-Object { Write-Host $_ }
if (-not ($lines -match '^END$')) { Write-Host 'The run did not finish.'; exit 2 }
if ($lines -match '^FAIL ') { exit 1 }
# Errors logged between tests (a reload, a hook running while the game settles) fail no single test.
$summary = @($lines -match '^SUMMARY ') | Select-Object -Last 1
if ($summary -match '\bstrayModErrors=([1-9]\d*)') { Write-Host "Blax Defaults logged $($Matches[1]) error(s) between tests (MODERR lines)."; exit 1 }
exit 0

BIN
docs/art/steam/forbid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -2,7 +2,7 @@
Every new shelf starts at Preferred and pulls meals out of the freezer, every new bill searches the whole map to make one item, and every tamed husky starts with no area and no training. Blax Defaults lets you tune one stockpile, shelf, bill, crop, building or animal, click "Make default", and every new one you make starts like it. Its forbid rules decide what stays forbidden when pawns go down, die or are stripped: the good weapons, the food and the medicine get allowed, the junk stays forbidden. Colonists, slaves and prisoners stay with Blax Castes.
Status: 1.0 is built; 1.1 to 1.5 are designed, no code yet. Checked against the RimWorld 1.7.5021 game code on 2026-11-29. RimWorld 1.7, package id `blax.defaults`. It keeps nothing in the save, so it can be added to or removed from a running colony at any time.
Status: 1.0 is on the Workshop; 1.1 (forbid rules) is built (2026-11-30); 1.2 to 1.5 are designed, no code yet. Checked against the RimWorld 1.7.5021 game code on 2026-11-29. RimWorld 1.7, package id `blax.defaults`. It keeps nothing in the save, so it can be added to or removed from a running colony at any time.
Changes on 2026-11-29, after two review rounds:
@ -23,7 +23,7 @@ Changes on 2026-11-29, forbid rules reworked:
- The rules reach apparel: an opt-in strip switch per rule forbids what stripping drops when the filter refuses it. Butchering stays vanilla.
- Everything the rules allow, corpses included, waits until no enemy that can still fight is on the map.
- A downed colonist's main weapon stays forbidden only while the colonist lies where it fell, for it to pick up again, as vanilla does. Once the colonist is rescued, carried off or dies, it has forgotten the weapon, and the rule decides. That also covers a kidnapped colonist's weapon, so its backlog item goes.
- After review: escaping prisoners stay in your colony, like rebelling slaves; a rule can't be turned on before it has a filter; an animal's corpse follows the animal switch even when the animal was hostile. The gear rules take 2.5 days instead of 2, and 1.1 stays at 4.
- After review: escaping prisoners stay in your colony, like rebelling slaves; a rule without a filter takes its suggested setup when ticked (Fabian's call, 2026-11-30, replacing "can't be turned on before it has a filter"); an animal's corpse follows the animal switch even when the animal was hostile. The gear rules take 2.5 days instead of 2, and 1.1 stays at 4.
- Hooks: scopes on `Pawn.Kill` and `Pawn_HealthTracker.MakeDowned` with a recorder on the `CompForbiddable.Forbidden` setter replace the postfix on `Pawn.DropAndForbidEverything`. That catches stacks a drop merges into and leaves trades, captures and map generation alone.
- Matched with the Castes, Zones and Slaves docs: all four carry the "go down, die or are stripped" sentence and Zones' work rule areas (its 1.6) in their ownership lines, and say "allowed area" for Castes' area slot. The Zones section says how work rule areas and the forbid rules compose, and the release numbers each doc cites of the others follow this re-cut.
@ -58,7 +58,7 @@ Change if you disagree.
- "Where" defaults to anywhere. Inside the home area the game already leaves dropped food and medicine allowed and forbids only weapons and an enemy's loot, so a home-area rule would not reach the food left forbidden outdoors.
- Everything a rule allows waits until no enemy that can still fight is on the map, so no rule sends a hauler into a fight. No switch for it.
- A downed colonist's main weapon stays forbidden only while the colonist lies where it fell, for it to pick up after getting up, as vanilla does. Once the colonist is rescued, carried off or dies, it has forgotten the weapon, and the rule decides.
- A rule can't be turned on until it has a filter, saved with Edit or the suggested setup. Forgetting the filter turns the rule off.
- Ticking a rule that has no filter yet saves its suggested setup first and turns the rule on in one click (decided 2026-11-30); Edit changes it from there. Forgetting the filter turns the rule off.
- Suggested setups, applied only when you press the button: enemies get every item, but hit points 50 to 100% and Normal or better, anywhere, stripping on, so a Poor rifle or one below 50% stays forbidden while food, medicine, drugs and silver are allowed. Your colony gets every item, full ranges, anywhere, stripping off.
- Butchering strips corpses too but stays vanilla under the strip switch: what a butcher strips lands next to the bench, where a burn bill or a dumping stockpile takes it.
- Defaults are global, shared by every save, in their own file in the game's Config folder. Not in mod settings: a mod settings file that fails to load is replaced by fresh settings on the next write, which is how Defaults' users lost theirs. No per-colony layer yet.
@ -207,7 +207,7 @@ Setup, S (half a day): the repo with About.xml, the csproj and the `[StaticConst
- The game's default is built on a scratch `new StorageSettings()` and written with `StorageSettings.CopyFrom` (:90-95), whose `ThingFilter.CopyAllowancesFrom` replaces the allowed defs, special filters and ranges (Verse/ThingFilter.cs:634-665). For stockpiles the scratch gets `SetFromPreset` with the type's preset and Priority Normal, as the vanilla constructor does (RimWorld/Zone_Stockpile.cs:37-43). `SetFromPreset` alone only adds categories (Verse/ThingFilter.cs:779-800), so on an existing stockpile it would keep everything already allowed. For buildings the scratch copies `def.building.defaultStorageSettings` (RimWorld/BuildingProperties.cs:289), or keeps the empty filter at the priority a fresh `StorageSettings(parent)` takes when the def has none, as `PostMake` leaves it. Defaults never edits that field, so it always holds the loaded value.
- **Settings:** covered by `enabled`.
- **Save and removal:** writes only the selected thing's own storage settings.
- **Overlaps:** Blax Zones 1.3 adds "Receive deliveries" and sell gizmos to the same stockpiles and shelves; a button inside the tab keeps the gizmo bar short. Adaptive Storage - Global Settings (3530785055, 61,986, 1.7) applies filters to many buildings on demand; the last click wins.
- **Overlaps:** Blax Zones 1.4 adds "Receive deliveries" and sell gizmos to the same stockpiles and shelves; a button inside the tab keeps the gizmo bar short. Adaptive Storage - Global Settings (3530785055, 61,986, 1.7) applies filters to many buildings on demand; the last click wins.
- **Replaces:** for one preset per kind, the manual save and load of [KV] Save Storage, Outfit, Crafting, Drug and Operation Settings (3222246658, 109,174, 1.7) and Simple Stockpile Presets (Continued) (2189006791, 16,278, 1.7).
- **Effort:** S, half a day.
- **Tests:** The menu builder `StorageDefaultsMenu.OptionsFor(parent)` runs on a stockpile, a dumping stockpile, a shelf, a shelf blueprint and two linked shelves.
@ -344,7 +344,7 @@ Per pawn kind:
#### Gear rules for your colony and for enemies
- **Players get:** Two rules on the settings page, "Gear your colony drops" and "Gear enemies drop", each off until you turn it on. When one of the group's pawns goes down or dies, everything the game forbids that matches the rule's filter is allowed again once the fight is over (next feature); what doesn't match stays forbidden, as in vanilla. A rule never forbids a dropped thing the game left allowed. Your colony is colonists, slaves (Ideology), colony mechs (Biotech), colony animals and prisoners, also while they break out; enemies are everyone else hostile to you when they go down or die. Neutral visitors, traders and quest lodgers keep the game's rules, and a line under the rules says so. A downed colonist's main weapon stays forbidden while the colonist lies where it fell, so it picks the weapon up after getting up, as vanilla does; once the colonist is rescued, carried off or dies, the rule decides. Each rule has:
- a filter: Edit opens the vanilla item filter with the hit points and quality sliders stockpiles have and its special filters (tainted, biocoded, rotten, smeltable). The row says what it allows ("all items, hit points 50 to 100%, Normal or better"). Until a filter is saved, by Edit or the suggested setup, the rule's checkbox and its strip switch are disabled and say "Edit the filter or use the suggested setup first". Forget on the row asks first, deletes the filter and turns the rule and its strip switch off;
- a filter: Edit opens the vanilla item filter with the hit points and quality sliders stockpiles have and its special filters (tainted, biocoded, rotten, smeltable). The row says what it allows ("all items, hit points 50 to 100%, Normal or better"). Ticking the rule while it has no filter saves the suggested setup (below) as its filter, strip switch included, and turns it on; a message says so ("Using the suggested setup: ..."). The strip switch stays disabled until the rule has a filter. Forget on the row asks first, deletes the filter and turns the rule and its strip switch off;
- "Where": anywhere (the default) or only inside the home area;
- "Stripping forbids what doesn't match" (see below);
- "Use the suggested setup", which asks first. Enemies: every item, hit points 50 to 100%, Normal or better, anywhere, stripping on, so a Poor rifle or one below 50% stays forbidden while food, medicine, drugs and silver are allowed. Your colony: every item, full ranges, anywhere, stripping off.
@ -369,7 +369,7 @@ Per pawn kind:
- Forced Rearmament (3232549170, 22,494, 1.7) and Where is my weapon? (1539028008, 201,950, no 1.7) make colonists fetch their dropped weapon; the remembered weapon waiting while its owner lies where it fell suits both.
- Allow Tool (761421485, 1,388,637, no 1.7; its changelog lists an option to unforbid the items next to a downed pawn you finish off) and Keyz' Allow Utilities (3524716849, 91,139, 1.7) allow by hand and compose. Pick Up And Haul (1279012058, 1,784,724, no 1.7) hauls what is allowed. Hospitality (753498552, 768,458, no 1.7): guests stay vanilla.
- No Workshop mod found that allows dropped things by quality or condition (searched 2026-11-29).
- The overlap warnings gain this category: KilledEnemyAutoAllowed (Continued) and its 1.0 original (1858219355, 291), Allow Everything, Non uno Pinata and, for the corpse rules, Allow Dead Animals. Package ids are read from each mod's About.xml before shipping.
- The overlap warnings gain this category: KilledEnemyAutoAllowed (Continued) (`Mlie.KilledEnemyAutoAllowed`), Allow Everything (`AndrewRaphaelLukasik.AllowEverything`), Non uno Pinata (`avilmask.NonUnoPinata`) and, for the corpse rules, Allow Dead Animals (`AndrewRaphaelLukasik.AllowDeadAnimals`), each read from the About.xml in the mod's public source on 2026-11-30. Not detected: the 1.0 original of KilledEnemyAutoAllowed (1858219355, 291, 1.0 only), whose About.xml predates package ids; the id the game makes up for it hashes its description. The overlap texts say these mods "do some of the same things", since they set no starting settings.
- **Replaces:** KilledEnemyAutoAllowed (Continued) (5.2k) for your colony and enemies: with both rules on, every item allowed, anywhere, and the corpse rules on, what dying pawns drop is allowed everywhere, while neutral pawns' drops stay vanilla. Allow Everything (3.8k) for what downed and dead pawns drop.
- **Effort:** M + S, 2.5 days, including the settings section and the suggested setups; the S is the remembered weapon's wait.
- **Tests:** No hostile pawn on the test map unless a test says so.
@ -662,7 +662,7 @@ Castes owns every humanlike player pawn: colonists, slaves and prisoners, their
- Zone beds are spawned by Zones' `AddCell`, not by a frame, so the build scope (1.2) never sees them.
- Zones' own zone defaults stay in Zones: its backlog holds "Make default" for new delivery and sleeping zones.
- The forbid rules (1.1) act only inside `Pawn.Kill`, `Pawn_HealthTracker.MakeDowned` and `Pawn.Strip`, and the wait list holds only what they recorded there, so goods Zones delivers keep the forbid flag of the vanilla call.
- Work rule areas (Zones 1.6) compose with the forbid rules. A rule decides whether a dropped thing stays forbidden; Zones' "Don't haul from here" decides whether haulers fetch it, and "Haul first" brings it in before other hauling. So a Normal rifle allowed in a killbox painted "Don't haul from here" lies there until the player unticks the rule. "Only inside the home area" reads the vanilla home area (`map.areaManager.Home`), which work rule areas never change. Neither mod hooks the other's code.
- Work rule areas (Zones 1.3) compose with the forbid rules. A rule decides whether a dropped thing stays forbidden; Zones' "Don't haul from here" decides whether haulers fetch it, and "Haul first" brings it in before other hauling. So a Normal rifle allowed in a killbox painted "Don't haul from here" lies there until the player unticks the rule. "Only inside the home area" reads the vanilla home area (`map.areaManager.Home`), which work rule areas never change. Neither mod hooks the other's code.
### Blax Slaves

View File

@ -1,4 +1,4 @@
[b]Your own starting settings for new stockpiles, shelves and bills.[/b] Set up one shelf, click "Make default for new shelves", and every new shelf starts like it. Nothing changes until you save a default, and the things you already have keep their settings. Colonists, slaves and prisoners are not part of this mod: that is the job of [url=https://steamcommunity.com/sharedfiles/filedetails/?id=3848261054]Blax Castes[/url].
[b]Your own starting settings for new stockpiles, shelves and bills, and rules for what stays forbidden when pawns go down or die.[/b] Set up one shelf, click "Make default for new shelves", and every new shelf starts like it. Nothing changes until you save a default or turn a rule on, and the things you already have keep their settings. Colonists, slaves and prisoners are not part of this mod: that is the job of [url=https://steamcommunity.com/sharedfiles/filedetails/?id=3848261054]Blax Castes[/url].
✅ RimWorld 1.7 🔧 Needs [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2009463077]Harmony[/url] 🧩 Works with any DLC combination 💾 Nothing goes into your save
@ -6,7 +6,7 @@
[list]
[*]📦 [b]New stockpiles start from your default.[/b] Drag a stockpile or a dumping stockpile and it gets the filter and priority you saved for that type. Growing an existing stockpile leaves its filter alone.
[*]🗄️ [b]New storage buildings too.[/b] Shelves, small shelves, bookcases and hoppers start with your default from the moment you place the blueprint, and so does modded storage built the same way, such as the racks from Weapon Racks. Changes you make on the blueprint still win, and a shelf that auto-rebuild puts back keeps its old settings.
[*]🔘 [b]A "Defaults" button in the storage tab[/b] with "Make default for new shelves", "Load your default", "Load the game's default" and "Forget the default for new shelves", which asks first. On a stockpile you pick the stockpile type. The tooltip tells you whether new ones start from your default.
[*]🔘 [b]A "Defaults" button in the storage tab[/b] with "Make default for new shelves", "Load your default", "Load the game's default" and "Forget the default for new shelves", which asks first. On a stockpile you pick the stockpile type.
[*]🧹 [b]New shelves start empty.[/b] The settings page button "New shelves start empty at Normal" lists your storage buildings with general-purpose shelves ticked, and Confirm saves an empty default at Normal for each ticked one. Hoppers start unticked so the nutrient paste dispenser keeps its food, and so do bookcases, storage for one kind of item and kinds that already have a default. These defaults also refuse items that mods add later.
[*]🏚️ [b]Only what you build.[/b] Ruins, map generation and trader stock keep the game's settings, and a default never makes a building take items it can't hold.
[/list]
@ -18,21 +18,28 @@
[*]🩺 [b]Left alone:[/b] surgery, mech gestation, pasted bills and the bills you already have.
[/list]
[img]https://cdn.blax.at/blax-gaming/defaults/forbid.png[/img]
[list]
[*]🛡️ [b]Gear rules for your colony and for enemies.[/b] When a pawn goes down or dies, what the game forbids is allowed again if it matches your filter, with hit points and quality ranges. Say enemy weapons only at 50 to 100% and Normal or better, food and medicine always.
[*]⚔️ [b]Once the fight is over,[/b] so no hauler walks into one. A downed colonist's weapon stays forbidden while the colonist lies there, so it picks it up again.
[*]👕 [b]Stripping can forbid what doesn't match,[/b] such as a Poor tuque. Butchering stays as it is.
[*]🦴 [b]Corpses outside the home area[/b] can stay allowed: animals, enemies, the rest.
[*]⚙️ Every rule ships off; ticking one uses a suggested setup you can edit. What visitors, traders and quest lodgers drop stays vanilla.
[/list]
[img]https://cdn.blax.at/blax-gaming/defaults/file.png[/img]
[list]
[*]📁 [b]One file for every save.[/b] Your defaults live in their own file in the game's Config folder (BlaxDefaults/Defaults.xml), shared by every save and never written into one. Add or remove the mod in a running colony.
[*]🛟 [b]Hard to lose.[/b] Each write is read back and checked before it replaces the file, the previous version stays as a backup, and a broken file is kept under its own name instead of overwriting the backup.
[*]🔌 [b]Removed a mod?[/b] Its items stay in your defaults, are skipped while it is gone, and work again when it is back.
[*]📋 [b]Settings page[/b] (Mod settings > Blax Defaults): every default with what it sets, Edit and Forget, and a switch per section. It works from the main menu.
[*]⚠️ [b]Overlap warnings.[/b] Mods that set the same starting settings are named on the settings page and in one window on the first game you load, with "Don't remind me".
[*]⚠️ [b]Overlap warnings.[/b] Mods that do the same things are named on the settings page and in one window on the first game you load, with "Don't remind me".
[/list]
🧩 [b]Any DLC combination works,[/b] core only included, and 1.0 needs no DLC for anything. Items from a DLC in a default, such as wastepack in a dumping stockpile, are skipped while that DLC is off and work again when it is back. Anomaly's corpse stockpile and Odyssey's fishing zones are not covered.
🧩 [b]Any DLC combination works,[/b] core only included, and no feature needs a DLC. Items from a DLC in a default, such as wastepack in a dumping stockpile, are skipped while that DLC is off and work again when it is back. Anomaly's corpse stockpile and Odyssey's fishing zones are not covered.
[img]https://cdn.blax.at/blax-gaming/defaults/planned.png[/img]
Not in this version yet. Planned for the next releases:
Planned for the next releases:
[list]
[*]🛡️ Forbid rules: when your colonists, slaves, prisoners or enemies go down or die, dropped gear that matches your filter is allowed again once the fight is over. For example enemy weapons and apparel only at 50% hit points or more and Normal quality or better, their food and medicine always.
[*]🪦 Graves, sarcophagi, mortars and other storage, defaults per recipe and the bills a new workbench comes with.
[*]🐄 Animals: area, follow flags and training per species, auto-slaughter limits.
[*]🌱 Crops for new growing zones, settings for new doors, lamps, heaters and coolers.
@ -43,13 +50,15 @@ Not in this version yet. Planned for the next releases:
Blax Defaults does what these mods do, so you can unsubscribe them. While one is active, the settings page names it.
[list]
[*]♻️ [FSF] No Default Shelf Storage (the quick setup empties new shelves per kind and leaves hoppers alone)
[*]♻️ Default Ingredient Radius
[*]♻️ Default Bill Ingredient Radius
[*]♻️ Default Ingredient Radius and Default Bill Ingredient Radius
[*]♻️ KilledEnemyAutoAllowed (Continued) (gear rules with every item, corpse switches on)
[*]♻️ Allow Dead Animals (the animal corpse switch)
[*]♻️ Allow Everything (for what downed and dead pawns drop)
[/list]
[img]https://cdn.blax.at/blax-gaming/defaults/compatibility.png[/img]
[list]
[*]⚠️ 1trickPwnyta's Defaults and Set my Defaults set starting settings for stockpiles and shelves too, and 1trickPwnyta's sets values for every new bill. Blax Defaults 1.0 covers those, so set each in one mod. Their bill lists per recipe or per workbench are not in 1.0 (planned for 1.1), so keep those mods for that and for their other defaults. The overlap warning doesn't detect the unofficial Defaults 1.7 repack yet.
[*]⚠️ 1trickPwnyta's Defaults and Set my Defaults set starting settings for stockpiles and shelves too, and 1trickPwnyta's sets values for every new bill. Set each of those in one mod. Their bill lists per recipe or per workbench come in 1.2, so keep those mods for that and their other defaults. The overlap warning doesn't detect the unofficial Defaults 1.7 repack yet.
[*]⚠️ [FSF] FrozenSnowFox Tweaks: its "No Default Storage Settings" option does what the quick setup does. Use one of the two.
[*]⚠️ Better Workbench Management also sets where the products of new bills go. Set that in one mod only.
[*]✔️ Replace Stuff: replacing a shelf's material keeps its settings.