diff --git a/src/player/player.tscn b/src/player/player.tscn index 9f7027e..6e9c564 100644 --- a/src/player/player.tscn +++ b/src/player/player.tscn @@ -118,6 +118,8 @@ metadata/_custom_type_script = "uid://d11erhxna68vd" [node name="DebugMovement" type="Node" parent="."] unique_name_in_owner = true script = ExtResource("10_ylhto") +normal_speed = 500.0 +fast_speed = 1000.0 metadata/_custom_type_script = "uid://htwqrc73xg7q" [node name="DebugHUD" type="CanvasLayer" parent="." node_paths=PackedStringArray("player")] diff --git a/src/world/generation/feature/generation_feature.gd b/src/world/generation/feature/generation_feature.gd new file mode 100644 index 0000000..c77ba6c --- /dev/null +++ b/src/world/generation/feature/generation_feature.gd @@ -0,0 +1,9 @@ +class_name GenerationFeature extends Node3D +## Base class for world features generated during worldgen. +## +## Layers contain features. Some features may contain layers. + + +func probe() -> void: + # TODO may want to make low-detail & high-detail probes distinct + pass # Implemented in derived type. diff --git a/src/world/generation/feature/generation_feature.gd.uid b/src/world/generation/feature/generation_feature.gd.uid new file mode 100644 index 0000000..280cb5d --- /dev/null +++ b/src/world/generation/feature/generation_feature.gd.uid @@ -0,0 +1 @@ +uid://drk82eeqk2mjs diff --git a/src/world/generation/generated_world.gd b/src/world/generation/generated_world.gd index fe45bc2..0a8dc28 100644 --- a/src/world/generation/generated_world.gd +++ b/src/world/generation/generated_world.gd @@ -1,21 +1,10 @@ class_name GeneratedWorld extends Node3D -@export var generation_radius := 6.0 - -var chunks: Dictionary[Vector2, Chunk] = {} - - -func get_chunk(chunk_pos: Vector2) -> Chunk: - if chunk_pos not in chunks: - var chunk := Chunk.generate_chunk(chunk_pos) - add_child(chunk) - chunks[chunk_pos] = chunk - return chunks[chunk_pos] - func _process(_delta: float) -> void: - var camera := get_viewport().get_camera_3d() - var center := Chunk.world_to_chunk(camera.global_position) - for x in range(center.x - generation_radius, center.x + generation_radius): - for y in range(center.y - generation_radius, center.y + generation_radius): - get_chunk(Vector2(x, y)) + # Probe all child generation layers & features each frame + for c: Node in get_children(): + if c is GenerationLayer: + (c as GenerationLayer).probe() + elif c is GenerationFeature: + (c as GenerationFeature).probe() diff --git a/src/world/generation/generated_world.tscn b/src/world/generation/generated_world.tscn index c335129..1b97cf5 100644 --- a/src/world/generation/generated_world.tscn +++ b/src/world/generation/generated_world.tscn @@ -1,6 +1,9 @@ -[gd_scene load_steps=2 format=3 uid="uid://cop4mkrv70yhc"] +[gd_scene load_steps=3 format=3 uid="uid://cop4mkrv70yhc"] [ext_resource type="Script" uid="uid://dka00cyvfr21t" path="res://src/world/generation/generated_world.gd" id="1_m2u13"] +[ext_resource type="PackedScene" uid="uid://dlhc1te2ip8vg" path="res://src/world/generation/layer/arcology_grid_layer/arcology_grid_layer.tscn" id="2_k55gd"] [node name="GeneratedWorld" type="Node3D"] script = ExtResource("1_m2u13") + +[node name="ArcologyGridLayer" parent="." instance=ExtResource("2_k55gd")] diff --git a/src/world/generation/layer/generation_layer.gd b/src/world/generation/layer/generation_layer.gd new file mode 100644 index 0000000..e256b62 --- /dev/null +++ b/src/world/generation/layer/generation_layer.gd @@ -0,0 +1,7 @@ +class_name GenerationLayer extends Node3D +## A composite layer of world generation logic. + + +## Probe this layer and any sub-layers at the world generation point, generating features as needed. +func probe() -> void: + pass # Implement in derived type diff --git a/src/world/generation/layer/generation_layer.gd.uid b/src/world/generation/layer/generation_layer.gd.uid new file mode 100644 index 0000000..1f53d09 --- /dev/null +++ b/src/world/generation/layer/generation_layer.gd.uid @@ -0,0 +1 @@ +uid://ciq8lxydnfc77 diff --git a/src/world/generation/worldgen_manager/worldgen_manager.gd b/src/world/generation/worldgen_manager/worldgen_manager.gd index f808c36..3bc7312 100644 --- a/src/world/generation/worldgen_manager/worldgen_manager.gd +++ b/src/world/generation/worldgen_manager/worldgen_manager.gd @@ -2,3 +2,20 @@ class_name WorldGenManagerType extends Node ## Global autoloaded singleton controller for worldgen parameters @export var noise: FastNoiseLite + +## Generate features with the lowest detail, like large distant structures, within this radius +@export var low_detail_radius := 100000.0 +## Generate features with medium detail, like buildings, within this radius +@export var med_detail_radius := 1024.0 +## Generate features with high detail, like small complicated objects, within this radius +@export var high_detail_radius := 64.0 + + +## Get the world-space coordinate to generate around. +func get_generation_point() -> Vector3: + var viewport := get_viewport() + if viewport: + var camera := viewport.get_camera_3d() + if camera: + return camera.global_position + return Vector3.ZERO diff --git a/src/world/world.tscn b/src/world/world.tscn index 49bf536..e59942d 100644 --- a/src/world/world.tscn +++ b/src/world/world.tscn @@ -2,7 +2,7 @@ [ext_resource type="PackedScene" uid="uid://dtbulshrxetes" path="res://src/player/player.tscn" id="1_1k4gi"] [ext_resource type="Script" uid="uid://bd046eokvcnu2" path="res://addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd" id="2_6fy3g"] -[ext_resource type="PackedScene" uid="uid://cop4mkrv70yhc" path="res://src/world/generation/generated_world.tscn" id="2_jte2u"] +[ext_resource type="PackedScene" uid="uid://cop4mkrv70yhc" path="res://src/world/generation/generated_world.tscn" id="3_jte2u"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_6fy3g"] sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1) @@ -56,18 +56,16 @@ data = PackedVector3Array(-0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0 environment = SubResource("Environment_bsf3i") [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0) +transform = Transform3D(-0.54954004, 0.51725316, -0.6560906, -0.17890637, 0.69422466, 0.69716895, 0.8160872, 0.5005011, -0.2889644, 0, 0, 0) shadow_enabled = true directional_shadow_split_1 = 0.015 directional_shadow_split_2 = 0.105 directional_shadow_max_distance = 400.0 -[node name="GeneratedWorld" parent="." instance=ExtResource("2_jte2u")] - [node name="Camera3D" type="Camera3D" parent="."] physics_interpolation_mode = 1 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 121.5, 0) -far = 40000.0 +far = 100000.0 [node name="PhantomCameraHost" type="Node" parent="Camera3D"] process_priority = 300 @@ -100,23 +98,4 @@ skeleton = NodePath("../..") [node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerSpawn/ReferenceCube/StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_6fy3g") -[node name="BigTorus" type="CSGTorus3D" parent="."] -transform = Transform3D(-0.76604444, 0.64278764, 0, -0.5421216, -0.6460753, -0.53729963, -0.34536955, -0.4115954, 0.8433914, 10000, 2000, 0) -inner_radius = 4000.0 -outer_radius = 8000.0 -sides = 32 -ring_sides = 16 - -[node name="FarTower" type="CSGCylinder3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5000, -4000) -radius = 2000.0 -height = 10000.0 -sides = 32 -cone = true - -[node name="NearTower" type="CSGCylinder3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -600, 500, -400) -radius = 200.0 -height = 1000.0 -sides = 32 -cone = true +[node name="GeneratedWorld" parent="." instance=ExtResource("3_jte2u")]