make recipe selection and buffers of smelter and reprocessing plant behave like other buildings, except that a recipe may be chosen automatically
This commit is contained in:
@@ -145,14 +145,18 @@ Any ship, module, building, or assembler recipe id that appears in no unlock gro
|
||||
- REQ-BLD-DECON-QUEUE: Fully-built factory buildings marked for demolition (REQ-BLD-DECONSTRUCT) enter a **deconstruction queue** that is processed one building at a time and runs in parallel with the construction queue (REQ-BLD-QUEUE) — the two queues advance independently and simultaneously. Each building takes `world.toml [world].deconstruction_time_seconds` (default 0.1) to deconstruct, the same duration for every building type. When a building's deconstruction completes it is removed from the world and its refund is credited (REQ-BLD-DECONSTRUCT). A building **stops operating the moment it enters the queue**: it runs no production and transports no items, and no longer participates as a live building (its tunnel pairing is re-evaluated as if it were gone, REQ-BLD-TUNNEL-PAIR), but it still physically occupies its tiles until removed, so those tiles stay blocked for placement. A queued building can be taken back out of the deconstruction queue before it is removed (REQ-BLD-DECONSTRUCT-CLICK, REQ-BLD-DECONSTRUCT-BOX) — including the one currently being deconstructed; doing so discards any deconstruction progress, credits no refund, and the building resumes operating (and re-pairs, REQ-BLD-TUNNEL-PAIR). Construction sites never enter the deconstruction queue (REQ-BLD-DECONSTRUCT). Every building in the deconstruction queue is rendered with the deconstruct tint — the `visuals.toml [overlays].deconstruct_tint` color, the same tint applied to a building hovered in deconstruct mode (REQ-UI-DECONSTRUCT-BORDER) — so queued buildings are visually distinct.
|
||||
- REQ-BLD-DECONSTRUCT-CLICK: While in deconstruct mode (REQ-UI-HOTKEYS, REQ-UI-DECONSTRUCT-BUTTON), left-clicking a placed factory building or construction site in the game world marks it for demolition, following the rules of REQ-BLD-DECONSTRUCT: a fully-built building is added to the deconstruction queue (REQ-BLD-DECON-QUEUE), and a construction site is removed instantly with the full refund. Left-clicking a fully-built building that is **already in the deconstruction queue** instead removes it from the queue (un-queues it, REQ-BLD-DECON-QUEUE), with no refund; repeated clicks on the same building therefore alternate between queueing and un-queueing it. Clicking a building that cannot be deconstructed (the HQ or a player defence station, per REQ-BLD-DECONSTRUCT), or clicking empty world space, has no effect. Deconstruct mode stays active after each action so the player can continue without re-entering the mode; it is exited via the Q toggle (REQ-UI-HOTKEYS) or the Deconstruct button (REQ-UI-DECONSTRUCT-BUTTON).
|
||||
- REQ-BLD-DECONSTRUCT-BOX: While in deconstruct mode (REQ-UI-HOTKEYS, REQ-UI-DECONSTRUCT-BUTTON), the player can click and drag a selection box in the game world. A selection rectangle is drawn while dragging, using the same box-drag gesture and coverage semantics as the multi-select box (REQ-UI-MULTI-SELECT). On mouse up, following the rules of REQ-BLD-DECONSTRUCT: every construction site covered by the box is removed instantly with the full refund; and among the fully-built deconstructible buildings covered by the box, if **all** of them are already in the deconstruction queue they are all removed from it (un-queued, REQ-BLD-DECON-QUEUE), otherwise every covered building not yet in the queue is added to the deconstruction queue (already-queued ones stay). Buildings that cannot be deconstructed (the HQ and player defence stations, per REQ-BLD-DECONSTRUCT) are excluded from the box demolition; ships and defence stations are never affected.
|
||||
- REQ-BLD-SITE-CONFIG: A construction site — a building that has been placed but is still queued or under construction (REQ-BLD-QUEUE) — can be selected and configured exactly like the equivalent operational building, before it finishes building. Whatever configuration the building type supports is available on the site: the recipe for a Miner or Assembler (REQ-UI-SELECT-BUTTON), the produced-ship schematic and its module layout for a Shipyard (REQ-UI-SELECT-BUTTON, REQ-MOD-UI-PREVIEW, REQ-MOD-UI-DIALOG), and the output filters for a Splitter (REQ-BLD-SPLITTER) — all set through the same selection panel controls (REQ-UI-CONFIG-INLINE). Only currently unlocked recipes and schematics are offered, exactly as for operational buildings (REQ-LOCK-UI-RECIPE, REQ-LOCK-UI-SCHEMATIC, REQ-LOCK-UI-SPLITTER). The configuration is stored on the construction site and carries over unchanged when construction completes, so the building becomes operational already configured. A construction site has no input/output buffers and runs no production cycle, so the buffer and production-progress portions of the panel (REQ-UI-SINGLE-SELECTION, REQ-UI-PRODUCTION-PROGRESS) are not shown for it; only its construction progress (REQ-UI-CONSTRUCTION-PROGRESS) and its configuration controls appear. (Blueprint placement already applies a stored recipe or schematic to a construction site on placement per REQ-UI-BLUEPRINT-PLACE; this requirement additionally lets the player set or change that configuration directly on an existing site.)
|
||||
- REQ-BLD-SITE-CONFIG: A construction site — a building that has been placed but is still queued or under construction (REQ-BLD-QUEUE) — can be selected and configured exactly like the equivalent operational building, before it finishes building. Whatever configuration the building type supports is available on the site: the recipe for a Miner, Assembler, Smelter or Reprocessing Plant (REQ-UI-SELECT-BUTTON, REQ-BLD-AUTO-RECIPE), the produced-ship schematic and its module layout for a Shipyard (REQ-UI-SELECT-BUTTON, REQ-MOD-UI-PREVIEW, REQ-MOD-UI-DIALOG), and the output filters for a Splitter (REQ-BLD-SPLITTER) — all set through the same selection panel controls (REQ-UI-CONFIG-INLINE). Only currently unlocked recipes and schematics are offered, exactly as for operational buildings (REQ-LOCK-UI-RECIPE, REQ-LOCK-UI-SCHEMATIC, REQ-LOCK-UI-SPLITTER). The configuration is stored on the construction site and carries over unchanged when construction completes, so the building becomes operational already configured. A construction site has no input/output buffers and runs no production cycle, so the buffer and production-progress portions of the panel (REQ-UI-SINGLE-SELECTION, REQ-UI-PRODUCTION-PROGRESS) are not shown for it; only its construction progress (REQ-UI-CONSTRUCTION-PROGRESS) and its configuration controls appear. (Blueprint placement already applies a stored recipe or schematic to a construction site on placement per REQ-UI-BLUEPRINT-PLACE; this requirement additionally lets the player set or change that configuration directly on an existing site.)
|
||||
|
||||
## Building Types
|
||||
|
||||
- REQ-BLD-MINER: **Miner** (2×2): The player selects which ore type it extracts. Each ore type corresponds to a `recipes.toml [[recipe]]` entry with `building = "miner"`, defining the output item and `duration_seconds`. Every asteroid tile is equivalent for mining — any miner can produce any ore type based solely on its selected recipe. Ore never depletes. Only implicitly unlocked ore-type recipes are available for selection (REQ-LOCK-UI-RECIPE).
|
||||
- REQ-BLD-SMELTER: **Smelter** (2×2): Converts ore or scrap into basic materials. No recipe selection required. Inputs, outputs, and rates are defined in `recipes.toml [[recipe]]` entries with `building = "smelter"`.
|
||||
- REQ-BLD-SMELTER: **Smelter** (2×2): Converts ore or scrap into basic materials. Its recipe is selected as any other building's is, except that it also picks one for itself from the first material it is offered (REQ-BLD-AUTO-RECIPE). Inputs, outputs, and rates are defined in `recipes.toml [[recipe]]` entries with `building = "smelter"`.
|
||||
- REQ-BLD-ASSEMBLER: **Assembler** (3×3): The player selects a recipe from the config-defined crafting tree. Produces the selected output item at the rate defined in the corresponding `recipes.toml [[recipe]]` entry with `building = "assembler"`. Only implicitly unlocked recipes are available for selection (REQ-LOCK-UI-RECIPE).
|
||||
- REQ-BLD-REPROCESSING: **Reprocessing Plant** (3×3): Consumes scrap per cycle and produces exactly one **kind** of higher-level intermediate product per cycle via weighted random pick, in that output's configured amount (which may be more than one item). The input quantity, possible output items, per-output weights, and amounts are defined in `recipes.toml [[recipe]]` entries with `building = "reprocessing_plant"` (`inputs`, `outputs[].item`, `outputs[].amount`, `outputs[].weight`). Weights are normalized at load time; their sum does not need to equal 1. The output is rolled at cycle start (see REQ-MAT-CYCLE); the pool of eligible outputs is restricted to implicitly unlocked item types (REQ-LOCK-REPROCESSING-POOL). Its output side follows the general rules with no exception: one buffer per possible output item (REQ-MAT-OUTPUT-BUFFER), and a cycle starts only when every possible roll would fit (REQ-MAT-CYCLE) — which is also what denies the player a reroll by stalling the output belt.
|
||||
- REQ-BLD-REPROCESSING: **Reprocessing Plant** (3×3): Consumes scrap per cycle and produces exactly one **kind** of higher-level intermediate product per cycle via weighted random pick, in that output's configured amount (which may be more than one item). The input quantity, possible output items, per-output weights, and amounts are defined in `recipes.toml [[recipe]]` entries with `building = "reprocessing_plant"` (`inputs`, `outputs[].item`, `outputs[].amount`, `outputs[].weight`). Weights are normalized at load time; their sum does not need to equal 1. The output is rolled at cycle start (see REQ-MAT-CYCLE); the pool of eligible outputs is restricted to implicitly unlocked item types (REQ-LOCK-REPROCESSING-POOL). Its output side follows the general rules with no exception: one buffer per possible output item (REQ-MAT-OUTPUT-BUFFER), and a cycle starts only when every possible roll would fit (REQ-MAT-CYCLE) — which is also what denies the player a reroll by stalling the output belt. Like the Smelter it picks its recipe from the first material it is offered while none is set (REQ-BLD-AUTO-RECIPE).
|
||||
- REQ-BLD-AUTO-RECIPE: **Automatic recipe selection.** The Smelter and the Reprocessing Plant (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING) are *auto-recipe buildings*. They carry a selected recipe and are configured exactly as a Miner or Assembler is — the same selection button and dialog (REQ-UI-SELECT-BUTTON), buffers sized for that one recipe alone (REQ-MAT-INPUT-BUFFER, REQ-MAT-OUTPUT-BUFFER), and the same pre-configuration on a construction site (REQ-BLD-SITE-CONFIG). They differ in one respect only:
|
||||
- **Selection while none is set.** When such a building has no recipe, the first material offered at any of its input ports that some recipe of its type consumes selects that recipe; the material is then accepted as normal. This holds for every intake path — a belt, splitter or tunnel exit at an input port, and a directly coupled producer (REQ-MAT-DIRECT-COUPLE) — because a building that accepts nothing would otherwise leave a coupled producer stuck at its port forever. The choice is deterministic: input ports are examined in order, and where several recipes of the type consume the offered material the first in config order wins.
|
||||
- **No further switching.** Once a recipe is set the building keeps it. It does not switch when its buffers run empty, nor when a material belonging to another of its recipes arrives — that material is simply not an accepted input, exactly as for any other building.
|
||||
- **The player is always in control.** Selecting a different recipe clears the buffers (REQ-MAT-INPUT-BUFFER, REQ-MAT-OUTPUT-BUFFER); that is how a building left holding part of a cycle nothing feeds any more is freed, and how a selection the player did not want is corrected. For these buildings the dialog's clearing option is captioned `(Auto)` rather than `(None)` (REQ-UI-SELECT-OPTIONS): it unsets the recipe and hands the building back to automatic selection.
|
||||
- REQ-BLD-SHIPYARD: **Shipyard** (4×2): The player selects a schematic. When all required materials — the ship's base materials (`[ship.schematic].materials`) plus the materials of all modules in the configured layout (REQ-MOD-MATERIALS) — are present in its input buffer, the shipyard consumes them and begins a production cycle lasting the ship's base `[ship.schematic].production_time_seconds` plus the sum of production times contributed by all module instances in the configured layout (REQ-MOD-PRODUCTION-TIME). One ship of that type is spawned with the configured modules when the cycle completes. The shipyard cannot start a new cycle while one is in progress. If the player confirms a layout change (REQ-MOD-UI-DIALOG) while a production cycle is in progress, the current cycle is cancelled and all consumed materials are discarded; the shipyard returns to idle with the new layout configuration. Confirming a layout identical to the one already configured is not a change and cancels nothing (REQ-MAT-INPUT-BUFFER).
|
||||
- REQ-BLD-SALVAGE-BAY: **Salvage Bay** (3×2): A dedicated drop-off point for salvage ships. It has a single output buffer — scrap is the only thing it ever holds — whose holding capacity is defined by the `output_buffer_capacity` field of the `salvage_bay` entry in `buildings.toml` (rather than by a production cycle, since the Salvage Bay has no recipe). A ship at the bay hands over one unit of scrap per tick while the buffer has free space; a full buffer blocks further drop-off until space frees up (consistent with the buffer-full semantics of REQ-MAT-OUTPUT-BUFFER). Held scrap is pushed onto connected output belts.
|
||||
- REQ-BLD-BELT: **Belt** (1×1): Transports items. A belt tile has one direction (N, S, E, W) set at placement (modified by rotation). Curved belts are auto-derived: when a belt tile's outgoing direction leads into another belt whose direction is orthogonal, the downstream belt is rendered and behaves as a curve. Belt speed is defined in `world.toml [world].belt_speed_tiles_per_second` (REQ-GW-BELT-SPEED). A belt accepts items only through a non-output edge (REQ-MAT-ACCEPT-DIR).
|
||||
@@ -390,7 +394,7 @@ Any ship, module, building, or assembler recipe id that appears in no unlock gro
|
||||
|
||||
- REQ-LOCK-REPROCESSING-POOL: The pool of possible outputs for a Reprocessing Plant cycle (REQ-BLD-REPROCESSING) is restricted to item types that are currently implicitly unlocked (REQ-LOCK-IMPLICIT). Weights are renormalized over the eligible outputs. If no eligible outputs remain, the Reprocessing Plant cannot start a production cycle.
|
||||
|
||||
- REQ-LOCK-UI-RECIPE: Locked miner ore-type recipes and assembler recipes are not shown in their respective recipe-selection dialogs (REQ-UI-SELECT-BUTTON).
|
||||
- REQ-LOCK-UI-RECIPE: Locked miner ore-type recipes and assembler recipes are not shown in their respective recipe-selection dialogs (REQ-UI-SELECT-BUTTON). Smelter and Reprocessing Plant recipes are never granted by an unlock group (REQ-LOCK-EXPLICIT restricts `recipes` grants to assembler recipes), so they are available from the start and their dialogs list them all; what gates them in practice is whether the building itself is unlocked (REQ-LOCK-BUILDING).
|
||||
|
||||
- REQ-LOCK-UI-SCHEMATIC: Locked ship schematics are not shown in the shipyard's schematic-selection dialog (REQ-UI-SELECT-BUTTON).
|
||||
|
||||
@@ -494,7 +498,7 @@ The screen is a single column: a header bar across the top and the game world vi
|
||||
- REQ-UI-PORT-TARGET-GLYPH: While in builder mode (REQ-BLD-BUILDER-MODE), the builder-mode ghost additionally shows, for each of the building's output ports, a directional glyph drawn centered in the port's **target cell** — the cell immediately outside the footprint that the port pushes into, i.e. the cell the surface-mask output-port indicator occupies (see Surface Mask Format). As in REQ-UI-PORT-GLYPH the glyph is a `>` rotated to face the port's exit direction (`>` East, `^` North, `<` West, `v` South), previewing where the port's output will go before placement. This is in addition to the on-tile port glyph of REQ-UI-PORT-GLYPH, and — unlike that indicator — is shown only for the builder-mode ghost, not for operational buildings, construction sites, or the blueprint-placement ghost (REQ-UI-BLUEPRINT-PLACE). A building with multiple output ports (e.g. a splitter) shows one target-cell glyph per port. The target-cell glyph is drawn larger than the on-tile port glyph so it stands out as the flow-direction preview. Exceptions: the Tunnel Entry shows no target-cell glyph, because it receives items (which may arrive from any of its non-mouth edges, REQ-BLD-TUNNEL-ENTRY) rather than emitting into a single adjacent cell; the Shipyard shows none either, because its output port is a ship-spawn point (REQ-SHP-SPAWN-PLAYER) rather than a belt-item output (REQ-MAT-OUTPUT-EMERGE).
|
||||
- REQ-UI-STATUS-LIGHT: Every operational production building — Miner, Smelter, Assembler, Reprocessing Plant, Shipyard, and Salvage Bay — renders a small **status light**: a filled circle with a black outline drawn in the building's upper-right corner, letting the player read a building's production state without selecting it. The light is anchored to the footprint corner that is the upper-right corner in the building's default orientation and rotates with the building — like the output-port glyph (REQ-UI-PORT-GLYPH) — so it stays on the same physical corner of the building as it is rotated. The status light is rendered only for operational buildings; construction sites (which instead show construction progress, REQ-UI-CONSTRUCTION-PROGRESS) and the builder-mode ghost do not render it. Buildings that are not production buildings — belts, splitters, tunnel entries/exits, and the HQ — have no status light. The black outline is constant; the fill color reflects the building's current production state.
|
||||
- For the five production buildings (Miner, Smelter, Assembler, Reprocessing Plant, Shipyard), the fill color is determined by evaluating, in order:
|
||||
- **Grey** — no recipe or schematic is selected. This applies only to buildings with a player-facing selection (Miner, Assembler, Shipyard); the Smelter and Reprocessing Plant always run an implicit recipe (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING) and are never grey.
|
||||
- **Grey** — no recipe or schematic is selected. Every production building can show it, an auto-recipe building included: it is grey until something is offered at an input port for it to select a recipe from, and again whenever the player hands it back to automatic selection (REQ-BLD-AUTO-RECIPE).
|
||||
- **Green** — the building is currently producing: a production cycle is active (REQ-MAT-CYCLE; for the Shipyard, an in-progress production cycle per REQ-BLD-SHIPYARD).
|
||||
- **Red** — the building is idle because a required input is missing from its input buffers, so it cannot start a cycle. Missing input takes precedence over a blocked output side: if any required input is missing the light is red even when an output buffer is also out of room.
|
||||
- **Yellow** — the building is idle with all required inputs present but the output side cannot take the cycle: at least one item the cycle could produce has no room in its own buffer, so no new cycle can start (REQ-MAT-OUTPUT-BUFFER, REQ-MAT-CYCLE). A buffer short of a full cycle's worth of free space blocks just as a completely full one does.
|
||||
@@ -558,8 +562,7 @@ The panel shows exactly one **content** at a time, picked from the catalog in RE
|
||||
|
||||
| Selection | Header right slot | Configuration group | Runtime group |
|
||||
|---|---|---|---|
|
||||
| Miner, Assembler | status | recipe control + recipe summary | buffers + production |
|
||||
| Smelter, Reprocessing Plant | status | recipe summary | buffers + production |
|
||||
| Miner, Assembler, Smelter, Reprocessing Plant | status | recipe control + recipe summary | buffers + production |
|
||||
| Shipyard | status | schematic control + layout preview + Configure | buffers + production |
|
||||
| Salvage Bay | status | — | buffers |
|
||||
| HQ | — | — | block stock + HP |
|
||||
@@ -582,26 +585,24 @@ The panel shows exactly one **content** at a time, picked from the catalog in RE
|
||||
- an **input** chip shows the per-cycle amount below the count (the items consumed per run, e.g. `/ 2 per cycle`), or the count alone when the building has no selected recipe or schematic to give one;
|
||||
- an **output** chip shows the count against **that item's own** output buffer capacity as `a / b` (REQ-MAT-OUTPUT-BUFFER), with the item's name below. Each output chip therefore stands for one buffer, and a Reprocessing Plant shows one per possible roll.
|
||||
|
||||
Input and output chips form separately captioned sections (REQ-UI-SELECTION-CARD). A section lists a chip for **every item the building's cycle involves**, and for an auto-recipe building every item it handles at all, whether or not the buffer currently holds any: an empty buffer reads `0` rather than its chip disappearing, so the card keeps one shape while the building runs. A section left with no chips at all is not shown. The production section (REQ-UI-PRODUCTION-PROGRESS) sits **between them**, so the card reads in the direction the materials flow: what goes in, what is being made of it, what has come out. For a selected construction site the buffer sections are omitted (REQ-BLD-SITE-CONFIG).
|
||||
Input and output chips form separately captioned sections (REQ-UI-SELECTION-CARD). A section lists a chip for **every item the building's cycle involves**, whether or not the buffer currently holds any: an empty buffer reads `0` rather than its chip disappearing, so the card keeps one shape while the building runs. A section left with no chips at all is not shown. The production section (REQ-UI-PRODUCTION-PROGRESS) sits **between them**, so the card reads in the direction the materials flow: what goes in, what is being made of it, what has come out. For a selected construction site the buffer sections are omitted (REQ-BLD-SITE-CONFIG).
|
||||
|
||||
**Only unlocked items are listed.** A building's buffers may carry entries for items the player cannot make yet — an auto-recipe building's buffers are sized over *every* recipe of its type (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING), including recipes that are still locked. Those entries are left out of both sections, consistent with the rest of the UI hiding what is not unlocked yet (REQ-LOCK-UI-RECIPE, REQ-LOCK-UI-SPLITTER), so a Smelter shows the ores it can actually smelt rather than every ore in the game.
|
||||
|
||||
**An idle auto-recipe building still shows what it handles.** Having no selected recipe (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING), it would otherwise show empty sections whenever it happens to be between cycles. Its input and output sections instead list the unlocked items of every recipe of its type — the same union its buffers were sized over — with a count and no per-cycle denominator, since no one recipe is in force. While a cycle is running, that cycle's recipe supplies the denominators as for any other building.
|
||||
- REQ-UI-RECIPE-SUMMARY: Below the recipe/schematic selection control, a building running a recipe or schematic shows a one-line **recipe summary**: each input item's icon on its colored square (REQ-UI-ITEM-ICON) with its per-cycle amount and the inputs separated by `+`, an arrow, each output item's icon on its colored square with its per-cycle amount, and the cycle time in seconds. It restates what the building will do without opening the selection dialog, and it is the panel's only display of the cycle time. For a Shipyard the summary is built from the schematic's materials and production time including the placed modules' contributions (REQ-BLD-SHIPYARD, REQ-MOD-STAT-CALC), matching the buffers beneath it. Auto-recipe buildings (Smelter, Reprocessing Plant — REQ-BLD-SMELTER, REQ-BLD-REPROCESSING) have no player-selected recipe and so show no selection control; they show the summary of the recipe currently in production and, while between cycles, of the one they ran last. They keep it rather than dropping it, because a summary that came and went with each cycle would resize the card in step with the building's status (REQ-UI-SELECTION-STATUS), which is the one thing the panel must not do while the player is reading it (REQ-UI-SELECTION-PANEL). Such a building shows no summary only until it has run its first cycle. A building with no recipe or schematic selected shows no summary.
|
||||
**Only unlocked items are listed.** Should a building's buffers carry an entry for an item the player cannot make yet, it is left out of both sections, consistent with the rest of the UI hiding what is not unlocked yet (REQ-LOCK-UI-RECIPE, REQ-LOCK-UI-SPLITTER).
|
||||
- REQ-UI-RECIPE-SUMMARY: Below the recipe/schematic selection control, a building running a recipe or schematic shows a one-line **recipe summary**: each input item's icon on its colored square (REQ-UI-ITEM-ICON) with its per-cycle amount and the inputs separated by `+`, an arrow, each output item's icon on its colored square with its per-cycle amount, and the cycle time in seconds. It restates what the building will do without opening the selection dialog, and it is the panel's only display of the cycle time. For a Shipyard the summary is built from the schematic's materials and production time including the placed modules' contributions (REQ-BLD-SHIPYARD, REQ-MOD-STAT-CALC), matching the buffers beneath it. A building with no recipe or schematic selected shows no summary — including an auto-recipe building that has yet to select one (REQ-BLD-AUTO-RECIPE), which shows none until it does and keeps it from then on, so the card does not resize in step with the building's status (REQ-UI-SELECTION-STATUS, REQ-UI-SELECTION-PANEL).
|
||||
- REQ-UI-PRODUCTION-PROGRESS: For buildings that produce items or ships (miner, smelter, assembler, reprocessing plant, shipyard), the panel's runtime group shows a captioned **production section** between the input and output buffer sections (REQ-UI-SINGLE-SELECTION): a horizontal progress bar filled to the completion of the active production cycle, with that completion beside the caption as an integer percentage (e.g. `72%`), or the text `idle` in place of the percentage and an empty bar when no production cycle is active. The cycle time is shown in the recipe summary (REQ-UI-RECIPE-SUMMARY) rather than repeated here. When no recipe or schematic is selected, the production section is not shown at all.
|
||||
- REQ-UI-MULTI-SELECT: The player selects multiple objects by box-drag or by Ctrl+clicking individual objects to add or remove them from the selection. Multi-select operates within a single category (REQ-UI-SELECTION-CATEGORIES). A box-drag that covers at least one building selects buildings (any field objects within the box are ignored — buildings win); a box-drag that covers no building but does cover ships, defence stations, or debris selects all of those field objects together (REQ-UI-ENTITY-CLICK-SELECT, REQ-UI-DEBRIS-MULTI-SELECT).
|
||||
- REQ-UI-MULTI-SELECTION: When multiple buildings are selected and the selection does not aggregate (REQ-UI-SELECTION-AGGREGATE), the panel shows a count summary. Its header names the size of the selection as `<n> buildings` in place of an object name, and carries no symbol and nothing in its right slot. Below it is one row per selected building type — the type's symbol, its name, and the number selected as `x<count>` — one type per row, and no per-building detail. A final row shows the **total building block cost** of the selection, captioned `Total cost` with the value followed by the `building_block` item icon (REQ-UI-BLOCKS-ICON, REQ-UI-ITEM-ICON): the sum of each selected building's placement cost (`buildings.toml [[building]].cost`, per REQ-BLD-COST), counting only player-placeable buildings (buildings with a button in the build button bar); non-player-placeable buildings (the HQ and defence stations) are excluded from the total, consistent with the blueprint total (REQ-UI-BLUEPRINT-CARD). Construction sites count at their building type's full placement cost regardless of construction progress.
|
||||
- REQ-UI-CONFIG-INLINE: Recipe and schematic configuration for a selected building is shown within this panel, in its configuration group (REQ-UI-SELECTION-CARD). Recipe selection (miner, assembler) and schematic selection (shipyard) use the selection button and dialog (REQ-UI-SELECT-BUTTON) rather than an inline control. For shipyards, the panel additionally shows the ship layout preview and "Configure" button below the schematic selection button (REQ-MOD-UI-PREVIEW).
|
||||
- REQ-UI-SELECT-BUTTON: **Recipe and schematic selection control.** Recipe selection (Miner ore type, Assembler recipe) and schematic selection (Shipyard) are each presented in the selection panel as a single **selection button** whose caption is the name of the currently selected recipe or schematic, or a placeholder ("Select recipe" / "Select schematic") when none is selected. Clicking the button opens a modal **selection dialog** that pauses the game (speed set to 0×; on close, the speed is restored to what it was before the dialog was opened) and that opens centered on the selection panel, as every modal opened from the panel does (REQ-UI-PANEL-MODAL). The dialog contains a vertical list of option buttons, one per selectable option, each describing itself (REQ-UI-SELECT-OPTIONS) — only options that are currently unlocked are shown (REQ-LOCK-UI-RECIPE for recipes, REQ-LOCK-UI-SCHEMATIC for schematics). Neither the option buttons nor the selection button carries a tooltip: an option button states what it makes on its own face, and what the building has selected is drawn beneath the selection button as the recipe summary (REQ-UI-RECIPE-SUMMARY), with the production paths of the items involved reachable by hovering the card's item chips (REQ-UI-ITEM-TOOLTIP). Clicking an option button selects that recipe/schematic, closes the dialog, and updates the selection button's caption in the selection panel. The dialog can be dismissed without changing the current selection (e.g. closing it without clicking an option). Selecting a new recipe or schematic has the same effects as before (REQ-MAT-INPUT-BUFFER, REQ-MAT-OUTPUT-BUFFER, REQ-BLD-SHIPYARD).
|
||||
- REQ-UI-CONFIG-INLINE: Recipe and schematic configuration for a selected building is shown within this panel, in its configuration group (REQ-UI-SELECTION-CARD). Recipe selection (miner, assembler, smelter, reprocessing plant) and schematic selection (shipyard) use the selection button and dialog (REQ-UI-SELECT-BUTTON) rather than an inline control. For shipyards, the panel additionally shows the ship layout preview and "Configure" button below the schematic selection button (REQ-MOD-UI-PREVIEW).
|
||||
- REQ-UI-SELECT-BUTTON: **Recipe and schematic selection control.** Recipe selection (Miner ore type, Assembler recipe, and the Smelter's and Reprocessing Plant's recipe per REQ-BLD-AUTO-RECIPE) and schematic selection (Shipyard) are each presented in the selection panel as a single **selection button** whose caption is the name of the currently selected recipe or schematic, or a placeholder ("Select recipe" / "Select schematic") when none is selected. Clicking the button opens a modal **selection dialog** that pauses the game (speed set to 0×; on close, the speed is restored to what it was before the dialog was opened) and that opens centered on the selection panel, as every modal opened from the panel does (REQ-UI-PANEL-MODAL). The dialog contains a vertical list of option buttons, one per selectable option, each describing itself (REQ-UI-SELECT-OPTIONS) — only options that are currently unlocked are shown (REQ-LOCK-UI-RECIPE for recipes, REQ-LOCK-UI-SCHEMATIC for schematics). Neither the option buttons nor the selection button carries a tooltip: an option button states what it makes on its own face, and what the building has selected is drawn beneath the selection button as the recipe summary (REQ-UI-RECIPE-SUMMARY), with the production paths of the items involved reachable by hovering the card's item chips (REQ-UI-ITEM-TOOLTIP). Clicking an option button selects that recipe/schematic, closes the dialog, and updates the selection button's caption in the selection panel. The dialog can be dismissed without changing the current selection (e.g. closing it without clicking an option). Selecting a new recipe or schematic has the same effects as before (REQ-MAT-INPUT-BUFFER, REQ-MAT-OUTPUT-BUFFER, REQ-BLD-SHIPYARD).
|
||||
- REQ-UI-SELECT-OPTIONS: **Option list of the selection dialog.** The selection dialog (REQ-UI-SELECT-BUTTON) lists its options as a **single vertical column** of buttons, one per option, rather than a grid: each button is as wide as the dialog and states what the option does, which needs a line of its own. No option button carries a tooltip — the button face is the whole description, so the player reads every option's inputs, product, and time from the list itself without hovering anything. Should the column be taller than the space the window leaves the dialog — a fully unlocked Assembler offers more options than any window can hold, and a modal is never resized to fit (REQ-UI-PANEL-MODAL) — the list **scrolls** within the dialog rather than the dialog growing past the window.
|
||||
- A **recipe** option (Miner, Assembler) shows the **recipe name** on its first line and, beneath it, that recipe drawn as the recipe summary line draws it (REQ-UI-RECIPE-SUMMARY): each input item's icon on its colored square with its per-cycle amount, an arrow, each output item's icon with its amount, and the cycle time. A miner recipe consumes nothing, so its line begins at the arrow.
|
||||
- A **ship schematic** option (Shipyard) shows the ship's `display_name` on its first line and, beneath it, the icons and quantities of its base required materials (`[ship.schematic].materials`, excluding any module contributions) with the base production time (`[ship.schematic].production_time_seconds`). A ship is not an item and has no icon of its own, so this line names no output: the button's caption is what it produces.
|
||||
- The `(None)` option shows its text caption alone.
|
||||
- The `(None)` option shows its text caption alone. On an auto-recipe building it is captioned `(Auto)` instead, because there it does not leave the building idle but returns it to automatic selection (REQ-BLD-AUTO-RECIPE).
|
||||
- REQ-UI-ITEM-TOOLTIP: **Item production tooltip.** Hovering an item chip in the selection panel — an input or output buffer chip (REQ-UI-SINGLE-SELECTION) or the HQ's block stock chip (REQ-UI-HQ-PANEL) — shows a tooltip telling the player where that item comes from. It has a heading and a body:
|
||||
- the heading is the **hovered item's name**. For an input chip this is the only place the item is named at all, since such a chip carries a count and no name (REQ-UI-SINGLE-SELECTION).
|
||||
- the body is the caption `Produced by` followed by one **recipe line** per unlocked recipe that produces the item. A recipe line is a small **card** of two rows: the icon of the building that runs the recipe (REQ-UI-BUILD-ICON) and the recipe's name on the first, and the recipe itself on the second, drawn as the recipe summary draws it (REQ-UI-RECIPE-SUMMARY) — each input item's icon on its colored square with its per-cycle amount, the inputs separated by `+`, an arrow, each output item's icon with its amount, and the cycle time. Two rows rather than one because an identity and a cycle read as different things, and a single row of icons, names and numbers runs too long to scan; a card around each because several producers stacked as bare lines read as one field of icons and numbers rather than as separate recipes. A line drawn where its surroundings already frame it — on an option button (REQ-UI-SELECT-OPTIONS), or as the panel's recipe summary — takes no card of its own. An item may have several producers — an iron ingot is smelted from ore, smelted from scrap, and recovered by reprocessing — and the building icon and recipe name are what tell those lines apart and tell the player which building to place for which path.
|
||||
|
||||
**Only recipes the player can run are listed**, consistent with the rest of the UI hiding what the player cannot make yet. What that means differs by building, because only Miner and Assembler recipes are unlocked individually (REQ-LOCK-UI-RECIPE): those are listed once unlocked, while a Smelter's or Reprocessing Plant's implicit recipes (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING) are listed once **their building** is unlocked (REQ-LOCK-BUILDING) — there is no sense in naming a path through a plant the player cannot place. Two cases have no recipe line to show, and each says so in place of the list rather than leaving the tooltip bare:
|
||||
**Only recipes the player can run are listed**, consistent with the rest of the UI hiding what the player cannot make yet. What that means differs by building, because only Miner and Assembler recipes are unlocked individually (REQ-LOCK-UI-RECIPE): those are listed once unlocked, while a Smelter's or Reprocessing Plant's recipes (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING) are listed once **their building** is unlocked (REQ-LOCK-BUILDING) — there is no sense in naming a path through a plant the player cannot place. Two cases have no recipe line to show, and each says so in place of the list rather than leaving the tooltip bare:
|
||||
- **An item no recipe produces at all.** Scrap is salvaged from debris (REQ-RES-DEBRIS-DROP) rather than crafted, so its tooltip reads `Salvaged from debris` in place of the `Produced by` caption and lists nothing beneath it.
|
||||
- **An item whose every producing recipe is still locked.** The caption stays `Produced by`, and the single line beneath it reads `Undiscovered`: the player is told the item is made somehow, without being shown a path they have not unlocked yet.
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ bool isConfigurableBuildingType(BuildingType type)
|
||||
{
|
||||
case BuildingType::Miner: // recipe (REQ-BLD-MINER)
|
||||
case BuildingType::Assembler: // recipe (REQ-BLD-ASSEMBLER)
|
||||
case BuildingType::Smelter: // recipe (REQ-BLD-AUTO-RECIPE)
|
||||
case BuildingType::ReprocessingPlant: // recipe (REQ-BLD-AUTO-RECIPE)
|
||||
case BuildingType::Shipyard: // schematic and layout (REQ-BLD-SHIPYARD, REQ-MOD-LAYOUT)
|
||||
case BuildingType::Splitter: // output filters (REQ-BLD-SPLITTER)
|
||||
return true;
|
||||
|
||||
@@ -30,9 +30,9 @@ std::optional<BuildingType> parseBuildingType(const std::string& id);
|
||||
// Canonical id string for a BuildingType. The inverse of parseBuildingType.
|
||||
std::string buildingTypeId(BuildingType type);
|
||||
|
||||
// Smelter and Reprocessing Plant have no player-selected recipe
|
||||
// (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING). They auto-process whatever inputs
|
||||
// they receive, matching against every recipe of their building type.
|
||||
// Smelter and Reprocessing Plant pick a recipe for themselves from the first material
|
||||
// offered to them while they have none (REQ-BLD-AUTO-RECIPE). In every other respect
|
||||
// their recipe is selected and held exactly as any other building's.
|
||||
bool isAutoRecipeBuildingType(BuildingType type);
|
||||
|
||||
// Buildings that run a production cycle: Miner, Smelter, Assembler, Reprocessing
|
||||
@@ -45,7 +45,9 @@ bool isProductionBuildingType(BuildingType type);
|
||||
bool isBeltSubsystemType(BuildingType type);
|
||||
|
||||
// Building types with player-facing settings that a blueprint can carry and hand to an
|
||||
// existing building (REQ-UI-BLUEPRINT-TRANSFER): Miner and Assembler (recipe), Shipyard
|
||||
// (schematic and module layout), Splitter (output filters). Every other type has nothing
|
||||
// to configure, so a blueprint of one has nothing to transfer.
|
||||
// existing building (REQ-UI-BLUEPRINT-TRANSFER): Miner, Assembler, Smelter and
|
||||
// Reprocessing Plant (recipe -- the last two select their own when they have none,
|
||||
// REQ-BLD-AUTO-RECIPE), Shipyard (schematic and module layout), Splitter (output
|
||||
// filters). Every other type has nothing to configure, so a blueprint of one has
|
||||
// nothing to transfer.
|
||||
bool isConfigurableBuildingType(BuildingType type);
|
||||
|
||||
@@ -60,36 +60,6 @@ void initBuffers(Building& b, const RecipeDef& recipe)
|
||||
addOutputCaps(b.outputBuffer.caps, b.type, recipe);
|
||||
}
|
||||
|
||||
void initAutoBuffers(const GameConfig& config, Building& b)
|
||||
{
|
||||
b.inputBuffer.counts.clear();
|
||||
b.inputBuffer.caps.clear();
|
||||
|
||||
b.outputBuffer.items.clear();
|
||||
b.outputBuffer.caps.clear();
|
||||
|
||||
// Union both sides over every recipe of this building type: the cap for each item is
|
||||
// twice the largest per-cycle amount across those recipes, on the input side as on
|
||||
// the output side (REQ-MAT-INPUT-BUFFER, REQ-MAT-OUTPUT-BUFFER).
|
||||
for (const RecipeDef& recipe : config.recipes.recipes)
|
||||
{
|
||||
if (recipe.building != b.type)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const RecipeIngredient& ing : recipe.inputs)
|
||||
{
|
||||
const ItemType type{ing.item};
|
||||
b.inputBuffer.counts[type] = 0;
|
||||
b.inputBuffer.caps[type] =
|
||||
std::max(b.inputBuffer.caps[type], 2 * ing.amount);
|
||||
}
|
||||
|
||||
addOutputCaps(b.outputBuffer.caps, b.type, recipe);
|
||||
}
|
||||
}
|
||||
|
||||
void initShipyardBuffers(const GameConfig& config, Building& b)
|
||||
{
|
||||
b.inputBuffer.counts.clear();
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
// REQ-MAT-OUTPUT-BUFFER).
|
||||
void initBuffers(Building& b, const RecipeDef& recipe);
|
||||
|
||||
// Buffers for an auto-recipe building (Smelter, Reprocessing Plant), unioned over
|
||||
// every recipe of its type (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING).
|
||||
void initAutoBuffers(const GameConfig& config, Building& b);
|
||||
|
||||
// Buffers for a shipyard: its schematic's materials plus those of every placed
|
||||
// module (REQ-BLD-SHIPYARD).
|
||||
void initShipyardBuffers(const GameConfig& config, Building& b);
|
||||
|
||||
@@ -200,12 +200,6 @@ void BuildingSystem::setRecipe(FactoryState& state, BuildingId id, const std::st
|
||||
{
|
||||
if (site.id == id)
|
||||
{
|
||||
// Auto-recipe buildings have no player-selected recipe
|
||||
// (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING); ignore any attempt to set one.
|
||||
if (isAutoRecipeBuildingType(site.type))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// No-op if the recipe is unchanged, so a redundant selection does
|
||||
// not wipe an already-configured ship layout.
|
||||
if (site.recipeId == recipeId)
|
||||
@@ -223,12 +217,6 @@ void BuildingSystem::setRecipe(FactoryState& state, BuildingId id, const std::st
|
||||
{
|
||||
if (building.id == id)
|
||||
{
|
||||
// Auto-recipe buildings have no player-selected recipe
|
||||
// (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING); ignore any attempt to set one.
|
||||
if (isAutoRecipeBuildingType(building.type))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// No-op if the recipe is unchanged, so a redundant selection does
|
||||
// not wipe an already-configured ship layout or reset buffers.
|
||||
if (building.recipeId == recipeId)
|
||||
@@ -407,6 +395,10 @@ void BuildingSystem::tickBeltPull(FactoryState& state)
|
||||
{
|
||||
const std::optional<ItemType> peeked = m_belts.peekItem(building.inputPorts[i]);
|
||||
if (!peeked) { continue; }
|
||||
// A Smelter or Reprocessing Plant without a recipe takes the first material
|
||||
// offered to it as its selection (REQ-BLD-AUTO-RECIPE); the ports are walked
|
||||
// in order, so which offer comes first is fixed.
|
||||
selectAutoRecipeIfUnset(building, *peeked);
|
||||
if (!canAcceptInput(building, i, *peeked)) { continue; }
|
||||
const std::optional<Item> taken = m_belts.tryTakeItem(building.inputPorts[i]);
|
||||
if (taken)
|
||||
@@ -417,6 +409,25 @@ void BuildingSystem::tickBeltPull(FactoryState& state)
|
||||
}
|
||||
}
|
||||
|
||||
void BuildingSystem::selectAutoRecipeIfUnset(Building& building, const ItemType& offered)
|
||||
{
|
||||
// Only while it holds none: once set, a recipe is the player's to change
|
||||
// (REQ-BLD-AUTO-RECIPE). Buildings that select their own recipe are the only ones
|
||||
// this applies to; everyone else ignores an offer they have no recipe for.
|
||||
if (!building.recipeId.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
const RecipeDef* recipe = findAutoRecipeFor(m_config, building.type, offered);
|
||||
if (!recipe)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
building.recipeId = recipe->id;
|
||||
initBuffers(building, *recipe);
|
||||
}
|
||||
|
||||
bool BuildingSystem::canAcceptInput(const Building& consumer,
|
||||
std::size_t inputPortIndex,
|
||||
const ItemType& type) const
|
||||
@@ -477,6 +488,10 @@ bool BuildingSystem::tryDirectCoupleDeposit(FactoryState& state, BuildingId prod
|
||||
if (in.direction != outputPort.direction) { continue; }
|
||||
if (inputBodyTile(in.tile, in.direction) != outputPort.tile) { continue; }
|
||||
|
||||
// A coupling is an offer too, so an unset auto-recipe building selects from it
|
||||
// (REQ-BLD-AUTO-RECIPE). Without this a Smelter placed flush against a producer
|
||||
// would accept nothing and leave it stuck at its port for good.
|
||||
selectAutoRecipeIfUnset(*consumer, item.type);
|
||||
if (!canAcceptInput(*consumer, j, item.type)) { return false; }
|
||||
depositToInputBelt(*consumer, j, item);
|
||||
return true;
|
||||
@@ -502,15 +517,14 @@ void BuildingSystem::tickProduction(FactoryState& state, Tick currentTick)
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool autoRecipe = isAutoRecipeBuildingType(building.type);
|
||||
if (!autoRecipe && building.recipeId.empty())
|
||||
if (building.recipeId.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If a production cycle is active, check for completion. Completion only
|
||||
// needs the already-decided outputs, so it does not depend on which
|
||||
// recipe is selected or auto-chosen.
|
||||
// recipe is selected.
|
||||
if (building.production)
|
||||
{
|
||||
if (currentTick < building.production->completesAt)
|
||||
@@ -531,30 +545,28 @@ void BuildingSystem::tickProduction(FactoryState& state, Tick currentTick)
|
||||
// waits, exactly as it would have on the following tick.
|
||||
}
|
||||
|
||||
// Idle: gather the candidate recipes to try. Auto-recipe buildings
|
||||
// (Smelter, Reprocessing Plant) have no selected recipe and try every
|
||||
// recipe of their type in config order, running the first whose inputs
|
||||
// are satisfied (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING). Other buildings
|
||||
// try only their selected recipe.
|
||||
const std::vector<const RecipeDef*> candidates =
|
||||
gatherCandidateRecipes(m_config, building);
|
||||
|
||||
for (const RecipeDef* recipe : candidates)
|
||||
// Idle: try to start the building's one selected recipe. Every type holds
|
||||
// exactly one, a Smelter and a Reprocessing Plant included -- they differ only
|
||||
// in how theirs first got set (REQ-BLD-AUTO-RECIPE).
|
||||
const RecipeDef* recipe = getSelectedRecipe(m_config, building);
|
||||
if (!recipe)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 1. All required inputs present?
|
||||
if (!recipeInputsAvailable(building, *recipe))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. Room for every output this cycle could produce -- checked before
|
||||
// anything is rolled (REQ-MAT-CYCLE). The roll below is committed the
|
||||
// moment the cycle starts, so a plant that could not store some outcome
|
||||
// must not start at all: that is what stops a stalled output belt from
|
||||
// biasing the distribution towards the outputs that still fit. Emerging
|
||||
// items count against their buffer (REQ-MAT-OUTPUT-EMERGE). The status
|
||||
// light asks the same question to decide yellow (REQ-UI-STATUS-LIGHT), so
|
||||
// the test lives in one place.
|
||||
// 2. Room for every output this cycle could produce -- checked before anything
|
||||
// is rolled (REQ-MAT-CYCLE). The roll below is committed the moment the cycle
|
||||
// starts, so a plant that could not store some outcome must not start at all:
|
||||
// that is what stops a stalled output belt from biasing the distribution
|
||||
// towards the outputs that still fit. Emerging items count against their
|
||||
// buffer (REQ-MAT-OUTPUT-EMERGE). The status light asks the same question to
|
||||
// decide yellow (REQ-UI-STATUS-LIGHT), so the test lives in one place.
|
||||
if (!recipeOutputsFit(building, *recipe))
|
||||
{
|
||||
continue;
|
||||
@@ -591,8 +603,6 @@ void BuildingSystem::tickProduction(FactoryState& state, Tick currentTick)
|
||||
prod.completesAt = currentTick + secondsToTicks(recipe->durationSeconds);
|
||||
prod.chosenOutputs = std::move(chosen);
|
||||
building.production = std::move(prod);
|
||||
break; // At most one cycle starts per tick.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,6 +188,13 @@ private:
|
||||
// (on construction completion, or when un-queuing a deconstruction). No-op for
|
||||
// non-belt-subsystem types. Splitter filters are (re)applied after placement.
|
||||
|
||||
// Selects a recipe for an auto-recipe building that has none, from a material being
|
||||
// offered to it at one of its input ports (REQ-BLD-AUTO-RECIPE). No-op for every
|
||||
// other building, for one that already holds a recipe, and for a material none of
|
||||
// its recipes consumes. Called from both intake paths -- the belt pull and the
|
||||
// direct coupling -- since either can be where the first material arrives.
|
||||
void selectAutoRecipeIfUnset(Building& building,
|
||||
const ItemType& offered);
|
||||
// True if the consumer would accept `type` at the given input port right now:
|
||||
// it is a required input (or a building block for the HQ), the reservation-aware
|
||||
// buffer has room, and the input belt entry is free (REQ-MAT-INPUT-INTAKE).
|
||||
|
||||
@@ -67,12 +67,6 @@ void ConstructionSystem::tick(FactoryState& state, BeltSystem& belts, Tick curre
|
||||
{
|
||||
initSalvageBayBuffer(m_config, building);
|
||||
}
|
||||
else if (isAutoRecipeBuildingType(building.type))
|
||||
{
|
||||
// Smelter/Reprocessing Plant need no recipe selection; buffers are set
|
||||
// up from all recipes of the type (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING).
|
||||
initAutoBuffers(m_config, building);
|
||||
}
|
||||
else if (!building.recipeId.empty())
|
||||
{
|
||||
if (building.type == BuildingType::Shipyard)
|
||||
|
||||
@@ -8,29 +8,37 @@
|
||||
#include "ModulesConfig.h"
|
||||
#include "ShipsConfig.h"
|
||||
|
||||
std::vector<const RecipeDef*>
|
||||
gatherCandidateRecipes(const GameConfig& config, const Building& b)
|
||||
const RecipeDef* getSelectedRecipe(const GameConfig& config, const Building& b)
|
||||
{
|
||||
std::vector<const RecipeDef*> candidates;
|
||||
if (isAutoRecipeBuildingType(b.type))
|
||||
if (b.recipeId.empty())
|
||||
{
|
||||
for (const RecipeDef& r : config.recipes.recipes)
|
||||
return nullptr;
|
||||
}
|
||||
return config.recipes.findRecipeDef(b.recipeId, b.type);
|
||||
}
|
||||
|
||||
const RecipeDef* findAutoRecipeFor(const GameConfig& config, BuildingType type,
|
||||
const ItemType& item)
|
||||
{
|
||||
if (r.building == b.type && !r.inputs.empty())
|
||||
if (!isAutoRecipeBuildingType(type))
|
||||
{
|
||||
candidates.push_back(&r);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Config order decides where a material feeds more than one recipe of the type, so
|
||||
// the same offer always picks the same recipe (REQ-BLD-AUTO-RECIPE).
|
||||
for (const RecipeDef& recipe : config.recipes.recipes)
|
||||
{
|
||||
if (recipe.building != type) { continue; }
|
||||
for (const RecipeIngredient& ing : recipe.inputs)
|
||||
{
|
||||
if (ItemType{ing.item} == item)
|
||||
{
|
||||
return &recipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const RecipeDef* recipe = config.recipes.findRecipeDef(b.recipeId, b.type);
|
||||
if (recipe)
|
||||
{
|
||||
candidates.push_back(recipe);
|
||||
}
|
||||
}
|
||||
return candidates;
|
||||
return nullptr;
|
||||
}
|
||||
bool recipeInputsAvailable(const Building& b, const RecipeDef& recipe)
|
||||
{
|
||||
@@ -130,17 +138,11 @@ bool hasInputsToStart(const GameConfig& config, const Building& b)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Recipe buildings: startable if any candidate recipe's inputs are satisfied.
|
||||
// A Miner recipe has no inputs, so an idle Miner is always startable here and its
|
||||
// only idle reason is an output buffer without room for the next cycle.
|
||||
for (const RecipeDef* recipe : gatherCandidateRecipes(config, b))
|
||||
{
|
||||
if (recipeInputsAvailable(b, *recipe))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
// Recipe buildings: startable if the selected recipe's inputs are satisfied. A Miner
|
||||
// recipe has no inputs, so an idle Miner is always startable here and its only idle
|
||||
// reason is an output buffer without room for the next cycle.
|
||||
const RecipeDef* recipe = getSelectedRecipe(config, b);
|
||||
return recipe != nullptr && recipeInputsAvailable(b, *recipe);
|
||||
}
|
||||
|
||||
bool outputBufferHasRoom(const Building& b, const ItemType& type, int itemCount)
|
||||
@@ -192,14 +194,9 @@ bool canStartCycle(const GameConfig& config, const Building& b)
|
||||
return hasInputsToStart(config, b);
|
||||
}
|
||||
|
||||
for (const RecipeDef* recipe : gatherCandidateRecipes(config, b))
|
||||
{
|
||||
if (recipeInputsAvailable(b, *recipe) && recipeOutputsFit(b, *recipe))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
const RecipeDef* recipe = getSelectedRecipe(config, b);
|
||||
return recipe != nullptr && recipeInputsAvailable(b, *recipe)
|
||||
&& recipeOutputsFit(b, *recipe);
|
||||
}
|
||||
|
||||
std::optional<ProductionStatus>
|
||||
@@ -220,9 +217,10 @@ getProductionStatus(const GameConfig& config, const Building& building)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Grey only applies to player-configured types; auto-recipe buildings
|
||||
// (Smelter, Reprocessing Plant) always run an implicit recipe.
|
||||
if (!isAutoRecipeBuildingType(building.type) && building.recipeId.empty())
|
||||
// Every production building can be unconfigured, an auto-recipe building included:
|
||||
// it holds no recipe until one is offered to it, and the player can hand it back to
|
||||
// automatic selection (REQ-BLD-AUTO-RECIPE, REQ-UI-STATUS-LIGHT).
|
||||
if (building.recipeId.empty())
|
||||
{
|
||||
return ProductionStatus::Unconfigured;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,16 @@ enum class ProductionStatus
|
||||
// Pure functions of the config and the building itself — they read no factory
|
||||
// state, so they are free functions rather than BuildingSystem members.
|
||||
|
||||
// Recipes this building could run: every recipe of its type for an auto-recipe
|
||||
// building (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING), otherwise just its selected one.
|
||||
std::vector<const RecipeDef*> gatherCandidateRecipes(const GameConfig& config,
|
||||
const Building& b);
|
||||
// The recipe this building runs, or null when it has none selected. Every building type
|
||||
// holds exactly one, a Smelter and a Reprocessing Plant included -- they only differ in
|
||||
// how theirs first gets set (REQ-BLD-AUTO-RECIPE).
|
||||
const RecipeDef* getSelectedRecipe(const GameConfig& config, const Building& b);
|
||||
|
||||
// The recipe an auto-recipe building adopts when this material is offered to it while it
|
||||
// has none: the first recipe of its type, in config order, that consumes the material
|
||||
// (REQ-BLD-AUTO-RECIPE). Null when no recipe of the type takes it.
|
||||
const RecipeDef* findAutoRecipeFor(const GameConfig& config, BuildingType type,
|
||||
const ItemType& item);
|
||||
|
||||
// True when the building's input buffer holds every ingredient the recipe needs.
|
||||
bool recipeInputsAvailable(const Building& b, const RecipeDef& recipe);
|
||||
|
||||
@@ -629,12 +629,13 @@ TEST_CASE("BuildingSystem: smelter input buffer fills from adjacent west-flowing
|
||||
// Smelter mask ["AA ","AA>"] → body (0,0),(1,0),(0,1),(1,1).
|
||||
// Output port (2,1) East. Input port example: (2,0) West.
|
||||
const BuildingId sid = f.bs.place(f.state, BuildingType::Smelter, QPoint(0, 0), Rotation::East, 0).value();
|
||||
// Smelters have no recipe selection (REQ-BLD-SMELTER); they auto-accept any
|
||||
// ore/scrap that is an input to a smelter recipe.
|
||||
// A smelter starts with no recipe and picks one from the first material offered to
|
||||
// it (REQ-BLD-AUTO-RECIPE), which is what lets it accept the ore below.
|
||||
|
||||
// Complete construction (15s → tick 450+1 = 451 ticks).
|
||||
Tick tick = 0;
|
||||
runTicks(f.bs, f.cfg, f.state, f.belts, f.stock, static_cast<int>(secondsToTicks(15.0)) + 1, tick);
|
||||
REQUIRE(findBuilding(f.state, sid)->recipeId.empty());
|
||||
|
||||
// Place west-flowing belt at (2,0): belt flows West, delivers to smelter.
|
||||
f.belts.placeBelt(QPoint(2, 0), Rotation::West);
|
||||
@@ -645,6 +646,13 @@ TEST_CASE("BuildingSystem: smelter input buffer fills from adjacent west-flowing
|
||||
|
||||
const Building* b = findBuilding(f.state, sid);
|
||||
REQUIRE(b != nullptr);
|
||||
// The ore selected the recipe that consumes it, and its buffers were sized for that
|
||||
// recipe alone -- copper ore is not one of its inputs any more.
|
||||
REQUIRE(b->recipeId == "iron_ingot");
|
||||
REQUIRE(b->inputBuffer.caps.count(ItemType{"iron_ore"}) == 1);
|
||||
REQUIRE(b->inputBuffer.caps.count(ItemType{"copper_ore"}) == 0);
|
||||
REQUIRE(b->outputBuffer.caps.count(ItemType{"iron_ingot"}) == 1);
|
||||
REQUIRE(b->outputBuffer.caps.count(ItemType{"copper_ingot"}) == 0);
|
||||
// The item was accepted; it may still be travelling inward on the input belt,
|
||||
// so count buffered + in-transit (REQ-MAT-INPUT-INTAKE).
|
||||
REQUIRE(b->pendingInputCount(ItemType{"iron_ore"}) >= 1);
|
||||
@@ -749,10 +757,10 @@ TEST_CASE("BuildingSystem: smelter auto-smelts ore without a recipe selection",
|
||||
REQUIRE(hasIronIngot);
|
||||
}
|
||||
|
||||
// With mixed inputs, the smelter runs whichever recipe is currently satisfiable
|
||||
// and leaves an incomplete batch of another input waiting (see the union-of-
|
||||
// inputs caps in initAutoBuffers).
|
||||
TEST_CASE("BuildingSystem: smelter runs a satisfiable recipe while an incomplete batch waits",
|
||||
// A belt carrying mixed ore is the realistic case for REQ-BLD-AUTO-RECIPE: the first ore
|
||||
// to arrive settles the recipe, and everything else on that belt is refused rather than
|
||||
// smelted alongside it.
|
||||
TEST_CASE("BuildingSystem: mixed ore on one belt leaves the smelter on the first ore's recipe",
|
||||
"[building]")
|
||||
{
|
||||
PlacementFixture f(kFastBeltSpeed_tps);
|
||||
@@ -762,8 +770,7 @@ TEST_CASE("BuildingSystem: smelter runs a satisfiable recipe while an incomplete
|
||||
Tick tick = 0;
|
||||
runTicks(f.bs, f.cfg, f.state, f.belts, f.stock, static_cast<int>(secondsToTicks(15.0)) + 1, tick);
|
||||
|
||||
// Feed 1 iron_ore (iron_ingot needs 2 — incomplete) then 2 copper_ore
|
||||
// (copper_ingot needs 2 — satisfiable) via the west-flowing input belt.
|
||||
// Feed 1 iron_ore, then 2 copper_ore, via the west-flowing input belt.
|
||||
f.belts.placeBelt(QPoint(2, 0), Rotation::West);
|
||||
const char* fed[] = { "iron_ore", "copper_ore", "copper_ore" };
|
||||
for (const char* id : fed)
|
||||
@@ -773,24 +780,26 @@ TEST_CASE("BuildingSystem: smelter runs a satisfiable recipe while an incomplete
|
||||
f.bs.tickBeltPull(f.state);
|
||||
}
|
||||
|
||||
// copper_ingot cycle is 2.5s; run to completion.
|
||||
runTicks(f.bs, f.cfg, f.state, f.belts, f.stock, static_cast<int>(secondsToTicks(2.5)) + 2, tick);
|
||||
|
||||
const Building* b = findBuilding(f.state, sid);
|
||||
REQUIRE(b != nullptr);
|
||||
|
||||
// Copper was smelted; the lone iron_ore still waits for a second unit.
|
||||
bool hasCopperIngot = false;
|
||||
// The iron ore came first, so the smelter smelts iron and nothing else. The copper
|
||||
// was never taken in, so no copper ingot was made.
|
||||
REQUIRE(b->recipeId == "iron_ingot");
|
||||
for (const Item& item : outputSideItems(*b))
|
||||
{
|
||||
if (item.type.id == "copper_ingot") { hasCopperIngot = true; }
|
||||
REQUIRE(item.type.id != "copper_ingot");
|
||||
}
|
||||
REQUIRE(hasCopperIngot);
|
||||
REQUIRE(b->pendingInputCount(ItemType{"copper_ore"}) == 0);
|
||||
|
||||
// The lone iron ore still waits for a second unit: the recipe needs two.
|
||||
const std::map<ItemType, int>::const_iterator ironIt =
|
||||
b->inputBuffer.counts.find(ItemType{"iron_ore"});
|
||||
REQUIRE(ironIt != b->inputBuffer.counts.end());
|
||||
REQUIRE(ironIt->second == 1);
|
||||
REQUIRE_FALSE(b->production.has_value());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -925,13 +934,16 @@ TEST_CASE("BuildingSystem: reprocessing plant sizes one output buffer per possib
|
||||
|
||||
const BuildingId id = f.bs.place(f.state, BuildingType::ReprocessingPlant,
|
||||
QPoint(0, 0), Rotation::East, 0).value();
|
||||
// Reprocessing plants have no recipe selection (REQ-BLD-REPROCESSING); the
|
||||
// single reprocessing recipe is applied automatically on completion.
|
||||
|
||||
// Complete construction (25s).
|
||||
Tick tick = 0;
|
||||
runTicks(f.bs, f.cfg, f.state, f.belts, f.stock, static_cast<int>(secondsToTicks(25.0)) + 1, tick);
|
||||
|
||||
// A plant holds no buffers until it has a recipe (REQ-BLD-AUTO-RECIPE); selecting
|
||||
// one sizes them, exactly as the first scrap offered to it would.
|
||||
REQUIRE(findBuilding(f.state, id)->outputBuffer.caps.empty());
|
||||
f.bs.setRecipe(f.state, id, "reprocessing_cycle");
|
||||
|
||||
const Building* b = findBuilding(f.state, id);
|
||||
REQUIRE(b != nullptr);
|
||||
// reprocessing_cycle outputs: 2 iron_ingot (60%), 1 circuit_board (30%),
|
||||
@@ -1029,30 +1041,133 @@ TEST_CASE("BuildingSystem: reprocessing plant runs a second cycle while holding
|
||||
REQUIRE(getProductionStatus(f.cfg, *b) == ProductionStatus::Producing);
|
||||
}
|
||||
|
||||
TEST_CASE("BuildingSystem: one item's backlog does not block another item's cycle",
|
||||
"[building]")
|
||||
{
|
||||
// Per-item buffers, so a smelter holding iron ingots can still smelt copper
|
||||
// (REQ-MAT-OUTPUT-BUFFER). Under one shared capacity the iron would have blocked it.
|
||||
PlacementFixture f;
|
||||
// ---------------------------------------------------------------------------
|
||||
// Automatic recipe selection (REQ-BLD-AUTO-RECIPE)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Building smelter;
|
||||
smelter.type = BuildingType::Smelter;
|
||||
initAutoBuffers(f.cfg, smelter);
|
||||
|
||||
// Copper ore in, and the iron_ingot buffer filled to its cap.
|
||||
smelter.inputBuffer.counts[ItemType{"copper_ore"}] =
|
||||
smelter.inputBuffer.caps.at(ItemType{"copper_ore"});
|
||||
const int ironCap = smelter.outputBuffer.caps.at(ItemType{"iron_ingot"});
|
||||
for (int i = 0; i < ironCap; ++i)
|
||||
// Places a smelter and runs it to completion, leaving it with no recipe.
|
||||
static BuildingId buildSmelter(PlacementFixture& f, QPoint anchor, Tick& tick)
|
||||
{
|
||||
smelter.outputBuffer.items.push_back(makeItem("iron_ingot"));
|
||||
const BuildingId id =
|
||||
f.bs.place(f.state, BuildingType::Smelter, anchor, Rotation::East, 0).value();
|
||||
runTicks(f.bs, f.cfg, f.state, f.belts, f.stock,
|
||||
static_cast<int>(secondsToTicks(15.0)) + 1, tick);
|
||||
return id;
|
||||
}
|
||||
|
||||
REQUIRE_FALSE(outputBufferHasRoom(smelter, ItemType{"iron_ingot"}, 1));
|
||||
REQUIRE(outputBufferHasRoom(smelter, ItemType{"copper_ingot"}, 1));
|
||||
REQUIRE(canStartCycle(f.cfg, smelter));
|
||||
REQUIRE(getProductionStatus(f.cfg, smelter) == ProductionStatus::Producing);
|
||||
TEST_CASE("BuildingSystem: an unset auto-recipe building is unconfigured", "[building]")
|
||||
{
|
||||
// It holds no recipe until one is offered to it, so it reads grey like any other
|
||||
// unconfigured building (REQ-BLD-AUTO-RECIPE, REQ-UI-STATUS-LIGHT).
|
||||
PlacementFixture f;
|
||||
Tick tick = 0;
|
||||
const BuildingId id = buildSmelter(f, QPoint(0, 0), tick);
|
||||
|
||||
const Building* b = findBuilding(f.state, id);
|
||||
REQUIRE(b != nullptr);
|
||||
REQUIRE(b->recipeId.empty());
|
||||
REQUIRE(b->inputBuffer.caps.empty());
|
||||
REQUIRE(b->outputBuffer.caps.empty());
|
||||
REQUIRE(getProductionStatus(f.cfg, *b) == ProductionStatus::Unconfigured);
|
||||
}
|
||||
|
||||
TEST_CASE("BuildingSystem: a set recipe is never replaced by a later material",
|
||||
"[building]")
|
||||
{
|
||||
// Once set the recipe is the player's to change: a material belonging to another of
|
||||
// its recipes is simply not an accepted input (REQ-BLD-AUTO-RECIPE).
|
||||
PlacementFixture f(kFastBeltSpeed_tps);
|
||||
Tick tick = 0;
|
||||
const BuildingId id = buildSmelter(f, QPoint(0, 0), tick);
|
||||
|
||||
// Iron ore first, which selects the iron recipe.
|
||||
f.belts.placeBelt(QPoint(2, 0), Rotation::West);
|
||||
f.belts.tryPutItem(QPoint(2, 0), makeItem("iron_ore"));
|
||||
f.belts.tick();
|
||||
f.bs.tickBeltPull(f.state);
|
||||
REQUIRE(findBuilding(f.state, id)->recipeId == "iron_ingot");
|
||||
|
||||
// Copper ore next: refused, and the recipe stands.
|
||||
f.belts.tryPutItem(QPoint(2, 0), makeItem("copper_ore"));
|
||||
f.belts.tick();
|
||||
f.bs.tickBeltPull(f.state);
|
||||
|
||||
const Building* b = findBuilding(f.state, id);
|
||||
REQUIRE(b->recipeId == "iron_ingot");
|
||||
REQUIRE(b->pendingInputCount(ItemType{"copper_ore"}) == 0);
|
||||
// The copper is still sitting on the belt, refused rather than swallowed.
|
||||
REQUIRE(f.belts.peekItem(westPort(QPoint(2, 0))).has_value());
|
||||
}
|
||||
|
||||
TEST_CASE("BuildingSystem: a manually selected recipe is not overridden", "[building]")
|
||||
{
|
||||
// The player's selection is a recipe like any other, so auto-selection stays out of
|
||||
// the way and the smelter refuses ore it does not smelt (REQ-BLD-AUTO-RECIPE).
|
||||
PlacementFixture f(kFastBeltSpeed_tps);
|
||||
Tick tick = 0;
|
||||
const BuildingId id = buildSmelter(f, QPoint(0, 0), tick);
|
||||
|
||||
f.bs.setRecipe(f.state, id, "copper_ingot");
|
||||
REQUIRE(findBuilding(f.state, id)->recipeId == "copper_ingot");
|
||||
|
||||
f.belts.placeBelt(QPoint(2, 0), Rotation::West);
|
||||
f.belts.tryPutItem(QPoint(2, 0), makeItem("iron_ore"));
|
||||
f.belts.tick();
|
||||
f.bs.tickBeltPull(f.state);
|
||||
|
||||
const Building* b = findBuilding(f.state, id);
|
||||
REQUIRE(b->recipeId == "copper_ingot");
|
||||
REQUIRE(b->pendingInputCount(ItemType{"iron_ore"}) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("BuildingSystem: selecting a different recipe frees a stuck auto-recipe building",
|
||||
"[building]")
|
||||
{
|
||||
// A smelter left holding part of a cycle nothing feeds any more is freed by
|
||||
// selecting another recipe, which clears the buffers -- that is why no separate
|
||||
// clear action exists (REQ-BLD-AUTO-RECIPE, REQ-MAT-INPUT-BUFFER).
|
||||
PlacementFixture f(kFastBeltSpeed_tps);
|
||||
Tick tick = 0;
|
||||
const BuildingId id = buildSmelter(f, QPoint(0, 0), tick);
|
||||
|
||||
// One iron ore, where the recipe needs two: it can never run.
|
||||
f.belts.placeBelt(QPoint(2, 0), Rotation::West);
|
||||
f.belts.tryPutItem(QPoint(2, 0), makeItem("iron_ore"));
|
||||
f.belts.tick();
|
||||
f.bs.tickBeltPull(f.state);
|
||||
runTicks(f.bs, f.cfg, f.state, f.belts, f.stock, 30, tick);
|
||||
|
||||
const Building* stuck = findBuilding(f.state, id);
|
||||
REQUIRE(stuck->recipeId == "iron_ingot");
|
||||
REQUIRE(stuck->pendingInputCount(ItemType{"iron_ore"}) == 1);
|
||||
REQUIRE_FALSE(stuck->production.has_value());
|
||||
|
||||
f.bs.setRecipe(f.state, id, "copper_ingot");
|
||||
const Building* freed = findBuilding(f.state, id);
|
||||
REQUIRE(freed->recipeId == "copper_ingot");
|
||||
REQUIRE(freed->pendingInputCount(ItemType{"iron_ore"}) == 0);
|
||||
REQUIRE(freed->inputBuffer.caps.count(ItemType{"copper_ore"}) == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("BuildingSystem: selecting (Auto) returns the building to automatic selection",
|
||||
"[building]")
|
||||
{
|
||||
// The dialog's clearing option unsets the recipe rather than leaving the building
|
||||
// idle for good: the next material offered selects one again (REQ-BLD-AUTO-RECIPE).
|
||||
PlacementFixture f(kFastBeltSpeed_tps);
|
||||
Tick tick = 0;
|
||||
const BuildingId id = buildSmelter(f, QPoint(0, 0), tick);
|
||||
|
||||
f.bs.setRecipe(f.state, id, "copper_ingot");
|
||||
f.bs.setRecipe(f.state, id, std::string()); // the "(Auto)" option
|
||||
REQUIRE(findBuilding(f.state, id)->recipeId.empty());
|
||||
|
||||
f.belts.placeBelt(QPoint(2, 0), Rotation::West);
|
||||
f.belts.tryPutItem(QPoint(2, 0), makeItem("iron_ore"));
|
||||
f.belts.tick();
|
||||
f.bs.tickBeltPull(f.state);
|
||||
|
||||
REQUIRE(findBuilding(f.state, id)->recipeId == "iron_ingot");
|
||||
}
|
||||
|
||||
TEST_CASE("BuildingSystem: reprocessing plant produces one cycle output then stalls",
|
||||
@@ -1063,8 +1178,8 @@ TEST_CASE("BuildingSystem: reprocessing plant produces one cycle output then sta
|
||||
|
||||
const BuildingId id = f.bs.place(f.state, BuildingType::ReprocessingPlant,
|
||||
QPoint(0, 0), Rotation::East, 0).value();
|
||||
// Reprocessing plants have no recipe selection (REQ-BLD-REPROCESSING); the
|
||||
// single reprocessing recipe is applied automatically on completion.
|
||||
// The plant selects its recipe from the first scrap offered to it
|
||||
// (REQ-BLD-AUTO-RECIPE), which is what the belt feeding below does.
|
||||
|
||||
// Complete construction (25s).
|
||||
Tick tick = 0;
|
||||
@@ -1242,10 +1357,12 @@ TEST_CASE("isConfigurableBuildingType: only types with player-facing settings",
|
||||
CHECK(isConfigurableBuildingType(BuildingType::Shipyard));
|
||||
CHECK(isConfigurableBuildingType(BuildingType::Splitter));
|
||||
|
||||
// Smelter and Reprocessing Plant run implicit recipes (REQ-BLD-SMELTER,
|
||||
// REQ-BLD-REPROCESSING) and the rest have no settings whatsoever.
|
||||
CHECK_FALSE(isConfigurableBuildingType(BuildingType::Smelter));
|
||||
CHECK_FALSE(isConfigurableBuildingType(BuildingType::ReprocessingPlant));
|
||||
// Smelter and Reprocessing Plant carry a recipe like any other, even though they can
|
||||
// also select it themselves (REQ-BLD-AUTO-RECIPE).
|
||||
CHECK(isConfigurableBuildingType(BuildingType::Smelter));
|
||||
CHECK(isConfigurableBuildingType(BuildingType::ReprocessingPlant));
|
||||
|
||||
// The rest have no settings whatsoever.
|
||||
CHECK_FALSE(isConfigurableBuildingType(BuildingType::SalvageBay));
|
||||
CHECK_FALSE(isConfigurableBuildingType(BuildingType::Belt));
|
||||
CHECK_FALSE(isConfigurableBuildingType(BuildingType::TunnelEntry));
|
||||
@@ -1295,8 +1412,15 @@ TEST_CASE("resolveBlueprintGhost: a partial overlap of the same type is invalid"
|
||||
// Both footprints stay on the asteroid, so terrain is not what fails here.
|
||||
f.bs.place(f.state, BuildingType::Smelter, QPoint(-3, 0), Rotation::East, 0);
|
||||
|
||||
CHECK(resolveOne(f, BuildingType::Smelter, QPoint(-2, 0), Rotation::East).action
|
||||
// Judged on where it sits, with no cursor to hit-test: the overlap is what decides.
|
||||
CHECK(resolveInConstellation(f, BuildingType::Smelter, QPoint(-2, 0), Rotation::East).action
|
||||
== BlueprintGhostAction::Invalid);
|
||||
|
||||
// With the cursor on the existing smelter the single-building gesture answers first
|
||||
// and hands it the settings, since a smelter carries a recipe (REQ-BLD-AUTO-RECIPE,
|
||||
// REQ-UI-BLUEPRINT-TRANSFER) -- the same as for a miner.
|
||||
CHECK(resolveOne(f, BuildingType::Smelter, QPoint(-2, 0), Rotation::East).action
|
||||
== BlueprintGhostAction::Transfer);
|
||||
}
|
||||
|
||||
TEST_CASE("resolveBlueprintGhost: a single configurable building transfers its settings",
|
||||
@@ -1457,11 +1581,11 @@ TEST_CASE("resolveBlueprintGhost: a constellation mixes transfers and plain over
|
||||
REQUIRE(miner.action == BlueprintGhostAction::Transfer);
|
||||
CHECK(*miner.targetId == minerId);
|
||||
|
||||
// A smelter runs an implicit recipe (REQ-BLD-SMELTER), so there is nothing to hand
|
||||
// over and it is simply left as it is.
|
||||
// A smelter carries a recipe too now (REQ-BLD-AUTO-RECIPE), so a blueprint of one
|
||||
// has something to hand over just as the miner does.
|
||||
const BlueprintGhostResolved smelter =
|
||||
resolveInConstellation(f, BuildingType::Smelter, QPoint(-5, 0), Rotation::East);
|
||||
REQUIRE(smelter.action == BlueprintGhostAction::CompatibleOverlap);
|
||||
REQUIRE(smelter.action == BlueprintGhostAction::Transfer);
|
||||
CHECK(*smelter.targetId == smelterId);
|
||||
}
|
||||
|
||||
@@ -1803,6 +1927,7 @@ TEST_CASE("BuildingSystem: getProductionStatus classifies production state", "[b
|
||||
REQUIRE(reprocessingRecipe->outputs.size() >= 2);
|
||||
|
||||
Building plant; plant.type = BuildingType::ReprocessingPlant;
|
||||
plant.recipeId = reprocessingRecipe->id;
|
||||
initBuffers(plant, *reprocessingRecipe);
|
||||
for (const RecipeIngredient& ing : reprocessingRecipe->inputs)
|
||||
{
|
||||
@@ -1829,11 +1954,33 @@ TEST_CASE("BuildingSystem: getProductionStatus classifies production state", "[b
|
||||
REQUIRE(statusOf(plant) == ProductionStatus::Starved);
|
||||
}
|
||||
|
||||
SECTION("Smelter (auto-recipe) is never grey")
|
||||
SECTION("Smelter: grey until it has a recipe, then judged like any other building")
|
||||
{
|
||||
// It holds no recipe until one is offered to it, so grey now applies to it too
|
||||
// (REQ-BLD-AUTO-RECIPE, REQ-UI-STATUS-LIGHT).
|
||||
Building smelter; smelter.type = BuildingType::Smelter;
|
||||
// No player-selectable recipe and empty inputs -> red, not grey.
|
||||
REQUIRE(statusOf(smelter) == ProductionStatus::Starved);
|
||||
REQUIRE(statusOf(smelter) == ProductionStatus::Unconfigured);
|
||||
|
||||
const RecipeDef* smelterRecipe = nullptr;
|
||||
for (const RecipeDef& r : f.cfg.recipes.recipes)
|
||||
{
|
||||
if (r.building == BuildingType::Smelter && !r.inputs.empty())
|
||||
{
|
||||
smelterRecipe = &r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
REQUIRE(smelterRecipe != nullptr);
|
||||
|
||||
smelter.recipeId = smelterRecipe->id;
|
||||
initBuffers(smelter, *smelterRecipe);
|
||||
REQUIRE(statusOf(smelter) == ProductionStatus::Starved); // recipe, but no ore
|
||||
|
||||
for (const RecipeIngredient& ing : smelterRecipe->inputs)
|
||||
{
|
||||
smelter.inputBuffer.counts[ItemType{ing.item}] = ing.amount;
|
||||
}
|
||||
REQUIRE(statusOf(smelter) == ProductionStatus::Producing);
|
||||
}
|
||||
|
||||
SECTION("Shipyard: unconfigured, then starved without materials, then producing")
|
||||
|
||||
@@ -27,7 +27,7 @@ struct ItemProduction
|
||||
//
|
||||
// What counts as available differs by building type, because only Miner and Assembler
|
||||
// recipes are individually unlocked (REQ-LOCK-UI-RECIPE): those are filtered by the
|
||||
// unlock state, while a Smelter's or Reprocessing Plant's implicit recipes
|
||||
// unlock state, while a Smelter's or Reprocessing Plant's recipes
|
||||
// (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING) are filtered by whether their building is
|
||||
// unlocked yet (REQ-LOCK-BUILDING) -- there is no sense in naming a path through a
|
||||
// plant the player cannot place.
|
||||
|
||||
@@ -50,7 +50,13 @@ std::vector<RecipeSelectionOption> buildRecipeSelectionOptions(
|
||||
BuildingType type, Simulation& sim, const GameConfig& config)
|
||||
{
|
||||
std::vector<RecipeSelectionOption> options;
|
||||
options.push_back({std::string(), QObject::tr("(None)"), RecipeLineRow::Spec()});
|
||||
// The clearing option. On a building that picks its own recipe it does not leave the
|
||||
// building idle but hands it back to that selection, and says so
|
||||
// (REQ-UI-SELECT-OPTIONS, REQ-BLD-AUTO-RECIPE).
|
||||
options.push_back({std::string(),
|
||||
isAutoRecipeBuildingType(type) ? QObject::tr("(Auto)")
|
||||
: QObject::tr("(None)"),
|
||||
RecipeLineRow::Spec()});
|
||||
|
||||
if (type == BuildingType::Shipyard)
|
||||
{
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
#include "AutoProductionContent.h"
|
||||
|
||||
#include "Building.h"
|
||||
#include "BuildingTarget.h"
|
||||
#include "GameConfig.h"
|
||||
#include "ProductionRules.h"
|
||||
|
||||
AutoProductionContent::AutoProductionContent(const SelectionContext& context,
|
||||
const SelectionRequest& request,
|
||||
QWidget* parent)
|
||||
: BufferedBuildingContent(context, request.buildings.front(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
BufferedBuildingContent::CycleInfo AutoProductionContent::getCycleInfo(
|
||||
const BuildingTarget& target) const
|
||||
{
|
||||
CycleInfo info;
|
||||
// An auto-recipe building always runs an implicit recipe (REQ-BLD-SMELTER,
|
||||
// REQ-BLD-REPROCESSING), so its production section is always shown -- but only a
|
||||
// running cycle names a recipe, so while it is idle there is no cycle to describe.
|
||||
info.runsProduction = true;
|
||||
|
||||
if (target.building)
|
||||
{
|
||||
// What the building handles at all, so its buffers are not blank whenever it
|
||||
// happens to be between cycles (REQ-UI-SINGLE-SELECTION). This is the same union
|
||||
// of every recipe of its type that the simulation sized the buffers over, and
|
||||
// the locked ones among them are dropped when the card lists them.
|
||||
for (const RecipeDef* recipe :
|
||||
gatherCandidateRecipes(*getContext().config, *target.building))
|
||||
{
|
||||
for (const RecipeIngredient& ingredient : recipe->inputs)
|
||||
{
|
||||
info.handledInputs.push_back(ingredient.item);
|
||||
}
|
||||
for (const RecipeOutput& output : recipe->outputs)
|
||||
{
|
||||
info.handledOutputs.push_back(output.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Which recipe describes the cycle: the one running, or -- between cycles -- the one
|
||||
// that ran last. Dropping it while idle would take the summary row and the chips'
|
||||
// per-cycle amounts away and bring them back with every cycle, resizing the card in
|
||||
// step with the building's status (REQ-UI-RECIPE-SUMMARY). Only a building that has
|
||||
// never run has nothing to describe.
|
||||
if (target.building && target.building->production.has_value())
|
||||
{
|
||||
m_lastRecipeId = target.building->production->recipeId;
|
||||
}
|
||||
if (!target.building || m_lastRecipeId.empty())
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
const RecipeDef* recipe =
|
||||
getContext().config->recipes.findRecipeDef(m_lastRecipeId, target.type);
|
||||
if (!recipe)
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
for (const RecipeIngredient& ingredient : recipe->inputs)
|
||||
{
|
||||
info.perCycleInputs[ingredient.item] = ingredient.amount;
|
||||
}
|
||||
for (const RecipeOutput& output : recipe->outputs)
|
||||
{
|
||||
info.perCycleOutputs[output.item] = output.amount;
|
||||
}
|
||||
info.durationSeconds = recipe->durationSeconds;
|
||||
return info;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "BufferedBuildingContent.h"
|
||||
#include "SelectionContentFactory.h"
|
||||
|
||||
// The card for a Smelter or a Reprocessing Plant (REQ-UI-SELECTION-CONTENT). Both
|
||||
// auto-process whatever they receive and have no player-facing recipe selection
|
||||
// (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING), so the card has no configuration group at
|
||||
// all; its cycle is whichever recipe is in production, or the last one that was.
|
||||
class AutoProductionContent : public BufferedBuildingContent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AutoProductionContent(const SelectionContext& context,
|
||||
const SelectionRequest& request, QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
CycleInfo getCycleInfo(const BuildingTarget& target) const override;
|
||||
|
||||
private:
|
||||
// The recipe last seen in production, which keeps describing the cycle while the
|
||||
// building sits between cycles (REQ-UI-RECIPE-SUMMARY). Mutable because it is a
|
||||
// record of what getCycleInfo() has observed rather than state of its own: the card
|
||||
// shows the same thing whether or not it has been asked before.
|
||||
mutable std::string m_lastRecipeId;
|
||||
};
|
||||
@@ -20,7 +20,6 @@ SET(HDRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ClearBeltControl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BufferedBuildingContent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/RecipeProductionContent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/AutoProductionContent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ShipyardContent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/StorageContent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/HqContent.h
|
||||
@@ -55,7 +54,6 @@ SET(SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ClearBeltControl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BufferedBuildingContent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/RecipeProductionContent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/AutoProductionContent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ShipyardContent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/StorageContent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/HqContent.cpp
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "SelectionContentFactory.h"
|
||||
|
||||
#include "AutoProductionContent.h"
|
||||
#include "BeltContent.h"
|
||||
#include "DebrisContent.h"
|
||||
#include "FactoryQueries.h"
|
||||
@@ -27,10 +26,9 @@ SelectionContentKind getKindForType(BuildingType type)
|
||||
{
|
||||
case BuildingType::Miner:
|
||||
case BuildingType::Assembler:
|
||||
return SelectionContentKind::RecipeProduction;
|
||||
case BuildingType::Smelter:
|
||||
case BuildingType::ReprocessingPlant:
|
||||
return SelectionContentKind::AutoProduction;
|
||||
return SelectionContentKind::RecipeProduction;
|
||||
case BuildingType::Shipyard:
|
||||
return SelectionContentKind::Shipyard;
|
||||
case BuildingType::SalvageBay:
|
||||
@@ -160,8 +158,6 @@ SelectionContent* createContent(const ContentKey& key, const SelectionRequest& r
|
||||
return nullptr;
|
||||
case SelectionContentKind::RecipeProduction:
|
||||
return new RecipeProductionContent(context, request, parent);
|
||||
case SelectionContentKind::AutoProduction:
|
||||
return new AutoProductionContent(context, request, parent);
|
||||
case SelectionContentKind::Shipyard:
|
||||
return new ShipyardContent(context, request, parent);
|
||||
case SelectionContentKind::Storage:
|
||||
|
||||
@@ -31,8 +31,7 @@ struct SelectionRequest
|
||||
enum class SelectionContentKind
|
||||
{
|
||||
None, // nothing selected: the panel hides itself entirely
|
||||
RecipeProduction, // Miner, Assembler
|
||||
AutoProduction, // Smelter, Reprocessing Plant
|
||||
RecipeProduction, // Miner, Assembler, Smelter, Reprocessing Plant
|
||||
Shipyard,
|
||||
Storage, // Salvage Bay
|
||||
Hq,
|
||||
|
||||
Reference in New Issue
Block a user