35 lines
916 B
GDScript
35 lines
916 B
GDScript
extends Node
|
|
|
|
enum TEAMS {
|
|
DEFENCE,
|
|
ATTACK,
|
|
SPECTATE,
|
|
UNASSIGNED
|
|
}
|
|
|
|
var dynamic_objects_spawner: MultiplayerSpawner
|
|
|
|
func spawn(data: Dictionary) -> void:
|
|
spawn_internal.rpc_id(1,data)
|
|
|
|
@rpc("any_peer","call_local","reliable")
|
|
func spawn_internal(data: Dictionary) -> void:
|
|
if multiplayer.is_server() == false:
|
|
printerr(str(multiplayer.get_remote_sender_id())+" tried to spawn internally on "+str(multiplayer.get_unique_id()))
|
|
return
|
|
|
|
var object = dynamic_objects_spawner.spawn(data)
|
|
|
|
if data.has("position"):
|
|
object.global_position = data.position
|
|
|
|
func despawn(path: NodePath):
|
|
despawn_internal.rpc_id(1,path)
|
|
|
|
@rpc("any_peer","call_local","reliable")
|
|
func despawn_internal(path: NodePath) -> void:
|
|
if multiplayer.is_server() == false:
|
|
printerr(str(multiplayer.get_remote_sender_id())+" tried to despawn internally on "+str(multiplayer.get_unique_id()))
|
|
return
|
|
|
|
get_node(path).queue_free()
|