extends Control # #100: "an small alert on top right appear when a new wave is coming. No # timer should be visible." # # The second half of that is a constraint on this file, not just a note. # GameState deliberately offers no remaining-seconds accessor - only # wave_warning_pulse(), which is a 0..1 throb - so there is no number here # that could be rendered as a countdown even by accident. The urgency is # carried by the pulse rate, which says "soon" without saying "in 4". const GLOW: Color = Color(1.0, 0.45, 0.2) const TEXT: String = "WAVE INCOMING" var label: Label func _ready() -> void: mouse_filter = Control.MOUSE_FILTER_IGNORE visible = false label = Label.new() label.text = TEXT label.mouse_filter = Control.MOUSE_FILTER_IGNORE label.add_theme_font_size_override("font_size", 22) label.add_theme_color_override("font_color", GLOW) label.add_theme_color_override("font_outline_color", Color(0.05, 0.01, 0.0, 0.95)) label.add_theme_constant_override("outline_size", 3) label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER add_child(label) resized.connect(_layout) _layout() func _layout() -> void: if label == null: return # Room on the left for the chevron _draw() puts there. label.position = Vector2(size.y, 0.0) label.size = Vector2(maxf(size.x - size.y, 0.0), size.y) func _process(_delta: float) -> void: var incoming: bool = GameState.wave_is_incoming() if incoming != visible: visible = incoming if incoming: queue_redraw() func _draw() -> void: if not visible: return var pulse: float = GameState.wave_warning_pulse() var alpha: float = 0.35 + 0.65 * pulse draw_rect(Rect2(Vector2.ZERO, size), Color(0.16, 0.04, 0.01, 0.62)) NeonDraw.draw_glowing_path(self, PackedVector2Array([ Vector2(0.0, 0.0), Vector2(size.x, 0.0), Vector2(size.x, size.y), Vector2(0.0, size.y), Vector2(0.0, 0.0), ]), Color(GLOW, alpha), 0.9, 0.7) # A warning triangle, not a clock face. var centre: Vector2 = Vector2(size.y * 0.5, size.y * 0.5) var radius: float = size.y * 0.28 NeonDraw.draw_glowing_polygon(self, PackedVector2Array([ centre + Vector2(0.0, -radius), centre + Vector2(radius * 0.92, radius * 0.72), centre + Vector2(-radius * 0.92, radius * 0.72), ]), Color(GLOW, alpha), 1.0)