PlanetSetup/PlanetSetupSpawn define a curated capture-point/enemy layout for a surface profile; PlanetSetups scans res://PlanetSetups/ at first use (not a hardcoded preload table) so dropping in a new .tres is the only step needed to add one, and resolves the same setup for the same planet deterministically, same pattern as WorldGen.planet_data_at_chunk. PlanetSurfaceController composes a PlanetSetupHost onto the landed surface alongside the existing resource-provider feature scene. Ships two starter setups (rocky_default, gas_default) with placeholder capture-point markers; #43 replaces the markers with the real CapturePoint scene through the same apply_setup() entry point. Part of the #40 conquest-mechanic breakdown.
33 lines
1 KiB
GDScript
33 lines
1 KiB
GDScript
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.
|
|
|
|
const MARKER_COLOR: Color = Color(0.55, 0.85, 1.0)
|
|
const MARKER_RADIUS: float = 36.0
|
|
|
|
var setup: Resource
|
|
|
|
|
|
func apply_setup(new_setup: Resource) -> void:
|
|
setup = new_setup
|
|
for child in get_children():
|
|
child.queue_free()
|
|
if setup == null:
|
|
return
|
|
for point in setup.capture_points:
|
|
_add_capture_point_marker(point)
|
|
|
|
|
|
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()
|