generated from GarandPLG/rust-flake-template
Add Task trait and improve miner task display
Define a full `Task` trait with icon and path accessors. Implement the trait for `DiggingTask` and delegate it through the `Tasks` enum. Introduce helper functions in `MinerUnit` to convert coordinates to spreadsheet‑style strings and use them in a revamped `get_tasks_formatted`. Update the unit rendering logic to show the tasks queue only when tasks are present.
This commit is contained in:
1 parent
7c9e3d28f0
commit
d2f5968861
5 files changed
+97
-5
No files matched your search
@@ -39,6 +39,7 @@ pub trait Unit {
|
||||
let hp_percent: u16 = hp * 100 / max_hp;
|
||||
let can_dig: bool = self.get_can_dig();
|
||||
let digging_power: f32 = self.get_digging_power();
|
||||
let have_any_tasks: bool = self.get_tasks().is_empty();
|
||||
let tasks: String = self.get_tasks_formatted();
|
||||
|
||||
let mut lines: Vec<Line<'_>> = Vec::from([
|
||||
@@ -52,7 +53,6 @@ pub trait Unit {
|
||||
hp_percent.green(),
|
||||
"% )".gray(),
|
||||
]),
|
||||
Line::from_iter(["Tasks Queue: ".gray(), tasks.green()]),
|
||||
]);
|
||||
|
||||
if can_dig {
|
||||
@@ -62,6 +62,10 @@ pub trait Unit {
|
||||
]));
|
||||
}
|
||||
|
||||
if !have_any_tasks {
|
||||
lines.push(Line::from_iter(["Tasks Queue: ".gray(), tasks.green()]));
|
||||
}
|
||||
|
||||
lines
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user