generated from GarandPLG/rust-flake-template
Refactor DiggingTask and embed it in Tasks enum
- Remove lifetime and path storage from DiggingTask, make it Copy. - Add a placeholder `new` constructor that accepts a path. - Update the Tasks enum to hold a DiggingTask value. - Reorder module declarations and re‑export order for tasks. - Add a commented‑out tasks field to MinerUnit as a preparation step.
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
use crate::app::widgets::CellWidget;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct DiggingTask<'a> {
|
||||
path: Vec<&'a CellWidget>,
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct DiggingTask {
|
||||
// path: Vec<(usize, usize)>,
|
||||
}
|
||||
|
||||
impl DiggingTask {
|
||||
pub fn new(path: Vec<(u16, u16)>) -> Self {
|
||||
Self {
|
||||
// path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
mod digging;
|
||||
mod tasks_enum;
|
||||
mod task_trait;
|
||||
mod tasks_enum;
|
||||
|
||||
pub use tasks_enum::Tasks;
|
||||
pub use digging::DiggingTask;
|
||||
pub use task_trait::Task;
|
||||
pub use tasks_enum::Tasks;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use crate::app::states::skirmish_states::tasks::DiggingTask;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Tasks {
|
||||
Digging,
|
||||
Digging(DiggingTask),
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::app::states::skirmish_states::{Players, units::Unit};
|
||||
use crate::app::states::skirmish_states::{Players, tasks::Tasks, units::Unit};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct MinerUnit {
|
||||
@@ -6,6 +6,7 @@ pub struct MinerUnit {
|
||||
hp: u16,
|
||||
can_dig: bool,
|
||||
digging_power: f32,
|
||||
// tasks: Vec<Tasks>,
|
||||
}
|
||||
|
||||
impl MinerUnit {
|
||||
@@ -15,6 +16,7 @@ impl MinerUnit {
|
||||
hp: 100,
|
||||
can_dig: true,
|
||||
digging_power: 0.55,
|
||||
// tasks: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user