mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Work on fixing networking. Fixed hosting, and character uploading.
This commit is contained in:
parent
71d2cf0358
commit
00711977d4
@ -56,6 +56,10 @@ func start_hosting(p_port : int = 0) -> int:
|
|||||||
|
|
||||||
var peer : NetworkedMultiplayerENet = NetworkedMultiplayerENet.new()
|
var peer : NetworkedMultiplayerENet = NetworkedMultiplayerENet.new()
|
||||||
var err : int = peer.create_server(p_port, 32)
|
var err : int = peer.create_server(p_port, 32)
|
||||||
|
|
||||||
|
if err:
|
||||||
|
return err
|
||||||
|
|
||||||
get_tree().set_network_peer(peer)
|
get_tree().set_network_peer(peer)
|
||||||
|
|
||||||
_connected_to_server()
|
_connected_to_server()
|
||||||
@ -185,7 +189,7 @@ remotesync func cspawn_player(info : Dictionary, sid : int, pos : Vector3):
|
|||||||
Logger.verbose("NetworkManager cspawn_player")
|
Logger.verbose("NetworkManager cspawn_player")
|
||||||
|
|
||||||
if sid == get_tree().get_network_unique_id():
|
if sid == get_tree().get_network_unique_id():
|
||||||
local_player_master.player = ESS.get_ess_entity_spawner().spawn_player(info["selected_class"] as int, pos, info["name"] as String, str(sid), sid)
|
local_player_master.player = ESS.entity_spawner.spawn_player(info["selected_class"] as int, pos, info["name"] as String, str(sid), sid)
|
||||||
call_deferred("set_terrarin_player")
|
call_deferred("set_terrarin_player")
|
||||||
|
|
||||||
if get_tree().is_network_server() and not splayers_dict.has(sid):
|
if get_tree().is_network_server() and not splayers_dict.has(sid):
|
||||||
@ -195,7 +199,7 @@ remotesync func cspawn_player(info : Dictionary, sid : int, pos : Vector3):
|
|||||||
var pm : PlayerMaster = PlayerMaster.new()
|
var pm : PlayerMaster = PlayerMaster.new()
|
||||||
pm.sid = sid
|
pm.sid = sid
|
||||||
|
|
||||||
pm.player = ESS.get_ess_entity_spawner().spawn_networked_player(info["selected_class"] as int, pos, info["name"] as String, str(sid), sid)
|
pm.player = ESS.entity_spawner.spawn_networked_player(info["selected_class"] as int, pos, info["name"] as String, str(sid), sid)
|
||||||
|
|
||||||
if get_tree().is_network_server() and not splayers_dict.has(sid):
|
if get_tree().is_network_server() and not splayers_dict.has(sid):
|
||||||
splayers_dict[sid] = pm
|
splayers_dict[sid] = pm
|
||||||
@ -209,11 +213,11 @@ func upload_character(data : String) -> void:
|
|||||||
rpc_id(1, "sreceive_upload_character", data)
|
rpc_id(1, "sreceive_upload_character", data)
|
||||||
|
|
||||||
master func sreceive_upload_character(data: String) -> void:
|
master func sreceive_upload_character(data: String) -> void:
|
||||||
ESS.get_ess_entity_spawner().spawn_networked_player_from_data(data, Vector3(0, 10, 0), multiplayer.get_rpc_sender_id())
|
ESS.entity_spawner.load_uploaded_character(data, Vector3(0, 10, 0), multiplayer.get_rpc_sender_id())
|
||||||
|
|
||||||
func set_terrarin_player():
|
func set_terrarin_player():
|
||||||
Logger.verbose("NetworkManager cspawn_player")
|
Logger.verbose("NetworkManager cspawn_player")
|
||||||
|
|
||||||
var terrarin : TerraWorld = get_node("/root/GameScene/VoxelWorld")
|
var terrarin : TerraWorld = get_node("/root/main/World")
|
||||||
|
|
||||||
terrarin.set_player(local_player_master.player.get_body() as Spatial)
|
terrarin.set_player(local_player_master.player.get_body() as Spatial)
|
||||||
|
@ -52,11 +52,11 @@ func on_network_peer_packet(id : int, packet : PoolByteArray) ->void:
|
|||||||
|
|
||||||
func spawn_for(player : Entity, target: Entity) -> void:
|
func spawn_for(player : Entity, target: Entity) -> void:
|
||||||
Logger.info("spawnfor " + target.name)
|
Logger.info("spawnfor " + target.name)
|
||||||
# rpc_id(player.get_network_master(), "creceive_spawn_for", to_json(target.to_dict()), target.name, target.translation)
|
rpc_id(player.get_network_master(), "creceive_spawn_for", to_json(target.to_dict()), target.name, target.translation)
|
||||||
|
|
||||||
func despawn_for(player : Entity, target: Entity) -> void:
|
func despawn_for(player : Entity, target: Entity) -> void:
|
||||||
Logger.info("despawnfor " + target.name)
|
Logger.info("despawnfor " + target.name)
|
||||||
# rpc_id(player.get_network_master(), "creceive_despawn_for", target.get_path())
|
rpc_id(player.get_network_master(), "creceive_despawn_for", target.get_path())
|
||||||
|
|
||||||
remote func creceive_spawn_for(data: String, global_name : String, position: Vector3) -> Entity:
|
remote func creceive_spawn_for(data: String, global_name : String, position: Vector3) -> Entity:
|
||||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||||
@ -112,6 +112,22 @@ func load_player(file_name : String, position : Vector3, network_owner : int) ->
|
|||||||
|
|
||||||
return createinfo.created_entity
|
return createinfo.created_entity
|
||||||
|
|
||||||
|
func load_uploaded_character(data : String, position : Vector3, network_owner : int) -> Entity:
|
||||||
|
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||||
|
|
||||||
|
createinfo.guid = _next_entity_guid
|
||||||
|
_next_entity_guid += 1
|
||||||
|
# createinfo.player_name = name
|
||||||
|
createinfo.entity_controller = EntityEnums.ENITIY_CONTROLLER_PLAYER
|
||||||
|
createinfo.entity_player_type = EntityEnums.ENTITY_PLAYER_TYPE_PLAYER
|
||||||
|
createinfo.serialized_data = parse_json(data)
|
||||||
|
createinfo.transform.origin = position
|
||||||
|
createinfo.networked = false
|
||||||
|
Logger.info("Player spawned ")
|
||||||
|
ESS.request_entity_spawn(createinfo)
|
||||||
|
|
||||||
|
return createinfo.created_entity
|
||||||
|
|
||||||
func spawn_player_for_menu(class_id : int, name : String, parent : Node) -> Entity:
|
func spawn_player_for_menu(class_id : int, name : String, parent : Node) -> Entity:
|
||||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||||
var cls : EntityData = ESS.resource_db.get_entity_data(class_id)
|
var cls : EntityData = ESS.resource_db.get_entity_data(class_id)
|
||||||
|
@ -108,3 +108,5 @@ func show_loading_screen() -> void:
|
|||||||
func hide_loading_screen() -> void:
|
func hide_loading_screen() -> void:
|
||||||
_loading_screen.hide()
|
_loading_screen.hide()
|
||||||
|
|
||||||
|
func switch_scene_to_world() -> void:
|
||||||
|
switch_scene(StartSceneTypes.WORLD)
|
||||||
|
Loading…
Reference in New Issue
Block a user