fix
This commit is contained in:
@@ -25,32 +25,32 @@ const RIVER_NEIGHBOUR_OFFSETS: Dictionary = {
|
||||
}
|
||||
|
||||
@export_group("Rails")
|
||||
@export var rail_path: Path3D
|
||||
@export var rail_path: Path3D #rail path
|
||||
|
||||
@export_group("Biomes")
|
||||
@export var biome_list: Array[Biome]
|
||||
@export var biome_list: Array[Biome] #list of scenes for the biome
|
||||
|
||||
@export_group("Grid and Area")
|
||||
@export var chunk_size: float = 20.0
|
||||
@export var eye_line: int = 3
|
||||
@export var district_scale: float = 0.05
|
||||
@export var chunk_size: float = 20.0 #size of a cell; default 20 (global position is defined dividing x and z for this value)
|
||||
@export var eye_line: int = 3 #cells to be considerated around the train (e.g. 3 => a square of cells from -3 to 3 around train cell)
|
||||
@export var district_scale: float = 0.05 #noise value to distribuite biome; low values create large area, high values create biome with more variants
|
||||
|
||||
@export_group("Lamppost")
|
||||
@export var lamppost_wire_material: ShaderMaterial
|
||||
@export_range(0.01, 1.0) var wire_thickness: float = 0.05
|
||||
@export var lamppost_dist_factor: int = 10
|
||||
@export var lamppost_dist_factor: int = 10 #max distance of connections
|
||||
|
||||
var board: Dictionary = {}
|
||||
var last_pos_train: Vector2i = Vector2i(999999, 999999)
|
||||
var noise_generator: FastNoiseLite
|
||||
var altitude_generator: FastNoiseLite
|
||||
var wire_connections: Dictionary = {}
|
||||
var chunk_candidate_cache: Dictionary = {}
|
||||
var chunk_candidate_cache: Dictionary = {} #node cache (metadata)
|
||||
var pending_generation_cells: Array[Vector2i] = []
|
||||
var pending_cleanup_cells: Array[Vector2i] = []
|
||||
var pending_wire_cells: Array[Vector2i] = []
|
||||
var pending_wire_lookup: Dictionary = {}
|
||||
var rail_chunk_catalogue: Dictionary = {}
|
||||
var rail_chunk_catalogue: Dictionary = {} #rails chunk list
|
||||
|
||||
var manual_biome: Biome = null
|
||||
|
||||
@@ -59,7 +59,8 @@ func _ready() -> void:
|
||||
|
||||
#connect events
|
||||
UIEvents.update_rail_chunks.connect(_update_rail_chunks)
|
||||
|
||||
|
||||
#noise generator for biome and altitute
|
||||
noise_generator = FastNoiseLite.new()
|
||||
noise_generator.noise_type = FastNoiseLite.TYPE_PERLIN
|
||||
noise_generator.seed = randi()
|
||||
@@ -70,8 +71,10 @@ func _ready() -> void:
|
||||
altitude_generator.seed = randi()
|
||||
altitude_generator.frequency = district_scale * 0.5
|
||||
|
||||
#fill cache with available chunk
|
||||
_warm_chunk_candidate_cache()
|
||||
_warm_rail_chunk_catalogue()
|
||||
#set unique pieces
|
||||
_update_set_pieces()
|
||||
|
||||
func _update_set_pieces() -> void:
|
||||
@@ -128,6 +131,7 @@ func _destroy_and_regenrate_world() -> void:
|
||||
_refresh_world(current_pos)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
#based on constant values the queue are evalutated by frame and not all together
|
||||
_drain_cleanup_queue()
|
||||
_drain_generation_queue()
|
||||
_drain_wire_queue()
|
||||
@@ -153,6 +157,15 @@ func collect_all_chunkinfo(root: Node, list: Array[Node]) -> void:
|
||||
for child in root.get_children():
|
||||
collect_all_chunkinfo(child, list)
|
||||
|
||||
func collect_all_propinfo(root: Node, list: Array[Node]) -> void:
|
||||
if root == null: return
|
||||
|
||||
if "available_props" in root:
|
||||
list.append(root)
|
||||
|
||||
for child in root.get_children():
|
||||
collect_all_propinfo(child, list)
|
||||
|
||||
func _warm_chunk_candidate_cache() -> void:
|
||||
var unique_scenes: Dictionary = {}
|
||||
|
||||
@@ -514,6 +527,30 @@ func _pick_backup_scene(zone_catalogue: Array[PackedScene], grid_pos: Vector2i)
|
||||
return scene
|
||||
return zone_catalogue[0]
|
||||
|
||||
func _spawn_props_for_chunk(root: Node) -> void:
|
||||
var prop_markers: Array[Node] = []
|
||||
collect_all_propinfo(root, prop_markers)
|
||||
|
||||
for marker in prop_markers:
|
||||
_spawn_prop_for_marker(marker)
|
||||
|
||||
func _spawn_prop_for_marker(marker: Node) -> void:
|
||||
if marker.available_props.is_empty():
|
||||
return
|
||||
|
||||
var prop_scene = marker.available_props.pick_random()
|
||||
if prop_scene == null:
|
||||
return
|
||||
|
||||
var prop_instance = prop_scene.instantiate()
|
||||
var prop_node = prop_instance as Node3D
|
||||
if prop_node == null:
|
||||
prop_instance.queue_free()
|
||||
return
|
||||
|
||||
marker.add_child(prop_node)
|
||||
prop_node.transform = Transform3D.IDENTITY
|
||||
|
||||
func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
|
||||
if board.has(grid_pos): return true
|
||||
|
||||
@@ -681,6 +718,7 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
new_chunk.position = Vector3(grid_pos.x * chunk_size, 0, grid_pos.y * chunk_size)
|
||||
new_chunk.rotation.y = choise.rotation * (-PI / 2.0)
|
||||
add_child(new_chunk)
|
||||
_spawn_props_for_chunk(new_chunk)
|
||||
|
||||
var info_new = _get_cached_chunk_info(new_chunk, choise.scene)
|
||||
|
||||
@@ -711,6 +749,7 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
var backup = backup_scene.instantiate()
|
||||
backup.position = Vector3(grid_pos.x * chunk_size, 0, grid_pos.y * chunk_size)
|
||||
add_child(backup)
|
||||
_spawn_props_for_chunk(backup)
|
||||
|
||||
var info_backup = _get_cached_chunk_info(backup, backup_scene)
|
||||
var backup_uniqueness = _get_chunk_uniqueness_from_info(info_backup)
|
||||
|
||||
4
core/biome_generator/prop_info.gd
Normal file
4
core/biome_generator/prop_info.gd
Normal file
@@ -0,0 +1,4 @@
|
||||
extends Marker3D
|
||||
class_name PropInfo
|
||||
|
||||
@export var available_props: Array[PackedScene]
|
||||
1
core/biome_generator/prop_info.gd.uid
Normal file
1
core/biome_generator/prop_info.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dg6ngy4pmtsyc
|
||||
Reference in New Issue
Block a user