generated from GarandPLG/rust-flake-template
Show unit task queue and mark in side panel
Add `get_tasks` to the `Unit` trait and implement it for `MinerUnit`, `Units` enum and `Option<Units>`. Use the new method in `base_text` to display a “Tasks Queue” line. Refactor task assignment in `BoardState` to a chained call. Update the skirmish view and `SidePanelWidget` to pass a flag indicating whether the displayed unit is the currently marked one, and highlight the unit name accordingly.
This commit is contained in:
1 parent
a7d8823bf2
commit
e4728aab5d
6 files changed
+41
-5
No files matched your search
@@ -25,6 +25,8 @@ pub trait Unit {
|
||||
|
||||
fn get_coords(&self) -> (usize, usize);
|
||||
|
||||
fn get_tasks(&self) -> String;
|
||||
|
||||
fn set_task(&mut self, task: Tasks);
|
||||
|
||||
fn base_text(&self) -> Vec<Line<'_>> {
|
||||
@@ -34,6 +36,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 tasks: String = self.get_tasks();
|
||||
|
||||
let mut lines: Vec<Line<'_>> = Vec::from([
|
||||
Line::from_iter(["Owner: ".gray(), owner]),
|
||||
@@ -46,6 +49,7 @@ pub trait Unit {
|
||||
hp_percent.green(),
|
||||
"% )".gray(),
|
||||
]),
|
||||
Line::from_iter(["Tasks Queue: ".gray(), tasks.green()]),
|
||||
]);
|
||||
|
||||
if can_dig {
|
||||
|
||||
Reference in new issue
Block a user