Huge amount of updates

This commit is contained in:
2025-02-12 13:07:21 +01:00
parent 349b6b7226
commit 687c2ae1f5
96 changed files with 15637 additions and 156 deletions

View File

@ -0,0 +1,4 @@
extends Node
const DEFAULT_JUMP_VELOCITY: float = 5
const DEFAULT_CHARACTER_SPEED: float = 7.0

View File

@ -0,0 +1,49 @@
class_name Functions extends Node
func get_root_node() -> GameRoot:
return get_tree().get_root().find_child("GameRoot", true, false)
func get_server_node() -> ServerData:
return get_tree().get_root().find_child("ServerData", true, false)
func get_map_node() -> MapController:
return get_tree().get_root().find_child("Map", true, false)
func player_data_into_dict(player_data: PlayerData) -> Dictionary:
var result: Dictionary = {
"id": player_data.id,
"username": player_data.id,
"score": player_data.score,
"damage": player_data.damage,
"headshots": player_data.headshots,
"active": player_data.active
}
var side: String
match player_data.side:
-1:
side = "undefined"
0:
side = "attack"
1:
side = "defend"
result["side"] = side
return result
func player_data_from_dict(player_data: Dictionary) -> PlayerData:
var result := PlayerData.new()
result.id = player_data.get("id")
result.username = player_data.get("username")
result.active = player_data.get("active")
result.damage = player_data.get("damage")
result.headshots = player_data.get("headshots")
result.score = player_data.get("score")
var side: int
match player_data.side:
"undefined":
side = -1
"attack":
side = 0
"defend":
side = 1
result.side = side
return result

View File

@ -0,0 +1,50 @@
extends Node
class_name Logger
var thread: Thread = Thread.new()
var mutex: Mutex = Mutex.new()
var log_queue: Array[String] = []
var running: bool = true
func _ready():
thread.start(log_writer)
func info(msg: Variant):
mutex.lock()
log_queue.append("[color=white][b]INFO:[/b] [/color]" + msg)
mutex.unlock()
func debug(msg: Variant):
mutex.lock()
log_queue.append("[color=cyan][b]DEBUG:[/b] [/color]" + msg)
mutex.unlock()
func warning(msg: Variant):
mutex.lock()
log_queue.append("[color=yellow][b]WARN:[/b] [/color]" + msg)
push_warning(msg)
mutex.unlock()
func error(msg: Variant):
mutex.lock()
log_queue.append("[color=red][b]ERROR:[/b] [/color]" + msg)
push_error(msg)
mutex.unlock()
func log_writer():
while running:
mutex.lock()
while log_queue.size() > 0:
var log_message = log_queue.pop_front()
print_rich(log_message)
mutex.unlock()
# Prevent high CPU usage
await get_tree().create_timer(0.1).timeout
func _exit_tree():
running = false
thread.wait_to_finish()