class_name LuneTowerIndicator extends Control ## One building as a symbol in the team's shape language (round = Blau, angular = Rot) with ## its HP as a bar underneath. Destroyed buildings remain as a hollow outline with a cross. var team: int = 0 var tier: String = "outer" var alive: bool = true var fraction: float = 1.0 var attackable: bool = false func _init() -> void: mouse_filter = Control.MOUSE_FILTER_PASS custom_minimum_size = Vector2(22, 27) func set_state(is_alive: bool, hp_fraction: float, is_attackable: bool) -> bool: var value: float = snappedf(clampf(hp_fraction, 0.0, 1.0), .01) if is_alive == alive and is_equal_approx(value, fraction) and is_attackable == attackable: return false alive = is_alive fraction = value attackable = is_attackable queue_redraw() return true func _draw() -> void: var edge: float = minf(size.x, size.y - 5.0) var box := Rect2(Vector2((size.x - edge) * .5, 0), Vector2(edge, edge)) var tint: Color = LuneUiTheme.team_color(team) var shape: String = "shape_%d" % clampi(team, 0, 1) if alive: LuneGlyphs.draw(self, shape, box, LuneUiTheme.TEAM_DARK[clampi(team, 0, 1)].lightened(.1)) LuneGlyphs.draw(self, shape, box.grow(-edge * .08), Color(tint, .35)) LuneGlyphs.draw(self, "ancient" if tier == "core" else "tower", box.grow(-edge * .24), Color("f4efe4")) var bar := Rect2(Vector2(box.position.x + 1, size.y - 3), Vector2(box.size.x - 2, 3)) draw_rect(bar, Color(0, 0, 0, .6)) draw_rect(Rect2(bar.position, Vector2(bar.size.x * fraction, bar.size.y)), LuneHpBar.health_color(fraction, tint)) else: var outline := Color(.5, .52, .55, .8) LuneGlyphs.draw(self, shape, box, Color(0, 0, 0, .35)) LuneGlyphs.draw(self, "close", box.grow(-edge * .18), outline)