extends Control
class_name MiniMapView

# Pure drawing surface for hud/mini_map.gd — split out because CanvasLayer
# (which the rest of the HUD overlays use for their `layer` property, see
# player_list.gd/kill_feed.gd) isn't a CanvasItem and can't override _draw().
# mini_map.gd owns all game-state polling and just pokes these two arrays
# before calling queue_redraw().

# Normalized (0..1 within world_bounds) positions of every wall/asteroid
# tile, cached once by mini_map.gd since the map layout never changes.
var hazard_points: PackedVector2Array = PackedVector2Array()

# [{pos: Vector2 (normalized 0..1), color: Color}], rebuilt every refresh.
var player_points: Array = []

const BG_COLOR := Color(0.04, 0.28, 0.08, 0.6)
const BORDER_COLOR := Color(0.5, 0.85, 0.5, 0.8)
const HAZARD_COLOR := Color(0.65, 0.65, 0.65, 0.9)
const HAZARD_RADIUS := 1.5
const PLAYER_RADIUS := 3.0


func _draw() -> void:
	var rect := Rect2(Vector2.ZERO, size)
	draw_rect(rect, BG_COLOR, true)

	for p in hazard_points:
		draw_circle(p * size, HAZARD_RADIUS, HAZARD_COLOR)

	for entry in player_points:
		draw_circle(entry.pos * size, PLAYER_RADIUS, entry.color)

	draw_rect(rect, BORDER_COLOR, false, 1.5)
