Skip to main content

ClientState

Struct ClientState 

Source
pub struct ClientState<G: GameClientDef> { /* private fields */ }
Expand description

Generic оркестрация клиентского ядра поверх игровой G: GameClientDef: сетевой буфер (interpolator), очередь событийных кадров, hot-буфер рендер-тика. Байтовая раскладка hot-буфера (флаги/камера/N танков×поля/M динамики×поля/predicted-хвост) не меняется — см. write_hot.

Implementations§

Source§

impl<G: GameClientDef> ClientState<G>

Source

pub fn new(cfg: EngineClientConfig, game_cfg: &G::Config) -> Self

Source

pub fn push_frame(&mut self, data: &[u8], local_now: f64) -> bool

Бинарный кадр из транспорта: распаковка, вставка в буфер по seq, reconciliation предикта по player-блоку. false — кадр отброшен (чужой порт, версия или повреждённые данные).

Source

pub fn game(&self) -> &G

Игровая половина ядра: игровая обёртка ABI (ClientCore плагина) достаёт через неё свои подсистемы — движок их формы не знает.

Source

pub fn my_game_id(&self) -> Option<u32>

Source

pub fn offset(&self) -> Option<f64>

Source

pub fn sample(&mut self, local_now: f64) -> usize

Рендер-тик: выдача пересечённых кадров (фильтр дублей → JSON-очередь), интерполяция, шаг предикта, запись hot-буфера. Возвращает длину hot-буфера в f32-элементах.

Source

pub fn hot(&self) -> &[f32]

Source

pub fn take_frames(&mut self) -> String

Событийные кадры JSON-строкой [{game, camera}, …]; очередь очищается.

Source

pub fn apply_input(&mut self, action: &str, key_name: &str, local_now: f64)

Source

pub fn apply_aim(&mut self, x: f32, y: f32, flags: u32, local_now: f64)

Source

pub fn try_action(&mut self, local_now: f64) -> Option<String>

Source

pub fn cycle_item(&mut self, back: bool)

Source

pub fn set_model(&mut self, model_name: &str)

Source

pub fn set_active(&mut self, active: bool)

Смена режима игрок/спектатор (KEYSET_DATA).

Source

pub fn set_map(&mut self, map_json: &str) -> Result<(), String>

Данные карты (MAP_DATA): мир raycast + сброс буфера и предикта.

Source

pub fn sync_panel(&mut self, panel_json: &str)

Source

pub fn reset(&mut self)

Полный сброс (порт CLEAR).

Source

pub fn resync(&mut self)

Ресинк часов после долгой паузы вкладки (visibilitychange → visible): сетевая половина начинает с чистого листа, чтобы следующий кадр пересеял оффсет точно, а не догонял EMA десятки кадров. Игровую половину (предикт, своя идентичность) не трогаем — сущности на полотне живы.

Source

pub fn debug_json(&self) -> String

Зеркало серверного EngineSim::debug_json на клиенте: состояние сетевого буфера (глубина, окно seq, оффсет, последний кадр), свой gameId, размеры hot-буфера и очереди событийных кадров.

Source

pub fn take_divergence(&mut self) -> String

Записи расхождения предикта с авторитетным состоянием (JSON, см. client::divergence); очередь очищается. "null" — детектор выключен (боевой конфиг без секции divergence).

Source

pub fn decode_frame(&self, data: &[u8]) -> String

Чистая распаковка кадра v3 в JSON-форму unpackFrame (тесты/харнесс).

Auto Trait Implementations§

§

impl<G> Freeze for ClientState<G>
where G: Freeze,

§

impl<G> RefUnwindSafe for ClientState<G>
where G: RefUnwindSafe,

§

impl<G> Send for ClientState<G>
where G: Send,

§

impl<G> Sync for ClientState<G>
where G: Sync,

§

impl<G> Unpin for ClientState<G>
where G: Unpin,

§

impl<G> UnsafeUnpin for ClientState<G>
where G: UnsafeUnpin,

§

impl<G> UnwindSafe for ClientState<G>
where G: 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.