spaceship/enemies/EnemySpawnerComponentArtillery.tscn

10 lines
288 B
Text
Raw Normal View History

Enemy mothership (#53) A large, slow capital enemy that periodically launches chasers and artillery on their own intervals and fires a heavily telegraphed line beam capable of killing several player vessels at once. Spawning reuses #52's EnemySpawnerComponent as-is via two preset scenes (EnemySpawnerComponentChaser.tscn: 5s/chaser, EnemySpawnerComponentArtillery.tscn: 18s/max 2/artillery) rather than adding multi-type support to the component - two instances of a single-purpose component is the composition this codebase already uses everywhere ("enemy bomber" in the original request is read here as the existing artillery enemy's slow telegraphed AOE, not a new enemy type - flagged as a judgment call in the ticket). New EnemyBigLaserComponent.gd ("big_laser") fires a standalone EnemyBigLaserBeam on a long cooldown - the beam owns its whole charge/ fire/flash sequence once launched, so the mothership dying mid-charge doesn't cancel an already-telegraphed shot, same design as EnemyArtilleryComponent/ArtilleryShell. The aim direction is locked once in launch() and never re-read - nothing in the charging phase touches the fleet's position again, which is what makes it dodgeable. Damage is a line-segment check (projection + perpendicular distance) against every player_ships member; Ship.take_damage() already handles shield absorption per-ship. MothershipEnemyDefinition.tres: max_hp 60, speed 35 (slow), a ~96-unit hull, pursuit + two spawners + big_laser, no type switch anywhere - every stat from the definition, every behaviour from a component. Tests: new tests/test_enemy_mothership.gd, split into beam mechanics (tested directly, not through the component's own cooldown timing, which would make the geometry assertions timing-fragile) and the composed definition (tested through a real Enemy.tscn instance). Screenshot of the charge telegraph mid-countdown. Full suite: 80/80. Found and fixed a real bug along the way, in EnemySpawnerComponent.gd (#52): its `enemy_scene: PackedScene = preload("res://Enemy.tscn")` member-level preload could get permanently baked in as a broken, empty PackedScene when a definition's component_scenes chain led back to Enemy.tscn while it was still mid-load - confirmed empirically via ResourceLoader.has_cached() being true (a good copy existed) while the preloaded reference's own resource_path was empty. This only surfaces when a SINGLE definition composes two instances of a script carrying such a preload (the mothership's chaser/artillery spawner presets; #52's single-spawner turret never hit it). Fixed by resolving enemy_scene lazily via load() on first use instead of at compile time, and additionally made a fresh spawner count down from a full interval before its first spawn rather than firing on tick one, which also happens to keep two sibling spawners with different intervals from ever landing their first attempt on the same frame. 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-16 10:19:02 +02:00
[gd_scene load_steps=2 format=3]
#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>
2026-08-21 19:44:14 +02:00
[ext_resource type="Script" path="res://enemies/EnemySpawnerComponent.gd" id="1"]
Enemy mothership (#53) A large, slow capital enemy that periodically launches chasers and artillery on their own intervals and fires a heavily telegraphed line beam capable of killing several player vessels at once. Spawning reuses #52's EnemySpawnerComponent as-is via two preset scenes (EnemySpawnerComponentChaser.tscn: 5s/chaser, EnemySpawnerComponentArtillery.tscn: 18s/max 2/artillery) rather than adding multi-type support to the component - two instances of a single-purpose component is the composition this codebase already uses everywhere ("enemy bomber" in the original request is read here as the existing artillery enemy's slow telegraphed AOE, not a new enemy type - flagged as a judgment call in the ticket). New EnemyBigLaserComponent.gd ("big_laser") fires a standalone EnemyBigLaserBeam on a long cooldown - the beam owns its whole charge/ fire/flash sequence once launched, so the mothership dying mid-charge doesn't cancel an already-telegraphed shot, same design as EnemyArtilleryComponent/ArtilleryShell. The aim direction is locked once in launch() and never re-read - nothing in the charging phase touches the fleet's position again, which is what makes it dodgeable. Damage is a line-segment check (projection + perpendicular distance) against every player_ships member; Ship.take_damage() already handles shield absorption per-ship. MothershipEnemyDefinition.tres: max_hp 60, speed 35 (slow), a ~96-unit hull, pursuit + two spawners + big_laser, no type switch anywhere - every stat from the definition, every behaviour from a component. Tests: new tests/test_enemy_mothership.gd, split into beam mechanics (tested directly, not through the component's own cooldown timing, which would make the geometry assertions timing-fragile) and the composed definition (tested through a real Enemy.tscn instance). Screenshot of the charge telegraph mid-countdown. Full suite: 80/80. Found and fixed a real bug along the way, in EnemySpawnerComponent.gd (#52): its `enemy_scene: PackedScene = preload("res://Enemy.tscn")` member-level preload could get permanently baked in as a broken, empty PackedScene when a definition's component_scenes chain led back to Enemy.tscn while it was still mid-load - confirmed empirically via ResourceLoader.has_cached() being true (a good copy existed) while the preloaded reference's own resource_path was empty. This only surfaces when a SINGLE definition composes two instances of a script carrying such a preload (the mothership's chaser/artillery spawner presets; #52's single-spawner turret never hit it). Fixed by resolving enemy_scene lazily via load() on first use instead of at compile time, and additionally made a fresh spawner count down from a full interval before its first spawn rather than firing on tick one, which also happens to keep two sibling spawners with different intervals from ever landing their first attempt on the same frame. 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-16 10:19:02 +02:00
[node name="EnemySpawnerComponentArtillery" type="Node"]
script = ExtResource("1")
spawn_interval = 18.0
spawned_enemy_id = "artillery"
max_alive = 2
spawn_radius = 130.0