nimble_client_logic

Struct ClientLogic

source
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>

source

pub fn new(deterministic_simulation_version: Version) -> Self

Creates a new ClientLogic instance, initializing all fields.

source

pub const fn debug_authoritative_steps(&self) -> &Queue<StepMap<Step<StepT>>>

Returns a reference to the incoming authoritative steps.

source

pub const fn phase(&self) -> &ClientLogicPhase

source

pub fn latency(&self) -> Option<MinMaxAvg<u16>>

source

pub fn pop_all_authoritative_steps( &mut self, ) -> (TickId, Vec<StepMap<Step<StepT>>>)

source

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.
source

pub const fn debug_connect_request_id(&self) -> Option<ClientRequestId>

source

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.

source

pub fn can_push_predicted_step(&self) -> bool

source

pub fn is_in_game(&self) -> bool

source

pub fn push_predicted_step( &mut self, tick_id: TickId, step: StepMap<StepT>, ) -> Result<(), ClientLogicError>

Adds a predicted step to the outgoing steps queue.

§Arguments
  • tick_id: The tick ID of the step.
  • step: The predicted step to add.
§Errors

Returns a [StepsError] if the step is empty or cannot be added.

source

pub fn predicted_step_count_in_queue(&self) -> usize

source

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.

source

pub fn game_mut(&mut self) -> Option<&mut StateT>

source

pub fn receive( &mut self, now: Millis, command: &HostToClientCommands<Step<StepT>>, ) -> Result<(), ClientLogicError>

Receives a command from the host and processes it accordingly.

§Arguments
  • command: The command from the host.
§Errors

Returns a [ClientErrorKind] if the command cannot be processed.

source

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.

source

pub fn local_players(&self) -> Vec<LocalPlayer>

Trait Implementations§

source§

impl<StateT: Debug + BufferDeserializer, StepT: Debug + Clone + Deserialize + Serialize + Debug + Display> Debug for ClientLogic<StateT, StepT>

source§

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

Formats the value using the given formatter. Read more

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>
where StateT: Send, StepT: Send,

§

impl<StateT, StepT> Sync for ClientLogic<StateT, StepT>
where StateT: Sync, StepT: Sync,

§

impl<StateT, StepT> Unpin for ClientLogic<StateT, StepT>
where StateT: Unpin, StepT: Unpin,

§

impl<StateT, StepT> UnwindSafe for ClientLogic<StateT, StepT>
where StateT: UnwindSafe, StepT: UnwindSafe,

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.