Enemy.gd now resolves stats/hull/color from EnemyDefinition resources and composes behaviour from capability components (EnemyPursuitComponent holds today's chase-the-nearest-ship logic), the same shape Ship.gd already uses for vessels. Fleet lookups go through a "player_fleet" group instead of a hardcoded ../Fleet sibling path, so an enemy parented anywhere (e.g. under a planet surface's SurfaceFeatures) still finds it. Also closes a real gap: enemies previously had no way to damage the fleet at range at all (Ship only reacted to physical contact, Projectile.gd was player-only). Ship.take_damage() is now a proper entry point - contact damage routes through it unchanged - and EnemyProjectile lets an enemy component fire at player_ships. Both ranged enemy archetypes in #45/#46 build on this. Part of the #40 conquest-mechanic breakdown.
43 lines
1.8 KiB
GDScript
43 lines
1.8 KiB
GDScript
extends Node2D
|
|
|
|
|
|
func _ready() -> void:
|
|
GameState.buildings.clear()
|
|
GameState.extractors.clear()
|
|
GameState.transporters.clear()
|
|
GameState.vessel_levels["unlock_gas_bomber"] = 1
|
|
var main: Node = load("res://Main.tscn").instantiate()
|
|
add_child(main)
|
|
main.get_node("BackgroundLayer").visible = false
|
|
main.get_node("AsteroidField").visible = false
|
|
main.get_node("PlanetField").visible = false
|
|
main.get_node("BuildingField").visible = false
|
|
main.get_node("EnemySpawner").set_process(false)
|
|
main.get_node("AsteroidField").set_process(false)
|
|
var fleet: Node = main.get_node("Fleet")
|
|
fleet.spawn_ships(4, Vector2.ZERO, PackedStringArray([
|
|
GameState.VESSEL_INTERCEPTOR, GameState.VESSEL_SHIELD,
|
|
GameState.VESSEL_GAS_BOMBER, GameState.VESSEL_GAS_BOMBER]))
|
|
var skill: GasBombController = main.get_node("GasBombController")
|
|
skill._process(0.0)
|
|
# Show both per-ship states in one frame: the first bomber is rearming,
|
|
# while the second has a fully lit hull and supplies the aim.
|
|
var rearming: Node = fleet.ships[2].get_component("gas_bomber")
|
|
rearming.consume_shot(GasBombController.COOLDOWN)
|
|
rearming.tick(GasBombController.COOLDOWN * 0.5)
|
|
main.get_node("Camera2D").zoom = Vector2(1.8, 1.8)
|
|
var button: Control = main.get_node("UI/GasBombButton")
|
|
var press := InputEventScreenTouch.new()
|
|
press.index = 9
|
|
press.position = button.global_position + button.size * 0.5
|
|
press.pressed = true
|
|
skill.handle_touch(press)
|
|
var drag := InputEventScreenDrag.new()
|
|
drag.index = 9
|
|
drag.position = press.position + Vector2(-245, -235)
|
|
skill.handle_drag(drag)
|
|
for offset in [Vector2(-65, 0), Vector2(45, -45), Vector2(55, 65)]:
|
|
var enemy: Node = load("res://Enemy.tscn").instantiate()
|
|
enemy.position = skill.aim_target + offset
|
|
main.add_child(enemy)
|
|
enemy.speed = 0.0 # after add_child - _ready() sets it from the definition
|