mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Snow on spots
This commit is contained in:
parent
c8b1155b75
commit
01c068a892
@ -9,7 +9,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
generation::EntityInfo,
|
generation::EntityInfo,
|
||||||
terrain::{Block, Structure, TerrainChunk, TerrainChunkSize},
|
terrain::{Block, BlockKind, Structure, TerrainChunk, TerrainChunkSize},
|
||||||
vol::{ReadVol, RectVolSize, WriteVol},
|
vol::{ReadVol, RectVolSize, WriteVol},
|
||||||
};
|
};
|
||||||
use std::{borrow::Cow, ops::Deref};
|
use std::{borrow::Cow, ops::Deref};
|
||||||
@ -199,16 +199,19 @@ impl<'a> Canvas<'a> {
|
|||||||
structure: &Structure,
|
structure: &Structure,
|
||||||
seed: u32,
|
seed: u32,
|
||||||
units: Vec2<Vec2<i32>>,
|
units: Vec2<Vec2<i32>>,
|
||||||
|
with_snow: bool,
|
||||||
) {
|
) {
|
||||||
let info = self.info();
|
let info = self.info();
|
||||||
self.foreach_col(|canvas, wpos2d, col| {
|
self.foreach_col(|canvas, wpos2d, col| {
|
||||||
let rpos2d = wpos2d - origin.xy();
|
let rpos2d = wpos2d - origin.xy();
|
||||||
let rpos2d = units.x * rpos2d.x + units.y * rpos2d.y;
|
let rpos2d = units.x * rpos2d.x + units.y * rpos2d.y;
|
||||||
|
|
||||||
for z in structure.get_bounds().min.z..structure.get_bounds().max.z {
|
let mut above = true;
|
||||||
|
for z in (structure.get_bounds().min.z..structure.get_bounds().max.z).rev() {
|
||||||
if let Ok(sblock) = structure.get(rpos2d.with_z(z)) {
|
if let Ok(sblock) = structure.get(rpos2d.with_z(z)) {
|
||||||
|
let mut add_snow = false;
|
||||||
let _ = canvas.map(wpos2d.with_z(origin.z + z), |block| {
|
let _ = canvas.map(wpos2d.with_z(origin.z + z), |block| {
|
||||||
if let Some(block) = block_from_structure(
|
if let Some(new_block) = block_from_structure(
|
||||||
info.index,
|
info.index,
|
||||||
*sblock,
|
*sblock,
|
||||||
wpos2d.with_z(origin.z + z),
|
wpos2d.with_z(origin.z + z),
|
||||||
@ -217,11 +220,24 @@ impl<'a> Canvas<'a> {
|
|||||||
col,
|
col,
|
||||||
|sprite| block.with_sprite(sprite),
|
|sprite| block.with_sprite(sprite),
|
||||||
) {
|
) {
|
||||||
block
|
if !new_block.is_air() {
|
||||||
|
if with_snow && col.snow_cover && above {
|
||||||
|
add_snow = true;
|
||||||
|
}
|
||||||
|
above = false;
|
||||||
|
}
|
||||||
|
new_block
|
||||||
} else {
|
} else {
|
||||||
block
|
block
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if add_snow {
|
||||||
|
let _ = canvas.set(
|
||||||
|
wpos2d.with_z(origin.z + z + 1),
|
||||||
|
Block::new(BlockKind::Snow, Rgb::new(210, 210, 255)),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -405,7 +405,7 @@ pub fn apply_spots_to(canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
|
|||||||
.map(|c| c.alt as i32)
|
.map(|c| c.alt as i32)
|
||||||
.unwrap_or(0),
|
.unwrap_or(0),
|
||||||
);
|
);
|
||||||
canvas.blit_structure(origin, &structure, seed, units);
|
canvas.blit_structure(origin, &structure, seed, units, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn entities
|
// Spawn entities
|
||||||
|
Loading…
x
Reference in New Issue
Block a user