forked from StrafesNET/strafe-client
this doesn't need to be option
This commit is contained in:
parent
af478bce28
commit
c485c02b05
@ -3,7 +3,7 @@ use strafesnet_snf::bot::BotDebug;
|
|||||||
pub enum Instruction{
|
pub enum Instruction{
|
||||||
//TODO: pass map id
|
//TODO: pass map id
|
||||||
Create,
|
Create,
|
||||||
Delete,
|
//Delete,
|
||||||
Push{
|
Push{
|
||||||
ins:strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction>,
|
ins:strafesnet_common::instruction::TimedInstruction<strafesnet_common::physics::Instruction>,
|
||||||
},
|
},
|
||||||
@ -14,30 +14,18 @@ pub enum Instruction{
|
|||||||
//push pushes an instruction to the file
|
//push pushes an instruction to the file
|
||||||
|
|
||||||
pub struct Worker{
|
pub struct Worker{
|
||||||
file:Option<BotDebug>,
|
file:BotDebug,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new<'a>(scope:&'a std::thread::Scope<'a,'_>)->crate::worker::QNWorker<'a,Instruction>{
|
pub fn new<'a>(scope:&'a std::thread::Scope<'a,'_>)->crate::worker::QNWorker<'a,Instruction>{
|
||||||
let mut worker=Worker{
|
let mut worker=Worker{
|
||||||
file:None,
|
file:BotDebug::new().unwrap(),
|
||||||
};
|
};
|
||||||
crate::worker::QNWorker::new(scope,move|instruction|{
|
crate::worker::QNWorker::new(scope,move|instruction|{
|
||||||
match instruction{
|
match instruction{
|
||||||
Instruction::Create=>{
|
Instruction::Create=>worker.file=BotDebug::new().unwrap(),
|
||||||
worker.file=Some(BotDebug::new().unwrap())
|
//Instruction::Delete=>worker.file.delete().unwrap(),
|
||||||
},
|
Instruction::Push{ins}=>worker.file.push(ins).unwrap(),
|
||||||
Instruction::Delete=>{
|
|
||||||
match worker.file.take(){
|
|
||||||
Some(file)=>file.delete().unwrap(),
|
|
||||||
None=>println!("no file created!"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Instruction::Push{ins}=>{
|
|
||||||
match &mut worker.file{
|
|
||||||
Some(file)=>file.push(ins).unwrap(),
|
|
||||||
None=>println!("no file created!"),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user