A team game with an emphasis on movement (with no shooting), inspired by Overwatch and Zineth
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

  1. extends HTTPRequest
  2. var is_update_payload = false
  3. var save_to
  4. var time = 0
  5. func _ready():
  6. connect("request_completed", self, "_request_completed")
  7. # Check if we need an update
  8. request("https://www.cosinegaming.com/static/vanagloria/version.json", [], false)
  9. set_process(true)
  10. func _request_completed(result, response_code, headers, body):
  11. if result != RESULT_SUCCESS:
  12. print("ERROR: COULD NOT UPDATE. RESULT #" + str(result))
  13. completed()
  14. return
  15. if not is_update_payload:
  16. # Just checking if we need an update
  17. var server = JSON.parse(body.get_string_from_utf8()).result
  18. # 0.0.0 -> Update-shell application, needs more resources
  19. if server.version == util.version and util.version != "0.0.0":
  20. print("Game up-to-date! Launching")
  21. completed()
  22. else:
  23. is_update_payload = true
  24. save_to = server.save_location
  25. use_threads = true
  26. print("Need to update! Downloading " + server.download_path)
  27. request(server.download_path)
  28. else:
  29. print("Update recieved. Saving to " + save_to)
  30. var file = File.new()
  31. file.open(save_to, File.WRITE)
  32. file.store_buffer(body)
  33. file.close()
  34. restart()
  35. func _process(delta):
  36. time += delta
  37. var fake_progress = 1 - (0.8 / time)
  38. get_node("../ProgressBar").value = 100*fake_progress
  39. func restart():
  40. # Pass on args to new instance, then quit
  41. var output = []
  42. OS.execute("./vanagloria", [], false, output) # Mirror just runs godot again
  43. get_tree().quit()
  44. func completed():
  45. get_tree().change_scene("res://scenes/lobby.tscn")