push project up sabs assets
This commit is contained in:
7
globals/globals.gd
Normal file
7
globals/globals.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
extends Node
|
||||
|
||||
|
||||
var game_data: GameData
|
||||
var game_state: GameState
|
||||
var lobby_data: LobbyData
|
||||
var multiplayer_data: MultiplayerData
|
||||
1
globals/globals.gd.uid
Normal file
1
globals/globals.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://biu64hvcxb1su
|
||||
40
globals/message_bus.gd
Normal file
40
globals/message_bus.gd
Normal file
@@ -0,0 +1,40 @@
|
||||
extends Node
|
||||
|
||||
|
||||
var message_types: Dictionary[String, Array] = {}
|
||||
|
||||
|
||||
func subscribe(id: String, callback: Callable) -> void:
|
||||
var listeners: Array = message_types.get(id)
|
||||
|
||||
if not listeners:
|
||||
message_types.set(id, Array())
|
||||
listeners = message_types.get(id)
|
||||
|
||||
listeners.append(callback)
|
||||
|
||||
|
||||
func emit(id: String, data: Variant) -> void:
|
||||
emit_propagation(id, data)
|
||||
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
func emit_request(id: String, data: Variant) -> void:
|
||||
var listeners: Array = message_types.get(id)
|
||||
if not listeners:
|
||||
push_error("'%s' not an existing message type to send...", [id])
|
||||
return
|
||||
|
||||
emit_propagation(id, data)
|
||||
for peer_id in multiplayer.get_peers():
|
||||
emit_propagation.rpc_id(peer_id, id, data)
|
||||
|
||||
@rpc("authority", "call_remote", "reliable")
|
||||
func emit_propagation(id: String, data: Variant) -> void:
|
||||
var listeners: Array = message_types.get(id)
|
||||
if not listeners:
|
||||
push_error("'%s' not an existing message type to send...", [id])
|
||||
return
|
||||
|
||||
for callback: Callable in listeners:
|
||||
callback.call(data)
|
||||
1
globals/message_bus.gd.uid
Normal file
1
globals/message_bus.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dgkbelaqw2a2g
|
||||
Reference in New Issue
Block a user