Files
roblox-bot-player/integration-tests/src/main.rs
2026-03-18 08:41:04 -07:00

36 lines
1.5 KiB
Rust

use strafesnet_roblox_bot_file::v0;
use strafesnet_roblox_bot_player::{bot,bvh,head};
use head::Time as PlaybackTime;
use strafesnet_common::session::Time as SessionTime;
fn main(){
let bot=include_bytes!("../../web-demo/bhop_marble_7cf33a64-7120-4514-b9fa-4fe29d9523d.qbot");
let timelines=v0::read_all_to_block(std::io::Cursor::new(bot)).unwrap();
let bot=bot::CompleteBot::new(timelines);
let bvh=bvh::Bvh::new(&bot);
// sample the position at 0.24s
let mut playback0=head::PlaybackHead::new(&bot,SessionTime::ZERO);
for i in 0..10{
let sample_time=PlaybackTime::from_millis(6543+1*i);
playback0.set_time(&bot,SessionTime::ZERO,sample_time);
let pos=playback0.get_position(&bot,SessionTime::ZERO);
// get the closest time on the timeline (convert to PlaybackTime which starts at 0)
let closest_time=bot.playback_time(bvh.closest_time_to_point(&bot,pos).unwrap());
println!("time={sample_time} closest_time={closest_time}");
}
// let mut playback1=head::PlaybackHead::new(&bot,SessionTime::ZERO);
// playback1.set_time(&bot,SessionTime::ZERO,sample_time);
}
#[test]
fn get_position_no_panic(){
let bot_file=include_bytes!("../../files/000002d3-852a-4e9f-b0c9-c95411683806.qbot");
let timelines=v0::read_all_to_block(std::io::Cursor::new(bot_file)).unwrap();
let bot=bot::CompleteBot::new(timelines);
let head=head::PlaybackHead::new(&bot,SessionTime::ZERO);
// This can panic if the head is mismanaged!
let _pos=head.get_position(&bot,SessionTime::ZERO);
}