SecondQuestReplaceComponent.gd 634 B

123456789101112131415161718192021
  1. class_name SecondQuestReplacer
  2. extends Node
  3. @export_file("*.tscn") var new_scene := ""
  4. @export var properties: Array[String] = []
  5. func _ready() -> void:
  6. if Global.second_quest and new_scene != "" and new_scene != owner.scene_file_path:
  7. if owner.owner != null:
  8. await owner.owner.ready
  9. var node = load(new_scene).instantiate()
  10. node.global_position = owner.global_position
  11. node.global_rotation = owner.global_rotation
  12. for i in properties:
  13. node.set(i, owner.get(i))
  14. owner.add_sibling(node)
  15. if owner is RopeElevatorPlatform:
  16. owner.linked_platform.linked_platform = node
  17. owner.queue_free()
  18. else:
  19. queue_free()