diff --git a/Scenes/Main.tscn b/Scenes/Main.tscn index 36d7a66..000a2e7 100644 --- a/Scenes/Main.tscn +++ b/Scenes/Main.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://Scripts/Main.gd" id="1_2yjjx"] [ext_resource type="PackedScene" uid="uid://deff7lt34nj0h" path="res://Spaces/Dungeon.tscn" id="2_4gs22"] -[ext_resource type="PackedScene" uid="uid://b83k3b5x1wmyl" path="res://Scenes/Player.tscn" id="3_eq7hn"] +[ext_resource type="PackedScene" uid="uid://d3e3a6xdwo2dp" path="res://Scenes/Player.tscn" id="3_eq7hn"] [sub_resource type="Environment" id="Environment_pn2uj"] diff --git a/Scenes/Player.tscn b/Scenes/Player.tscn index edc1979..fded525 100644 --- a/Scenes/Player.tscn +++ b/Scenes/Player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=2 format=3 uid="uid://b83k3b5x1wmyl"] +[gd_scene load_steps=2 format=3 uid="uid://d3e3a6xdwo2dp"] [ext_resource type="Script" path="res://Scripts/Player.gd" id="1_m1g7d"] diff --git a/Scripts/Main.gd b/Scripts/Main.gd index 5e3860d..1495afa 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -3,8 +3,10 @@ extends Node3D func _ready(): add_child($Dungeon.generate_geometry()) - $Player.position = $Dungeon.get_spawn_point() + var spawn = $Dungeon.get_spawn() + $Player.position = spawn.position $Player.position.y += 0.5 + $Player.rotation = spawn.rotation func _process(delta): diff --git a/Scripts/Space/Space.gd b/Scripts/Space/Space.gd index c07878a..61dbd99 100644 --- a/Scripts/Space/Space.gd +++ b/Scripts/Space/Space.gd @@ -21,14 +21,14 @@ func generate_geometry() -> Node3D: return root -func get_spawn_point() -> Vector3: +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.space_position(self) + return child.get_spawn_desc(self) stack.push_back(child) - return Vector3.ZERO + return null diff --git a/Scripts/Space/SpaceSpawn.gd b/Scripts/Space/SpaceSpawn.gd index 20311b6..b5a807f 100644 --- a/Scripts/Space/SpaceSpawn.gd +++ b/Scripts/Space/SpaceSpawn.gd @@ -5,6 +5,14 @@ extends SpaceEntity class_name SpaceSpawn -func space_position(space: Space) -> Vector3: +class Desc extends RefCounted: + var position: Vector3 + var rotation: Vector3 + + +func get_spawn_desc(space: Space) -> Desc: # todo: Get current region elevation - return Vector3(global_position.x * space.unit_scale, 0, global_position.y * space.unit_scale) + var desc := Desc.new() + desc.position = Vector3(global_position.x * space.unit_scale, 0, global_position.y * space.unit_scale) + desc.rotation.y = rotation_degrees + return desc diff --git a/Spaces/Dungeon.tscn b/Spaces/Dungeon.tscn index ddeea73..4957421 100644 --- a/Spaces/Dungeon.tscn +++ b/Spaces/Dungeon.tscn @@ -31,7 +31,7 @@ wall_texture = ExtResource("3_ondo6") [node name="Spawn" type="Sprite2D" parent="Room"] position = Vector2(-48, 32) -rotation = 0.159622 +rotation = 1.83259 scale = Vector2(0.25, 0.25) texture = ExtResource("3_7vff1") script = ExtResource("4_rhl23")