A second suicide vessel alongside the chaser, but where the chaser simply beelines, this one is a rhythm the player can read. It drifts in from beyond lock_range at half speed, LOCKS a point, rocks 30px back and forth along the charge axis for 1.2s, draws a thin line down its trajectory for the last 300ms, and only then crosses the gap in one straight 950px/s run before coasting to a stop and starting over. The lock is what makes the wind-up worth anything: nothing re-reads the fleet once it begins, so the charge goes where the target WAS and stepping off the line works. Same bargain as EnemyBigLaserBeam. EnemyLungeComponent is a Node2D rather than a plain Node because the trajectory line has to be drawn somewhere, and top_level keeps that drawing in world space while the hull it hangs off spins to face the lock. The roaming spawner gets a 25% lancer share. It is the only place the player meets an enemy off an authored map, so without that the lancer would exist only in the setup editor. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
49 lines
2.2 KiB
GDScript
49 lines
2.2 KiB
GDScript
class_name EnemyDefinitions
|
|
extends RefCounted
|
|
|
|
const DEFAULT_ID: String = "chaser"
|
|
const ORDER: PackedStringArray = ["chaser", "lancer", "sniper", "artillery", "turret_spawner", "enemy_mothership"]
|
|
const DEFINITIONS: Dictionary = {
|
|
"chaser": preload("res://enemies/ChaserEnemyDefinition.tres"),
|
|
"lancer": preload("res://enemies/LancerEnemyDefinition.tres"),
|
|
"sniper": preload("res://enemies/SniperEnemyDefinition.tres"),
|
|
"artillery": preload("res://enemies/ArtilleryEnemyDefinition.tres"),
|
|
"turret_spawner": preload("res://enemies/TurretSpawnerEnemyDefinition.tres"),
|
|
"enemy_mothership": preload("res://enemies/MothershipEnemyDefinition.tres"),
|
|
}
|
|
|
|
|
|
# The single place that knows what an enemy LOOKS like. Three things draw
|
|
# enemies - the enemy itself, the map editor's markers, and the editor's
|
|
# palette buttons - and each used to reimplement it from hull_points alone.
|
|
# Adding interior detail to the definitions therefore showed up in the game
|
|
# and nowhere else, so an editor marker no longer matched the ship it placed.
|
|
#
|
|
# `at` and `scale` exist because the palette draws into a small button
|
|
# centred on itself, while the other two draw around their own origin at
|
|
# full size.
|
|
static func draw_definition(item: CanvasItem, definition: Resource, glow: Color,
|
|
scale: float = 1.0, at: Vector2 = Vector2.ZERO) -> void:
|
|
if definition == null:
|
|
return
|
|
var core: Color = definition.core_color
|
|
item.draw_set_transform(at, 0.0, Vector2(scale, scale))
|
|
NeonDraw.draw_glowing_polygon(item, definition.hull_points, glow, 1.0, core)
|
|
var lines: PackedVector2Array = definition.detail_lines
|
|
for i in range(0, lines.size() - 1, 2):
|
|
NeonDraw.draw_glowing_line(item, lines[i], lines[i + 1], glow, 0.85, 0.55, core)
|
|
var rings: PackedVector2Array = definition.detail_rings
|
|
for i in range(0, rings.size() - 1, 2):
|
|
NeonDraw.draw_glowing_circle(item, rings[i], rings[i + 1].x, glow, 0.85, core)
|
|
item.draw_set_transform(Vector2.ZERO, 0.0, Vector2.ONE)
|
|
|
|
|
|
static func get_definition(enemy_id: String) -> Resource:
|
|
return DEFINITIONS.get(enemy_id, DEFINITIONS[DEFAULT_ID])
|
|
|
|
|
|
static func all() -> Array:
|
|
var result: Array = []
|
|
for enemy_id in ORDER:
|
|
result.append(DEFINITIONS[enemy_id])
|
|
return result
|