extends Node2D var enemy: CharacterBody2D var _tier_label: Label func _ready() -> void: enemy = get_parent() as CharacterBody2D top_level = true z_index = 30 light_mask = 4 _tier_label = Label.new() _tier_label.mouse_filter = Control.MOUSE_FILTER_IGNORE _tier_label.light_mask = 4 _tier_label.position = Vector2(-50, -23) _tier_label.size = Vector2(100, 16) _tier_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER _tier_label.add_theme_font_size_override("font_size", 11) _tier_label.add_theme_color_override("font_outline_color", Color("08111d")) _tier_label.add_theme_constant_override("outline_size", 3) add_child(_tier_label) _update_position() _update_tier_label() func _process(_delta: float) -> void: _update_position() _update_tier_label() queue_redraw() func _update_position() -> void: global_position = enemy.global_position + Vector2(0, -enemy.get_visual_size() * 0.5 - 12.0) func _tier_color() -> Color: return Color("ff76d6") if enemy.loot_tier == 2 else (Color("ffc785") if enemy.loot_tier == 1 else Color("ef5967")) func _update_tier_label() -> void: _tier_label.text = "BOSS" if enemy.loot_tier == 2 else ("ELITA" if enemy.loot_tier == 1 else "") _tier_label.add_theme_color_override("font_color", _tier_color()) func get_health_ratio() -> float: return clampf(enemy.hull / maxf(enemy.max_hull, 0.001), 0.0, 1.0) func _draw() -> void: if not is_instance_valid(enemy) or enemy.hull <= 0.0: return var width := 72.0 if enemy.loot_tier == 2 else (56.0 if enemy.loot_tier == 1 else 44.0) var background := Rect2(-width * 0.5, -3.0, width, 6.0) draw_rect(background.grow(1.0), Color("08111dee")) draw_rect(background, Color("39232bee")) var color := _tier_color() draw_rect(Rect2(background.position, Vector2(width * get_health_ratio(), 6.0)), color)