#84: move 215 root files into a folder hierarchy

Everything lived in one flat directory, so a diff gave no clue what area it
touched and finding the file you wanted meant knowing its exact name. Twelve
folders now, grouped by what a thing IS rather than what type it is - a
vessel's definition, its component scenes and its upgrade resources sit
together, because that is the set you read when you change one of them.

  buildings  core  controllers  enemies  logistics  planets
  resources  shaders  surface  ui  vessels  vfx  world

332 files moved and every res:// reference rewritten - 306 files touched,
including the autoload and main-scene paths in project.godot. Nothing renamed:
this is purely where files sit, so the diff is a pile of pure moves and no
behaviour is buried in it. ui_theme.tres, icon.svg and web_shell.html stay at
the root, where Godot and the export preset expect them.

Verified three ways, because a suite alone would not have caught all of it:
the full 117 pass, the web export builds clean, and the game renders.

The export is why that matters. The FIRST export after the move failed with
"Attempt to open script 'res://GameState.gd'" - the old path - while
project.godot on disk plainly said res://core/GameState.gd. That is this
project's documented Android FUSE mtime trap: Godot served a cached copy of a
file whose content had changed. A `touch` fixed it. Nothing in the test suite
would have found that, because the suite runs from a copy on a native
filesystem - the one place the bug cannot happen.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Loïc Wisniewski 2026-08-21 19:44:14 +02:00
commit 2f161621c3
495 changed files with 571 additions and 567 deletions

View file

@ -1,78 +0,0 @@
class_name EnemySpawnerComponent
extends Node
# Continuously spawns another enemy type beside its host, at a fixed
# interval, capped at max_alive concurrently. The spawned enemies are
# added as children of the spawner's OWN PARENT - not the spawner itself -
# so killing the spawner never frees its already-spawned children (they
# are siblings, not descendants) and so a surface-hosted spawner keeps its
# spawns under the same host a `../Fleet`-style path assumption would miss
# (see #44's note on why that hazard exists for anything parented under a
# planet surface's PlanetSetupHost rather than directly under Main.tscn).
var capability_id: String = "spawner"
@export var spawn_interval: float = 4.0
@export var spawned_enemy_id: String = "chaser"
@export var max_alive: int = 6
@export var spawn_radius: float = 90.0
var spawn_timer: float = 0.0
var spawned: Array = []
# Resolved lazily via load() on first use rather than preload()d as a
# compile-time constant: when a definition's component_scenes chain leads
# BACK to Enemy.tscn while it is still mid-load (e.g. two different preset
# scenes of this same script both live on one definition, as the
# mothership's chaser/artillery spawners are), the preloaded constant can
# get permanently baked in as a broken, empty PackedScene - confirmed by
# ResourceLoader.has_cached() being true (a good copy exists) while the
# preloaded reference's own resource_path was empty. load() at first real
# use instead always resolves against whatever is actually in the cache
# by then.
var enemy_scene: PackedScene = null
func _ready() -> void:
# Start counting down from a full interval rather than firing on the
# very first tick: besides reading more naturally (a freshly-placed
# spawner doesn't insta-spawn), this keeps two sibling spawners with
# different intervals (e.g. the mothership's chaser/artillery presets)
# from both landing their first attempt on the exact same physics
# frame - which hit a transient PackedScene.instantiate() failure on
# this engine build when it happened.
spawn_timer = spawn_interval
func tick(delta: float) -> void:
spawned = spawned.filter(func(node): return is_instance_valid(node))
if spawned.size() >= max_alive:
return
spawn_timer -= delta
if spawn_timer > 0.0:
return
spawn_timer = spawn_interval
var fleet: Node2D = get_tree().get_first_node_in_group("player_fleet")
if fleet == null or fleet.ships.is_empty():
return
var spawner: Node2D = get_parent()
var host: Node = spawner.get_parent()
if host == null:
return
var angle: float = randf() * TAU
var offset: Vector2 = Vector2(cos(angle), sin(angle)) * spawn_radius
if enemy_scene == null:
enemy_scene = load("res://Enemy.tscn")
var new_enemy: Node2D = enemy_scene.instantiate()
new_enemy.enemy_id = spawned_enemy_id
# spawner.position is already expressed in `host`'s local space, and
# new_enemy is about to be added to that same `host` - unlike
# EnemyRangedWeaponComponent's projectile, which reparents to root and
# needs global_position, there is no space conversion needed here.
new_enemy.position = spawner.position + offset
host.add_child(new_enemy)
spawned.append(new_enemy)