42 lines
1.7 KiB
GDScript3
42 lines
1.7 KiB
GDScript3
|
|
extends Node2D
|
||
|
|
|
||
|
|
const WORLD_TO_LOCAL: float = 0.04
|
||
|
|
|
||
|
|
@onready var tracker: Node2D = get_node("../../../ExplorationTracker")
|
||
|
|
@onready var fleet: Node2D = get_node("../../../Fleet")
|
||
|
|
|
||
|
|
|
||
|
|
func _process(_delta: float) -> void:
|
||
|
|
if is_visible_in_tree():
|
||
|
|
queue_redraw()
|
||
|
|
|
||
|
|
|
||
|
|
func _draw() -> void:
|
||
|
|
var chunk_size_local: float = WorldGen.CHUNK_SIZE * WORLD_TO_LOCAL
|
||
|
|
|
||
|
|
for chunk in tracker.get_explored_chunks():
|
||
|
|
var origin_local: Vector2 = WorldGen.chunk_origin(chunk) * WORLD_TO_LOCAL
|
||
|
|
var biome: int = WorldGen.biome_at_chunk(chunk)
|
||
|
|
var color: Color = WorldGen.biome_color(biome)
|
||
|
|
var rect: Rect2 = Rect2(origin_local, Vector2(chunk_size_local, chunk_size_local))
|
||
|
|
draw_rect(rect, color, true)
|
||
|
|
draw_rect(rect, Color(0.0, 0.0, 0.0, 0.4), false, 1.5)
|
||
|
|
|
||
|
|
if WorldGen.has_planet_at_chunk(chunk):
|
||
|
|
# Same deterministic per-chunk data PlanetField spawns the
|
||
|
|
# actual Planet from - the marker stays put on the map even
|
||
|
|
# for a chunk whose Planet node isn't currently loaded (out of
|
||
|
|
# spawn_radius_chunks of the fleet).
|
||
|
|
var data: Dictionary = WorldGen.planet_data_at_chunk(chunk)
|
||
|
|
var planet_local: Vector2 = origin_local + data.local_pos * WORLD_TO_LOCAL
|
||
|
|
draw_circle(planet_local, 5.0, Color(0.7, 0.65, 0.55))
|
||
|
|
draw_arc(planet_local, 5.0, 0.0, TAU, 16, Color(1.0, 1.0, 1.0, 0.9), 1.0, true)
|
||
|
|
|
||
|
|
var fleet_local: Vector2 = fleet.get_centroid() * WORLD_TO_LOCAL
|
||
|
|
var marker_points: PackedVector2Array = PackedVector2Array([
|
||
|
|
fleet_local + Vector2(0, -10),
|
||
|
|
fleet_local + Vector2(7, 8),
|
||
|
|
fleet_local + Vector2(-7, 8),
|
||
|
|
])
|
||
|
|
draw_colored_polygon(marker_points, Color(0.3, 0.9, 1.0))
|
||
|
|
draw_polyline(PackedVector2Array([marker_points[0], marker_points[1], marker_points[2], marker_points[0]]), Color(1, 1, 1), 1.5, true)
|