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.
This commit is contained in:
Loïc Wisniewski 2026-08-15 21:22:10 +02:00
commit c4e2ee7178
16 changed files with 511 additions and 36 deletions

View file

@ -1,14 +1,13 @@
class_name PlanetSetupHost
extends Node2D
# Instantiates the contents of a PlanetSetup onto a landed surface. Capture
# points are placeholder markers here; #43 replaces them with the real
# CapturePoint scene through the same apply_setup() entry point, and enemy
# spawning is filled in by the enemy-foundation ticket (#44). Keeping this
# seam stable is the point of this ticket.
# Instantiates the contents of a PlanetSetup onto a landed surface: one
# CapturePoint per authored point - registering/restoring conquest progress
# through GameState so re-landing on a partly-taken planet keeps its
# progress - and one enemy per authored spawn.
const MARKER_COLOR: Color = Color(0.55, 0.85, 1.0)
const MARKER_RADIUS: float = 36.0
const CAPTURE_POINT_SCENE: PackedScene = preload("res://CapturePoint.tscn")
const ENEMY_SCENE: PackedScene = preload("res://Enemy.tscn")
var setup: Resource
@ -19,15 +18,25 @@ func apply_setup(new_setup: Resource) -> void:
child.queue_free()
if setup == null:
return
for point in setup.capture_points:
_add_capture_point_marker(point)
GameState.register_capture_points(GameState.planet_id, setup.capture_points.size())
for i in range(setup.capture_points.size()):
_add_capture_point(i, setup.capture_points[i])
for spawn in setup.enemy_spawns:
_add_enemy(spawn)
func _add_capture_point_marker(at: Vector2) -> void:
var marker: NeonPiece = NeonPiece.create(self, at, MARKER_COLOR)
var points: PackedVector2Array = PackedVector2Array()
for i in range(16):
var angle: float = float(i) / 16.0 * TAU
points.append(Vector2(cos(angle), sin(angle)) * MARKER_RADIUS)
marker.add_polygon(points, 0.6)
marker.queue_redraw()
func _add_capture_point(index: int, at: Vector2) -> void:
var point: Node = CAPTURE_POINT_SCENE.instantiate()
point.point_index = index
point.position = at
add_child(point)
if GameState.is_point_captured(GameState.planet_id, index):
point.mark_captured()
func _add_enemy(spawn: Resource) -> void:
var enemy: Node = ENEMY_SCENE.instantiate()
enemy.enemy_id = spawn.enemy_id
enemy.position = spawn.position
add_child(enemy)