WorldSaveData.gd 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. extends Spatial
  2. export var collected_items = []
  3. export var flowerspot_status = []
  4. func _ready():
  5. # Called when the node is added to the scene for the first time.
  6. # Initialization here
  7. pass
  8. func save_world_data(lv_name):
  9. collected_items.clear()
  10. flowerspot_status.clear()
  11. #print ("WorldSaveData.gd::save_world_data called - " + lv_name)
  12. var spawners = get_tree().get_nodes_in_group("group_spawner")
  13. for s in spawners:
  14. if (s.spawned_object != null):
  15. var wr = weakref(s.spawned_object)
  16. if (!wr.get_ref() or str(s.spawned_object) == "[Deleted Object]"):
  17. print (str(s.spawned_object) + str(" collected"))
  18. collected_items.push_back(s.name)
  19. else:
  20. print (str(s.spawned_object) + str(" OK"))
  21. if (wr.get_ref() and str(s.spawned_object) == "[Deleted Object]"):
  22. print ("ERROR: !wr.get_ref() got wrong result")
  23. else:
  24. collected_items.push_back(s.name)
  25. var spots = get_tree().get_nodes_in_group("group_flowerspot")
  26. for s in spots:
  27. var flowerspot = []
  28. flowerspot.push_back(s.name)
  29. flowerspot.push_back(s.status)
  30. flowerspot_status.push_back(flowerspot)
  31. get_node("/root/Save").save_node_data_by_name(self, lv_name + str(self.name))
  32. func save():
  33. var save_dict = {
  34. collected_items = collected_items,
  35. flowerspot_status = flowerspot_status
  36. }
  37. return save_dict