spaceship/VesselGasBomberComponent.gd

54 lines
1.5 KiB
GDScript3
Raw Normal View History

2026-08-15 10:12:33 +02:00
class_name VesselGasBomberComponent
extends Node2D
2026-08-15 04:45:15 +02:00
var capability_id := "gas_bomber"
2026-08-15 10:12:33 +02:00
var cooldown_duration := 5.0
var cooldown_left := 0.0
const READY_COLOR := Color(1.0, 0.25, 0.78)
const COOLING_COLOR := Color(0.38, 0.16, 0.32)
func setup() -> void:
queue_redraw()
func is_ready() -> bool:
return cooldown_left <= 0.0
func consume_shot(duration: float) -> bool:
if not is_ready():
return false
cooldown_duration = maxf(duration, 0.001)
cooldown_left = cooldown_duration
queue_redraw()
return true
func tick(delta: float) -> void:
if cooldown_left <= 0.0:
return
cooldown_left = maxf(cooldown_left - delta, 0.0)
queue_redraw()
func cooldown_progress() -> float:
return 1.0 - cooldown_left / maxf(cooldown_duration, 0.001)
func _draw() -> void:
var parent_ship: Node = get_parent()
var core: Color = parent_ship.core_color if parent_ship != null else Color.WHITE
if is_ready():
# Bright, complete halo: this bomber owns one available shot.
NeonDraw.draw_glowing_circle(self, Vector2.ZERO, 31.0, READY_COLOR, 0.9, core)
draw_circle(Vector2.ZERO, 4.0, Color(READY_COLOR, 0.5))
return
# A muted full ring says "not ready"; the bright arc fills clockwise so
# the individual bomber also communicates how close it is to rearming.
draw_arc(Vector2.ZERO, 31.0, 0.0, TAU, 48, Color(COOLING_COLOR, 0.65), 4.0, true)
var progress := cooldown_progress()
if progress > 0.001:
draw_arc(Vector2.ZERO, 31.0, -PI / 2.0,
-PI / 2.0 + TAU * progress, 48, Color(READY_COLOR, 0.92), 4.0, true)