Added world container

This commit is contained in:
Rob Kelly 2024-11-17 11:53:13 -07:00
parent d762bfc8f1
commit 101cd700ae
3 changed files with 42 additions and 25 deletions

View File

@ -12,7 +12,7 @@ config_version=5
config/name="GFOLF 2"
config/description="GFOLF: Combat Golf Action"
run/main_scene="res://levels/debug_level/debug_level.tscn"
run/main_scene="res://src/world/world.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
run/max_fps=60
@ -56,6 +56,10 @@ config/controls/camera/x_axis_acceleration=30.0
config/controls/camera/y_axis_acceleration=30.0
config/controls/camera/invert_pitch=false
[global_group]
WorldGroup="Singleton group for the active world instance, if any."
[gui]
theme/custom="res://src/ui/main_theme.tres"

27
src/world/world.gd Normal file
View File

@ -0,0 +1,27 @@
class_name World extends Node
## Container scene for a game world instance.
##
## A world contains player(s) and the active level, manages player states,
## and transitions between active levels.
@export var initial_level: PackedScene = preload("res://levels/debug_level/debug_level.tscn")
@onready var level: Node3D = %Level
@onready var ui: Control = %UI
func _ready() -> void:
load_level(initial_level)
## Instantiate and mantle the given level scene.
##
## This will free any currently-loaded level!
func load_level(level_scene: PackedScene) -> void:
# Remove any currently-loaded level assets
for c: Node in level.get_children():
c.queue_free()
# Load the level
var instance: Node3D = level_scene.instantiate()
level.add_child(instance)

View File

@ -1,33 +1,19 @@
[gd_scene load_steps=4 format=3 uid="uid://cwnwcd8kushl3"]
[gd_scene load_steps=2 format=3 uid="uid://cwnwcd8kushl3"]
[ext_resource type="Shader" path="res://src/shaders/retro_postprocessing.gdshader" id="1_3gv54"]
[ext_resource type="PackedScene" uid="uid://bm2o3mex10v11" path="res://levels/debug_level/debug_level.tscn" id="1_pge3b"]
[ext_resource type="Script" path="res://src/world/world.gd" id="1_ybjyx"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_sc4r2"]
shader = ExtResource("1_3gv54")
shader_parameter/change_color_depth = true
shader_parameter/target_color_depth = 8
shader_parameter/dithering = true
shader_parameter/scale_resolution = true
shader_parameter/target_resolution_scale = 3
shader_parameter/enable_recolor = false
[node name="World" type="Node" groups=["WorldGroup"]]
script = ExtResource("1_ybjyx")
[node name="World" type="Node"]
[node name="Level" type="Node3D" parent="."]
unique_name_in_owner = true
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
material = SubResource("ShaderMaterial_sc4r2")
[node name="UI" type="Control" parent="."]
unique_name_in_owner = true
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
handle_input_locally = false
size = Vector2i(1280, 720)
render_target_update_mode = 4
[node name="Level" type="Node3D" parent="SubViewportContainer/SubViewport"]
[node name="TestLevel" parent="SubViewportContainer/SubViewport/Level" instance=ExtResource("1_pge3b")]
mouse_filter = 1