35 lines
684 B
GDScript
35 lines
684 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_point() -> Vector3:
|
|
var stack := [self]
|
|
|
|
while stack:
|
|
var node = stack.pop_front()
|
|
for child in node.get_children():
|
|
if child is SpaceSpawn:
|
|
return child.space_position(self)
|
|
stack.push_back(child)
|
|
|
|
return Vector3.ZERO
|