Compose planet surfaces from profiles

This commit is contained in:
Loïc Wisniewski 2026-08-14 16:05:32 +02:00
commit 2f68515f33
19 changed files with 123 additions and 39 deletions

View file

@ -1,5 +1,7 @@
extends Node2D
const SURFACE_PROFILES = preload("res://PlanetSurfaceProfiles.gd")
# Bootstraps the surviving fleet on this scene's own startup (from
# GameState, since this is a fresh scene tree - nothing here carries
# over automatically) and handles the always-available exit prompt that
@ -13,29 +15,14 @@ extends Node2D
@onready var planet_name_label: Label = get_node("../UI/PlanetNameLabel")
@onready var exit_button: IconButton = get_node("../UI/ExitButton")
@onready var fade_rect: ColorRect = get_node("../FadeOverlay/FadeRect")
@onready var background: ColorRect = get_node("../BackgroundLayer/LunarBackground")
@onready var feature_host: Node2D = get_node("../SurfaceFeatures")
var transitioning: bool = false
func _ready() -> void:
if GameState.planet_type == "gas_giant":
# A gas giant is not lunar terrain: its surface view uses a deep,
# coloured atmosphere instead of the rocky field. The background is
# shader-driven, so changing ColorRect.color does not tint it; update
# the actual palette uniforms.
get_node("../RockField").visible = false
get_node("../GasVentField").visible = true
var background: ColorRect = get_node("../BackgroundLayer/LunarBackground")
var atmosphere: ShaderMaterial = background.material
atmosphere.set_shader_parameter("base_color", Color(0.13, 0.025, 0.22, 1.0))
atmosphere.set_shader_parameter("crater_color", Color(0.055, 0.008, 0.11, 1.0))
atmosphere.set_shader_parameter("highlight_color", Color(0.52, 0.17, 0.7, 1.0))
# The lunar surface uses dark captions on a bright ground. Flip only
# those captions for the night-dark gas atmosphere.
for caption_path in ["../UI/BankCaption", "../UI/FleetCaption"]:
var caption: Label = get_node(caption_path)
caption.add_theme_color_override("font_color", Color(0.78, 0.88, 0.94))
caption.add_theme_color_override("font_outline_color", Color(0.02, 0.01, 0.05, 0.9))
_compose_surface(SURFACE_PROFILES.get_profile(GameState.surface_profile_id))
fleet.spawn_ships(GameState.surviving_ship_count, Vector2.ZERO)
camera.position = Vector2.ZERO
camera.zoom = Vector2(GameState.return_camera_zoom, GameState.return_camera_zoom)
@ -47,6 +34,21 @@ func _ready() -> void:
tween.tween_property(fade_rect, "color:a", 0.0, fade_duration)
func _compose_surface(profile: Resource) -> void:
var atmosphere: ShaderMaterial = background.material
atmosphere.set_shader_parameter("base_color", profile.base_color)
atmosphere.set_shader_parameter("crater_color", profile.crater_color)
atmosphere.set_shader_parameter("highlight_color", profile.highlight_color)
for caption_path in ["../UI/BankCaption", "../UI/FleetCaption"]:
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)
func _on_exit_pressed() -> void:
if transitioning:
return