From 91b90675c4173f46bba1d22dc392e52ba92d4eeb Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 2 Aug 2024 12:11:23 -0700 Subject: [PATCH] prototype --- src/bot.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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: