extends MultiplayerSpawner

func _ready() -> void:
	spawn_function = request_spawn
	Session.dynamic_objects_spawner = self

func request_spawn(data: Variant) -> Node:
	if  data.has("scene") == false:
		return Node.new()
	var node = load(data.scene).instantiate()
	if data.has("impulse"):
		if data.has_all(["ammo","remaining_ammo","slot"]):
			node.weapon.ammo = data.ammo
			node.weapon.remaining_ammo = data.remaining_ammo
			node.slot = data.slot
		
		node.apply_impulse(data.impulse)
		
	for key in data.keys():
		if key in ["scene","ammo","remaining_ammo","slot","position","rotation"]:
			continue
		node.set(key,data[key])
	return node
	
