1
Fork 0

initial construct implementation

This commit is contained in:
Andy Killorin 2023-12-29 15:28:42 -06:00
parent f9531a6961
commit d309a4264c
Signed by: ank
GPG key ID: B6241CA3B552BCA4
3 changed files with 16 additions and 5 deletions

View file

@ -7,7 +7,7 @@ use tokio::task::AbortHandle;
use tracing::{info, error};
use typetag::serde;
use crate::{SharedControl, mine::{Remove, ChunkedTask, Quarry}, blocks::{Vec3, Direction, Position}, tasks::{TaskState, Task}, turtle::TurtleCommander};
use crate::{SharedControl, mine::{Remove, ChunkedTask, Quarry}, blocks::{Vec3, Direction, Position}, tasks::{TaskState, Task}, turtle::TurtleCommander, construct::BuildSimple};
pub fn forms_api() -> Router<SharedControl> {
Router::new()
@ -110,9 +110,18 @@ async fn omni_inner(state: SharedControl, req: GoogleOmniForm) -> anyhow::Result
let schematic = rustmatica::Litematic::from_bytes(&schematic.bytes().await?)?;
let region = schematic.regions.get(0).context("no regions")?;
info!("schematic \"{}\" downloaded", &schematic.name);
info!("{} blocks", schematic.total_blocks());
info!("{} regions", schematic.regions.len());
let input = Position::new(
Vec3::new(53,73,77),
Direction::West,
);
schedule.add_task(Box::new(BuildSimple::new(position, region, input)));
},
GoogleOmniFormMode::RemoveVein => {
let block = req.block.context("missing block name")?;

View file

@ -33,6 +33,7 @@ mod blocks;
mod names;
mod mine;
mod fell;
mod construct;
mod paths;
mod safe_kill;
mod turtle;
@ -70,6 +71,7 @@ async fn main() -> Result<(), Error> {
.with_target("server::googleforms", Level::TRACE)
.with_target("server::fell", Level::WARN)
.with_target("server::mine", Level::INFO)
.with_target("server::construct", Level::TRACE)
.with_target("server::depot", Level::TRACE);
let log = fs::OpenOptions::new().append(true).create(true).open(SAVE.get().unwrap().join("avarus.log")).await?;

View file

@ -466,7 +466,7 @@ impl ChunkedTask {
}
#[derive(Clone)]
struct ChunkedTaskGuard {
pub struct ChunkedTaskGuard {
parent: ChunkedTask,
chunk: i32,
complete: bool,
@ -481,16 +481,16 @@ impl ChunkedTaskGuard {
}
}
fn id(&self) -> i32 {
pub fn id(&self) -> i32 {
self.chunk
}
fn finish(mut self) {
pub fn finish(mut self) {
self.parent.mark_done(self.chunk);
self.complete = true;
}
fn cancel(self) {
pub fn cancel(self) {
drop(self) // nop
}
}