Skip to main content

LocalWorldManager

Struct LocalWorldManager 

Source
pub struct LocalWorldManager { /* private fields */ }
Expand description

Unified manager for one connection’s host-side and remote-side entity state, routing commands and events between them.

Implementations§

Source§

impl LocalWorldManager

Source

pub fn new( address: &Option<SocketAddr>, host_type: HostType, user_key: u64, global_world_manager: &dyn GlobalWorldManagerType, ) -> Self

Creates a LocalWorldManager for the given address, host type, user key, and global world manager reference.

Source

pub fn entity_converter(&self) -> &dyn LocalEntityAndGlobalEntityConverter

Returns a read-only entity converter backed by the internal entity map.

Source

pub fn entity_converter_mut<'a, 'b>( &'b mut self, global_world_manager: &'a dyn GlobalWorldManagerType, ) -> EntityConverterMut<'a, 'b>

Returns a mutable entity converter that can also allocate new host entity IDs.

Source

pub fn has_global_entity(&self, global_entity: &GlobalEntity) -> bool

Returns true if global_entity is currently tracked by either the host or remote engine.

Source

pub fn has_local_entity(&self, local_entity: &OwnedLocalEntity) -> bool

Returns true if local_entity is currently registered in its respective engine.

Source

pub fn get_host_entity_channel( &self, entity: &HostEntity, ) -> Option<&HostEntityChannel>

Get a reference to a HostEntityChannel (for testing)

Source

pub fn get_host_entity_channel_mut( &mut self, entity: &HostEntity, ) -> Option<&mut HostEntityChannel>

Get a mutable reference to a HostEntityChannel (for testing)

Source

pub fn has_host_entity(&self, host_entity: &HostEntity) -> bool

Returns true if host_entity is currently tracked by the host engine.

Source

pub fn host_init_entity( &mut self, global_entity: &GlobalEntity, component_kinds: Vec<ComponentKind>, component_kinds_map: &ComponentKinds, is_static: bool, )

Allocates a host entity ID and enqueues the initial spawn command(s) when global_entity enters connection scope.

Source

pub fn migrate_entity_remote_to_host( &mut self, global_entity: &GlobalEntity, ) -> Result<HostEntity, String>

BULLETPROOF: Migrate entity from remote (client) control to host (server) control

This method performs a complete, atomic migration of an entity from client control to server control, including:

  • Force-draining all buffered operations
  • Preserving component state
  • Installing entity redirects
  • Updating command references
  • Cleaning up old entity channels
§Errors

This method will panic if:

  • The entity doesn’t exist in the local entity map
  • The entity is not currently remote-owned
  • Any step of the migration process fails
§Safety

This method is designed to be atomic - either the entire migration succeeds or the system remains in a consistent state. No partial migrations are possible.

Source

pub fn host_send_enable_delegation(&mut self, global_entity: &GlobalEntity)

Sends an EnableDelegation command to the remote peer via the host engine.

Source

pub fn host_local_enable_delegation(&mut self, host_entity: &HostEntity)

Forces the HostEntityChannel for host_entity into the Delegated state locally without sending a wire message.

Source

pub fn host_send_migrate_response( &mut self, global_entity: &GlobalEntity, old_remote_entity: &RemoteEntity, new_host_entity: &HostEntity, )

Sends a MigrateResponse command to notify the peer that an entity has migrated to the server’s control.

Source

pub fn host_send_set_auth( &mut self, global_entity: &GlobalEntity, auth_status: EntityAuthStatus, )

Sends a SetAuthority command for global_entity with the given auth_status.

Source

pub fn host_reserve_entity( &mut self, global_entity: &GlobalEntity, ) -> HostEntity

Pre-allocates a HostEntity slot for global_entity before it is sent to the peer.

Source

pub fn host_remove_reserved_entity( &mut self, global_entity: &GlobalEntity, ) -> Option<HostEntity>

Removes and returns any previously reserved HostEntity for global_entity, if one exists.

Source

pub fn remote_entities(&self) -> Vec<GlobalEntity>

Returns the GlobalEntity list for all entities currently tracked as remote-owned.

Source

pub fn send_enable_delegation_response(&mut self, global_entity: &GlobalEntity)

Sends an EnableDelegationResponse acknowledgement to the server after receiving an EnableDelegation message.

Source

pub fn remote_send_request_auth(&mut self, global_entity: &GlobalEntity)

Sends a RequestAuthority command for global_entity via the remote engine.

Source

pub fn remote_receive_set_auth( &mut self, global_entity: &GlobalEntity, auth_status: EntityAuthStatus, )

Update the RemoteEntityChannel’s AuthChannel status (used after migration)

Source

pub fn get_remote_entity_auth_status( &self, global_entity: &GlobalEntity, ) -> Option<EntityAuthStatus>

Get auth status of a remote entity’s channel (for testing)

Source

pub fn entity_waitlist_mut(&mut self) -> &mut RemoteEntityWaitlist

Returns a mutable reference to the entity waitlist managed by the remote engine.

Source

pub fn receiver_buffer_message( &mut self, id: MessageIndex, msg: EntityMessage<OwnedLocalEntity>, )

Buffers an incoming entity message at the given sequence id for ordered delivery.

Source

pub fn take_incoming_events<E: Copy + Eq + Hash + Send + Sync, W: WorldMutType<E>>( &mut self, spawner: &mut dyn GlobalEntitySpawner<E>, global_world_manager: &dyn GlobalWorldManagerType, component_kinds: &ComponentKinds, world: &mut W, now: &Instant, ) -> Vec<EntityEvent>

Drains all buffered incoming messages and update events, applies them to world, and returns the resulting EntityEvents.

Source

pub fn register_authed_entity( &mut self, global_manager: &dyn GlobalWorldManagerType, global_entity: &GlobalEntity, )

Registers global_entity as authority-granted, enabling update tracking for its components.

Source

pub fn deregister_authed_entity( &mut self, global_manager: &dyn GlobalWorldManagerType, global_entity: &GlobalEntity, )

Deregisters global_entity from authority, stopping update tracking for its components.

Source

pub fn remote_spawn_entity(&mut self, global_entity: &GlobalEntity)

Notifies the remote waitlist that global_entity’s remote entity has been spawned.

Source

pub fn remote_despawn_entity(&mut self, global_entity: &GlobalEntity)

Despawns the remote entity mapped from global_entity and cleans up the entity map.

Source

pub fn despawn_entity(&mut self, global_entity: &GlobalEntity)

Sends a Despawn command for global_entity through whichever engine owns it.

Source

pub fn pause_entity(&mut self, global_entity: &GlobalEntity)

Pause replication for a ScopeExit::Persist entity that has left scope. The entity stays in the client’s entity pool; no further updates are sent until resume_entity is called on re-entry.

Source

pub fn resume_entity(&mut self, global_entity: &GlobalEntity)

Resume replication for a paused ScopeExit::Persist entity that has re-entered scope. Accumulated deltas will be delivered on the next update cycle.

Source

pub fn is_entity_paused(&self, global_entity: &GlobalEntity) -> bool

Returns true if global_entity is currently paused (scope-exited with ScopeExit::Persist).

Source

pub fn insert_component( &mut self, global_entity: &GlobalEntity, component_kind: &ComponentKind, )

Sends an InsertComponent command for global_entity, routing through host or remote engine as appropriate.

Source

pub fn remove_component( &mut self, global_entity: &GlobalEntity, component_kind: &ComponentKind, )

Sends a RemoveComponent command for global_entity, routing through host or remote engine as appropriate.

Source

pub fn send_publish( &mut self, host_type: HostType, global_entity: &GlobalEntity, )

Sends a Publish command for global_entity, routing through host or remote engine based on ownership.

Source

pub fn send_unpublish( &mut self, host_type: HostType, global_entity: &GlobalEntity, )

Sends an Unpublish command for global_entity, routing through host or remote engine based on ownership.

Source

pub fn send_enable_delegation( &mut self, host_type: HostType, origin_is_owning_client: bool, global_entity: &GlobalEntity, )

Sends an EnableDelegation command (with optional preceding Publish) for global_entity.

Source

pub fn send_disable_delegation(&mut self, global_entity: &GlobalEntity)

Sends a DisableDelegation command for global_entity via the host engine.

Source

pub fn remote_send_release_auth(&mut self, global_entity: &GlobalEntity)

Sends a ReleaseAuthority command for global_entity, routing through whichever engine owns it.

Source

pub fn collect_messages(&mut self, now: &Instant, rtt_millis: &f32)

Processes dropped packet TTLs and handles update-packet retransmit logic for the current tick.

Source

pub fn take_outgoing_events<E: Copy + Eq + Hash + Send + Sync, W: WorldRefType<E>>( &mut self, now: &Instant, rtt_millis: &f32, world: &W, converter: &dyn EntityAndGlobalEntityConverter<E>, global_world_manager: &dyn GlobalWorldManagerType, ) -> (VecDeque<(MessageIndex, EntityCommand)>, HashMap<GlobalEntity, HashSet<ComponentKind>>)

Collects pending outbound commands and component-update events, returning them as a pair of command queue and dirty-component map.

Source

pub fn process_delivered_commands(&mut self)

Advances the delivery state machine, applying any newly acknowledged host-side commands to the delivered engine.

Source

pub fn take_update_events<E: Copy + Eq + Hash + Send + Sync, W: WorldRefType<E>>( &mut self, world: &W, world_converter: &dyn EntityAndGlobalEntityConverter<E>, global_world_manager: &dyn GlobalWorldManagerType, ) -> HashMap<GlobalEntity, HashSet<ComponentKind>>

Builds the dirty-component map for the current tick from mutation receivers and the world state.

Source

pub fn get_message_processor_helpers( &mut self, ) -> (&dyn LocalEntityAndGlobalEntityConverter, &mut RemoteEntityWaitlist)

Returns the entity converter and entity waitlist as a pair, used during message deserialization.

Source

pub fn update_sent_command_entity_refs( &mut self, _global_entity: &GlobalEntity, old_entity: OwnedLocalEntity, new_entity: OwnedLocalEntity, )

Patches all in-flight command packets to replace old_entity references with new_entity.

Source

pub fn extract_host_entity_commands( &mut self, global_entity: &GlobalEntity, ) -> Vec<EntityCommand>

Extracts and returns all pending EntityCommands from the host engine channel for global_entity.

Source

pub fn extract_host_component_kinds( &self, global_entity: &GlobalEntity, ) -> HashSet<ComponentKind>

Returns the set of component kinds currently registered on the host engine channel for global_entity.

Source

pub fn remove_host_entity(&mut self, global_entity: &GlobalEntity)

Removes the host engine channel and entity map entry for global_entity.

Source

pub fn insert_remote_entity( &mut self, global_entity: &GlobalEntity, remote_entity: RemoteEntity, component_kinds: HashSet<ComponentKind>, )

Registers a remote entity migrated from the host side into the remote engine with an initial component set.

Source

pub fn install_entity_redirect( &mut self, old: OwnedLocalEntity, new: OwnedLocalEntity, )

Installs a redirect so lookups of old transparently resolve to new for a TTL period.

Source

pub fn apply_entity_redirect( &self, entity: OwnedLocalEntity, ) -> OwnedLocalEntity

Returns the redirected entity for entity if a redirect is installed, otherwise returns entity unchanged.

Source

pub fn replay_entity_command( &mut self, global_entity: &GlobalEntity, command: EntityCommand, )

Re-submits command for global_entity through the remote engine after a migration.

Trait Implementations§

Source§

impl PacketNotifiable for LocalWorldManager

Source§

fn notify_packet_delivered(&mut self, packet_index: PacketIndex)

Notifies the manager that a packet has been delivered

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V