54 lines
1.5 KiB
Rust
54 lines
1.5 KiB
Rust
use strafesnet_common::instruction::TimedInstruction;
|
|
use strafesnet_common::session::Time as SessionTime;
|
|
use strafesnet_roblox_bot_player::{bot::Bot,graphics::Graphics,head::PlaybackHead};
|
|
|
|
pub enum SessionControlInstruction{
|
|
SetPaused(bool),
|
|
}
|
|
pub enum SessionPlaybackInstruction{
|
|
SkipForward,
|
|
SkipBack,
|
|
DecreaseTimescale,
|
|
IncreaseTimescale,
|
|
}
|
|
|
|
pub enum Instruction{
|
|
SessionControl(SessionControlInstruction),
|
|
SessionPlayback(SessionPlaybackInstruction),
|
|
Render,
|
|
Resize(winit::dpi::PhysicalSize<u32>),
|
|
}
|
|
|
|
pub struct PlayerWorker<'a>{
|
|
graphics_thread:Graphics<'a>,
|
|
bot:Bot,
|
|
playback_head:PlaybackHead,
|
|
}
|
|
impl<'a> PlayerWorker<'a>{
|
|
pub fn new(
|
|
bot:Bot,
|
|
graphics_thread:Graphics<'a>,
|
|
)->Self{
|
|
let playback_head=PlaybackHead::new(SessionTime::ZERO);
|
|
Self{
|
|
bot,
|
|
graphics_thread,
|
|
playback_head,
|
|
}
|
|
}
|
|
pub fn send(&mut self,ins:TimedInstruction<Instruction,SessionTime>){
|
|
match ins.instruction{
|
|
Instruction::SessionControl(session_control_instruction)=>{},
|
|
Instruction::SessionPlayback(session_playback_instruction)=>{},
|
|
Instruction::Render=>{
|
|
self.playback_head.advance_time(&self.bot,ins.time);
|
|
let (pos,angles)=self.playback_head.get_position_angles(&self.bot,ins.time);
|
|
self.graphics_thread.send(strafesnet_roblox_bot_player::graphics::Instruction::Render{pos,angles});
|
|
},
|
|
Instruction::Resize(physical_size)=>{
|
|
self.graphics_thread.send(strafesnet_roblox_bot_player::graphics::Instruction::Resize(glam::uvec2(physical_size.width,physical_size.height)));
|
|
},
|
|
}
|
|
}
|
|
}
|