create/kill world process

This commit is contained in:
Nordup 2023-04-23 03:12:34 +03:00
parent 6ea7db44c4
commit 1e6718b37d
2 changed files with 21 additions and 4 deletions

View file

@ -15,8 +15,7 @@ func load_gate(config_url: String) -> void:
c_gate = ConfigGate.new(config_path, config_url) c_gate = ConfigGate.new(config_path, config_url)
var image_path = await FileDownloader.download(c_gate.image_url) var image_path = await FileDownloader.download(c_gate.image_url)
var gate = Gate.create(config_url, c_gate.title, c_gate.description, var gate = Gate.create(config_url, c_gate.title, c_gate.description, image_path, "", "", "")
image_path, "", "", "")
gate_events.gate_info_loaded_emit(gate) gate_events.gate_info_loaded_emit(gate)
gate.godot_config = await FileDownloader.download(c_gate.godot_config_url) gate.godot_config = await FileDownloader.download(c_gate.godot_config_url)

View file

@ -8,9 +8,12 @@ var gate: Gate
var c_g_script: ConfigGlobalScript var c_g_script: ConfigGlobalScript
var c_godot: ConfigGodot var c_godot: ConfigGodot
var pid: int
func _ready() -> void: func _ready() -> void:
gate_events.gate_loaded.connect(load_pack) # gate_events.gate_loaded.connect(load_pack)
gate_events.gate_loaded.connect(create_process)
func load_pack(_gate: Gate) -> void: func load_pack(_gate: Gate) -> void:
@ -40,5 +43,20 @@ func unload_pack() -> void:
if c_g_script != null: c_g_script.unload_config() if c_g_script != null: c_g_script.unload_config()
func create_process(_gate: Gate) -> void:
gate = _gate
var pack_file = ProjectSettings.globalize_path(gate.resource_pack)
var args = ["--main-pack", pack_file]
print("./godot " + " ".join(args))
pid = OS.create_instance(args)
func kill_process() -> void:
if OS.is_process_running(pid):
OS.kill(pid)
func _exit_tree() -> void: func _exit_tree() -> void:
unload_pack() # unload_pack()
kill_process()