Address review comments.

This commit is contained in:
Joshua Yanovski 2020-09-27 17:06:46 +02:00
parent 529533466c
commit 5af5ceb1f9
8 changed files with 19 additions and 15 deletions

View File

@ -125,6 +125,15 @@ impl Block {
}
}
/// TODO: See if we can generalize this somehow.
#[inline]
pub const fn water(sprite: SpriteKind) -> Self {
Self {
kind: BlockKind::Water,
attr: [sprite as u8, 0, 0],
}
}
#[inline]
pub fn get_color(&self) -> Option<Rgb<u8>> {
if self.has_color() {

View File

@ -491,8 +491,6 @@ pub fn block_from_structure(
let lerp = ((field.get(Vec3::from(structure_pos)).rem_euclid(256)) as f32 / 255.0) * 0.85
+ ((field.get(pos + std::i32::MAX / 2).rem_euclid(256)) as f32 / 255.0) * 0.15;
const EMPTY_SPRITE: Rgb<u8> = Rgb::new(SpriteKind::Empty as u8, 0, 0);
match sblock {
StructureBlock::None => None,
StructureBlock::Hollow => Some(with_sprite(SpriteKind::Empty)),
@ -501,12 +499,9 @@ pub fn block_from_structure(
sample.surface_color.map(|e| (e * 255.0) as u8),
)),
StructureBlock::Normal(color) => Some(Block::new(BlockKind::Misc, color)),
StructureBlock::Water => Some(Block::new(BlockKind::Water, EMPTY_SPRITE)),
StructureBlock::GreenSludge => Some(Block::new(
// TODO: If/when liquid supports other colors again, revisit this.
BlockKind::Water,
EMPTY_SPRITE,
)),
StructureBlock::Water => Some(Block::water(SpriteKind::Empty)),
// TODO: If/when liquid supports other colors again, revisit this.
StructureBlock::GreenSludge => Some(Block::water(SpriteKind::Empty)),
// None of these BlockKinds has an orientation, so we just use zero for the other color
// bits.
StructureBlock::Liana => Some(with_sprite(SpriteKind::Liana)),

View File

@ -209,7 +209,7 @@ pub fn apply_caves_to<'a>(
}
#[allow(clippy::eval_order_dependence)]
pub fn apply_caves_supplement<'a>(
// NOTE: Used only for dynamic elemens like chests and entities!
// NOTE: Used only for dynamic elements like chests and entities!
dynamic_rng: &mut impl Rng,
wpos2d: Vec2<i32>,
mut get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,

View File

@ -416,7 +416,7 @@ impl Castle {
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
pub fn apply_supplement<'a>(
&'a self,
// NOTE: Used only for dynamic elemens like chests and entities!
// NOTE: Used only for dynamic elements like chests and entities!
_dynamic_rng: &mut impl Rng,
_wpos2d: Vec2<i32>,
_get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,

View File

@ -163,7 +163,7 @@ impl Dungeon {
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
pub fn apply_supplement<'a>(
&'a self,
// NOTE: Used only for dynamic elemens like chests and entities!
// NOTE: Used only for dynamic elements like chests and entities!
dynamic_rng: &mut impl Rng,
wpos2d: Vec2<i32>,
_get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,
@ -417,7 +417,7 @@ impl Floor {
#[allow(clippy::match_single_binding)] // TODO: Pending review in #587
fn apply_supplement(
&self,
// NOTE: Used only for dynamic elemens like chests and entities!
// NOTE: Used only for dynamic elements like chests and entities!
dynamic_rng: &mut impl Rng,
area: Aabr<i32>,
origin: Vec3<i32>,

View File

@ -108,7 +108,7 @@ impl Site {
pub fn apply_supplement<'a>(
&'a self,
// NOTE: Used only for dynamic elemens like chests and entities!
// NOTE: Used only for dynamic elements like chests and entities!
dynamic_rng: &mut impl Rng,
wpos2d: Vec2<i32>,
get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,

View File

@ -531,7 +531,7 @@ impl Archetype for House {
.noise
.chance(Vec3::new(center_offset.x, center_offset.y, z), 0.2)
{
// NOTE: Used only for dynamic elemens like chests and entities!
// NOTE: Used only for dynamic elements like chests and entities!
let mut dynamic_rng = rand::thread_rng();
let furniture = match self.noise.get(Vec3::new(
center_offset.x,

View File

@ -836,7 +836,7 @@ impl Settlement {
#[allow(clippy::eval_order_dependence)] // TODO: Pending review in #587
pub fn apply_supplement<'a>(
&'a self,
// NOTE: Used only for dynamic elemens like chests and entities!
// NOTE: Used only for dynamic elements like chests and entities!
dynamic_rng: &mut impl Rng,
wpos2d: Vec2<i32>,
mut get_column: impl FnMut(Vec2<i32>) -> Option<&'a ColumnSample<'a>>,