Skip to content

Commit

Permalink
mw_common/game/TileKind: split foundation into two kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
inodentry committed Jan 3, 2024
1 parent 923d2ac commit 66a8343
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
16 changes: 10 additions & 6 deletions lib/mw_common/src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ pub enum ItemKind {
#[bits = 3]
pub enum TileKind {
Water,
Foundation,
Destroyed,
#[default]
Regular,
Fertile,
FoundationStruct,
FoundationRoad,
Forest,
Mountain,
Destroyed,
}

impl TileKind {
Expand All @@ -51,11 +52,12 @@ impl TileKind {
match self {
TileKind::Water |
TileKind::Forest |
TileKind::Mountain => false,
TileKind::Mountain |
TileKind::FoundationStruct => false,
TileKind::Regular |
TileKind::Fertile |
TileKind::Destroyed |
TileKind::Foundation => true,
TileKind::FoundationRoad => true,
}
}

Expand All @@ -67,15 +69,17 @@ impl TileKind {
TileKind::Regular |
TileKind::Fertile |
TileKind::Destroyed |
TileKind::Foundation => false,
TileKind::FoundationRoad |
TileKind::FoundationStruct=> false,
}
}

pub const fn is_harvestable(self) -> bool {
match self {
TileKind::Water |
TileKind::Destroyed |
TileKind::Foundation => false,
TileKind::FoundationRoad |
TileKind::FoundationStruct => false,
TileKind::Regular |
TileKind::Fertile |
TileKind::Forest |
Expand Down
3 changes: 2 additions & 1 deletion lib/mw_dataformat/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ impl From<mw_common::game::TileKind> for MsgTileKind {
fn from(value: mw_common::game::TileKind) -> Self {
match value {
mw_common::game::TileKind::Water => MsgTileKind::Water,
mw_common::game::TileKind::Foundation => MsgTileKind::Foundation,
mw_common::game::TileKind::FoundationRoad => MsgTileKind::Foundation,
mw_common::game::TileKind::FoundationStruct => MsgTileKind::Foundation,
mw_common::game::TileKind::Regular => MsgTileKind::Regular,
mw_common::game::TileKind::Fertile => MsgTileKind::Fertile,
mw_common::game::TileKind::Forest => MsgTileKind::Forest,
Expand Down
3 changes: 2 additions & 1 deletion src/gfx2d/sprites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ fn tile_kind<C: Coord>(
for (mut spr, kind, pos) in &mut q {
spr.index = i_base + match kind {
TileKind::Water => super::sprite::TILE_WATER,
TileKind::Foundation => super::sprite::TILE_FOUNDATION,
TileKind::FoundationRoad => super::sprite::TILE_FOUNDATION,
TileKind::FoundationStruct => super::sprite::TILE_FOUNDATION,
TileKind::Regular => super::sprite::TILE_LAND,
TileKind::Fertile => super::sprite::TILE_FERTILE,
TileKind::Forest => super::sprite::TILE_FOREST,
Expand Down
3 changes: 2 additions & 1 deletion src/gfx2d/tilemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ fn tile_kind<C: Coord>(
for (mut index, mut color, kind, pos) in &mut q {
index.0 = (i_base + match kind {
TileKind::Water => super::sprite::TILE_WATER,
TileKind::Foundation => super::sprite::TILE_FOUNDATION,
TileKind::FoundationRoad => super::sprite::TILE_FOUNDATION,
TileKind::FoundationStruct => super::sprite::TILE_FOUNDATION,
TileKind::Regular => super::sprite::TILE_LAND,
TileKind::Fertile => super::sprite::TILE_FERTILE,
TileKind::Forest => super::sprite::TILE_FOREST,
Expand Down

0 comments on commit 66a8343

Please sign in to comment.