pub struct ClientLogic<StateT: BufferDeserializer, StepT: Clone + Deserialize + Serialize + Debug + Display> { /* private fields */ }
Expand description
ClientLogic
manages the client’s state and communication logic
with the host in a multiplayer game session.
§Type Parameters
StateT
: A type implementing representing the game state.StepT
: A type implementing representing the game steps.
Implementations§
Source§impl<StateT: BufferDeserializer, StepT: Clone + Deserialize + Serialize + Debug + Display> ClientLogic<StateT, StepT>
impl<StateT: BufferDeserializer, StepT: Clone + Deserialize + Serialize + Debug + Display> ClientLogic<StateT, StepT>
Sourcepub fn new(deterministic_simulation_version: Version) -> Self
pub fn new(deterministic_simulation_version: Version) -> Self
Creates a new ClientLogic
instance, initializing all fields.
Returns a reference to the incoming authoritative steps.
pub const fn phase(&self) -> &ClientLogicPhase
pub fn latency(&self) -> Option<MinMaxAvg<u16>>
Sourcepub fn set_joining_player(&mut self, local_players: Vec<LocalIndex>)
pub fn set_joining_player(&mut self, local_players: Vec<LocalIndex>)
Sets the joining player request for this client.
§Arguments
join_game_request
: The join game request to send to the host.
pub const fn debug_connect_request_id(&self) -> Option<ClientRequestId>
Sourcepub fn send(&mut self, now: Millis) -> Vec<ClientToHostCommands<StepT>>
pub fn send(&mut self, now: Millis) -> Vec<ClientToHostCommands<StepT>>
Returns client commands that should be sent to the host.
§Returns
A vector of ClientToHostCommands
representing all the commands to be sent to the host.
pub fn can_push_predicted_step(&self) -> bool
pub fn is_in_game(&self) -> bool
Sourcepub fn push_predicted_step(
&mut self,
tick_id: TickId,
step: StepMap<StepT>,
) -> Result<(), ClientLogicError>
pub fn push_predicted_step( &mut self, tick_id: TickId, step: StepMap<StepT>, ) -> Result<(), ClientLogicError>
pub fn predicted_step_count_in_queue(&self) -> usize
Sourcepub const fn game(&self) -> Option<&StateT>
pub const fn game(&self) -> Option<&StateT>
Returns the received game state from the host.
§Returns
An Option
containing a reference to the received game state, if available.
pub fn game_mut(&mut self) -> Option<&mut StateT>
Sourcepub fn receive(
&mut self,
now: Millis,
command: &HostToClientCommands<Step<StepT>>,
) -> Result<(), ClientLogicError>
pub fn receive( &mut self, now: Millis, command: &HostToClientCommands<Step<StepT>>, ) -> Result<(), ClientLogicError>
Sourcepub fn server_buffer_delta_ticks(&self) -> Option<i16>
pub fn server_buffer_delta_ticks(&self) -> Option<i16>
Returns the average server buffer delta tick, if available.
§Returns
An optional average server buffer delta tick.
pub fn local_players(&self) -> Vec<LocalPlayer>
Trait Implementations§
Auto Trait Implementations§
impl<StateT, StepT> Freeze for ClientLogic<StateT, StepT>where
StateT: Freeze,
impl<StateT, StepT> RefUnwindSafe for ClientLogic<StateT, StepT>where
StateT: RefUnwindSafe,
StepT: RefUnwindSafe,
impl<StateT, StepT> Send for ClientLogic<StateT, StepT>
impl<StateT, StepT> Sync for ClientLogic<StateT, StepT>
impl<StateT, StepT> Unpin for ClientLogic<StateT, StepT>
impl<StateT, StepT> UnwindSafe for ClientLogic<StateT, StepT>where
StateT: UnwindSafe,
StepT: UnwindSafe,
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
Mutably borrows from an owned value. Read more