work
This commit is contained in:
parent
498c628280
commit
b6206d52c8
@ -1,33 +1,39 @@
|
||||
use crate::session::SessionState;
|
||||
use crate::graphics_worker::Instruction as GraphicsInstruction;
|
||||
use crate::session::{Instruction as SessionInstruction,Session, Simulation};
|
||||
use strafesnet_common::physics::Time as PhysicsTime;
|
||||
use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner};
|
||||
use strafesnet_common::timer::Timer;
|
||||
|
||||
type TimedSessionInstruction=strafesnet_common::instruction::TimedInstruction<crate::session::Instruction>;
|
||||
type TimedSessionInstruction=strafesnet_common::instruction::TimedInstruction<SessionInstruction,SessionTimeInner>;
|
||||
|
||||
pub fn new<'a>(
|
||||
mut graphics_worker:crate::compat_worker::INWorker<'a,crate::graphics_worker::Instruction>,
|
||||
user_settings:crate::settings::UserSettings,
|
||||
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTimeInner>>{
|
||||
)->crate::compat_worker::QNWorker<'a,TimedSessionInstruction>{
|
||||
let physics=crate::physics::PhysicsContext::default();
|
||||
let timer=Timer::unpaused(SessionTime::ZERO,PhysicsTime::ZERO);
|
||||
let simulation=Simulation::new(timer,physics);
|
||||
let mouse_interpolator=crate::mouse_interpolator::MouseInterpolator::new();
|
||||
let mut session=SessionState::new(
|
||||
physics,
|
||||
user_settings
|
||||
let mut session=Session::new(
|
||||
user_settings,
|
||||
simulation,
|
||||
);
|
||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction,SessionTimeInner>|{
|
||||
crate::compat_worker::QNWorker::new(move |ins:TimedSessionInstruction|{
|
||||
session.handle_instruction(&ins);
|
||||
match ins.instruction{
|
||||
Instruction::Render=>{
|
||||
SessionInstruction::Render=>{
|
||||
let frame_state=session.get_frame_state(ins.time);
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Render(frame_state)).unwrap();
|
||||
graphics_worker.send(GraphicsInstruction::Render(frame_state)).unwrap();
|
||||
},
|
||||
Instruction::Resize(size)=>{
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Resize(size,session.user_settings().clone())).unwrap();
|
||||
SessionInstruction::Resize(size)=>{
|
||||
graphics_worker.send(GraphicsInstruction::Resize(size,session.user_settings().clone())).unwrap();
|
||||
},
|
||||
Instruction::ChangeMap(map)=>{
|
||||
SessionInstruction::ChangeMap(map)=>{
|
||||
session.change_map(ins.time,&map);
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::ChangeMap(map)).unwrap();
|
||||
graphics_worker.send(GraphicsInstruction::ChangeMap(map)).unwrap();
|
||||
},
|
||||
Instruction::Input(_)=>(),
|
||||
Instruction::SetPaused(_)=>(),
|
||||
SessionInstruction::Input(_)=>(),
|
||||
SessionInstruction::SetPaused(_)=>(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ use strafesnet_common::timer::{Scaled,Timer};
|
||||
use strafesnet_common::physics::TimeInner as PhysicsTimeInner;
|
||||
use strafesnet_common::session::TimeInner as SessionTimeInner;
|
||||
|
||||
use crate::mouse_interpolator::MouseInterpolator;
|
||||
|
||||
pub struct FrameState{
|
||||
pub body:crate::physics::Body,
|
||||
pub camera:crate::physics::PhysicsCamera,
|
||||
@ -15,16 +17,53 @@ pub struct Simulation{
|
||||
timer:Timer<Scaled<SessionTimeInner,PhysicsTimeInner>>,
|
||||
physics:crate::physics::PhysicsContext,
|
||||
}
|
||||
|
||||
pub struct Replay{
|
||||
instruction:Vec<PhysicsInputInstruction>,
|
||||
simulation:Simulation,
|
||||
impl Simulation{
|
||||
pub const fn new(
|
||||
timer:Timer<Scaled<SessionTimeInner,PhysicsTimeInner>>,
|
||||
physics:crate::physics::PhysicsContext,
|
||||
)->Self{
|
||||
Self{
|
||||
timer,
|
||||
physics,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SessionState{
|
||||
pub struct Replay{
|
||||
last_instruction_id:usize,
|
||||
instructions:Vec<PhysicsInputInstruction>,
|
||||
simulation:Simulation,
|
||||
}
|
||||
impl Replay{
|
||||
pub const fn new(
|
||||
instructions:Vec<PhysicsInputInstruction>,
|
||||
simulation:Simulation,
|
||||
)->Self{
|
||||
Self{
|
||||
last_instruction_id:0,
|
||||
instructions,
|
||||
simulation,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Session{
|
||||
user_settings:crate::settings::UserSettings,
|
||||
mouse_interpolator:crate::mouse_interpolator::MouseInterpolator,
|
||||
//gui:GuiState
|
||||
simulation:Simulation,
|
||||
replays:Vec<Replay>,
|
||||
}
|
||||
impl Session{
|
||||
pub fn new(
|
||||
user_settings:crate::settings::UserSettings,
|
||||
simulation:Simulation,
|
||||
)->Self{
|
||||
Self{
|
||||
user_settings,
|
||||
mouse_interpolator:MouseInterpolator::new(),
|
||||
simulation,
|
||||
replays:Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::physics_worker::InputInstruction;
|
||||
use strafesnet_common::integer;
|
||||
use strafesnet_common::instruction::TimedInstruction;
|
||||
use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user