GodotSectors/Scripts/Space/Space.gd

35 lines
694 B
GDScript3
Raw Permalink Normal View History

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:
2024-08-02 03:58:22 +00:00
var geometry: MeshInstance3D = child.generate_geometry(self)
root.add_child(geometry)
return root
2024-08-02 02:12:13 +00:00
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:
2024-08-02 02:12:13 +00:00
return child.get_spawn_desc(self)
stack.push_back(child)
2024-08-02 02:12:13 +00:00
return null