diff --git a/1.7/Assemblies/BlaxDefaults.dll b/1.7/Assemblies/BlaxDefaults.dll
index e72e05b..27f8160 100644
Binary files a/1.7/Assemblies/BlaxDefaults.dll and b/1.7/Assemblies/BlaxDefaults.dll differ
diff --git a/1.7/Assemblies/BlaxDefaults.pdb b/1.7/Assemblies/BlaxDefaults.pdb
index 16faccb..472a061 100644
Binary files a/1.7/Assemblies/BlaxDefaults.pdb and b/1.7/Assemblies/BlaxDefaults.pdb differ
diff --git a/About/About.xml b/About/About.xml
index c92c7a5..0e8b708 100644
--- a/About/About.xml
+++ b/About/About.xml
@@ -3,7 +3,7 @@
Blax Defaults
Blax Gaming
blax.defaults
- 1.0.0
+ 1.1.0
1.7
@@ -18,7 +18,7 @@
brrainz.harmony
- 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.
+ 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.
<color=#19C63C>Storage</color>
- 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.
+<color=#19C63C>Forbid rules</color>
+- 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.
+
<color=#19C63C>Your defaults stay</color>
- 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.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d556f1e..0ce7940 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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.
diff --git a/Languages/English/Keyed/BlaxDefaults_forbid.xml b/Languages/English/Keyed/BlaxDefaults_forbid.xml
new file mode 100644
index 0000000..5bbbdc9
--- /dev/null
+++ b/Languages/English/Keyed/BlaxDefaults_forbid.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+ Forbid rules
+ Forbid rules act when pawns go down, die or are stripped
+ Off: dropped gear, stripped things and corpses keep the game's forbidden flags. The rules and filters below stay saved.
+
+
+ Gear your colony drops
+ 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.
+ Gear enemies drop
+ 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.
+ No filter yet. Ticking the rule saves the suggested setup; Edit makes your own.
+ The rule is on, but its filter is not loaded (the defaults file could not be read), so it acts as off.
+ Where
+ Anywhere
+ Only inside the home area
+ 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.
+ Stripping forbids what doesn't match
+ 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.
+ Tick the rule or edit its filter first.
+ Use the suggested setup
+ Replace the filter of "{0}" with the suggested setup? {1}
+ Every item, any hit points and quality, anywhere, stripping off.
+ 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.
+ Using the suggested setup for "{0}": {1}. Edit changes it.
+ Forget the filter of "{0}"? The rule and its strip switch turn off, and dropped gear keeps the game's flags again.
+ What neutral visitors, traders and quest lodgers drop keeps the game's flags.
+
+
+ all items
+ no items
+ allows {0} of {1} items
+ hit points {0} to {1}%
+ {0} or better
+ up to {0}
+ only {0}
+ {0} to {1}
+ refuses: {0}
+
+
+ Filter: {0}
+ 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.
+
+
+ The game forbids new corpses outside the home area. These switches leave them allowed, once the fight is over:
+ Animal corpses outside the home area are allowed
+ Any animal: wild ones, yours, manhunters and predators.
+ Enemy corpses outside the home area are allowed
+ Anyone hostile to you that is not an animal: raiders, hostile mechs and the like.
+ Other corpses outside the home area are allowed
+ Everyone else: your own colonists and mechs, neutral visitors, traders.
+
+
+ Leaves everything pawns drop when they go down or die allowed, corpses too
+ Allows the items on the map, also what a forbid rule leaves forbidden
+ Keeps gear on pawns that go down or die, so little drops for the forbid rules to sort
+ Allows animal corpses, like the animal corpse switch
+
+
diff --git a/Languages/English/Keyed/BlaxDefaults_page.xml b/Languages/English/Keyed/BlaxDefaults_page.xml
index e926f3c..935c565 100644
--- a/Languages/English/Keyed/BlaxDefaults_page.xml
+++ b/Languages/English/Keyed/BlaxDefaults_page.xml
@@ -5,7 +5,7 @@
Apply saved defaults to new things
- 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.
+ 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.
No defaults saved yet.
1 default.
{0} defaults.
diff --git a/Languages/English/Keyed/BlaxDefaults_setup.xml b/Languages/English/Keyed/BlaxDefaults_setup.xml
index 3286cff..daa8cb5 100644
--- a/Languages/English/Keyed/BlaxDefaults_setup.xml
+++ b/Languages/English/Keyed/BlaxDefaults_setup.xml
@@ -18,17 +18,17 @@
Saved {0} empty defaults.
- Warn about mods that set the same defaults
+ Warn about mods that do the same things
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.
- These active mods set some of the same starting settings:
+ These active mods do some of the same things as Blax Defaults:
{MOD}: {WHAT}
- Set each of these in one mod only, or the two overwrite each other.
- Mods that set the same defaults
- {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.
+ Use each of these features in one mod only, or the two work against each other.
+ Mods that do the same things
+ 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.
Don't remind me
Not shown again
-
+
Starting settings for stockpiles, storage buildings and bills
Shelves start empty at Normal
Its "No Default Storage Settings" option empties the starting filter of storage buildings
diff --git a/README.md b/README.md
index 9e39c0d..a94e8b7 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,9 @@
[](https://steamcommunity.com/sharedfiles/filedetails/?id=3848261264)
[](https://steamcommunity.com/sharedfiles/filedetails/?id=2009463077)
[](#dlc-support)
-[](CHANGELOG.md)
+[](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-.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-.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.
---
diff --git a/Source/Art/README.md b/Source/Art/README.md
index f909a83..180bdf7 100644
--- a/Source/Art/README.md
+++ b/Source/Art/README.md
@@ -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 |
diff --git a/Source/BlaxDefaults/BlaxDefaultsMod.cs b/Source/BlaxDefaults/BlaxDefaultsMod.cs
index 4806123..0567c7e 100644
--- a/Source/BlaxDefaults/BlaxDefaultsMod.cs
+++ b/Source/BlaxDefaults/BlaxDefaultsMod.cs
@@ -24,6 +24,9 @@ namespace BlaxDefaults
/// New production bills get the values of "Every new bill".
public static bool BillsOn => Enabled && (Settings == null || Settings.billDefaults);
+ /// The forbid rules may act (each rule still needs its own switch and filter).
+ public static bool ForbidOn => Enabled && (Settings == null || Settings.forbidRules);
+
public override string SettingsCategory() => "Blax Defaults";
public override void DoSettingsWindowContents(Rect inRect) => SettingsPage.Draw(inRect);
diff --git a/Source/BlaxDefaults/BlaxDefaultsSettings.cs b/Source/BlaxDefaults/BlaxDefaultsSettings.cs
index 3161c4c..1247831 100644
--- a/Source/BlaxDefaults/BlaxDefaultsSettings.cs
+++ b/Source/BlaxDefaults/BlaxDefaultsSettings.cs
@@ -18,7 +18,27 @@ namespace BlaxDefaults
public bool storageDefaults = true;
/// New production bills get the values of "Every new bill".
public bool billDefaults = true;
- /// The settings page and one message per session name active mods that set the same defaults.
+ /// The forbid rules as a category: off, no gear rule, strip switch or corpse switch acts.
+ public bool forbidRules = true;
+ /// "Gear your colony drops". Acts only with a saved filter under forbid:colony.
+ public bool colonyGearRule;
+ /// The colony rule's "Where": anywhere (true) or only inside the home area.
+ public bool colonyGearAnywhere = true;
+ /// "Gear enemies drop". Acts only with a saved filter under forbid:enemies.
+ public bool enemyGearRule;
+ /// The enemy rule's "Where": anywhere (true) or only inside the home area.
+ public bool enemyGearAnywhere = true;
+ /// Stripping one of your colony's pawns or corpses forbids what the colony filter refuses.
+ public bool colonyStripRule;
+ /// Stripping an enemy or an enemy corpse forbids what the enemy filter refuses.
+ public bool enemyStripRule;
+ /// Animal corpses outside the home area are allowed.
+ public bool animalCorpsesAllowed;
+ /// Enemy corpses outside the home area are allowed.
+ public bool enemyCorpsesAllowed;
+ /// Other corpses outside the home area are allowed.
+ public bool otherCorpsesAllowed;
+ /// The settings page and one message per session name active mods that do some of the same things.
public bool warnOverlaps = true;
/// Package ids whose overlap message the player dismissed with "Don't remind me".
public List dismissedOverlaps = new List();
@@ -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();
}
diff --git a/Source/BlaxDefaults/DefaultsEntry.cs b/Source/BlaxDefaults/DefaultsEntry.cs
index 45f0727..2843250 100644
--- a/Source/BlaxDefaults/DefaultsEntry.cs
+++ b/Source/BlaxDefaults/DefaultsEntry.cs
@@ -52,7 +52,8 @@ namespace BlaxDefaults
///
/// The library keys. One default per kind: "stockpile:Stockpile", "stockpile:Dumping",
- /// "stockpile:<designator type name>", "storage:<ThingDef>" and "bill:*" in 1.0. Later releases
+ /// "stockpile:<designator type name>", "storage:<ThingDef>" and "bill:*" in 1.0, "forbid:colony" and
+ /// "forbid:enemies" (the forbid rules' filters) in 1.1. Later releases
/// add their own prefixes (bill:<RecipeDef>, bench:, animal:, slaughter:, mech:, grower:, building:).
///
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:";
+
+ /// The filter of "Gear your colony drops" (1.1).
+ public const string ForbidColony = "forbid:colony";
+ /// The filter of "Gear enemies drop" (1.1).
+ public const string ForbidEnemies = "forbid:enemies";
/// The vanilla stockpile (DefaultStockpile preset): Designator_ZoneAddStockpile_Resources and _Expand.
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);
+
/// The part after the prefix: "Shelf" for "storage:Shelf".
public static string NameOf(string key)
{
diff --git a/Source/BlaxDefaults/Dialog_EditStorageTemplate.cs b/Source/BlaxDefaults/Dialog_EditStorageTemplate.cs
index 34602f5..6ee8729 100644
--- a/Source/BlaxDefaults/Dialog_EditStorageTemplate.cs
+++ b/Source/BlaxDefaults/Dialog_EditStorageTemplate.cs
@@ -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".
///
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;
- 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;
+ 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();
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));
}
diff --git a/Source/BlaxDefaults/ForbidHooks.cs b/Source/BlaxDefaults/ForbidHooks.cs
new file mode 100644
index 0000000..9636f12
--- /dev/null
+++ b/Source/BlaxDefaults/ForbidHooks.cs
@@ -0,0 +1,513 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HarmonyLib;
+using RimWorld;
+using Verse;
+using Verse.AI;
+
+namespace BlaxDefaults
+{
+ ///
+ /// 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.
+ ///
+ public sealed class ForbidScope
+ {
+ public readonly Pawn Pawn;
+ public readonly ForbidGroup Group;
+ /// True for Pawn_HealthTracker.MakeDowned, false for Pawn.Kill.
+ public readonly bool Downing;
+ public readonly List Recorded = new List();
+
+ public ForbidScope(Pawn pawn, ForbidGroup group, bool downing)
+ {
+ Pawn = pawn;
+ Group = group;
+ Downing = downing;
+ }
+ }
+
+ ///
+ /// 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.
+ ///
+ public static class ForbidHooks
+ {
+ [ThreadStatic] private static List stack;
+ [ThreadStatic] private static int butchering;
+
+ /// True while a downing or death scope is open on this thread.
+ public static bool ScopeOpen
+ {
+ get
+ {
+ List s = stack;
+ return s != null && s.Count > 0;
+ }
+ }
+
+ /// True while butchering's ingredient step runs on this thread: stripping stays vanilla then.
+ public static bool Butchering => butchering > 0;
+
+ /// A scope opens while the game plays, no map is being made, and a rule or corpse switch could act.
+ 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()).Add(scope);
+ return scope;
+ }
+
+ public static void Pop(ForbidScope scope)
+ {
+ List s = stack;
+ if (s == null || scope == null)
+ return;
+ int i = s.LastIndexOf(scope);
+ if (i >= 0)
+ s.RemoveAt(i);
+ }
+
+ /// The recorder: a thing the game just forbade inside a scope goes to the innermost one.
+ public static void Record(Thing t)
+ {
+ List s = stack;
+ if (t == null || s == null || s.Count == 0)
+ return;
+ List 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--;
+ }
+
+ ///
+ /// 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.
+ ///
+ 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);
+ }
+
+ /// Allows the thing now when its map has no active threat, else puts it on the wait list.
+ 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);
+ }
+
+ /// What the strip prefix recorded: the rule of the stripped pawn's group and what it had.
+ public sealed class StripRecord
+ {
+ public ForbidRule Rule;
+ public List Things;
+ }
+
+ /// The strip prefix: null when the pawn's group has no strip switch acting.
+ 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();
+ 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 };
+ }
+
+ /// The strip postfix: forbids each recorded thing now on a map, inside "Where", that the filter refuses.
+ 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);
+ }
+ }
+ }
+
+ ///
+ /// 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.
+ ///
+ public static class ForbidWaitList
+ {
+ public const int CheckInterval = 250;
+
+ public sealed class Entry
+ {
+ public Thing Thing;
+ /// The gear rule, or null for a corpse.
+ public ForbidRule Rule;
+ /// The corpse switch, for a corpse.
+ public CorpseKind? Corpse;
+ /// The colonist that remembers this weapon, or null.
+ public Pawn Owner;
+ public Map Map;
+ }
+
+ private static readonly List entries = new List();
+ private static Game game;
+
+ /// No entries: the tick postfix returns at once.
+ public static bool IsEmpty => entries.Count == 0;
+
+ public static int Count
+ {
+ get
+ {
+ CheckGame();
+ return entries.Count;
+ }
+ }
+
+ /// True while the thing waits.
+ public static bool Contains(Thing t)
+ {
+ CheckGame();
+ return t != null && entries.Any(e => e.Thing == t);
+ }
+
+ /// The waiting entry of the thing, or null.
+ 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);
+ }
+
+ /// Empties the list. Tests only (and a game change).
+ public static void Clear()
+ {
+ entries.Clear();
+ game = null;
+ }
+
+ private static void CheckGame()
+ {
+ if (entries.Count > 0 && game != Current.Game)
+ Clear();
+ }
+
+ /// The tick postfix: every CheckInterval ticks, the check for this map.
+ 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);
+ }
+
+ /// The check for one map, as described above.
+ public static void Check(Map map)
+ {
+ CheckGame();
+ List