Show the extractor derrick the moment it is built, not on respawn
Follow-up to #9: the marker was resolved once in Planet._ready() on the assumption that extractors are built on PlanetSurface.tscn, so a Planet node could never outlive a change to its own answer. That assumption was wrong. Extractors are built from SPACE, via BuildController._planet_under_fleet() with the fleet parked on the planet, so the Planet node is already in the tree with _ready() long since run. The derrick therefore did not appear until the planet happened to despawn and respawn - building one read as doing nothing. GameState now emits extractor_added, and Planet keeps its marker in step with it, redrawing only when its own answer actually changes. The test missed this because it spawned a fresh planet after registering the extractor, which is not the order the game does it in. It now keeps a planet alive across the build and asserts the derrick appears on that node. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
8dd5d7b78f
commit
2eb779e5de
3 changed files with 42 additions and 4 deletions
|
|
@ -29,6 +29,7 @@ var map_content: Node2D
|
|||
var planet_chunk: Vector2i
|
||||
var planet_name: String = ""
|
||||
var stage: int = 0
|
||||
var already_spawned: Node2D
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
|
|
@ -78,13 +79,29 @@ func _process(_delta: float) -> bool:
|
|||
print("TEST_PLANET_EXTRACTOR_MARKER: FAIL (map badge with no extractor)")
|
||||
quit(1)
|
||||
return true
|
||||
clean.queue_free()
|
||||
print("no extractor -> no derrick, no badge (planet '%s')" % planet_name)
|
||||
|
||||
# Deliberately keep this planet ALIVE across the build. An
|
||||
# extractor is built from space with the fleet parked on the
|
||||
# planet (BuildController._planet_under_fleet()), so the node is
|
||||
# already in the tree with _ready() long since run. Resolving the
|
||||
# marker only at _ready() meant the planet kept looking untouched
|
||||
# until it happened to despawn and respawn - the build read as
|
||||
# having done nothing at all. Spawning a fresh planet afterwards
|
||||
# (as the checks below do) cannot catch that.
|
||||
already_spawned = clean
|
||||
game_state.add_extractor(planet_name, WorldGen.chunk_origin(planet_chunk))
|
||||
stage = 1
|
||||
return false
|
||||
1:
|
||||
# --- the planet that was already on screen when it was built --
|
||||
if not already_spawned.shows_extractor:
|
||||
print("TEST_PLANET_EXTRACTOR_MARKER: FAIL (a planet already in the tree never picked up its derrick - the build reads as doing nothing)")
|
||||
quit(1)
|
||||
return true
|
||||
print("planet already in the tree picked up its derrick on build")
|
||||
already_spawned.queue_free()
|
||||
|
||||
# --- extractor built ----------------------------------------
|
||||
var mined: Node2D = _spawn_planet()
|
||||
if not mined.shows_extractor:
|
||||
|
|
|
|||
Loading…
Reference in a new issue