mirror of
https://github.com/Steffo99/nanogolf.git
synced 2024-11-21 15:44:21 +00:00
I started some changes I will undo
This commit is contained in:
parent
a10ad9aa64
commit
b466eb09eb
5 changed files with 44 additions and 22 deletions
|
@ -42,6 +42,7 @@ func find_name(player_name: String) -> SinglePlayerTracker:
|
|||
return tracker
|
||||
return null
|
||||
|
||||
|
||||
## Create a new [SinglePlayerTracker] for the given peer id, or return the one that already exists.
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
func create(peer_id: int) -> SinglePlayerTracker:
|
||||
|
|
12
scenes/single_peer_tracker.gd
Normal file
12
scenes/single_peer_tracker.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends Node
|
||||
class_name SinglePeerTracker
|
||||
|
||||
## Node representative of a single connected peer.
|
||||
##
|
||||
## That specific peer must have authority over this node.
|
||||
##
|
||||
## Then, that authority is used to connect to a specific player.
|
||||
|
||||
@rpc("authority", "call_local", "reliable")
|
||||
func takeover(player: SinglePlayerTracker):
|
||||
pass
|
6
scenes/single_peer_tracker.tscn
Normal file
6
scenes/single_peer_tracker.tscn
Normal file
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://gabtrafmbrmn"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/single_peer_tracker.gd" id="1_pofmw"]
|
||||
|
||||
[node name="SinglePeerTracker" type="Node"]
|
||||
script = ExtResource("1_pofmw")
|
|
@ -1,4 +1,4 @@
|
|||
extends MultiplayerSynchronizer
|
||||
extends Node
|
||||
class_name SinglePlayerTracker
|
||||
|
||||
## Node representative of a player connected to the room.
|
||||
|
@ -13,3 +13,25 @@ var player_color: Color = Color.WHITE
|
|||
|
||||
## Whether this player is currently connected or not.
|
||||
var player_connected: bool = false
|
||||
|
||||
## 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)
|
||||
|
|
|
@ -1,25 +1,6 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://drccgvtcng3ju"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://drccgvtcng3ju"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/single_player_tracker.gd" id="1_jwlkv"]
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_755wr"]
|
||||
properties/0/path = NodePath(".:player_connected")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 2
|
||||
properties/1/path = NodePath(".:player_name")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 2
|
||||
properties/2/path = NodePath(".:player_color")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 2
|
||||
properties/3/path = NodePath(".:strokes_per_hole")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 2
|
||||
|
||||
[node name="SinglePlayerTracker" type="MultiplayerSynchronizer"]
|
||||
root_path = NodePath(".")
|
||||
replication_interval = 1.0
|
||||
delta_interval = 0.125
|
||||
replication_config = SubResource("SceneReplicationConfig_755wr")
|
||||
visibility_update_mode = 2
|
||||
[node name="SinglePlayerTracker" type="Node"]
|
||||
script = ExtResource("1_jwlkv")
|
||||
|
|
Loading…
Reference in a new issue