generated from GarandPLG/rust-flake-template
Replace CellTag with CellStructure and embed BaseBuilding
The refactor removes the `Buildings` enum and the `building` module, replacing `CellTag` with a new `CellStructure` enum that directly holds a `BaseBuilding`. A `get_owner` method is added to `BaseBuilding` to support the new structure. All related imports, constructors, and rendering logic are updated to use `CellStructure` instead of the old tag and building fields.
This commit is contained in:
@@ -9,5 +9,5 @@ pub use main_menu::MainMenuState;
|
||||
pub use perk_decks::{PerkDecks, PerkDecksState};
|
||||
pub use settings::SettingsState;
|
||||
pub use skills_config::SkillsConfigState;
|
||||
pub use skirmish::{CellTag, GameMode, Players, SkirmishState, ZoomLevel};
|
||||
pub use skirmish::{CellStructure, GameMode, Players, SkirmishState, ZoomLevel};
|
||||
pub use skirmish_states::{FocusedCell, Offset};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::app::states::skirmish_states::BoardState;
|
||||
use crate::app::{buildings::BaseBuilding, states::skirmish_states::BoardState};
|
||||
use clap::ValueEnum;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -22,8 +22,8 @@ pub enum ZoomLevel {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum CellTag {
|
||||
Base(Players),
|
||||
pub enum CellStructure {
|
||||
Base(BaseBuilding),
|
||||
Tunel,
|
||||
Stone,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use crate::app::{
|
||||
buildings::{BaseBuilding, Buildings},
|
||||
buildings::BaseBuilding,
|
||||
helpers::{CellSizes, cell_size_helper, cells_area_helper},
|
||||
states::{CellTag, FocusedCell, Offset, Players, ZoomLevel, skirmish_states::MoveFocusedCell},
|
||||
states::{
|
||||
CellStructure, FocusedCell, Offset, Players, ZoomLevel, skirmish_states::MoveFocusedCell,
|
||||
},
|
||||
units::{MinerUnit, Units},
|
||||
widgets::CellWidget,
|
||||
};
|
||||
@@ -62,12 +64,12 @@ impl BoardState {
|
||||
let player_base: bool = row == player_base_coords.0 && col == player_base_coords.1;
|
||||
let enemy_base: bool = row == enemy_base_coords.0 && col == enemy_base_coords.1;
|
||||
|
||||
let tag: CellTag = if player_base {
|
||||
CellTag::Base(Players::Player)
|
||||
let structure: CellStructure = if player_base {
|
||||
CellStructure::Base(BaseBuilding::new(Players::Player))
|
||||
} else if enemy_base {
|
||||
CellTag::Base(Players::Enemy)
|
||||
CellStructure::Base(BaseBuilding::new(Players::Enemy))
|
||||
} else {
|
||||
CellTag::Stone
|
||||
CellStructure::Stone
|
||||
};
|
||||
|
||||
let unit: Option<Units> = if player_base {
|
||||
@@ -78,16 +80,8 @@ impl BoardState {
|
||||
None
|
||||
};
|
||||
|
||||
let building: Option<Buildings> = if player_base {
|
||||
Some(Buildings::Base(BaseBuilding::new(Players::Player)))
|
||||
} else if enemy_base {
|
||||
Some(Buildings::Base(BaseBuilding::new(Players::Enemy)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
rows.push(CellWidget::new(
|
||||
row, col, zoom_level, selected, tag, unit, building,
|
||||
row, col, zoom_level, selected, structure, unit,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user