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>,
pub input_history: VecDeque<InputRecord>,
pub last_reconciled_tick: u64,
pub prediction_enabled: bool,
pub room_bounds: Option<RoomBounds>,
}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: u64The latest tick received from the server.
system_manifest: BTreeMap<String, String>Manifest of system-wide metadata.
Optional shared world to push room bounds into directly (stored as usize for Send/Sync).
input_history: VecDeque<InputRecord>History of inputs applied for Client-Side Prediction reconciliation.
last_reconciled_tick: u64The latest server tick that has been reconciled.
prediction_enabled: boolWhen true, the client simulates input locally and replays unacknowledged inputs
on top of server snapshots (client-side prediction + reconciliation).
When false, the client is pure server-authority: position is only updated from
server transforms and no local simulation is performed for the local player.
room_bounds: Option<RoomBounds>Authoritative world boundaries received from the server. Used for toroidal wrapping in Sandbox mode.
Implementations§
Source§impl ClientWorld
impl ClientWorld
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty ClientWorld.
prediction_enabled controls whether client-side prediction is active.
Pass false for pure server-authority mode (recommended during debugging).
Pass true to enable local simulation + reconciliation for responsive feel.
Sourcepub fn with_prediction(prediction_enabled: bool) -> Self
pub fn with_prediction(prediction_enabled: bool) -> Self
Creates a ClientWorld with explicit prediction setting.
Source§impl ClientWorld
impl ClientWorld
Sourcepub fn handle_game_event(&mut self, event: &GameEvent)
pub fn handle_game_event(&mut self, event: &GameEvent)
Handles discrete game events from the server.
Source§impl ClientWorld
impl ClientWorld
Trait Implementations§
Source§impl Debug for ClientWorld
impl Debug for ClientWorld
Source§impl Default for ClientWorld
impl Default for ClientWorld
Source§impl WorldState for ClientWorld
impl WorldState for ClientWorld
Source§fn get_local_id(&self, network_id: NetworkId) -> Option<LocalId>
fn get_local_id(&self, network_id: NetworkId) -> Option<LocalId>
NetworkId to the ECS’s local entity handle. Read moreSource§fn get_network_id(&self, local_id: LocalId) -> Option<NetworkId>
fn get_network_id(&self, local_id: LocalId) -> Option<NetworkId>
NetworkId. Read moreSource§fn extract_deltas(&mut self) -> Vec<ReplicationEvent>
fn extract_deltas(&mut self) -> Vec<ReplicationEvent>
Source§fn apply_updates(&mut self, updates: &[(ClientId, ComponentUpdate)])
fn apply_updates(&mut self, updates: &[(ClientId, ComponentUpdate)])
Source§fn spawn_networked(&mut self) -> NetworkId
fn spawn_networked(&mut self) -> NetworkId
NetworkId.Source§fn spawn_networked_for(&mut self, _client_id: ClientId) -> NetworkId
fn spawn_networked_for(&mut self, _client_id: ClientId) -> NetworkId
Source§fn despawn_networked(&mut self, network_id: NetworkId) -> Result<(), WorldError>
fn despawn_networked(&mut self, network_id: NetworkId) -> Result<(), WorldError>
NetworkId. Read moreSource§fn stress_test(&mut self, _count: u16, _rotate: bool)
fn stress_test(&mut self, _count: u16, _rotate: bool)
Source§fn spawn_kind(&mut self, _kind: u16, _x: f32, _y: f32, _rot: f32) -> NetworkId
fn spawn_kind(&mut self, _kind: u16, _x: f32, _y: f32, _rot: f32) -> NetworkId
Source§fn clear_world(&mut self)
fn clear_world(&mut self)
Source§fn state_hash(&self) -> u64
fn state_hash(&self) -> u64
Source§fn extract_reliable_events(&mut self) -> Vec<(Option<ClientId>, WireEvent)>
fn extract_reliable_events(&mut self) -> Vec<(Option<ClientId>, WireEvent)>
Source§fn advance_tick(&mut self)
fn advance_tick(&mut self)
Source§fn post_extract(&mut self)
fn post_extract(&mut self)
Source§fn spawn_kind_for(
&mut self,
kind: u16,
x: f32,
y: f32,
rot: f32,
_client_id: ClientId,
) -> NetworkId
fn spawn_kind_for( &mut self, kind: u16, x: f32, y: f32, rot: f32, _client_id: ClientId, ) -> NetworkId
Source§fn spawn_session_ship(
&mut self,
kind: u16,
x: f32,
y: f32,
rot: f32,
client_id: ClientId,
) -> NetworkId
fn spawn_session_ship( &mut self, kind: u16, x: f32, y: f32, rot: f32, client_id: ClientId, ) -> NetworkId
Source§fn queue_reliable_event(
&mut self,
_client_id: Option<ClientId>,
_event: GameEvent,
)
fn queue_reliable_event( &mut self, _client_id: Option<ClientId>, _event: GameEvent, )
Source§fn setup_world(&mut self)
fn setup_world(&mut self)
Auto Trait Implementations§
impl Freeze for ClientWorld
impl RefUnwindSafe for ClientWorld
impl Send for ClientWorld
impl Sync for ClientWorld
impl Unpin for ClientWorld
impl UnsafeUnpin for ClientWorld
impl UnwindSafe for ClientWorld
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request