2025-02-18 17:28:57 -05:00
|
|
|
extends Node3D
|
2025-02-18 14:29:18 -05:00
|
|
|
|
|
|
|
var client: StreamPeerTCP
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
GameKit.is_game_paused(false)
|
|
|
|
await get_tree().create_timer(1).timeout
|
|
|
|
connect_to_server()
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
if client == null:
|
|
|
|
return
|
|
|
|
|
|
|
|
client.poll()
|
|
|
|
|
|
|
|
if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
|
|
|
return
|
|
|
|
|
|
|
|
if Input.is_action_pressed("ui_pause"):
|
|
|
|
GameKit.is_game_paused(true)
|
|
|
|
$PauseScn/PauseWin.move_to_center();
|
|
|
|
$PauseScn/PauseWin.show()
|
|
|
|
|
|
|
|
func connect_to_server() -> void:
|
|
|
|
client = StreamPeerTCP.new()
|
|
|
|
var err = client.connect_to_host("127.0.0.1", 1337)
|
|
|
|
if err != OK:
|
|
|
|
print(err)
|
|
|
|
|
|
|
|
func _on_timer_timeout() -> void:
|
|
|
|
if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
|
|
|
return
|
|
|
|
|
|
|
|
client.put_data("This is Legends Online.".to_utf8_buffer())
|