33 lines
1 KiB
GDScript3
33 lines
1 KiB
GDScript3
|
|
class_name PlanetSetupHost
|
||
|
|
extends Node2D
|
||
|
|
|
||
|
|
# Instantiates the contents of a PlanetSetup onto a landed surface. Capture
|
||
|
|
# points are placeholder markers here; #43 replaces them with the real
|
||
|
|
# CapturePoint scene through the same apply_setup() entry point, and enemy
|
||
|
|
# spawning is filled in by the enemy-foundation ticket (#44). Keeping this
|
||
|
|
# seam stable is the point of this ticket.
|
||
|
|
|
||
|
|
const MARKER_COLOR: Color = Color(0.55, 0.85, 1.0)
|
||
|
|
const MARKER_RADIUS: float = 36.0
|
||
|
|
|
||
|
|
var setup: Resource
|
||
|
|
|
||
|
|
|
||
|
|
func apply_setup(new_setup: Resource) -> void:
|
||
|
|
setup = new_setup
|
||
|
|
for child in get_children():
|
||
|
|
child.queue_free()
|
||
|
|
if setup == null:
|
||
|
|
return
|
||
|
|
for point in setup.capture_points:
|
||
|
|
_add_capture_point_marker(point)
|
||
|
|
|
||
|
|
|
||
|
|
func _add_capture_point_marker(at: Vector2) -> void:
|
||
|
|
var marker: NeonPiece = NeonPiece.create(self, at, MARKER_COLOR)
|
||
|
|
var points: PackedVector2Array = PackedVector2Array()
|
||
|
|
for i in range(16):
|
||
|
|
var angle: float = float(i) / 16.0 * TAU
|
||
|
|
points.append(Vector2(cos(angle), sin(angle)) * MARKER_RADIUS)
|
||
|
|
marker.add_polygon(points, 0.6)
|
||
|
|
marker.queue_redraw()
|