spaceship/tests/_capture_points_preview.gd
Loïc Wisniewski c4e2ee7178 Add capture points and the planet conquest loop (#43)
CapturePoint tracks neutral/blocked/capturing/captured state by polling
proximity each frame (a ship in capture_radius, no enemy within
enemy_clear_radius), draining gradually rather than resetting when
interrupted, and calling GameState.mark_point_captured() on completion.
PlanetSetupHost now instantiates the real CapturePoint scene per
authored point (restoring already-captured state immediately on
re-landing) and spawns each setup's authored enemies, replacing the
placeholder markers from #42. CaptureLabel is a small self-polling HUD
(same convention as ResourceCounter) showing "CAPTURED n/m" or
"CONQUERED" with a one-shot fade on completion, themed per surface
profile alongside the existing bank/fleet captions.

test_planet_atmosphere_transition.gd's "no enemies on a landed
surface" assumption no longer holds now that setups can place guard
enemies by design - narrowed the check to what it actually needs to
prove: no space-side EnemySpawner/AsteroidField node leaks across the
scene swap.

Part of the #40 conquest-mechanic breakdown.
2026-08-15 21:22:10 +02:00

54 lines
2.2 KiB
GDScript

extends Node2D
# Preloaded by path rather than an `is CapturePoint` check - this preview
# runs through screenshot.sh, which (unlike run_tests.sh) does not run an
# import pass first, so the global class_name cache may not be warm yet.
const CAPTURE_POINT_SCRIPT = preload("res://CapturePoint.gd")
func _ready() -> void:
GameState.planet_name = "Kepler's Rest"
GameState.planet_id = "chunk:3:7"
GameState.planet_definition_id = "rocky"
GameState.surviving_ship_count = 3
GameState.rocks = 128
var surface: Node = load("res://PlanetSurface.tscn").instantiate()
surface.get_node("SurfaceController").fade_duration = 0.0
add_child(surface)
# Zoomed out so all three ~220-radius capture rings fit the frame with
# margin, regardless of wherever the real setup's points happen to sit.
surface.get_node("Camera2D").zoom = Vector2(0.55, 0.55)
var host: Node = surface.get_node("SurfaceFeatures/PlanetSetupHost")
var points: Array = []
for child in host.get_children():
if child.get_script() == CAPTURE_POINT_SCRIPT:
points.append(child)
# Lay the three points out in a compact, clearly-separated triangle for
# the screenshot, rather than the real (far-flung) authored positions.
var layout: Array = [Vector2(300, 150), Vector2(-300, 150), Vector2(0, -280)]
for i in range(mini(points.size(), layout.size())):
points[i].position = layout[i]
# Show all three states at once: captured, mid-fill, and blocked. Each
# point's own _process() would otherwise immediately recompute state
# from the real (empty, this far from any ship) fleet/enemy proximity
# and overwrite these on the very next frame, so freeze it after setting
# the display state - same technique as freezing enemy.speed for the
# gas bomber screenshot.
if points.size() >= 1:
points[0].mark_captured()
points[0].set_process(false)
GameState.mark_point_captured(GameState.planet_id, points[0].point_index)
if points.size() >= 2:
points[1].state = CAPTURE_POINT_SCRIPT.State.CAPTURING
points[1].progress = 0.55
points[1].queue_redraw()
points[1].set_process(false)
if points.size() >= 3:
points[2].state = CAPTURE_POINT_SCRIPT.State.BLOCKED
points[2].progress = 0.3
points[2].queue_redraw()
points[2].set_process(false)