Compare commits
20 Commits
progressio
...
cc38bf95fa
| Author | SHA1 | Date | |
|---|---|---|---|
| cc38bf95fa | |||
| b58bcfe272 | |||
| de1ebb8a5f | |||
| 24c18f8ac6 | |||
| 2cedd5d433 | |||
| f11db0c072 | |||
| 808e0c6a7b | |||
| e4ea4ca4b4 | |||
| fef22b9f86 | |||
| cdf89ce0dd | |||
| e8786c3922 | |||
| fc622670d2 | |||
| e32d384c99 | |||
| 24e0999d8a | |||
| fcaee000fa | |||
| 751ef27a7b | |||
| 3c1376828c | |||
| bd0675db66 | |||
| 5b86b15c71 | |||
| c6db4bf24a |
@@ -82,6 +82,6 @@ cost = 25
|
||||
player_placeable = true
|
||||
construction_time_seconds = 1
|
||||
surface_mask = [
|
||||
"SAA",
|
||||
"SAA>",
|
||||
"<AAS",
|
||||
" AAS",
|
||||
]
|
||||
|
||||
@@ -56,12 +56,9 @@ production_time_seconds = 3
|
||||
fill_color = "#FF8040"
|
||||
glyph = "Rm"
|
||||
|
||||
# damage 14 keeps a 60 HP drone at 5 hits — 15+ crosses a breakpoint that
|
||||
# silently adds ~25% effective DPS vs drones (docs/balancing/history.md,
|
||||
# round 6).
|
||||
[module.weapon]
|
||||
damage = 14
|
||||
attack_range_m = 80
|
||||
attack_range_m = 70
|
||||
attack_rate_hz = 1.5
|
||||
|
||||
|
||||
@@ -78,12 +75,9 @@ production_time_seconds = 4
|
||||
fill_color = "#FF8040"
|
||||
glyph = "Rl"
|
||||
|
||||
# attack_range_m 130 deliberately exceeds the station range of 120
|
||||
# (stations.toml) — the l gun is the only weapon that can besiege stations
|
||||
# without tanking their fire (docs/balancing/history.md, playtest 1).
|
||||
[module.weapon]
|
||||
damage = 52
|
||||
attack_range_m = 130
|
||||
attack_range_m = 100
|
||||
attack_rate_hz = 0.8
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@@ -17,6 +17,13 @@ player_buffer_width_tiles = 20
|
||||
contest_zone_width_tiles = 60
|
||||
enemy_buffer_width_tiles = 20
|
||||
|
||||
[scroll]
|
||||
# View pan speed (REQ-UI-SCROLL-SPEED): slow near the asteroid, fast across the
|
||||
# contest zone, with a linear ramp of the given width straddling each boundary.
|
||||
pan_speed_slow_tiles_per_second = 8.0
|
||||
pan_speed_fast_tiles_per_second = 24.0
|
||||
pan_ramp_band_width_tiles = 16
|
||||
|
||||
[expansion]
|
||||
columns_per_expansion_tiles = 10
|
||||
# x = expansions already purchased; ~1 per cycle mid-game, decelerating
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
# using the verified fitted threat values from tools/threat_report.py:
|
||||
# drone 10.5, frigate 47, destroyer 99, cruiser 233.5,
|
||||
# battlecruiser 354.5, battleship 722.5, dreadnought 1491.5,
|
||||
# carrier 1436.5, glass destroyer (8 small guns) 92, repair drone 17,
|
||||
# railgun_s-spam cruiser (12 small guns) 178.
|
||||
# carrier 1436.5, glass destroyer (8 small guns) 92, repair drone 17.
|
||||
# Module arrays mirror the ships' default_modules loadouts unless a
|
||||
# doctrine variant is the point of the arena.
|
||||
#
|
||||
@@ -349,50 +348,6 @@ enemy_buffer_width_tiles = 10
|
||||
{type = "railgun_s", x = 4, y = 1, rotation = "east"},
|
||||
]
|
||||
|
||||
[[arena]]
|
||||
name = "Railgun_s-spam cruisers vs default cruisers (1424 vs 1401)"
|
||||
# Tracks the playtest-1 meta: cruiser hulls filled with 12 small guns
|
||||
# (max DPS/threat, no armor, range 50) against the default m-gun fit.
|
||||
# The concentration tax means the spam side SHOULD win a brawl somewhat;
|
||||
# this arena bounds its margin — a blowout here means the small-gun
|
||||
# premium or the m-gun range edge needs retuning.
|
||||
height_tiles = 10
|
||||
player_buffer_width_tiles = 10
|
||||
contest_zone_width_tiles = 50
|
||||
enemy_buffer_width_tiles = 10
|
||||
|
||||
[[arena.team]]
|
||||
name = "Spam"
|
||||
[[arena.team.ship]]
|
||||
schematic = "cruiser"
|
||||
count = 8
|
||||
modules = [
|
||||
{type = "railgun_s", x = 1, y = 0, rotation = "east"},
|
||||
{type = "railgun_s", x = 2, y = 0, rotation = "east"},
|
||||
{type = "railgun_s", x = 0, y = 1, rotation = "east"},
|
||||
{type = "railgun_s", x = 1, y = 1, rotation = "east"},
|
||||
{type = "railgun_s", x = 2, y = 1, rotation = "east"},
|
||||
{type = "railgun_s", x = 3, y = 1, rotation = "east"},
|
||||
{type = "railgun_s", x = 0, y = 2, rotation = "east"},
|
||||
{type = "railgun_s", x = 1, y = 2, rotation = "east"},
|
||||
{type = "railgun_s", x = 2, y = 2, rotation = "east"},
|
||||
{type = "railgun_s", x = 3, y = 2, rotation = "east"},
|
||||
{type = "railgun_s", x = 1, y = 3, rotation = "east"},
|
||||
{type = "railgun_s", x = 2, y = 3, rotation = "east"},
|
||||
]
|
||||
|
||||
[[arena.team]]
|
||||
name = "Default"
|
||||
[[arena.team.ship]]
|
||||
schematic = "cruiser"
|
||||
count = 6
|
||||
modules = [
|
||||
{type = "railgun_m", x = 0, y = 1, rotation = "east"},
|
||||
{type = "railgun_m", x = 2, y = 1, rotation = "east"},
|
||||
{type = "armor_plates", x = 1, y = 0, rotation = "east"},
|
||||
{type = "maneuvering_thrusters", x = 1, y = 3, rotation = "east"},
|
||||
]
|
||||
|
||||
[[arena]]
|
||||
name = "Repair escort vs raw numbers (444 vs 444)"
|
||||
height_tiles = 10
|
||||
|
||||
@@ -17,6 +17,11 @@ player_buffer_width_tiles = 10
|
||||
contest_zone_width_tiles = 30
|
||||
enemy_buffer_width_tiles = 15
|
||||
|
||||
[scroll]
|
||||
pan_speed_slow_tiles_per_second = 8.0
|
||||
pan_speed_fast_tiles_per_second = 24.0
|
||||
pan_ramp_band_width_tiles = 16
|
||||
|
||||
[expansion]
|
||||
columns_per_expansion_tiles = 10
|
||||
cost_building_blocks_formula = "400 * 2^x"
|
||||
|
||||
@@ -21,12 +21,8 @@ REQ-* ids in [../requirements.md](../requirements.md).
|
||||
|
||||
First full balancing round complete (2026-07-06): targets → tree →
|
||||
numbers → threat-calculator parity → combat stats (arena-converged) →
|
||||
pacing. Playtesting in progress: playtest 1 (two full ~40-min wins,
|
||||
cruisers only) found the railgun_s-spam-cruiser meta, confirmed repair
|
||||
as overpowered, and exposed a 2.5–3× run-length gap; combat stats
|
||||
adjusted and re-checked in arena round 6 (see `history.md`). Next:
|
||||
playtest 2 with the new stats — pacing knobs (station scaling, threat
|
||||
rate, win pacing) wait for its result.
|
||||
pacing. Next step: full-game playtests against the run-shape targets in
|
||||
`targets.md`.
|
||||
|
||||
## Open action items
|
||||
|
||||
|
||||
@@ -94,16 +94,10 @@ geometry-validated against the hull grids)
|
||||
|
||||
## Combat stats
|
||||
|
||||
(arena-converged 2026-07, rounds 1–5; playtest-1 adjustments 2026-07-06 —
|
||||
see `history.md`)
|
||||
(arena-converged, 2026-07; see `history.md` rounds 1–5)
|
||||
|
||||
**Weapons:** railgun_s 2 dmg × 2.0 Hz (4.0 DPS), range 50 m;
|
||||
railgun_m 14 × 1.5 (21), range 80; railgun_l 52 × 0.8 (41.6), range 130.
|
||||
DPS per threat: s 0.62, m 0.48, l 0.41 — the concentration tax stands;
|
||||
reach is the bigger guns' compensation (ranges raised after playtest 1,
|
||||
which alone priced out the small-gun-spam meta). railgun_l deliberately
|
||||
outranges stations (120 m) to buy the siege role. railgun_m damage is
|
||||
breakpoint-sensitive: 15+ drops a 60 HP drone from 5 hits to 4.
|
||||
railgun_m 14 × 1.5 (21), range 70; railgun_l 52 × 0.8 (41.6), range 100.
|
||||
|
||||
**Hull HP** (15/threat prior + empirical trims): drone 60, frigate 300,
|
||||
destroyer 550, cruiser 1500, battlecruiser 2400, battleship 6300,
|
||||
@@ -115,9 +109,8 @@ destroyer 30|35|18|6|3, cruiser 24|25|12|4|2, battlecruiser 20|20|10|3|1.5,
|
||||
battleship 15|14|7|2|1, dreadnought/carrier 10|8|4|1|0.5.
|
||||
Sensors: 150/200/220/250/260/280/300/350 m.
|
||||
|
||||
**Other modules:** armor_plates +1200 HP; repair_tool 4 HP × 1 Hz,
|
||||
range 80 (halved after playtest 1 — free between-wave top-offs were never
|
||||
priced by the arena escort test); salvager range 60, cargo 20, 0.5 collections/s; afterburner
|
||||
**Other modules:** armor_plates +1200 HP; repair_tool 9 HP × 1 Hz,
|
||||
range 80; salvager range 60, cargo 20, 0.5 collections/s; afterburner
|
||||
×1.6 speed +60 accel; maneuvering_thrusters ×1.2 speed +10 maneuvering;
|
||||
sensor_booster +50 m; weapon_upgrade ×1.2 damage; weapon_primer ×1.2
|
||||
rate; weapon_stabilizer ×1.3 range ×0.8 rate.
|
||||
|
||||
@@ -94,68 +94,3 @@ range 200).
|
||||
— ~1 expansion per cycle mid-game, 2–3 cycles apart late.
|
||||
- **First full balancing round complete.** Next: full-game playtests
|
||||
against the run-shape targets.
|
||||
|
||||
## 2026-07-06 — playtest 1 (two full playthroughs)
|
||||
|
||||
Two complete runs, WON in ~40 min each with cruiser fleets only — never
|
||||
needing capitals. (Initially misread as "two pushes in 40 min, pacing on
|
||||
target"; corrected in round 6.) That is roughly cycle 8 against the
|
||||
win-cycle target of 20–24: a 2.5–3× pacing gap. Pacing knobs deliberately
|
||||
untouched this round — the runs rode 9 HP/s repair and stations nothing
|
||||
outranged, both nerfed below; playtest 2 measures the remaining gap.
|
||||
|
||||
- **Meta finding: cruisers filled with 12× railgun_s dominate.** Predicted
|
||||
by the numbers in hindsight: the concentration tax makes railgun_s the
|
||||
best DPS/threat (0.62 vs m 0.48, l 0.41), range is the big guns' only
|
||||
mechanical edge (armor is added HP, not damage reduction — no anti-swarm
|
||||
mechanic), repair sustain covers the closing distance, and stations
|
||||
outranged every ship gun (120 vs railgun_l's 100), so even capitals had
|
||||
to tank-and-brawl. The cruiser compounds it: first hull with a large
|
||||
1×1 canvas (12 cells) and a nearly quartz-free chain.
|
||||
- **Repair tool confirmed overpowered** (second signal after the
|
||||
persistent +24% arena escort margin): the arena only prices in-fight
|
||||
sustain; real runs add free full top-offs in every 15–45 s wave gap
|
||||
across the whole swarm. The 0.7 HP/s-per-threat prior is wrong for
|
||||
wave defence.
|
||||
- **Changes:** repair_tool 9→4 HP/s; railgun_l range 100→130 (now
|
||||
outranges stations — buys the siege role the capital ladder promises);
|
||||
railgun_m 14→16 dmg and range 70→80 (tax softened: m sits at 0.55
|
||||
DPS/threat, between s and l). Module threats unchanged (costs
|
||||
untouched), so no ladder recalculation needed.
|
||||
- New tracked arena added: railgun_s-spam cruisers (8× 178) vs default
|
||||
cruisers (6× 233.5) — the spam side should win a brawl somewhat, but a
|
||||
blowout means the small-gun premium needs retuning.
|
||||
- **Open:** re-run the arena suite to check the range/damage changes
|
||||
against the round 1–5 results; next playtest should verify big guns now
|
||||
feel worth climbing to and repair is merely good.
|
||||
|
||||
## 2026-07-06 — arena round 6 (checking the playtest-1 adjustments)
|
||||
|
||||
Mirrors healthy (5–8% margins, durations 24/66/91 s). Results:
|
||||
|
||||
- **Spam-cruiser arena: default cruisers +9% — the meta is priced out**,
|
||||
and the range buff alone did the work.
|
||||
- **Regression: drone swarm vs cruisers +47% for cruisers** (was +14%
|
||||
swarm in round 3). Besides the wider range gap, the damage buff crossed
|
||||
a breakpoint: 14 dmg kills a 60 HP drone in 5 hits, 16 in 4 — a hidden
|
||||
~25% effective-DPS gain vs drones. Change: **railgun_m damage 16→14**
|
||||
(range stays 80); the tax stands, reach is the compensation.
|
||||
- Battleship +30% and dreadnought +29% vs pure railgun_s fleets:
|
||||
**accepted as reach-doctrine texture** (BS was already accepted at
|
||||
+23%) — the l gun's 130 m standoff is exactly what the range buff
|
||||
bought; the counter is your own reach or 2:1 numbers, not equal-threat
|
||||
small guns. Watch, don't tune.
|
||||
- Repair escort flipped to raw +16%: **kept at 4 HP/s deliberately** —
|
||||
the arena cannot price the free between-wave top-offs, so slightly
|
||||
below par in-fight is the correct price for a module whose run-value
|
||||
includes them. Playtest 2 decides; 6 is the fallback if repair feels
|
||||
dead.
|
||||
- Station assault: the 3× swarm cracked the fortified position keeping
|
||||
45% EHP. No knob this round touched it; together with playtest 1's
|
||||
trivially easy pushes it flags **station strength as the first pacing
|
||||
lever** for the next pass.
|
||||
|
||||
**Pacing deferred:** playtest 1's 40-min wins predate the repair nerf
|
||||
and the l-gun siege range. If playtest 2 still wins by ~cycle 10, the
|
||||
levers are enemy station scaling (`3000 + 1500*x` likely too shallow),
|
||||
the threat rate, and possibly `artifact_win_count`.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Config files use the TOML format. The following config files drive game parameters:
|
||||
|
||||
- **world.toml** — world dimensions, region widths, expansion amounts, building refund percentage, wave timing, boss wave timing, belt speed, starting building blocks, departure interval, ship orbit factor, rally orbit radius, scrap-per-threat conversion, combat target-selection parameters (target score formula, overclaim penalty formula, target hysteresis), artifact chance formula, and artifact win count.
|
||||
- **world.toml** — world dimensions, region widths, expansion amounts, building refund percentage, wave timing, boss wave timing, belt speed, starting building blocks, departure interval, ship orbit factor, rally orbit radius, scrap-per-threat conversion, combat target-selection parameters (target score formula, overclaim penalty formula, target hysteresis), artifact chance formula, artifact win count, and view pan speeds (slow and fast horizontal pan speed and pan ramp band width).
|
||||
- **buildings.toml** — building block cost and construction time per building type.
|
||||
- **recipes.toml** — crafting recipes: inputs, outputs, quantities, durations, and reprocessing plant probabilities. Assembler recipe entries may optionally define `unlock_at_station_level` (integer): -1 means the recipe is explicitly unlocked at game start; a value ≥ 0 means the recipe starts locked and a schematic for it can be awarded via defence station destruction (see REQ-LOCK-EXPLICIT, REQ-DEF-SCHEMATIC-DROP). An assembler recipe schematic entry may also define an optional `unlock_requires` list of prerequisite schematic ids (REQ-LOCK-PREREQ).
|
||||
- **ships.toml** — per schematic: a human-readable display name (used in the UI), hull stats (HP, max linear speed, sensor range, main acceleration, maneuvering acceleration, angular acceleration, max rotation speed) as plain values, required build materials, the station level at which the schematic becomes available for unlock (`unlock_at_station_level`; -1 means the player starts with the schematic already unlocked), an optional `unlock_requires` prerequisite list (REQ-LOCK-PREREQ), a layout grid defining the ship's module slots, and a `default_modules` list used for enemy wave ships (see REQ-WAV-DEFAULT-MODULES).
|
||||
@@ -109,6 +109,8 @@ Modules in `modules.toml` define a `surface_mask` — a list of strings that des
|
||||
- REQ-BLD-BELT-DRAG: For belts, the player can click and drag across multiple tiles to place a construction site on each tile in one gesture.
|
||||
- REQ-BLD-TUNNEL-AUTO-SWITCH: After the player successfully places a Tunnel Entry construction site, builder mode automatically switches to Tunnel Exit (and vice versa), preserving the current ghost rotation. This makes it easy to immediately place the paired end without manually selecting the complementary type.
|
||||
- REQ-BLD-DEMOLISH: The player can demolish a placed factory building. Demolition returns `world.toml [world].refund_percentage` percent of the original building block cost (default 75%) to the global stock. Exception: if the building is still in the construction queue (not yet fully built, including the one currently being constructed), it is removed from the queue and the **full** building block cost is refunded. The HQ and player defence stations cannot be demolished.
|
||||
- REQ-BLD-DEMOLISH-CLICK: While in demolish mode (REQ-UI-HOTKEYS, REQ-UI-DEMOLISH-BUTTON), left-clicking a placed factory building or construction site in the game world demolishes it, following the refund rules of REQ-BLD-DEMOLISH — the partial refund for built buildings and the full refund for still-queued construction sites. Clicking a building that cannot be demolished (the HQ or a player defence station, per REQ-BLD-DEMOLISH), or clicking empty world space, has no effect. Demolish mode stays active after a demolition so the player can demolish further buildings without re-entering the mode; it is exited via the Q toggle (REQ-UI-HOTKEYS) or the Demolish button (REQ-UI-DEMOLISH-BUTTON).
|
||||
- REQ-BLD-DEMOLISH-BOX: While in demolish mode (REQ-UI-HOTKEYS, REQ-UI-DEMOLISH-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, every placed factory building and construction site covered by the box is demolished, each following the refund rules of REQ-BLD-DEMOLISH — the partial refund for built buildings and the full refund for still-queued construction sites. Buildings that cannot be demolished (the HQ and player defence stations, per REQ-BLD-DEMOLISH) 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 Selected Building 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
|
||||
@@ -401,7 +403,13 @@ The screen is divided into two columns: a main column (75% width) containing the
|
||||
|
||||
### Game World
|
||||
|
||||
- REQ-UI-SCROLL: The player scrolls the view horizontally across the scrollable area by pressing A (scroll left) and D (scroll right).
|
||||
- REQ-UI-SCROLL: The player scrolls the view horizontally across the scrollable area by pressing A (scroll left) and D (scroll right). The pan speed is not constant; it varies with the view's position per REQ-UI-SCROLL-SPEED.
|
||||
- REQ-UI-SCROLL-SPEED: The horizontal pan speed varies with position so the player crosses the empty middle of the world quickly while retaining fine control near the asteroid and near the front line. Two pan speeds are read from `world.toml [scroll]`: `pan_speed_slow_tiles_per_second` (the base speed, used while the view is over the asteroid and player buffer zone) and `pan_speed_fast_tiles_per_second` (the faster speed, used while the view is over the contest zone). Both are expressed in tiles per second and apply equally to the A and D scroll directions. The current pan speed is a function of the view's horizontal center X (REQ-GW-REGIONS defines the regions):
|
||||
- **Flat regions:** while the view center is left of the contest zone (over the asteroid or player buffer zone) and outside any ramp band, the pan speed is the slow speed; while the view center is inside the contest zone and outside any ramp band, the pan speed is the fast speed.
|
||||
- **Ramp bands:** a transition ramp band of width `world.toml [scroll].pan_ramp_band_width_tiles` tiles straddles each contest-zone boundary (the player defence stations on the left, the enemy defence stations on the right), centered on the boundary with half the band width on each side. While the view center is within a ramp band, the pan speed is linearly interpolated between the slow speed at the band's outer (non-contest-zone) edge and the fast speed at the band's inner (contest-zone) edge, by the view center's fractional position across the band. This produces smooth speed changes when entering and exiting the fast contest-zone range rather than an abrupt jump.
|
||||
- **Narrow contest zone:** should the two ramp bands overlap (a contest zone narrower than the band width), each ramp is clamped at the contest-zone center so the bands do not cross; the fast plateau then reduces to a single point at the center and the peak speed there may be below the fast speed.
|
||||
|
||||
Because the contest-zone boundaries shift as the scrollable area grows with each push (REQ-GW-PUSH-EXPAND, REQ-GW-SCROLL-LIMIT), the ramp bands are recomputed from the current contest-zone boundaries. This is a presentation-only concern and does not affect the simulation, consistent with REQ-UI-NO-ZOOM.
|
||||
- REQ-UI-CONSTRUCTION-PROGRESS: Construction sites display the building's glyph centered on the footprint (same as an operational building). Below the glyph — or centered on the footprint if the building has no glyph — a construction progress percentage is shown (integer, e.g. `42%`), increasing from 0% to 100% as construction completes.
|
||||
- REQ-UI-PORT-GLYPH: Every output port of every building is indicated by a directional glyph drawn on the port's tile. The glyph is a `>` rotated to face the port's exit direction (`>` for East, `^` for North, `<` for West, `v` for South). It is drawn at the midpoint between the tile center and the tile edge that the port exits through (i.e. halfway from center toward the exit edge). The indicator is rendered for all building states: operational buildings, construction sites, and the builder-mode ghost. Buildings with multiple output ports (e.g. splitters) show one indicator per port.
|
||||
- REQ-UI-HP-BARS: All entities with HP — the HQ, player and enemy defence stations, and player and enemy ships — render an HP bar below them. The bar is always visible regardless of current HP. The bar's filled portion represents the fraction of current HP to maximum HP.
|
||||
|
||||
@@ -305,6 +305,10 @@ WorldConfig ConfigLoader::loadWorld(const std::string& path)
|
||||
cfg.artifacts.artifactChanceFormula = requireFormula(tbl["artifacts"]["artifact_chance_formula"], file, "artifacts.artifact_chance_formula");
|
||||
cfg.artifacts.artifactWinCount = static_cast<int>(requireInt(tbl["artifacts"]["artifact_win_count"], file, "artifacts.artifact_win_count"));
|
||||
|
||||
cfg.scroll.panSpeedSlow_tps = requireDouble(tbl["scroll"]["pan_speed_slow_tiles_per_second"], file, "scroll.pan_speed_slow_tiles_per_second");
|
||||
cfg.scroll.panSpeedFast_tps = requireDouble(tbl["scroll"]["pan_speed_fast_tiles_per_second"], file, "scroll.pan_speed_fast_tiles_per_second");
|
||||
cfg.scroll.panRampBandWidth_tiles = static_cast<int>(requireInt(tbl["scroll"]["pan_ramp_band_width_tiles"], file, "scroll.pan_ramp_band_width_tiles"));
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,14 @@ struct WorldArtifacts
|
||||
int artifactWinCount;
|
||||
};
|
||||
|
||||
// View pan speed (REQ-UI-SCROLL-SPEED). Presentation-only; the simulation ignores these.
|
||||
struct WorldScroll
|
||||
{
|
||||
double panSpeedSlow_tps; // tiles/s, used outside the contest zone
|
||||
double panSpeedFast_tps; // tiles/s, used inside the contest zone
|
||||
int panRampBandWidth_tiles; // full width of the ramp band straddling each contest-zone boundary
|
||||
};
|
||||
|
||||
struct WorldConfig
|
||||
{
|
||||
int heightTiles; // REQ-GW-HEIGHT
|
||||
@@ -73,4 +81,5 @@ struct WorldConfig
|
||||
WorldWaves waves;
|
||||
WorldTargeting targeting;
|
||||
WorldArtifacts artifacts;
|
||||
WorldScroll scroll;
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@ SET(HDRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BeamFiredEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DebugDrawToggledEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CommandRequestedEvent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/PlayerCommandsAppliedEvent.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
|
||||
13
src/lib/eventsystem/event/PlayerCommandsAppliedEvent.h
Normal file
13
src/lib/eventsystem/event/PlayerCommandsAppliedEvent.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
// Emitted by GameWorldView once per frame after queued player commands have been
|
||||
// drained and applied to the simulation. It lets presentation widgets refresh
|
||||
// even while the game is paused (no tick advances, so no TickAdvancedEvent), for
|
||||
// example so a shipyard's layout preview appears immediately after its schematic
|
||||
// is chosen. It is a UI notification only and never feeds back into the command
|
||||
// queue, so it has no effect on replay recording or determinism.
|
||||
class PlayerCommandsAppliedEvent : public Event
|
||||
{
|
||||
};
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "FactionComponent.h"
|
||||
#include "GameOverEvent.h"
|
||||
#include "HealthComponent.h"
|
||||
#include "HqProxyComponent.h"
|
||||
#include "PositionComponent.h"
|
||||
#include "RepairBehavior.h"
|
||||
#include "SalvageScrapBehavior.h"
|
||||
@@ -62,6 +63,7 @@
|
||||
#include "ExpansionCostChangedEvent.h"
|
||||
#include "GameSpeedChangedEvent.h"
|
||||
#include "SchematicChoicesAvailableEvent.h"
|
||||
#include "PlayerCommandsAppliedEvent.h"
|
||||
#include "TickAdvancedEvent.h"
|
||||
|
||||
namespace
|
||||
@@ -212,6 +214,7 @@ void GameWorldView::onFrame()
|
||||
// Drain queued player commands once per frame, before the tick batch. This
|
||||
// runs even at 0x so a paused player sees placed construction sites
|
||||
// immediately, while staying deterministic (see docs/replay_design.md).
|
||||
const bool commandsApplied = m_commandManager.hasPending();
|
||||
m_commandManager.drain();
|
||||
|
||||
// A drained Reset reinitialized the simulation; reset the view to match.
|
||||
@@ -221,6 +224,17 @@ void GameWorldView::onFrame()
|
||||
resetForNewGame();
|
||||
}
|
||||
|
||||
// Notify presentation widgets that queued commands were applied, so a
|
||||
// paused player still sees the effect (e.g. a shipyard's layout preview
|
||||
// after picking a schematic) even though no tick advances. UI-only: this
|
||||
// does not touch the command queue or simulation, so replay recording
|
||||
// and determinism are unaffected.
|
||||
if (commandsApplied)
|
||||
{
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<PlayerCommandsAppliedEvent>());
|
||||
}
|
||||
|
||||
const int ticks = m_tickDriver.advance(
|
||||
static_cast<double>(elapsed), m_gameSpeedMultiplier);
|
||||
for (int i = 0; i < ticks; ++i)
|
||||
@@ -258,7 +272,9 @@ void GameWorldView::onFrame()
|
||||
|
||||
// Apply held scroll
|
||||
{
|
||||
const float delta = kScrollSpeedTilesPerSec
|
||||
// Pan speed depends on where the view is centered (REQ-UI-SCROLL-SPEED).
|
||||
const float viewCenterX = m_scrollXTiles + viewportWidthTiles() / 2.0f;
|
||||
const float delta = panSpeedTilesPerSecondAt(viewCenterX)
|
||||
* static_cast<float>(elapsed) / 1000.0f;
|
||||
const float scrollBefore = m_scrollXTiles;
|
||||
if (m_scrollLeft) { m_scrollXTiles -= delta; }
|
||||
@@ -474,6 +490,39 @@ float GameWorldView::enemyStationRightEdge() const
|
||||
return rightX;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// Linearly blend from valueAt0 (for x <= x0) to valueAt1 (for x >= x1), clamped
|
||||
// outside [x0, x1]. A zero- or negative-width band collapses to a hard step at x1.
|
||||
float lerpClamped(float valueAt0, float valueAt1, float x0, float x1, float x)
|
||||
{
|
||||
if (x1 <= x0) { return x < x1 ? valueAt0 : valueAt1; }
|
||||
const float t = std::max(0.0f, std::min(1.0f, (x - x0) / (x1 - x0)));
|
||||
return valueAt0 + (valueAt1 - valueAt0) * t;
|
||||
}
|
||||
}
|
||||
|
||||
float GameWorldView::panSpeedTilesPerSecondAt(float viewCenterXTiles) const
|
||||
{
|
||||
// Slow near the asteroid/player buffer, fast across the contest zone, with a
|
||||
// linear ramp straddling each contest-zone boundary (REQ-UI-SCROLL-SPEED). The
|
||||
// contest zone spans from the player buffer's right edge to the enemy stations,
|
||||
// the latter tracked live so the ramp follows the front line as it is pushed.
|
||||
const float slow = static_cast<float>(m_config->world.scroll.panSpeedSlow_tps);
|
||||
const float fast = static_cast<float>(m_config->world.scroll.panSpeedFast_tps);
|
||||
const float half = static_cast<float>(m_config->world.scroll.panRampBandWidth_tiles) / 2.0f;
|
||||
const float leftEdge = static_cast<float>(m_config->world.regions.playerBufferWidth_tiles);
|
||||
const float rightEdge = enemyStationRightEdge();
|
||||
|
||||
// Rising ramp at the left boundary (slow -> fast) and falling ramp at the right
|
||||
// boundary (fast -> slow); their minimum yields flat-slow outside, flat-fast in
|
||||
// the middle, and — if the bands overlap in a narrow contest zone — a single peak
|
||||
// below the fast speed where the two ramps cross.
|
||||
const float leftRamp = lerpClamped(slow, fast, leftEdge - half, leftEdge + half, viewCenterXTiles);
|
||||
const float rightRamp = lerpClamped(fast, slow, rightEdge - half, rightEdge + half, viewCenterXTiles);
|
||||
return std::min(leftRamp, rightRamp);
|
||||
}
|
||||
|
||||
void GameWorldView::clampScroll()
|
||||
{
|
||||
const float leftBound = asteroidLeftEdge();
|
||||
@@ -557,6 +606,41 @@ BuildingId GameWorldView::siteAtTile(QPoint tile) const
|
||||
}
|
||||
|
||||
|
||||
std::vector<BuildingId> GameWorldView::buildingsInBox(QPoint cornerA, QPoint cornerB) const
|
||||
{
|
||||
const int x0 = std::min(cornerA.x(), cornerB.x());
|
||||
const int y0 = std::min(cornerA.y(), cornerB.y());
|
||||
const int x1 = std::max(cornerA.x(), cornerB.x());
|
||||
const int y1 = std::max(cornerA.y(), cornerB.y());
|
||||
|
||||
std::vector<BuildingId> ids;
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
{
|
||||
for (const QPoint& cell : b.bodyCells)
|
||||
{
|
||||
if (cell.x() >= x0 && cell.x() <= x1
|
||||
&& cell.y() >= y0 && cell.y() <= y1)
|
||||
{
|
||||
ids.push_back(b.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
{
|
||||
for (const QPoint& cell : s.bodyCells)
|
||||
{
|
||||
if (cell.x() >= x0 && cell.x() <= x1
|
||||
&& cell.y() >= y0 && cell.y() <= y1)
|
||||
{
|
||||
ids.push_back(s.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
std::optional<QVector2D> GameWorldView::entityPosition(entt::entity entity) const
|
||||
{
|
||||
if (!m_sim->admin().isValid(entity) || !m_sim->admin().hasAll<PositionComponent>(entity))
|
||||
@@ -824,16 +908,19 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
port.direction, bv.outline);
|
||||
}
|
||||
|
||||
bool selected = false;
|
||||
for (BuildingId selId : m_selectedBuildingIds)
|
||||
// HP bar below the HQ footprint; the HQ's HP lives on its proxy entity.
|
||||
if (b.type == BuildingType::Hq)
|
||||
{
|
||||
if (selId == b.id) { selected = true; break; }
|
||||
}
|
||||
if (selected)
|
||||
{
|
||||
painter.setPen(QPen(m_visuals->overlays.selectedOutline, 2));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.drawRect(bboxRect.adjusted(-1, -1, 1, 1));
|
||||
m_sim->admin().forEach<HqProxyComponent, FactionComponent, HealthComponent>(
|
||||
[&](entt::entity /*e*/, const HqProxyComponent& /*hq*/,
|
||||
const FactionComponent& f, const HealthComponent& h)
|
||||
{
|
||||
if (h.maxHp > 0.0f)
|
||||
{
|
||||
drawHpBar(painter, bboxRect.left(), bboxRect.bottom() + 1.0,
|
||||
bboxRect.width(), h.hp / h.maxHp, f.isEnemy);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,20 +945,6 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.drawRect(bboxRect);
|
||||
|
||||
bool selected = false;
|
||||
for (BuildingId selId : m_selectedBuildingIds)
|
||||
{
|
||||
if (selId == s.id) { selected = true; break; }
|
||||
}
|
||||
if (selected)
|
||||
{
|
||||
painter.setOpacity(1.0);
|
||||
painter.setPen(QPen(m_visuals->overlays.selectedOutline, 2));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.drawRect(bboxRect.adjusted(-1, -1, 1, 1));
|
||||
painter.setOpacity(0.5);
|
||||
}
|
||||
|
||||
const BuildingDef* siteDef = findBuildingDef(s.type);
|
||||
if (siteDef)
|
||||
{
|
||||
@@ -916,6 +989,42 @@ void GameWorldView::drawBuildings(QPainter& painter)
|
||||
}
|
||||
}
|
||||
painter.setOpacity(1.0);
|
||||
|
||||
// Selection highlights are drawn last, after every building and construction
|
||||
// site fill, so a selected building surrounded by neighbours keeps its outline:
|
||||
// the highlight sits 1px outside the footprint (into adjacent tiles), and drawing
|
||||
// it inline would let later-drawn neighbours overpaint it with their body fill.
|
||||
drawSelectionHighlights(painter);
|
||||
}
|
||||
|
||||
void GameWorldView::drawSelectionHighlights(QPainter& painter)
|
||||
{
|
||||
painter.setPen(QPen(m_visuals->overlays.selectedOutline, 2));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
|
||||
for (BuildingId selId : m_selectedBuildingIds)
|
||||
{
|
||||
std::optional<QPoint> anchor;
|
||||
std::optional<QSize> footprint;
|
||||
|
||||
if (const Building* b = m_sim->buildings().findBuilding(selId))
|
||||
{
|
||||
anchor = b->anchor;
|
||||
footprint = b->footprint;
|
||||
}
|
||||
else if (const ConstructionSite* s = m_sim->buildings().findSite(selId))
|
||||
{
|
||||
anchor = s->anchor;
|
||||
footprint = s->footprint;
|
||||
}
|
||||
if (!anchor.has_value() || !footprint.has_value()) { continue; }
|
||||
|
||||
const QPointF tl = tileToWidget(*anchor);
|
||||
const QRectF bboxRect(tl.x(), tl.y(),
|
||||
footprint->width() * static_cast<qreal>(tilePx()),
|
||||
footprint->height() * static_cast<qreal>(tilePx()));
|
||||
painter.drawRect(bboxRect.adjusted(-1, -1, 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
void GameWorldView::drawBeltItems(QPainter& painter)
|
||||
@@ -993,14 +1102,8 @@ void GameWorldView::drawStations(QPainter& painter)
|
||||
// HP bar below footprint.
|
||||
if (h.maxHp > 0.0f)
|
||||
{
|
||||
const float fraction = std::max(0.0f, h.hp / h.maxHp);
|
||||
const qreal barH = static_cast<qreal>(tilePx()) * 0.12;
|
||||
const qreal barY = bboxRect.bottom() + 1.0;
|
||||
const qreal barW = bboxRect.width();
|
||||
painter.fillRect(QRectF(bboxRect.left(), barY, barW, barH),
|
||||
QColor(60, 60, 60));
|
||||
painter.fillRect(QRectF(bboxRect.left(), barY, barW * static_cast<qreal>(fraction), barH),
|
||||
f.isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
||||
drawHpBar(painter, bboxRect.left(), bboxRect.bottom() + 1.0,
|
||||
bboxRect.width(), h.hp / h.maxHp, f.isEnemy);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1046,18 +1149,24 @@ void GameWorldView::drawShips(QPainter& painter)
|
||||
|
||||
if (h.maxHp > 0.0f)
|
||||
{
|
||||
const float fraction = std::max(0.0f, h.hp / h.maxHp);
|
||||
const qreal barW = static_cast<qreal>(fwd) * 2.0;
|
||||
const qreal barH = static_cast<qreal>(tilePx()) * 0.12;
|
||||
const qreal barX = center.x() - static_cast<qreal>(fwd);
|
||||
const qreal barY = center.y() + static_cast<qreal>(fwd) + 1.0;
|
||||
painter.fillRect(QRectF(barX, barY, barW, barH), QColor(60, 60, 60));
|
||||
painter.fillRect(QRectF(barX, barY, barW * static_cast<qreal>(fraction), barH),
|
||||
fac.isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
||||
drawHpBar(painter, barX, barY, barW, h.hp / h.maxHp, fac.isEnemy);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GameWorldView::drawHpBar(QPainter& painter, qreal left, qreal top, qreal width,
|
||||
float fraction, bool isEnemy)
|
||||
{
|
||||
const qreal barH = static_cast<qreal>(tilePx()) * 0.12;
|
||||
const float clamped = std::max(0.0f, fraction);
|
||||
painter.fillRect(QRectF(left, top, width, barH), QColor(60, 60, 60));
|
||||
painter.fillRect(QRectF(left, top, width * static_cast<qreal>(clamped), barH),
|
||||
isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
||||
}
|
||||
|
||||
void GameWorldView::drawDebugSensorRanges(QPainter& painter)
|
||||
{
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
@@ -1223,8 +1332,28 @@ void GameWorldView::drawOverlays(QPainter& painter)
|
||||
}
|
||||
}
|
||||
|
||||
// Demolish hover tint
|
||||
if (m_demolishMode && m_demolishHoverBuildingId != kInvalidBuildingId)
|
||||
// Demolish tint: while dragging a demolish box, tint every covered
|
||||
// building/site (REQ-BLD-DEMOLISH-BOX); otherwise tint the hovered one.
|
||||
if (m_demolishMode && m_boxSelecting)
|
||||
{
|
||||
for (BuildingId id : buildingsInBox(m_boxStartTile, m_boxCurrentTile))
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
if (b && b->type == BuildingType::Hq) { continue; }
|
||||
const std::vector<QPoint>* cells = nullptr;
|
||||
const ConstructionSite* s = nullptr;
|
||||
if (b) { cells = &b->bodyCells; }
|
||||
else if ((s = m_sim->buildings().findSite(id))) { cells = &s->bodyCells; }
|
||||
if (cells)
|
||||
{
|
||||
for (const QPoint& cell : *cells)
|
||||
{
|
||||
painter.fillRect(tileRect(cell), m_visuals->overlays.demolishTint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_demolishMode && m_demolishHoverBuildingId != kInvalidBuildingId)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(m_demolishHoverBuildingId);
|
||||
if (b)
|
||||
@@ -1518,24 +1647,11 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
||||
}
|
||||
else if (m_demolishMode)
|
||||
{
|
||||
BuildingId hovered = buildingAtTile(tile);
|
||||
if (hovered == kInvalidBuildingId)
|
||||
{
|
||||
hovered = siteAtTile(tile);
|
||||
}
|
||||
if (hovered != kInvalidBuildingId)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(hovered);
|
||||
const bool isProtected = b && b->type == BuildingType::Hq;
|
||||
if (!isProtected)
|
||||
{
|
||||
std::shared_ptr<DemolishCommand> command =
|
||||
std::make_shared<DemolishCommand>();
|
||||
command->id = hovered;
|
||||
enqueueCommand(command);
|
||||
m_demolishHoverBuildingId = kInvalidBuildingId;
|
||||
}
|
||||
}
|
||||
// Start a demolish box drag; a plain click resolves as a 1x1 box on
|
||||
// release (REQ-BLD-DEMOLISH-CLICK, REQ-BLD-DEMOLISH-BOX).
|
||||
m_boxSelecting = true;
|
||||
m_boxStartTile = tile;
|
||||
m_boxCurrentTile = tile;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1623,6 +1739,7 @@ void GameWorldView::mouseMoveEvent(QMouseEvent* event)
|
||||
else if (m_demolishMode)
|
||||
{
|
||||
m_demolishHoverBuildingId = buildingAtTile(tile);
|
||||
if (m_boxSelecting) { m_boxCurrentTile = tile; }
|
||||
}
|
||||
else if (m_boxSelecting)
|
||||
{
|
||||
@@ -1644,44 +1761,33 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
m_boxSelecting = false;
|
||||
|
||||
const int x0 = std::min(m_boxStartTile.x(), m_boxCurrentTile.x());
|
||||
const int y0 = std::min(m_boxStartTile.y(), m_boxCurrentTile.y());
|
||||
const int x1 = std::max(m_boxStartTile.x(), m_boxCurrentTile.x());
|
||||
const int y1 = std::max(m_boxStartTile.y(), m_boxCurrentTile.y());
|
||||
const std::vector<BuildingId> boxIds =
|
||||
buildingsInBox(m_boxStartTile, m_boxCurrentTile);
|
||||
|
||||
std::vector<BuildingId> boxSel;
|
||||
for (const Building& b : m_sim->buildings().allBuildings())
|
||||
if (m_demolishMode)
|
||||
{
|
||||
for (const QPoint& cell : b.bodyCells)
|
||||
// Demolish every covered building/site; the HQ is protected
|
||||
// (REQ-BLD-DEMOLISH, REQ-BLD-DEMOLISH-BOX).
|
||||
for (BuildingId id : boxIds)
|
||||
{
|
||||
if (cell.x() >= x0 && cell.x() <= x1
|
||||
&& cell.y() >= y0 && cell.y() <= y1)
|
||||
{
|
||||
boxSel.push_back(b.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const ConstructionSite& s : m_sim->buildings().allSites())
|
||||
{
|
||||
for (const QPoint& cell : s.bodyCells)
|
||||
{
|
||||
if (cell.x() >= x0 && cell.x() <= x1
|
||||
&& cell.y() >= y0 && cell.y() <= y1)
|
||||
{
|
||||
boxSel.push_back(s.id);
|
||||
break;
|
||||
}
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
if (b && b->type == BuildingType::Hq) { continue; }
|
||||
std::shared_ptr<DemolishCommand> command =
|
||||
std::make_shared<DemolishCommand>();
|
||||
command->id = id;
|
||||
enqueueCommand(command);
|
||||
}
|
||||
m_demolishHoverBuildingId = kInvalidBuildingId;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event->modifiers() & Qt::ControlModifier))
|
||||
{
|
||||
m_selectedBuildingIds = boxSel;
|
||||
m_selectedBuildingIds = boxIds;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (BuildingId id : boxSel)
|
||||
for (BuildingId id : boxIds)
|
||||
{
|
||||
bool found = false;
|
||||
for (BuildingId sel : m_selectedBuildingIds)
|
||||
|
||||
@@ -115,10 +115,13 @@ private:
|
||||
|
||||
void drawTiles(QPainter& painter);
|
||||
void drawBuildings(QPainter& painter);
|
||||
void drawSelectionHighlights(QPainter& painter);
|
||||
void drawStations(QPainter& painter);
|
||||
void drawBeltItems(QPainter& painter);
|
||||
void drawScrap(QPainter& painter);
|
||||
void drawShips(QPainter& painter);
|
||||
void drawHpBar(QPainter& painter, qreal left, qreal top, qreal width,
|
||||
float fraction, bool isEnemy);
|
||||
void drawDebugSensorRanges(QPainter& painter);
|
||||
void drawDebugTargetLines(QPainter& painter);
|
||||
void drawDebugOverlay(QPainter& painter);
|
||||
@@ -137,12 +140,17 @@ private:
|
||||
|
||||
float asteroidLeftEdge() const;
|
||||
float enemyStationRightEdge() const;
|
||||
// Horizontal pan speed at a given view-center X, in tiles/s (REQ-UI-SCROLL-SPEED).
|
||||
float panSpeedTilesPerSecondAt(float viewCenterXTiles) const;
|
||||
void clampScroll();
|
||||
|
||||
bool isValidPlacement(BuildingType type, QPoint anchor, Rotation rot) const;
|
||||
const BuildingDef* findBuildingDef(BuildingType type) const;
|
||||
BuildingId buildingAtTile(QPoint tile) const;
|
||||
BuildingId siteAtTile(QPoint tile) const;
|
||||
// Ids of all buildings and construction sites whose footprint intersects
|
||||
// the tile box spanned by the two (unordered) corner tiles.
|
||||
std::vector<BuildingId> buildingsInBox(QPoint cornerA, QPoint cornerB) const;
|
||||
QVector2D widgetToWorld(QPoint widgetPt) const;
|
||||
|
||||
void drawPortGlyph(QPainter& painter, QPoint bodyTile,
|
||||
@@ -173,7 +181,6 @@ private:
|
||||
// Beam lifetime in game ticks so beams freeze with the simulation when
|
||||
// paused or slowed, instead of fading on wall-clock time (REQ-SHP-FIRING-BEAM).
|
||||
static constexpr Tick kBeamLifetimeTicks = secondsToTicks(0.3);
|
||||
static constexpr float kScrollSpeedTilesPerSec = 10.0f;
|
||||
|
||||
Simulation* m_sim;
|
||||
const GameConfig* m_config;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "ItemType.h"
|
||||
#include "LayoutDialogRequestedEvent.h"
|
||||
#include "ModulesConfig.h"
|
||||
#include "PlayerCommandsAppliedEvent.h"
|
||||
#include "RecipeSelectionDialog.h"
|
||||
#include "RecipeSelectionRequestedEvent.h"
|
||||
#include "Rotation.h"
|
||||
@@ -294,38 +295,12 @@ void SelectedBuildingPanel::buildSingle(BuildingId id)
|
||||
}
|
||||
m_recipeSelectButton->show();
|
||||
|
||||
if (type == BuildingType::Shipyard && !recipeId.empty())
|
||||
{
|
||||
const ShipDef* sDef = findShipDef(recipeId);
|
||||
if (sDef && !sDef->layout.empty())
|
||||
{
|
||||
ShipLayoutConfig layout;
|
||||
if (shipLayout.has_value())
|
||||
{
|
||||
layout = *shipLayout;
|
||||
}
|
||||
m_layoutPreview->setShipAndLayout(
|
||||
sDef->layout, layout, &m_config->modules.modules);
|
||||
m_layoutPreview->show();
|
||||
m_configureLayoutBtn->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_layoutPreview->hide();
|
||||
m_configureLayoutBtn->hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_layoutPreview->hide();
|
||||
m_configureLayoutBtn->hide();
|
||||
}
|
||||
updateShipyardLayoutWidgets(type, recipeId, shipLayout);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_recipeSelectButton->hide();
|
||||
m_layoutPreview->hide();
|
||||
m_configureLayoutBtn->hide();
|
||||
updateShipyardLayoutWidgets(type, recipeId, shipLayout);
|
||||
}
|
||||
|
||||
// Belt "Clear" removes items from a live belt tile; a construction site has
|
||||
@@ -363,32 +338,7 @@ void SelectedBuildingPanel::buildSingle(BuildingId id)
|
||||
|
||||
if (m_singleIsSite)
|
||||
{
|
||||
QString progress;
|
||||
if (s->completesAt == 0)
|
||||
{
|
||||
progress = tr("Queued");
|
||||
}
|
||||
else
|
||||
{
|
||||
const BuildingDef* def = nullptr;
|
||||
for (const BuildingDef& d : m_config->buildings.buildings)
|
||||
{
|
||||
if (d.type == s->type) { def = &d; break; }
|
||||
}
|
||||
if (def && def->constructionTimeSeconds > 0)
|
||||
{
|
||||
const Tick duration = secondsToTicks(def->constructionTimeSeconds);
|
||||
const Tick elapsed = m_sim->currentTick() - (s->completesAt - duration);
|
||||
const int pct = static_cast<int>(
|
||||
std::max(Tick(0), std::min(duration, elapsed)) * 100 / duration);
|
||||
progress = tr("%1% complete").arg(pct);
|
||||
}
|
||||
else
|
||||
{
|
||||
progress = tr("Building...");
|
||||
}
|
||||
}
|
||||
m_buffersLabel->setText(progress);
|
||||
refreshSiteProgress(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -396,6 +346,36 @@ void SelectedBuildingPanel::buildSingle(BuildingId id)
|
||||
}
|
||||
}
|
||||
|
||||
void SelectedBuildingPanel::refreshSiteProgress(const ConstructionSite* s)
|
||||
{
|
||||
QString progress;
|
||||
if (s->completesAt == 0)
|
||||
{
|
||||
progress = tr("Queued");
|
||||
}
|
||||
else
|
||||
{
|
||||
const BuildingDef* def = nullptr;
|
||||
for (const BuildingDef& d : m_config->buildings.buildings)
|
||||
{
|
||||
if (d.type == s->type) { def = &d; break; }
|
||||
}
|
||||
if (def && def->constructionTimeSeconds > 0)
|
||||
{
|
||||
const Tick duration = secondsToTicks(def->constructionTimeSeconds);
|
||||
const Tick elapsed = m_sim->currentTick() - (s->completesAt - duration);
|
||||
const int pct = static_cast<int>(
|
||||
std::max(Tick(0), std::min(duration, elapsed)) * 100 / duration);
|
||||
progress = tr("%1% complete").arg(pct);
|
||||
}
|
||||
else
|
||||
{
|
||||
progress = tr("Building...");
|
||||
}
|
||||
}
|
||||
m_buffersLabel->setText(progress);
|
||||
}
|
||||
|
||||
void SelectedBuildingPanel::refreshBuffers(const Building* b)
|
||||
{
|
||||
const RecipeDef* recipe = findRecipe(b);
|
||||
@@ -530,15 +510,38 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b)
|
||||
|
||||
m_buffersLabel->setText(bufText);
|
||||
|
||||
if (b->type == BuildingType::Shipyard && shipDef && !shipDef->layout.empty())
|
||||
// The recipe/schematic is applied via a queued command that only drains on a
|
||||
// later frame, so the per-tick refresh must own the shipyard preview and the
|
||||
// Configure Layout button's visibility; otherwise they stay hidden until the
|
||||
// building is re-selected (which re-runs buildSingle).
|
||||
updateShipyardLayoutWidgets(b->type, b->recipeId, b->shipLayout);
|
||||
}
|
||||
|
||||
void SelectedBuildingPanel::updateShipyardLayoutWidgets(
|
||||
BuildingType type,
|
||||
const std::string& recipeId,
|
||||
const std::optional<ShipLayoutConfig>& shipLayout)
|
||||
{
|
||||
const ShipDef* shipDef = (type == BuildingType::Shipyard)
|
||||
? findShipDef(recipeId)
|
||||
: nullptr;
|
||||
|
||||
if (shipDef && !shipDef->layout.empty())
|
||||
{
|
||||
ShipLayoutConfig layout;
|
||||
if (b->shipLayout.has_value())
|
||||
if (shipLayout.has_value())
|
||||
{
|
||||
layout = *b->shipLayout;
|
||||
layout = *shipLayout;
|
||||
}
|
||||
m_layoutPreview->setShipAndLayout(
|
||||
shipDef->layout, layout, &m_config->modules.modules);
|
||||
m_layoutPreview->show();
|
||||
m_configureLayoutBtn->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_layoutPreview->hide();
|
||||
m_configureLayoutBtn->hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,6 +566,21 @@ const ShipDef* SelectedBuildingPanel::findShipDef(const std::string& id) const
|
||||
}
|
||||
|
||||
void SelectedBuildingPanel::handleEvent(std::shared_ptr<const TickAdvancedEvent> /*event*/)
|
||||
{
|
||||
refreshSelectionDisplay(RefreshReason::PeriodicTick);
|
||||
}
|
||||
|
||||
void SelectedBuildingPanel::handleEvent(
|
||||
std::shared_ptr<const PlayerCommandsAppliedEvent> /*event*/)
|
||||
{
|
||||
// Player commands (e.g. choosing a shipyard schematic) are applied by a
|
||||
// queued drain, not synchronously. When the game is paused no tick advances,
|
||||
// so TickAdvancedEvent never fires; refresh here too, otherwise the panel
|
||||
// would not reflect the change until the next tick or a re-selection.
|
||||
refreshSelectionDisplay(RefreshReason::CommandApplied);
|
||||
}
|
||||
|
||||
void SelectedBuildingPanel::refreshSelectionDisplay(RefreshReason reason)
|
||||
{
|
||||
if (m_selectedEntity.has_value())
|
||||
{
|
||||
@@ -587,7 +605,18 @@ void SelectedBuildingPanel::handleEvent(std::shared_ptr<const TickAdvancedEvent>
|
||||
const ConstructionSite* s = m_sim->buildings().findSite(m_singleBuildingId);
|
||||
if (s)
|
||||
{
|
||||
rebuild();
|
||||
// A periodic tick only advances construction progress, so update just the
|
||||
// progress label. Rebuilding every tick would hide/re-show all widgets and
|
||||
// cancel any in-progress click on the recipe button. An applied command
|
||||
// may have changed the site's recipe/layout, so rebuild in that case.
|
||||
if (reason == RefreshReason::CommandApplied)
|
||||
{
|
||||
rebuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
refreshSiteProgress(s);
|
||||
}
|
||||
return;
|
||||
}
|
||||
buildEmpty();
|
||||
@@ -647,9 +676,11 @@ void SelectedBuildingPanel::onSelectRecipeClicked()
|
||||
return;
|
||||
}
|
||||
// The emit is synchronous: MainWindow pauses the game, runs the modal
|
||||
// selection dialog, applies the chosen recipe/schematic, and restores the
|
||||
// speed before this returns. rebuild() then refreshes the button caption,
|
||||
// tooltip, preview, and buffers for the new selection.
|
||||
// selection dialog, and restores the speed before this returns. The chosen
|
||||
// recipe/schematic is only *enqueued* as a command, though, and drains on a
|
||||
// later frame -- so this rebuild() still sees the old recipe. The per-tick
|
||||
// refreshBuffers() path picks up the new schematic (and shows the layout
|
||||
// preview + Configure Layout button) once the command has been applied.
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<RecipeSelectionRequestedEvent>(m_singleBuildingId));
|
||||
rebuild();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "EntitySelectedEvent.h"
|
||||
#include "EventHandler.h"
|
||||
#include "GameConfig.h"
|
||||
#include "PlayerCommandsAppliedEvent.h"
|
||||
#include "RecipesConfig.h"
|
||||
#include "SelectionChangedEvent.h"
|
||||
#include "ShipLayout.h"
|
||||
@@ -33,6 +34,7 @@ class QVBoxLayout;
|
||||
|
||||
class SelectedBuildingPanel : public QWidget,
|
||||
public CombinedEventHandler<TickAdvancedEvent,
|
||||
PlayerCommandsAppliedEvent,
|
||||
EntitySelectedEvent,
|
||||
SelectionChangedEvent,
|
||||
DebugDrawToggledEvent>
|
||||
@@ -46,6 +48,7 @@ public:
|
||||
|
||||
private:
|
||||
void handleEvent(std::shared_ptr<const TickAdvancedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const PlayerCommandsAppliedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const EntitySelectedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const SelectionChangedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const DebugDrawToggledEvent> event) override;
|
||||
@@ -56,7 +59,18 @@ private slots:
|
||||
void onSplitterFilterChanged();
|
||||
|
||||
private:
|
||||
// Why the selection display is being refreshed. A periodic tick only needs a
|
||||
// lightweight content update (e.g. a construction site's progress label),
|
||||
// whereas an applied player command may have changed the configuration and
|
||||
// needs a full structural rebuild.
|
||||
enum class RefreshReason
|
||||
{
|
||||
PeriodicTick,
|
||||
CommandApplied
|
||||
};
|
||||
|
||||
void onSelectionChanged(const std::vector<BuildingId>& ids);
|
||||
void refreshSelectionDisplay(RefreshReason reason);
|
||||
void rebuild();
|
||||
void hideAllWidgets();
|
||||
void clearContent();
|
||||
@@ -64,6 +78,10 @@ private:
|
||||
void buildSingle(BuildingId id);
|
||||
void buildMulti(const std::vector<BuildingId>& ids);
|
||||
void refreshBuffers(const Building* b);
|
||||
void refreshSiteProgress(const ConstructionSite* s);
|
||||
void updateShipyardLayoutWidgets(BuildingType type,
|
||||
const std::string& recipeId,
|
||||
const std::optional<ShipLayoutConfig>& shipLayout);
|
||||
void buildSplitterFilters(const std::optional<BeltSystem::SplitterInfo>& info);
|
||||
const RecipeDef* findRecipe(const Building* b) const;
|
||||
const ShipDef* findShipDef(const std::string& id) const;
|
||||
|
||||
Reference in New Issue
Block a user