Improved docs

This commit is contained in:
Joshua Barretto 2020-09-20 11:07:13 +01:00
parent ee3781d168
commit 49d1b3df6d
5 changed files with 41 additions and 52 deletions

View File

@ -16,7 +16,7 @@ fn criterion_benchmark(c: &mut Criterion) {
// Setup: Create chunk and fill it (dense) for z in [140, 220).
let mut chunk = TerrainChunk::new(
MIN_Z,
Block::new(BlockKind::Dense, Default::default()),
Block::new(BlockKind::Rock, Default::default()),
Block::empty(),
TerrainChunkMeta::void(),
);
@ -29,7 +29,7 @@ fn criterion_benchmark(c: &mut Criterion) {
),
) {
chunk
.set(pos, Block::new(BlockKind::Dense, Default::default()))
.set(pos, Block::new(BlockKind::Rock, Default::default()))
.unwrap();
}
@ -118,7 +118,7 @@ fn criterion_benchmark(c: &mut Criterion) {
MAX_Z,
),
) {
let _ = chunk.set(pos, Block::new(BlockKind::Dense, Default::default()));
let _ = chunk.set(pos, Block::new(BlockKind::Rock, Default::default()));
}
})
});

View File

@ -50,21 +50,11 @@ make_case_elim!(
);
impl BlockKind {
pub const fn is_air(&self) -> bool {
match self {
BlockKind::Air => true,
_ => false,
}
}
pub const fn is_air(&self) -> bool { matches!(self, BlockKind::Air) }
pub const fn is_fluid(&self) -> bool { *self as u8 & 0xF0 == 0x00 }
pub const fn is_liquid(&self) -> bool {
match self {
BlockKind::Water => true,
_ => false,
}
}
pub const fn is_liquid(&self) -> bool { self.is_fluid() && !self.is_air() }
pub const fn is_filled(&self) -> bool { !self.is_fluid() }
}
@ -199,7 +189,7 @@ impl Block {
self
}
/// If this block can have orientation, replace its sprite.
/// If this block can have orientation, give it a new orientation.
pub fn with_ori(mut self, ori: u8) -> Self {
if self.get_sprite().map(|s| s.has_ori()).unwrap_or(false) {
self.attr[1] = (self.attr[1] & !0b111) | (ori & 0b111);
@ -208,7 +198,7 @@ impl Block {
}
/// Remove the terrain sprite or solid aspects of a block
pub fn into_vacant(mut self) -> Self {
pub fn into_vacant(self) -> Self {
if self.is_fluid() {
Block::new(self.kind(), Rgb::zero())
} else {

View File

@ -170,39 +170,39 @@ impl SpriteKind {
}
pub fn has_ori(&self) -> bool {
match self {
matches!(
self,
SpriteKind::Window1
| SpriteKind::Window2
| SpriteKind::Window3
| SpriteKind::Window4
| SpriteKind::Bed
| SpriteKind::Bench
| SpriteKind::ChairSingle
| SpriteKind::ChairDouble
| SpriteKind::CoatRack
| SpriteKind::Crate
| SpriteKind::DrawerLarge
| SpriteKind::DrawerMedium
| SpriteKind::DrawerSmall
| SpriteKind::DungeonWallDecor
| SpriteKind::HangingBasket
| SpriteKind::HangingSign
| SpriteKind::WallLamp
| SpriteKind::Planter
| SpriteKind::Shelf
| SpriteKind::TableSide
| SpriteKind::TableDining
| SpriteKind::TableDouble
| SpriteKind::WardrobeSingle
| SpriteKind::WardrobeDouble
| SpriteKind::Pot
| SpriteKind::Chest
| SpriteKind::DropGate
| SpriteKind::DropGateBottom
| SpriteKind::Door
| SpriteKind::Beehive => true,
_ => false,
}
| SpriteKind::Window2
| SpriteKind::Window3
| SpriteKind::Window4
| SpriteKind::Bed
| SpriteKind::Bench
| SpriteKind::ChairSingle
| SpriteKind::ChairDouble
| SpriteKind::CoatRack
| SpriteKind::Crate
| SpriteKind::DrawerLarge
| SpriteKind::DrawerMedium
| SpriteKind::DrawerSmall
| SpriteKind::DungeonWallDecor
| SpriteKind::HangingBasket
| SpriteKind::HangingSign
| SpriteKind::WallLamp
| SpriteKind::Planter
| SpriteKind::Shelf
| SpriteKind::TableSide
| SpriteKind::TableDining
| SpriteKind::TableDouble
| SpriteKind::WardrobeSingle
| SpriteKind::WardrobeDouble
| SpriteKind::Pot
| SpriteKind::Chest
| SpriteKind::DropGate
| SpriteKind::DropGateBottom
| SpriteKind::Door
| SpriteKind::Beehive
)
}
}

View File

@ -8,8 +8,7 @@ use common::{
msg::ServerMsg,
recipe::default_recipe_book,
sync::{Uid, WorldSyncExt},
terrain::block::Block,
vol::{ReadVol, Vox},
vol::ReadVol,
};
use comp::LightEmitter;
use rand::Rng;

View File

@ -283,7 +283,7 @@ pub fn apply_scatter_to<'a>(
)
}),
// Underwater chests
(Chest, true, |c, col| (MUSH_FACT * 0.25, None)),
(Chest, true, |_, _| (MUSH_FACT * 0.1, None)),
];
for y in 0..vol.size_xy().y as i32 {