rimworld-blax-zones/README.md

129 lines
14 KiB
Markdown

![Blax Zones](About/Preview.png)
# Blax Zones
[![RimWorld 1.7](https://img.shields.io/badge/RimWorld-1.7-19C63C)](https://rimworldgame.com)
[![Steam Workshop](https://img.shields.io/badge/Steam_Workshop-subscribe-1b2838?logo=steam)](https://steamcommunity.com/sharedfiles/filedetails/?id=3848261160)
[![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.1](https://img.shields.io/badge/status-1.1-CDCDCD)](CHANGELOG.md)
RimWorld mod (1.7) by Blax Gaming. Drag a delivery zone and what you buy from orbital traders and trader caravans, plus quest rewards, lands in it, sorted by item filter and priority: medicine by the hospital, steel by the workshop. Trader caravans camp next to a zone you pick. Needs Harmony. Works with any DLC combination, core only included.
## Features
### Delivery zones
![Orbital purchases in a delivery zone](docs/media/delivery-zone.jpg)
- 📦 **Delivery zone.** "Delivery zone" sits in the Zone menu right after "Growing zone" and is dragged like a stockpile. It draws amber and grows with "Expand zone". Like every zone, it extends the home area 4 cells around itself while auto home area is on. `Source/BlaxZones/Designator_ZoneAdd_Delivery.cs`
- 🔽 **Delivery tab.** A priority from Low to Critical, "Orbital trade lands here", "Quest rewards land here" and "Caravan purchases land here" (all on), "Caravans camp here" (off) and an item filter that allows every item. Corpses and, with Biotech, Wastepack never land in a zone and are hidden from the filter. "Copy settings" and "Paste settings" move the filter, the priority and every checkbox to another delivery zone. `Source/BlaxZones/ITab_Delivery.cs`
- 🛰️ **Orbital purchases land in the zone.** Every item bought from an orbital trader, plus the silver from selling, drops into the best matching delivery zone instead of next to the trade beacon. The filter decides what fits, then the highest priority wins, then the oldest zone. Pods use the 400 cells nearest the middle of a zone: the free ones first, from the middle out, then a matching stack. `Source/BlaxZones/DeliveryRouter.cs`
- 👣 **Overflow you can reach.** When every fitting zone is full, pods land next to the top one, on a cell your colonists can reach, within 16 cells (5 to 30). Overflow from a zone your colonists can't reach lands at the vanilla spot, and so does all overflow with "Overflow lands next to the zone" off.
- 🎁 **Quest rewards land in the zone.** Item rewards that quests drop at the trade beacon, with Royalty Empire quests too, fall into the best matching delivery zone with "Quest rewards land here" ticked, one pod per stack, and the quest letter points there. Full zones overflow as orbital purchases do. `Source/BlaxZones/DeliveryRouter.Rewards.cs`
- 🐪 **Caravan purchases appear in the zone.** Goods bought from a visiting trader caravan or a Hospitality guest, and the silver from selling to them, appear in the best matching delivery zone with "Caravan purchases land here" ticked, instead of at the pack animals' feet. Nothing falls, so a roofed zone works: a medicine zone inside the hospital takes caravan medicine. When every fitting zone is full, the goods appear next to the top one while "Overflow lands next to the zone" is on and your colonists can reach it; otherwise they stay at the pack animals' feet. One message per trade names the zone, or says the goods lie next to it when it was full. `Source/BlaxZones/DeliveryRouter.Caravan.cs`
- 🟥 **Unusable cells marked.** While a delivery zone is selected, red outlines mark the cells drop pods can't use: roofed, water, inside an enclosed animal pen, blocked by a building, fogged, or out of your colonists' reach. The inspect pane counts them. `Source/BlaxZones/DeliveryRules.cs`
- 🛡️ **Nothing is lost.** Bought people and animals, refugees, prisoners, mechanoids and Wastepack from quests, raids, colonists you ransom back and lent colonists coming home land as before. With no fitting zone goods land at the vanilla spot, and so do they if anything in Blax Zones goes wrong. A mod that moves the vanilla drop spot keeps working as the fallback.
### Caravan camps
- ⛺ **Caravans camp at a zone.** With "Caravans camp here" ticked, visiting trader caravans and, with Royalty, tribute collectors gather within 6 cells of the zone, on open ground they can all reach. Goods bought from them appear in a delivery zone, or with "Route caravan purchases" off drop at their pack animals' feet, next to the zone. Visitor groups and Hospitality guests pick their own spot. `Source/BlaxZones/CampScope.cs`
- 🤝 **Trading-spot mods win.** Camping stands down, with one log line, while Trading Spot Rewritten, [KV] Trading Spot, [GMT] Trading Spot or Trading Control is active. `Source/BlaxZones/Compat.TradingSpots.cs`
### Save and settings
- 💾 **Save-safe.** Delivery zones are saved with Blax Zones' own map data, never in the game's zone list. Blax Zones can be added to a running save. Unsubscribing leaves a save that loads: the delivery zones are gone, vanilla zones stay, and the log shows two errors per map. `Source/BlaxZones/ZoneStore.cs`
- ⚙️ **Mod settings.** "Delivery zones" (hides the designator; existing zones stay and still receive deliveries), "Route orbital trade", "Route quest rewards", "Overflow lands next to the zone" with its overflow radius, "Route caravan purchases", "Message when goods arrive", "Caravans may camp at zones", "Reset to defaults".
### For other mods
- 🔌 `BlaxZones.ZonesApi` version 1: `int Version` and `bool TryFindDropSpot(Map map, Thing thing, out IntVec3 cell)`. It returns a cell for one drop pod holding that thing: in a delivery zone, picked by the zones' filters and priorities, their "Orbital trade lands here" checkboxes and the drop pod rules, or next to the top zone when every fitting zone is full and overflow is on. It returns false when no zone fits, always false for a pawn, and never throws. Spawn the pod exactly at the cell (`TradeUtility.SpawnDropPod` or `DropPodUtility.MakeDropPodAt`) and call again for the next thing after spawning, because a falling pod is what marks its cell as taken. Bind it by reflection; members are only ever added, each with a higher `Version`. Blax Slaves binds it for its planned silver payouts.
## Planned
In build order. What each area covers and its steps are in `docs/features.md`, the specs in `docs/design.md`.
- 🐔 **Animal sleeping zones.** Every cell is a sleeping spot, with species and body-size filters, so big stalls stay free of chickens. A button in the mod settings strips Blax Zones from a save first, for a removal with no errors.
- 🧹 **Work rule areas.** Paint named areas over anything, stockpiles and fields included, and tick rules per area: No cleaning, No firefighting, No repairs, Don't haul from here, Clean first, Haul first. A barn nobody cleans still gets its fires fought, and a hospital is cleaned first. Work rules never change work priorities or allowed areas, and right-click orders work in every area.
- 🗄️ **Storage, roofs and selling.** Stockpiles, shelves, racks and fridges receive deliveries directly, also under a roof. Orbital traders buy from flagged storage (needs a powered trade beacon). Random cargo pod events land in a zone you pick. All optional, off by default.
- 🛏️ **People sleeping zones.** Dorms and prisons for colonists, slaves (needs Ideology) and prisoners, one cell per sleeper, plus medical and shared zones.
- 🏷️ **Castes.** With Blax Castes, people sleeping zones can be limited by caste.
## DLC support
Blax Zones works with any combination of DLCs, core only included, and lists none as a dependency. Nothing in it needs a DLC.
- **Royalty** adds tribute collectors, who camp at the zone like trader caravans, and Empire quests, whose item rewards land in the zone like any other.
- **Biotech** adds Wastepack, which never lands in a zone and is hidden from the filter.
- **Ideology**, **Anomaly** and **Odyssey**: Blax Zones uses none of their content. Slave sleeping zones (planned) will need Ideology.
- **A save made with a DLC** loads without it. Delivery zone filters drop the missing items, with the same "Could not load reference" error per missing def that vanilla stockpile filters log, and the zone keeps working.
## Compatibility
- ✔️ Hospitality guests pick their own spot and never camp at the zone. Goods bought from them land in the zone like caravan goods.
- ✔️ Trading Spot Rewritten, [KV] Trading Spot, [GMT] Trading Spot and Trading Control: while one is active, caravan camps stand down and leave caravans to it.
- ✔️ A mod that moves vanilla's trade drop spot stays the fallback: a fitting zone wins, everything else lands at that mod's spot.
- ✔️ The `-Compat` test run loads Hospitality, Pick Up And Haul, Haul to Stack, RimFridge, Weapon Racks, Prison Labor, Prisoner Realism, Replace Stuff, Vanilla Expanded Framework, Vanilla Furniture Expanded with its Medical Module, Dubs Skylights, Vanilla Events Expanded, Blax Castes, Blax Defaults and Blax Slaves, and every test passes. Prison Labor logs one error of its own when a test makes a prisoner.
- ♻️ Replaces the orbital trade part of Trade Ships Drop Spot, the orbital trade and caravan spot parts of Trading Control, and [KV] Trading Spot and [GMT] Trading Spot. Since 1.1 also their quest reward part; while Trade Ships Drop Spot is active, a one-time message says you can unsubscribe from it, once you have a delivery zone.
- ❌ Multiplayer: not supported.
Load order: Harmony, Blax Castes, Blax Zones, Blax Slaves. No Blax mod needs another.
## Development
The repo is the mod folder. Link it into the game with a directory junction, run from the repo root (adjust the RimWorld path):
```powershell
New-Item -ItemType Junction -Path "E:\SteamLibrary\steamapps\common\RimWorld\Mods\BlaxZones" -Target (Get-Location).Path
```
Build (needs the .NET 10 SDK; output goes to `1.7/Assemblies/BlaxZones.dll`). `RimWorldDir` and `HarmonyDir` in the csproj point at the Steam install and the Harmony mod; override them with `-p:RimWorldDir=...` elsewhere.
```powershell
dotnet build Source\BlaxZones\BlaxZones.csproj -c Release
```
`Tests/run-tests.ps1` builds the mod and the test mod in `Tests/BlaxZonesTests`, starts RimWorld headless with its own save data folder in `%TEMP%\BlaxZonesTest`, runs the suite, saves and reloads, then loads the save with the mod's map data removed. Your mod list, saves and settings stay untouched. It needs Steam running. The script's header lists every switch.
```powershell
.\Tests\run-tests.ps1 # every installed DLC
.\Tests\run-tests.ps1 -NoDlc # core only
.\Tests\run-tests.ps1 -Dlc Royalty # only the DLCs named
.\Tests\run-tests.ps1 -Compat # next to the mods listed under Compatibility
```
Things only a real game can show are in `docs/ingame-check.md`. Design and roadmap: `docs/design.md`.
### Workshop upload
`Tools/workshop-upload.ps1` creates and updates the Workshop item from the command line. A small tool (`Tools/WorkshopUpload`) uses the Steamworks.NET build and `steam_api64.dll` that ship with RimWorld and attaches to the running, logged-in Steam client as RimWorld, so it needs no password, no game window and no dev mode.
```powershell
.\Tools\workshop-upload.ps1 # dry run: build, stage, check the Steam login and the item
.\Tools\workshop-upload.ps1 -Check # release check: every -Publish gate, then the list of problems
.\Tools\workshop-upload.ps1 -Publish -DescriptionFile docs\workshop-description.txt # upload and replace the description
```
The dry run and `-Check` upload nothing. The script stages only what players need (About, 1.7, Patches, Languages) in `%TEMP%`, sets the tags the game would (Mod plus the supported versions), the title from About.xml and the preview from `About/Preview.png`. The change note is every CHANGELOG.md entry newer than the version in `Tools/workshop-published.txt`.
The Workshop item is [3848261160](https://steamcommunity.com/sharedfiles/filedetails/?id=3848261160) (`About/PublishedFileId.txt`), so `-Publish` updates it. Without that file the first `-Publish` creates the item, Public unless you pass `-Visibility private` (Steam's own default for a new item is Private), and writes its id to `About/PublishedFileId.txt` before the content upload, so a failed upload is retried as an update and never makes a second item. After a successful upload it writes `Tools/workshop-published.txt`. Commit both files.
`-Publish` refuses unless:
- the shipped files are committed and pushed, and the top CHANGELOG.md entry matches `modVersion` in About.xml;
- two `Tests/run-tests.ps1` runs passed after the last build, one with every installed DLC and one with `-NoDlc` (`BlaxZonesTestResults.all.txt` and `BlaxZonesTestResults.nodlc.txt` in `%TEMP%\BlaxZonesTest`);
- `About/Preview.png` is under 1 MB;
- the description fits Steam's 8000-byte limit, every forgejo.blax.at link in it opens without a login, and every `[img]` host sends an `Access-Control-Allow-Origin` header. Steam loads description images cross-origin and shows a broken image otherwise. Forgejo's raw URLs send no such header, so the images are served from `cdn.blax.at/blax-gaming/zones/`, which does.
The Workshop page is `docs/workshop-description.txt` (Steam BBCode). Its art is rendered from `Source/Art` (see `Source/Art/README.md`), and `docs/workshop-media.md` lists the in-game clips worth recording. `-DescriptionOnly -DescriptionFile docs\workshop-description.txt` replaces just the text, with no build, no content upload and no change note.
The in-game route still works: `Tools/workshop-stage.ps1` swaps the junction for a clean copy, upload from Mods > Blax Zones > Advanced... > Upload to Steam Workshop (dev mode), then `Tools/workshop-stage.ps1 -Done` copies `About/PublishedFileId.txt` back into the repo and restores the junction.
---
## Made by Blax
[![Blax Software Open Source Initiative](docs/art/blax-oss-banner.svg)](https://www.blax.at)
🛠️ **Blax Gaming** is a project of **[Blax Software](https://www.blax.at)**, an Austrian software practice. We write Austrian-quality code in many fields: web platforms, mobile apps, backends, infrastructure, and the mods we play in our own colonies. Need something built? 👉 [www.blax.at](https://www.blax.at)