diff --git a/src/bot.rs b/src/bot.rs index ffdaee8..40e1b64 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -1,4 +1,6 @@ -use binrw::{BinReaderExt, binrw}; +use binrw::{binrw,BinReaderExt,BinWriterExt}; +use crate::newtypes::instruction::TimedInstruction; +use crate::newtypes::physics::PhysicsInputInstruction; #[derive(Debug)] pub enum Error{ @@ -8,6 +10,29 @@ pub enum Error{ File(crate::file::Error), } +pub struct BotDebug{ + name:String, + file:std::fs::File, +} + +impl BotDebug{ + pub fn new()->std::io::Result{ + let rng:u128=rand::random(); + let name=format!("{rng:x}"); + Ok(Self{ + file:std::fs::File::create(name.as_str())?, + name, + }) + } + pub fn delete(self)->std::io::Result<()>{ + std::mem::drop(self.file); + std::fs::remove_file(self.name) + } + pub fn push(&self,ins:TimedInstruction)->Result<(),binrw::Error>{ + self.file.write_le(ins) + } +} + /* block types BLOCK_BOT_HEADER: