GodotSectors/Scripts/Space/Space.gd

35 lines
678 B
GDScript

extends Node2D
## Scene based space to transform into 3d.
##
## Children of class SpaceEntity will be interpreted.
##
class_name Space
## Scaling of pixel to 3d space coordinates.
@export var unit_scale: float = 0.01
func generate_geometry() -> Node3D:
var root := Node3D.new()
for child in get_children():
if child is SpaceRegion:
var geometry = child.generate_geometry(self)
root.add_child(geometry)
return root
func get_spawn() -> SpaceSpawn.Desc:
var stack := [self]
while stack:
var node = stack.pop_front()
for child in node.get_children():
if child is SpaceSpawn:
return child.get_spawn_desc(self)
stack.push_back(child)
return null