generated from krampus/template-godot4
	Compare commits
	
		
			No commits in common. "b709118be222f2d3680e65304407e9ecec06812e" and "52e70f8c140245c0ce58b088f695f6c00374ac60" have entirely different histories.
		
	
	
		
			b709118be2
			...
			52e70f8c14
		
	
		
| @ -13,11 +13,11 @@ config_version=5 | |||||||
| config/name="Megalith" | config/name="Megalith" | ||||||
| run/main_scene="uid://daxngklaqlyba" | run/main_scene="uid://daxngklaqlyba" | ||||||
| config/features=PackedStringArray("4.5", "Forward Plus") | config/features=PackedStringArray("4.5", "Forward Plus") | ||||||
|  | run/max_fps=60 | ||||||
| 
 | 
 | ||||||
| [autoload] | [autoload] | ||||||
| 
 | 
 | ||||||
| PhantomCameraManager="*res://addons/phantom_camera/scripts/managers/phantom_camera_manager.gd" | PhantomCameraManager="*res://addons/phantom_camera/scripts/managers/phantom_camera_manager.gd" | ||||||
| WorldGenManager="*res://src/world/generation/worldgen_manager/worldgen_manager.tscn" |  | ||||||
| 
 | 
 | ||||||
| [debug] | [debug] | ||||||
| 
 | 
 | ||||||
| @ -31,7 +31,6 @@ gdscript/warnings/unsafe_call_argument=2 | |||||||
| 
 | 
 | ||||||
| window/size/viewport_width=1920 | window/size/viewport_width=1920 | ||||||
| window/size/viewport_height=1080 | window/size/viewport_height=1080 | ||||||
| window/vsync/vsync_mode=0 |  | ||||||
| 
 | 
 | ||||||
| [dotnet] | [dotnet] | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,29 +0,0 @@ | |||||||
| class_name Chunk extends Node3D |  | ||||||
| ## A discrete generated chunk of the world |  | ||||||
| 
 |  | ||||||
| const SIZE := Vector2(64, 64) |  | ||||||
| const SCENE := preload("res://src/world/generation/chunk/chunk.tscn") |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| func chunk_position() -> Vector2: |  | ||||||
| 	return Chunk.world_to_chunk(position) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| func generate() -> void: |  | ||||||
| 	# TODO: this |  | ||||||
| 	print_debug("Generating chunk at ", chunk_position()) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| static func chunk_to_world(chunk_pos: Vector2) -> Vector3: |  | ||||||
| 	return Vector3(chunk_pos.x * SIZE.x, 0, chunk_pos.y * SIZE.y) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| static func world_to_chunk(world_pos: Vector3) -> Vector2: |  | ||||||
| 	return Vector2(world_pos.x / SIZE.x, world_pos.z / SIZE.y) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| static func generate_chunk(chunk_pos: Vector2) -> Chunk: |  | ||||||
| 	var instance: Chunk = SCENE.instantiate() |  | ||||||
| 	instance.position = Chunk.chunk_to_world(chunk_pos) |  | ||||||
| 	instance.generate() |  | ||||||
| 	return instance |  | ||||||
| @ -1 +0,0 @@ | |||||||
| uid://chqpqe4anvamd |  | ||||||
| @ -1,23 +0,0 @@ | |||||||
| [gd_scene load_steps=4 format=3 uid="uid://crs68yhijqkca"] |  | ||||||
| 
 |  | ||||||
| [ext_resource type="Script" uid="uid://chqpqe4anvamd" path="res://src/world/generation/chunk/chunk.gd" id="1_87ter"] |  | ||||||
| 
 |  | ||||||
| [sub_resource type="PlaneMesh" id="PlaneMesh_0cma0"] |  | ||||||
| size = Vector2(64, 64) |  | ||||||
| subdivide_width = 64 |  | ||||||
| subdivide_depth = 64 |  | ||||||
| center_offset = Vector3(32, 0, 32) |  | ||||||
| 
 |  | ||||||
| [sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_87ter"] |  | ||||||
| points = PackedVector3Array(1.9073486e-06, 0, 1.9073486e-06, 1.9073486e-06, 0, 64, 64, 0, 1.9073486e-06, 64, 0, 64) |  | ||||||
| 
 |  | ||||||
| [node name="Chunk" type="Node3D"] |  | ||||||
| script = ExtResource("1_87ter") |  | ||||||
| 
 |  | ||||||
| [node name="MeshInstance3D" type="MeshInstance3D" parent="."] |  | ||||||
| mesh = SubResource("PlaneMesh_0cma0") |  | ||||||
| 
 |  | ||||||
| [node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"] |  | ||||||
| 
 |  | ||||||
| [node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"] |  | ||||||
| shape = SubResource("ConvexPolygonShape3D_87ter") |  | ||||||
| @ -1,21 +0,0 @@ | |||||||
| 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)) |  | ||||||
| @ -1 +0,0 @@ | |||||||
| uid://dka00cyvfr21t |  | ||||||
| @ -1,6 +0,0 @@ | |||||||
| [gd_scene load_steps=2 format=3 uid="uid://cop4mkrv70yhc"] |  | ||||||
| 
 |  | ||||||
| [ext_resource type="Script" uid="uid://dka00cyvfr21t" path="res://src/world/generation/generated_world.gd" id="1_m2u13"] |  | ||||||
| 
 |  | ||||||
| [node name="GeneratedWorld" type="Node3D"] |  | ||||||
| script = ExtResource("1_m2u13") |  | ||||||
| @ -1,4 +0,0 @@ | |||||||
| class_name WorldGenManagerType extends Node |  | ||||||
| ## Global autoloaded singleton controller for worldgen parameters |  | ||||||
| 
 |  | ||||||
| @export var noise: FastNoiseLite |  | ||||||
| @ -1 +0,0 @@ | |||||||
| uid://7frynyj4vspc |  | ||||||
| @ -1,10 +0,0 @@ | |||||||
| [gd_scene load_steps=3 format=3 uid="uid://dxelp6rnok01y"] |  | ||||||
| 
 |  | ||||||
| [ext_resource type="Script" uid="uid://7frynyj4vspc" path="res://src/world/generation/worldgen_manager/worldgen_manager.gd" id="1_7xvag"] |  | ||||||
| 
 |  | ||||||
| [sub_resource type="FastNoiseLite" id="FastNoiseLite_7xvag"] |  | ||||||
| 
 |  | ||||||
| [node name="WorldGenManager" type="Node"] |  | ||||||
| script = ExtResource("1_7xvag") |  | ||||||
| noise = SubResource("FastNoiseLite_7xvag") |  | ||||||
| metadata/_custom_type_script = "uid://7frynyj4vspc" |  | ||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user