Add portable RV homes and decor prototype
This commit is contained in:
parent
81decf2b71
commit
fe099f47dd
56 changed files with 5459 additions and 112 deletions
|
|
@ -141,6 +141,7 @@ var _last_server_protocol_version: int = 0
|
|||
var _last_server_world_seed: int = NetworkProtocol.DEFAULT_WORLD_SEED
|
||||
var _last_server_world_layout: StringName = WorldLayout.GENERATED
|
||||
var _server_capabilities: PackedStringArray = PackedStringArray()
|
||||
var _peer_space_ids: Dictionary[int, StringName] = {}
|
||||
var _profile_ready: bool = false
|
||||
var _player_identity: PlayerIdentityStore
|
||||
var _host_identity: HostIdentityStore
|
||||
|
|
@ -334,6 +335,7 @@ func _register_player_host() -> void:
|
|||
NetworkProtocol.FRIENDS_CAPABILITY,
|
||||
NetworkProtocol.MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
NetworkProtocol.FISHING_REPLICATION_CAPABILITY,
|
||||
NetworkProtocol.HOME_CAPABILITY,
|
||||
]),
|
||||
)
|
||||
_registry.update_appearance(1, _local_appearance_snapshot)
|
||||
|
|
@ -661,6 +663,7 @@ func supports_server_capability(capability: StringName) -> bool:
|
|||
NetworkProtocol.FRIENDS_CAPABILITY,
|
||||
NetworkProtocol.MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
NetworkProtocol.FISHING_REPLICATION_CAPABILITY,
|
||||
NetworkProtocol.HOME_CAPABILITY,
|
||||
"chat_v1",
|
||||
"mail_v1",
|
||||
"profile_v1",
|
||||
|
|
@ -685,6 +688,21 @@ func get_authenticated_peer_ids() -> Array[int]:
|
|||
return _registry.get_peer_ids()
|
||||
|
||||
|
||||
func set_peer_space(peer_id: int, space_id: StringName) -> bool:
|
||||
if not _registry.has_peer(peer_id) or space_id.is_empty():
|
||||
return false
|
||||
_peer_space_ids[peer_id] = space_id
|
||||
return true
|
||||
|
||||
|
||||
func get_peer_space(peer_id: int) -> StringName:
|
||||
return _peer_space_ids.get(peer_id, &"world")
|
||||
|
||||
|
||||
func peers_share_space(first_peer_id: int, second_peer_id: int) -> bool:
|
||||
return get_peer_space(first_peer_id) == get_peer_space(second_peer_id)
|
||||
|
||||
|
||||
func get_peer_rtt_ms(peer_id: int) -> int:
|
||||
if peer_id == 1:
|
||||
return 0
|
||||
|
|
@ -1030,6 +1048,7 @@ func _on_peer_disconnected(peer_id: int) -> void:
|
|||
_pending_identity_challenges.erase(peer_id)
|
||||
_authenticated_identity_cache.erase(peer_id)
|
||||
_operator_peer_ids.erase(peer_id)
|
||||
_peer_space_ids.erase(peer_id)
|
||||
_last_animation_state_by_peer.erase(peer_id)
|
||||
_pending_animation_state_by_peer.erase(peer_id)
|
||||
var recovery_attempt: String = _recovery_attempts.get(peer_id, "")
|
||||
|
|
@ -1313,6 +1332,7 @@ func submit_client_hello(data: Dictionary) -> void:
|
|||
for required_capability: String in [
|
||||
NetworkProtocol.MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
NetworkProtocol.FISHING_REPLICATION_CAPABILITY,
|
||||
NetworkProtocol.HOME_CAPABILITY,
|
||||
]:
|
||||
if required_capability not in client_capabilities:
|
||||
_reject_peer(
|
||||
|
|
@ -1546,6 +1566,7 @@ func receive_server_hello(data: Dictionary) -> void:
|
|||
for required_capability: String in [
|
||||
NetworkProtocol.MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
NetworkProtocol.FISHING_REPLICATION_CAPABILITY,
|
||||
NetworkProtocol.HOME_CAPABILITY,
|
||||
]:
|
||||
if required_capability not in _server_capabilities:
|
||||
_teardown_peer()
|
||||
|
|
@ -1578,6 +1599,7 @@ func receive_server_hello(data: Dictionary) -> void:
|
|||
NetworkProtocol.FRIENDS_CAPABILITY,
|
||||
NetworkProtocol.MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
NetworkProtocol.FISHING_REPLICATION_CAPABILITY,
|
||||
NetworkProtocol.HOME_CAPABILITY,
|
||||
]),
|
||||
)
|
||||
_registry.update_appearance(local_peer_id, _local_appearance_snapshot)
|
||||
|
|
@ -1623,6 +1645,7 @@ func receive_peer_despawn(peer_id: int) -> void:
|
|||
if state != State.JOINED_CLIENT:
|
||||
return
|
||||
_operator_peer_ids.erase(peer_id)
|
||||
_peer_space_ids.erase(peer_id)
|
||||
_last_animation_state_by_peer.erase(peer_id)
|
||||
_pending_animation_state_by_peer.erase(peer_id)
|
||||
_registry.remove_peer(peer_id)
|
||||
|
|
@ -2247,6 +2270,8 @@ func _broadcast_movement_snapshots() -> void:
|
|||
continue
|
||||
var snapshots: Array = []
|
||||
for subject_id: int in peer_ids:
|
||||
if not peers_share_space(recipient_id, subject_id):
|
||||
continue
|
||||
var subject_avatar: Player = _spawn_service.get_avatar(subject_id)
|
||||
if subject_avatar == null:
|
||||
continue
|
||||
|
|
@ -2315,7 +2340,7 @@ func _broadcast_movement_animation_updates(peer_ids: Array[int]) -> void:
|
|||
_animation_refresh_accumulator,
|
||||
ANIMATION_REFRESH_INTERVAL,
|
||||
)
|
||||
var updates: Array = []
|
||||
var updates_by_subject: Dictionary[int, Array] = {}
|
||||
for subject_id: int in peer_ids:
|
||||
var avatar: Player = _spawn_service.get_avatar(subject_id)
|
||||
if avatar == null:
|
||||
|
|
@ -2333,12 +2358,18 @@ func _broadcast_movement_animation_updates(peer_ids: Array[int]) -> void:
|
|||
_last_animation_state_by_peer[subject_id] = state.duplicate(true)
|
||||
var encoded: Array = _encode_movement_animation(subject_id, state)
|
||||
if not encoded.is_empty():
|
||||
updates.append(encoded)
|
||||
if updates.is_empty():
|
||||
updates_by_subject[subject_id] = encoded
|
||||
if updates_by_subject.is_empty():
|
||||
return
|
||||
for recipient_id: int in peer_ids:
|
||||
if recipient_id == 1:
|
||||
continue
|
||||
var updates: Array = []
|
||||
for subject_id: int in updates_by_subject:
|
||||
if peers_share_space(recipient_id, subject_id):
|
||||
updates.append(updates_by_subject[subject_id])
|
||||
if updates.is_empty():
|
||||
continue
|
||||
receive_movement_animations.rpc_id(recipient_id, updates)
|
||||
_movement_animation_packets_sent += 1
|
||||
_movement_animation_states_sent += updates.size()
|
||||
|
|
@ -2888,6 +2919,7 @@ func _teardown_peer() -> void:
|
|||
_pending_animation_state_by_peer.clear()
|
||||
_last_local_animation_action_signature.clear()
|
||||
_server_capabilities = PackedStringArray()
|
||||
_peer_space_ids.clear()
|
||||
_server_identity_fingerprint = ""
|
||||
_server_identity_public_key = ""
|
||||
_session_identity_keys.clear()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue