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.