Add planet setups as authored resources (#42)

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.
This commit is contained in:
Loïc Wisniewski 2026-08-15 14:41:37 +02:00
commit 5326852807
17 changed files with 350 additions and 4 deletions

View file

@ -2,6 +2,8 @@ extends Node2D
const SURFACE_PROFILES = preload("res://PlanetSurfaceProfiles.gd")
const PLANET_DEFINITIONS = preload("res://PlanetDefinitions.gd")
const PLANET_SETUPS = preload("res://PlanetSetups.gd")
const SETUP_HOST_SCENE: PackedScene = preload("res://PlanetSetupHost.tscn")
# Bootstraps the surviving fleet, including each vessel type, on this scene's
# own startup (from GameState, since this is a fresh scene tree - nothing here
@ -46,10 +48,21 @@ func _compose_surface(profile: Resource) -> void:
var caption: Label = get_node(caption_path)
caption.add_theme_color_override("font_color", profile.caption_color)
caption.add_theme_color_override("font_outline_color", profile.caption_outline_color)
if profile.features_scene == null:
return
var features: Node = profile.features_scene.instantiate()
feature_host.add_child(features)
if profile.features_scene != null:
var features: Node = profile.features_scene.instantiate()
feature_host.add_child(features)
var setup: Resource = PLANET_SETUPS.setup_for_planet(GameState.planet_id, profile.profile_id)
if setup != null:
# Untyped on purpose: a static PlanetSetupHost annotation here would
# need the global class_name cache to already know about it, which
# is only true after an editor/import pass has run (see #31/#35's
# load-order notes) - a plain Node reference plus duck-typed
# apply_setup() sidesteps that entirely, same as BuildingDefinitions
# and VesselDefinitions already do for their own resource types.
var setup_host: Node = SETUP_HOST_SCENE.instantiate()
feature_host.add_child(setup_host)
setup_host.apply_setup(setup)
func _on_exit_pressed() -> void: