mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Work on fixing networking.
This commit is contained in:
parent
7e420f538d
commit
67b3ce48f5
@ -358,11 +358,7 @@ func player_fly(delta : float) -> void:
|
||||
|
||||
move_and_slide(vel)
|
||||
|
||||
if multiplayer.has_network_peer():
|
||||
if not multiplayer.is_network_server():
|
||||
rpc_id(1, "sset_position", translation, rotation)
|
||||
else:
|
||||
sset_position(translation, rotation)
|
||||
crequest_set_position(translation, rotation)
|
||||
|
||||
|
||||
func player_walk(delta : float) -> void:
|
||||
@ -443,11 +439,7 @@ func player_walk(delta : float) -> void:
|
||||
# foot_audio.play()
|
||||
# last_sound_timer = 0
|
||||
|
||||
if multiplayer.has_network_peer():
|
||||
if not multiplayer.is_network_server():
|
||||
rpc_id(1, "sset_position", translation, rotation)
|
||||
else:
|
||||
sset_position(translation, rotation)
|
||||
crequest_set_position(translation, rotation)
|
||||
|
||||
|
||||
func process_movement_mob(delta : float) -> void:
|
||||
@ -529,7 +521,7 @@ func process_movement_mob(delta : float) -> void:
|
||||
facing.y = 0
|
||||
|
||||
vel = move_and_slide(vel, Vector3(0,1,0), true, 4, MAX_SLOPE_ANGLE)
|
||||
sset_position(translation, rotation)
|
||||
crequest_set_position(translation, rotation)
|
||||
|
||||
if vel.length_squared() < 0.12:
|
||||
sleep = true
|
||||
@ -721,18 +713,28 @@ func analog_force_change(vector, touchpad):
|
||||
func queue_camera_rotation(rot : Vector2) -> void:
|
||||
queued_camera_rotaions += rot
|
||||
|
||||
remote func sset_position(position : Vector3, rotation : Vector3) -> void:
|
||||
func sset_position(position : Vector3, rotation : Vector3) -> void:
|
||||
if multiplayer.network_peer and multiplayer.is_network_server():
|
||||
entity.vrpc("cset_position", position, rotation)
|
||||
#todo re-enable after path errors are fixed
|
||||
#entity.vrpc("cset_position", position, rotation)
|
||||
|
||||
if _controlled:
|
||||
cset_position(position, rotation)
|
||||
|
||||
|
||||
#todo remove, it's only here temporarily for testing
|
||||
remote func sset_position_rec(position : Vector3, rotation : Vector3) -> void:
|
||||
sset_position(position, rotation)
|
||||
|
||||
remote func crequest_set_position(position : Vector3, rotation : Vector3) -> void:
|
||||
if multiplayer.network_peer && !multiplayer.is_network_server():
|
||||
rpc_id(1, "sset_position_rec", translation, rotation)
|
||||
else:
|
||||
sset_position(position, rotation)
|
||||
|
||||
remote func cset_position(position : Vector3, rotation : Vector3) -> void:
|
||||
translation = position
|
||||
rotation = rotation
|
||||
|
||||
|
||||
func on_notification_ccast(what : int, info : SpellCastInfo) -> void:
|
||||
if what == SpellEnums.NOTIFICATION_CAST_STARTED:
|
||||
if anim_node_state_machine != null and not casting_anim:
|
||||
|
@ -53,7 +53,7 @@ func on_network_peer_packet(id : int, packet : PoolByteArray) ->void:
|
||||
func spawn_for(player : Entity, target: Entity) -> void:
|
||||
Logger.info("spawnfor " + target.name)
|
||||
print("spawnfor " + target.name)
|
||||
rpc_id(player.get_network_master(), "creceive_spawn_for", to_json(target.to_dict()), target.name, target.get_transform_3d())
|
||||
rpc_id(player.get_network_master(), "creceive_spawn_for", to_json(target.to_dict()), target.name, target.get_transform_3d().origin)
|
||||
|
||||
func despawn_for(player : Entity, target: Entity) -> void:
|
||||
Logger.info("despawnfor " + target.name)
|
||||
@ -82,7 +82,7 @@ remote func creceive_despawn_for(path : NodePath) -> void:
|
||||
if ent:
|
||||
ent.queue_free()
|
||||
|
||||
puppet func spawn_owned_player(data : String, position : Vector3) -> Entity:
|
||||
remote func spawn_owned_player(data : String, position : Vector3) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
|
||||
createinfo.guid = _next_entity_guid
|
||||
@ -95,10 +95,13 @@ puppet func spawn_owned_player(data : String, position : Vector3) -> Entity:
|
||||
createinfo.transform.origin = position
|
||||
|
||||
ESS.request_entity_spawn(createinfo)
|
||||
|
||||
var e : Entity = createinfo.created_entity
|
||||
e.set_network_master(createinfo.network_owner)
|
||||
e.c_is_controlled = true
|
||||
|
||||
Logger.info("Player spawned ")
|
||||
|
||||
return createinfo.created_entity
|
||||
return e
|
||||
|
||||
func load_player(file_name : String, position : Vector3, network_owner : int) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
@ -131,8 +134,11 @@ func load_uploaded_character(data : String, position : Vector3, network_owner :
|
||||
createinfo.networked = false
|
||||
Logger.info("Player spawned ")
|
||||
ESS.request_entity_spawn(createinfo)
|
||||
|
||||
return createinfo.created_entity
|
||||
var e : Entity = createinfo.created_entity
|
||||
e.set_network_master(network_owner)
|
||||
rpc_id(network_owner, "spawn_owned_player", data, position)
|
||||
|
||||
return e
|
||||
|
||||
func spawn_player_for_menu(class_id : int, name : String, parent : Node) -> Entity:
|
||||
var createinfo : EntityCreateInfo = EntityCreateInfo.new()
|
||||
|
Loading…
Reference in New Issue
Block a user