From d3bede8b1c8aebf9bcb24dd69f80e970909739d8 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 1 Aug 2024 14:06:40 -0700 Subject: [PATCH] wip bot worker --- src/bot_worker.rs | 38 ++++++++++++++++++++++++++++++++++++++ src/main.rs | 1 + 2 files changed, 39 insertions(+) create mode 100644 src/bot_worker.rs diff --git a/src/bot_worker.rs b/src/bot_worker.rs new file mode 100644 index 0000000..6a42915 --- /dev/null +++ b/src/bot_worker.rs @@ -0,0 +1,38 @@ +use strafesnet_snf::bot::BotInstructions; + +pub enum Instruction{ + //TODO: pass map id + Create, + Push{ + ins:strafesnet_common::instruction::TimedInstruction, + }, +} + +//a new worker is spawned on a thread +//create opens a new file +//push pushes an instruction to the file + +pub struct Worker{ + file:Option, +} + +pub fn new<'a>(scope:&'a std::thread::Scope<'a,'_>)->crate::worker::QNWorker<'a,Instruction>{ + let mut worker=Worker{ + file:None, + }; + crate::worker::QNWorker::new(scope,move|instruction|{ + match instruction{ + Instruction::Create=>{ + worker.file=Some(BotIntructions::new("hi.snfb")) + }, + Instruction::Push{ins}=>{ + match &worker.file{ + Some(file)=>file.push(ins), + None=>{ + println!("no file created!"), + } + } + }, + } + }) +} diff --git a/src/main.rs b/src/main.rs index 337ba79..9ea3bcf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ mod worker; mod physics; mod graphics; mod settings; +mod bot_worker; mod face_crawler; mod compat_worker; mod model_physics;