when an extractor is built on a planet it should how up that something is built there #9

Closed
opened 2026-08-10 21:29:47 +00:00 by metaheavens · 2 comments
Owner
No description provided.
Author
Owner

Done. A planet with an extractor built on it now shows it, in both places you look at a planet.

The extractor lives on PlanetSurface.tscn, a scene you are not looking at from space, so an already-mined planet was indistinguishable from an untouched one - you had to land to find out. Marking it only on the world map would have been half an answer, since most of the time you are looking at planets in space.

  • In space (Planet.gd): an amber derrick planted on the planet's outline. It is anchored to the shape's own topmost vertex rather than a fixed radius, so it sits ON the rim whatever lumpy shape the seed drew, instead of floating off it or sinking inside it.
  • On the world map (WorldMapContent.gd): a small amber badge on the planet marker, in the same amber, so the two read as the same fact.

Both are keyed by planet NAME via the existing GameState.has_extractor_at(). Planet.gd resolves it once in _ready() rather than polling: building an extractor happens on the surface scene, and coming back to space rebuilds Main.tscn from scratch, so a Planet node never outlives a change to its own answer.

Test

tests/test_planet_extractor_marker.gd checks that a planet with no extractor shows neither derrick nor badge, that building one turns both on, that the marker does not leak onto a different planet, and that the derrick actually clears the outline.

Mutation-testing the assertions caught a bug in my own test, which is why it is worth doing. The "is the derrick buried inside the planet?" check originally took the furthest of all four derrick points from the centre. That passes a derrick pointing straight into the ground: the two base corners sit a half-width to either side of the rim vertex, so they are sqrt(|base|^2 + w^2) from the centre and clear the rim on their own. I confirmed the hole by flipping DERRICK_HEIGHT negative - the test passed happily. The check now measures the tip alone (extractor_derrick_tip()), and the same mutation fails it.

mutation result
feature absent entirely FAIL (nonexistent property)
derrick pointing inward (DERRICK_HEIGHT negated) FAIL (derrick buried inside the planet) - passed before the fix above
flag ignores planet name (any extractor lights every planet) FAIL (marker leaked onto a different planet)

Looked at it

tests/_planet_derrick_preview.tscn renders a mined planet next to an untouched one for real (Xvfb + Mesa softpipe, via tests/screenshot.sh). The derrick is clearly visible on the left planet and absent on the right; I sized it up once after seeing it at gameplay scale. The map badge was checked the same way via tests/_marker_preview.tscn.

Full suite: 40/40 passing.

Done. A planet with an extractor built on it now shows it, in **both** places you look at a planet. The extractor lives on `PlanetSurface.tscn`, a scene you are not looking at from space, so an already-mined planet was indistinguishable from an untouched one - you had to land to find out. Marking it only on the world map would have been half an answer, since most of the time you are looking at planets in space. - **In space** (`Planet.gd`): an amber derrick planted on the planet's outline. It is anchored to the shape's own topmost vertex rather than a fixed radius, so it sits ON the rim whatever lumpy shape the seed drew, instead of floating off it or sinking inside it. - **On the world map** (`WorldMapContent.gd`): a small amber badge on the planet marker, in the same amber, so the two read as the same fact. Both are keyed by planet NAME via the existing `GameState.has_extractor_at()`. `Planet.gd` resolves it once in `_ready()` rather than polling: building an extractor happens on the surface scene, and coming back to space rebuilds `Main.tscn` from scratch, so a Planet node never outlives a change to its own answer. ## Test `tests/test_planet_extractor_marker.gd` checks that a planet with no extractor shows neither derrick nor badge, that building one turns both on, that the marker does not leak onto a different planet, and that the derrick actually clears the outline. Mutation-testing the assertions caught a bug **in my own test**, which is why it is worth doing. The "is the derrick buried inside the planet?" check originally took the furthest of all four derrick points from the centre. That passes a derrick pointing straight into the ground: the two base corners sit a half-width to either side of the rim vertex, so they are `sqrt(|base|^2 + w^2)` from the centre and clear the rim on their own. I confirmed the hole by flipping `DERRICK_HEIGHT` negative - the test passed happily. The check now measures the tip alone (`extractor_derrick_tip()`), and the same mutation fails it. | mutation | result | |---|---| | feature absent entirely | FAIL (nonexistent property) | | derrick pointing inward (`DERRICK_HEIGHT` negated) | FAIL (derrick buried inside the planet) - *passed before the fix above* | | flag ignores planet name (any extractor lights every planet) | FAIL (marker leaked onto a different planet) | ## Looked at it `tests/_planet_derrick_preview.tscn` renders a mined planet next to an untouched one for real (Xvfb + Mesa softpipe, via `tests/screenshot.sh`). The derrick is clearly visible on the left planet and absent on the right; I sized it up once after seeing it at gameplay scale. The map badge was checked the same way via `tests/_marker_preview.tscn`. Full suite: **40/40 passing**.
Author
Owner

Reopening the outcome here: you were right that this had no visible effect in game, and the cause was a wrong assumption of mine rather than a build/caching issue.

Planet.gd resolved the marker once in _ready(), on the stated assumption that extractors are built on PlanetSurface.tscn and that returning to space rebuilds Main.tscn from scratch - so a Planet node could never outlive a change to its own answer.

That is not how it works. Extractors are built from space, via BuildController._planet_under_fleet() with the fleet parked on the planet (BuildController.gd:334-341). The Planet node is therefore already in the tree with _ready() long since run, shows_extractor had already been resolved to false, and nothing ever updated it. The derrick only turned up if the planet later drifted out of PlanetField's spawn radius and came back. Building an extractor read as doing nothing at all.

Fixed in 2eb779e: GameState emits extractor_added, and Planet keeps its marker in step with it - redrawing only when its own answer actually changes, not per frame.

Why the test did not catch it: it registered the extractor and then spawned a planet, which is the opposite of the order the game does it in. Spawning fresh always looked right. The test now keeps a planet alive across the build and asserts the derrick appears on that already-present node; with the signal connection removed it fails with "a planet already in the tree never picked up its derrick".

That is a gap in how I verified the original ticket: I tested Planet.gd in isolation with a hand-set planet_name, and rendered a screenshot of planets that already had their extractor registered at spawn. Neither exercised the actual build flow, which is the only path a player takes.

Full suite: 40/40.

Reopening the outcome here: you were right that this had no visible effect in game, and the cause was a wrong assumption of mine rather than a build/caching issue. `Planet.gd` resolved the marker once in `_ready()`, on the stated assumption that extractors are built on `PlanetSurface.tscn` and that returning to space rebuilds `Main.tscn` from scratch - so a Planet node could never outlive a change to its own answer. That is not how it works. Extractors are built **from space**, via `BuildController._planet_under_fleet()` with the fleet parked on the planet (`BuildController.gd:334-341`). The Planet node is therefore already in the tree with `_ready()` long since run, `shows_extractor` had already been resolved to `false`, and nothing ever updated it. The derrick only turned up if the planet later drifted out of `PlanetField`'s spawn radius and came back. Building an extractor read as doing nothing at all. Fixed in 2eb779e: `GameState` emits `extractor_added`, and `Planet` keeps its marker in step with it - redrawing only when its own answer actually changes, not per frame. **Why the test did not catch it:** it registered the extractor and *then* spawned a planet, which is the opposite of the order the game does it in. Spawning fresh always looked right. The test now keeps a planet alive across the build and asserts the derrick appears on that already-present node; with the signal connection removed it fails with "a planet already in the tree never picked up its derrick". That is a gap in how I verified the original ticket: I tested `Planet.gd` in isolation with a hand-set `planet_name`, and rendered a screenshot of planets that already had their extractor registered at spawn. Neither exercised the actual build flow, which is the only path a player takes. Full suite: 40/40.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
metaheavens/spaceship#9
No description provided.