1
Fork 0
mirror of https://github.com/Steffo99/nanogolf.git synced 2024-11-24 17:14:19 +00:00
algodist-steffo-nanogolf/scenes/single_player_tracker.gd

38 lines
1 KiB
GDScript3
Raw Normal View History

2024-03-09 03:24:05 +00:00
extends Node
2024-02-27 02:54:47 +00:00
class_name SinglePlayerTracker
2024-03-07 04:06:37 +00:00
## Node representative of a player connected to the room.
##
## The peer of the player this node represents has authority over it.
2024-02-27 02:54:47 +00:00
## The player's name.
var player_name: String = "Player"
## The player's color.
var player_color: Color = Color.WHITE
2024-03-07 04:06:37 +00:00
## Whether this player is currently connected or not.
var player_connected: bool = false
2024-03-09 03:24:05 +00:00
## Change the name of this player.
@rpc("authority", "call_local", "reliable")
func set_player_name(value: String):
player_name = value
## Change the color of this player.
@rpc("authority", "call_local", "reliable")
func set_player_color(value: Color):
player_color = value
## Ask the authority for this player to repeat the player's name.
@rpc("any_peer", "call_local", "reliable")
func query_player_name():
if is_multiplayer_authority():
set_player_name.rpc(player_name)
## Ask the authority for this player to repeat the player's color.
@rpc("any_peer", "call_local", "reliable")
func query_player_color():
if is_multiplayer_authority():
set_player_color.rpc(player_color)