pub struct EngineSim<G: GameDef> {
pub cfg: EngineConfig,
pub world: PhysicsWorld,
pub map: Option<GameMap>,
pub nav: Option<NavigationSystem>,
pub spatial: SpatialGrid,
pub rng: Rng,
pub events: Vec<CoreEvent>,
pub sim: G::Sim,
/* private fields */
}Expand description
Движковый каркас симуляции: физический мир, карта, нав-граф/сетка
ботов, PRNG, аккумулятор фиксированного шага, очередь удаления тел,
события. Игровая логика (участники/оружие/снапшот-блоки) вынесена в
G::Sim (см. core/src/sim.rs) — движок зовёт её только через
on_fixed_step/on_contacts/on_before_destroy/on_ai_tick, не зная
деталей конкретной игры. Конкретная игра (тип G, дефолт для
GameState-алиасов — забота game-crate) не импортируется движком.
Fields§
§cfg: EngineConfig§world: PhysicsWorld§map: Option<GameMap>§spatial: SpatialGrid§rng: Rng§events: Vec<CoreEvent>§sim: G::SimImplementations§
Source§impl<G: GameDef> EngineSim<G>
impl<G: GameDef> EngineSim<G>
pub fn new(cfg: EngineConfig, game_cfg: &G::Config) -> Self
Sourcepub fn load_map(&mut self, json: &str) -> Result<(), String>
pub fn load_map(&mut self, json: &str) -> Result<(), String>
Создаёт карту из JSON (масштабирование внутри) и нав-граф ботов.
Sourcepub fn map_info_json(&self) -> String
pub fn map_info_json(&self) -> String
Информация о загруженной карте: setId, масштабированные респауны, размеры мира (JSON) — ‘null’, если карта не загружена.
pub fn spawn_actor( &mut self, game_id: u32, model_name: &str, team_id: u8, x: f32, y: f32, angle_deg: f32, ) -> Result<(), String>
pub fn remove_actor(&mut self, game_id: u32)
pub fn reset_actor( &mut self, game_id: u32, team_id: u8, x: f32, y: f32, angle_deg: f32, )
pub fn reset_all_vitals(&mut self)
pub fn spawn_scripted_actor( &mut self, game_id: u32, model_name: &str, team_id: u8, x: f32, y: f32, angle_deg: f32, ) -> Result<(), String>
pub fn remove_scripted_actor(&mut self, game_id: u32)
pub fn apply_input( &mut self, game_id: u32, seq: u32, action: &str, key_name: &str, )
Sourcepub fn apply_aim(&mut self, game_id: u32, seq: u32, x: f32, y: f32, flags: u32)
pub fn apply_aim(&mut self, game_id: u32, seq: u32, x: f32, y: f32, flags: u32)
Ввод указателем: мировая точка + биты состояния (см. GameSim::apply_aim).
pub fn last_input_seq(&self, game_id: u32) -> u32
Sourcepub fn take_events_json(&mut self) -> String
pub fn take_events_json(&mut self) -> String
События за тик (kill/health/ammo/weapon/shake) одной JSON-строкой; буфер очищается.
pub fn is_alive(&self, game_id: u32) -> bool
pub fn actor_position(&self, game_id: u32) -> Option<[f32; 2]>
pub fn prediction_state(&self, game_id: u32) -> Option<([f32; 8], bool)>
pub fn alive_players_flat(&self) -> Vec<f32>
Sourcepub fn players_json(&self) -> String
pub fn players_json(&self) -> String
Полный снапшот игроков (Game.getPlayersData), не дренируя накопители событий — для первого кадра (FIRST_SHOT_DATA).
Sourcepub fn step(&mut self, dt: f32)
pub fn step(&mut self, dt: f32)
Обновляет физику фиксированными шагами (Game.updateData), затем ИИ скриптовых участников (VIMP._onShotTick).
Sourcepub fn build_snapshot_blocks(&mut self) -> Vec<(String, Block)>
pub fn build_snapshot_blocks(&mut self) -> Vec<(String, Block)>
Собирает блоки тела снапшота, дренируя накопители событий. Вызывается на каждый отправляемый кадр (throttle — забота JS).
Sourcepub fn body_has_events(&self) -> bool
pub fn body_has_events(&self) -> bool
Содержал ли последний собранный body событийные блоки — для классификации канала WebRTC (meta reliable / state unreliable).
Sourcepub fn remove_players_and_shots(&mut self) -> Vec<String>
pub fn remove_players_and_shots(&mut self) -> Vec<String>
Удаляет всех игроков и снаряды, возвращает имена для очистки полотна клиентов (Game.removePlayersAndShots).
Sourcepub fn debug_json(&self) -> String
pub fn debug_json(&self) -> String
Курированный дамп мира (тела, коллайдеры, карта, нав-граф,
spatial-сетка, rng, аккумулятор фикс-шага) — читаемая
альтернатива сырому serialize_state (см. crate::debug).
Auto Trait Implementations§
impl<G> !RefUnwindSafe for EngineSim<G>
impl<G> !UnwindSafe for EngineSim<G>
impl<G> Freeze for EngineSim<G>
impl<G> Send for EngineSim<G>
impl<G> Sync for EngineSim<G>
impl<G> Unpin for EngineSim<G>
impl<G> UnsafeUnpin for EngineSim<G>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.