fix double spawn

This commit is contained in:
2026-06-06 12:51:46 +02:00
parent 2fa562d5d2
commit f049c538bd
2 changed files with 19 additions and 14 deletions

View File

@@ -823,6 +823,11 @@ func _get_static_spawn_chunk_root_from_point(spawn_point: Node) -> Node:
return null
func _get_static_entity_spawn_key(spawn_root: Node) -> String:
if spawn_root.scene_file_path != "":
return spawn_root.scene_file_path
return "instance:%s" % spawn_root.get_instance_id()
func _spawn_entities_for_static_spawn_points() -> void:
var current_scene = get_tree().current_scene
if current_scene == null:
@@ -849,14 +854,14 @@ func _spawn_entities_for_static_obstacle(root: Node, grid_pos: Vector2i) -> void
if spawn_root == null or not is_instance_valid(spawn_root):
return
var root_id: int = spawn_root.get_instance_id()
if static_entity_spawn_roots.has(root_id):
var tracked_root = static_entity_spawn_roots[root_id]
var root_key: String = _get_static_entity_spawn_key(spawn_root)
if static_entity_spawn_roots.has(root_key):
var tracked_root = static_entity_spawn_roots[root_key]
if is_instance_valid(tracked_root):
return
static_entity_spawn_roots.erase(root_id)
static_entity_spawn_roots.erase(root_key)
static_entity_spawn_roots[root_id] = spawn_root
static_entity_spawn_roots[root_key] = spawn_root
_spawn_entities_for_chunk(spawn_root, _choose_biome_name_by_cell(grid_pos))
func _spawn_entities_for_chunk(root: Node, biome_name: String) -> void: