mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 15:00:09 +01:00
Add quotes to rpc flags
see https://github.com/godotengine/godot/issues/72218
This commit is contained in:
committed by
Rémi Verschelde
parent
ecd12d2163
commit
a00465dee8
@@ -60,7 +60,7 @@ func _connected_fail():
|
||||
|
||||
|
||||
# Lobby management functions.
|
||||
@rpc(any_peer)
|
||||
@rpc("any_peer")
|
||||
func register_player(new_player_name):
|
||||
var id = multiplayer.get_remote_sender_id()
|
||||
players[id] = new_player_name
|
||||
@@ -72,7 +72,7 @@ func unregister_player(id):
|
||||
player_list_changed.emit()
|
||||
|
||||
|
||||
@rpc(call_local)
|
||||
@rpc("call_local")
|
||||
func load_world():
|
||||
# Change scene.
|
||||
var world = load("res://world.tscn").instantiate()
|
||||
|
||||
@@ -67,7 +67,7 @@ func set_player_name(value):
|
||||
get_node("label").text = value
|
||||
|
||||
|
||||
@rpc(call_local)
|
||||
@rpc("call_local")
|
||||
func exploded(_by_who):
|
||||
if stunned:
|
||||
return
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@rpc(call_local)
|
||||
@rpc("call_local")
|
||||
func exploded(by_who):
|
||||
$"../../Score".increase_score(by_who)
|
||||
$"AnimationPlayer".play("explode")
|
||||
|
||||
@@ -41,7 +41,8 @@ func _process(delta):
|
||||
_reset_ball.rpc(true)
|
||||
|
||||
|
||||
@rpc(any_peer, call_local) func bounce(left, random):
|
||||
@rpc("any_peer", "call_local")
|
||||
func bounce(left, random):
|
||||
# Using sync because both players can make it bounce.
|
||||
if left:
|
||||
direction.x = abs(direction.x)
|
||||
@@ -53,11 +54,13 @@ func _process(delta):
|
||||
direction = direction.normalized()
|
||||
|
||||
|
||||
@rpc(any_peer, call_local) func stop():
|
||||
@rpc("any_peer", "call_local")
|
||||
func stop():
|
||||
stopped = true
|
||||
|
||||
|
||||
@rpc(any_peer, call_local) func _reset_ball(for_left):
|
||||
@rpc("any_peer", "call_local")
|
||||
func _reset_ball(for_left):
|
||||
position = _screen_size / 2
|
||||
if for_left:
|
||||
direction = Vector2.LEFT
|
||||
|
||||
@@ -33,7 +33,8 @@ func _process(delta):
|
||||
|
||||
|
||||
# Synchronize position and speed to the other peers.
|
||||
@rpc(unreliable) func set_pos_and_motion(pos, motion):
|
||||
@rpc("unreliable")
|
||||
func set_pos_and_motion(pos, motion):
|
||||
position = pos
|
||||
_motion = motion
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ func _ready():
|
||||
print("Unique id: ", multiplayer.get_unique_id())
|
||||
|
||||
|
||||
@rpc(any_peer, call_local) func update_score(add_to_left):
|
||||
@rpc("any_peer", "call_local")
|
||||
func update_score(add_to_left):
|
||||
if add_to_left:
|
||||
score_left += 1
|
||||
score_left_node.set_text(str(score_left))
|
||||
|
||||
@@ -18,7 +18,7 @@ func _ready():
|
||||
multiplayer.peer_disconnected.connect(self._mp_peer_disconnected)
|
||||
|
||||
|
||||
@rpc(any_peer, call_local)
|
||||
@rpc("any_peer", "call_local")
|
||||
func ping(argument):
|
||||
_log("[Multiplayer] Ping from peer %d: arg: %s" % [multiplayer.get_remote_sender_id(), argument])
|
||||
|
||||
|
||||
@@ -10,24 +10,28 @@ const ACTIONS = ["roll", "pass"]
|
||||
var _players = []
|
||||
var _turn = -1
|
||||
|
||||
@rpc func _log(what):
|
||||
@rpc
|
||||
func _log(what):
|
||||
$HBoxContainer/RichTextLabel.add_text(what + "\n")
|
||||
|
||||
|
||||
@rpc(any_peer) func set_player_name(name):
|
||||
@rpc("any_peer")
|
||||
func set_player_name(name):
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
var sender = multiplayer.get_remote_sender_id()
|
||||
update_player_name.rpc(sender, name)
|
||||
|
||||
|
||||
@rpc(call_local) func update_player_name(player, name):
|
||||
@rpc("call_local")
|
||||
func update_player_name(player, name):
|
||||
var pos = _players.find(player)
|
||||
if pos != -1:
|
||||
_list.set_item_text(pos, name)
|
||||
|
||||
|
||||
@rpc(any_peer) func request_action(action):
|
||||
@rpc("any_peer")
|
||||
func request_action(action):
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
var sender = multiplayer.get_remote_sender_id()
|
||||
@@ -48,7 +52,8 @@ func do_action(action):
|
||||
_log.rpc("%s: %ss %d" % [player_name, action, val])
|
||||
|
||||
|
||||
@rpc(call_local) func set_turn(turn):
|
||||
@rpc("call_local")
|
||||
func set_turn(turn):
|
||||
_turn = turn
|
||||
if turn >= _players.size():
|
||||
return
|
||||
@@ -60,7 +65,8 @@ func do_action(action):
|
||||
_action.disabled = _players[turn] != multiplayer.get_unique_id()
|
||||
|
||||
|
||||
@rpc(call_local) func del_player(id):
|
||||
@rpc("call_local")
|
||||
func del_player(id):
|
||||
var pos = _players.find(id)
|
||||
if pos == -1:
|
||||
return
|
||||
@@ -72,7 +78,8 @@ func do_action(action):
|
||||
set_turn.rpc(_turn)
|
||||
|
||||
|
||||
@rpc(call_local) func add_player(id, pname=""):
|
||||
@rpc("call_local")
|
||||
func add_player(id, pname=""):
|
||||
_players.append(id)
|
||||
if pname == "":
|
||||
_list.add_item("... connecting ...", null, false)
|
||||
|
||||
Reference in New Issue
Block a user