Skip to main content

ClientWorld

Struct ClientWorld 

Source
pub struct ClientWorld {
    pub entities: BTreeMap<NetworkId, SabSlot>,
    pub player_network_id: Option<NetworkId>,
    pub latest_tick: u64,
    pub system_manifest: BTreeMap<String, String>,
    pub shared_world_ref: Option<usize>,
}
Expand description

A simplified client-side world that tracks entity states using SabSlot.

Fields§

§entities: BTreeMap<NetworkId, SabSlot>

Map of NetworkId to the last known authoritative state.

§player_network_id: Option<NetworkId>

The network ID of the player’s own ship, if known.

§latest_tick: u64

The latest tick received from the server.

§system_manifest: BTreeMap<String, String>

Manifest of system-wide metadata.

§shared_world_ref: Option<usize>

Optional shared world to push room bounds into directly (stored as usize for Send/Sync).

Implementations§

Source§

impl ClientWorld

Source

pub fn new() -> Self

Creates a new, empty ClientWorld.

Source§

impl ClientWorld

Source

pub fn handle_game_event(&mut self, event: &GameEvent)

Handles discrete game events from the server.

Source§

impl ClientWorld

Source

pub fn playground_apply_input( &mut self, move_x: f32, move_y: f32, actions_mask: u32, )

Applies playground input to the local player entity. Used for Sandbox mode simulation.

Trait Implementations§

Source§

impl Debug for ClientWorld

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClientWorld

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl WorldState for ClientWorld

Source§

fn get_local_id(&self, network_id: NetworkId) -> Option<LocalId>

Maps a protocol-level NetworkId to the ECS’s local entity handle. Read more
Source§

fn get_network_id(&self, local_id: LocalId) -> Option<NetworkId>

Maps a local ECS entity handle back to its protocol-level NetworkId. Read more
Source§

fn extract_deltas(&mut self) -> Vec<ReplicationEvent>

Extracts replication deltas for all components modified since the last tick. Read more
Source§

fn apply_updates(&mut self, updates: &[(ClientId, ComponentUpdate)])

Injects parsed state updates from the network into the ECS. Read more
Source§

fn simulate(&mut self)

Runs a single simulation frame for the ECS.
Source§

fn spawn_networked(&mut self) -> NetworkId

Spawns a new network-replicated entity and returns its NetworkId.
Source§

fn spawn_networked_for(&mut self, _client_id: ClientId) -> NetworkId

Spawns a new network-replicated entity owned by a specific client.
Source§

fn despawn_networked(&mut self, network_id: NetworkId) -> Result<(), WorldError>

Despawn a network-replicated entity by its NetworkId. Read more
Source§

fn stress_test(&mut self, _count: u16, _rotate: bool)

Triggers a bulk spawn of entities for stress testing.
Source§

fn spawn_kind(&mut self, _kind: u16, _x: f32, _y: f32, _rot: f32) -> NetworkId

Spawns a new network-replicated entity of a specific kind.
Source§

fn clear_world(&mut self)

Despawns all entities from the world.
Source§

fn extract_reliable_events(&mut self) -> Vec<(Option<ClientId>, WireEvent)>

Extracts discrete game events that should be sent reliably. Read more
Source§

fn advance_tick(&mut self)

Advances the world change tick at the start of each server tick, before inputs are applied.
Source§

fn post_extract(&mut self)

Called once per tick after extract_deltas, before the next advance_tick. Read more
Source§

fn spawn_kind_for( &mut self, kind: u16, x: f32, y: f32, rot: f32, _client_id: ClientId, ) -> NetworkId

Spawns a new network-replicated entity of a specific kind for a specific client.
Source§

fn spawn_session_ship( &mut self, kind: u16, x: f32, y: f32, rot: f32, client_id: ClientId, ) -> NetworkId

Spawns the authoritative session ship for a client and marks it as the possession target. Read more
Source§

fn queue_reliable_event( &mut self, _client_id: Option<ClientId>, _event: GameEvent, )

Queues a reliable game event to be sent to a specific client (or all if None).
Source§

fn setup_world(&mut self)

Setups the initial world state (e.g. Master Room).
Source§

fn get_entity_room(&self, _network_id: NetworkId) -> Option<NetworkId>

Returns the Room network_id for a given entity, if any.
Source§

fn get_client_room(&self, _client_id: ClientId) -> Option<NetworkId>

Returns the Room network_id for a client’s session ship, if any.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> GameTransportBounds for T
where T: Send + ?Sized,