mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added wall lamps
This commit is contained in:
parent
e991ff7d6d
commit
69436db64c
@ -90,6 +90,24 @@ impl BlockKind {
|
||||
/// fields.
|
||||
#[inline]
|
||||
pub const fn has_color(&self) -> bool { self.is_filled() }
|
||||
|
||||
/// Determine whether the block is 'terrain-like'. This definition is
|
||||
/// arbitrary, but includes things like rocks, soils, sands, grass, and
|
||||
/// other blocks that might be expected to the landscape. Plant matter and
|
||||
/// snow are *not* included.
|
||||
#[inline]
|
||||
pub const fn is_terrain(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
BlockKind::Rock
|
||||
| BlockKind::WeakRock
|
||||
| BlockKind::GlowingRock
|
||||
| BlockKind::GlowingWeakRock
|
||||
| BlockKind::Grass
|
||||
| BlockKind::Earth
|
||||
| BlockKind::Sand
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
|
@ -198,7 +198,7 @@ pub fn init(
|
||||
_ => {},
|
||||
},
|
||||
SiteKind::Refactor(site2) => {
|
||||
for _ in 0..(site.economy.pop as usize).min(site2.plots().len() * 3) {
|
||||
for _ in 0..site.economy.pop.min(site2.plots().len() as f32 * 1.5) as usize {
|
||||
rtsim.entities.insert(Entity {
|
||||
is_loaded: false,
|
||||
pos: site2
|
||||
|
@ -30,6 +30,7 @@ pub struct SpawnRules {
|
||||
}
|
||||
|
||||
impl SpawnRules {
|
||||
#[must_use]
|
||||
pub fn combine(self, other: Self) -> Self {
|
||||
// Should be commutative
|
||||
Self {
|
||||
|
@ -222,7 +222,7 @@ impl Site {
|
||||
|
||||
pub fn make_plaza(&mut self, land: &Land, rng: &mut impl Rng) -> Id<Plot> {
|
||||
let plaza_radius = rng.gen_range(1..4);
|
||||
let plaza_dist = 10.0 + plaza_radius as f32 * 5.0;
|
||||
let plaza_dist = 6.5 + plaza_radius as f32 * 4.0;
|
||||
let pos = attempt(32, || {
|
||||
self.plazas
|
||||
.choose(rng)
|
||||
@ -382,7 +382,7 @@ impl Site {
|
||||
match *build_chance.choose_seeded(rng.gen()) {
|
||||
// House
|
||||
1 => {
|
||||
let size = (2.0 + rng.gen::<f32>().powf(5.0) * 1.5).round() as u32;
|
||||
let size = (1.5 + rng.gen::<f32>().powf(5.0) * 1.0).round() as u32;
|
||||
if let Some((aabr, door_tile, door_dir)) = attempt(32, || {
|
||||
site.find_roadside_aabr(
|
||||
&mut rng,
|
||||
@ -713,7 +713,7 @@ impl Site {
|
||||
for z in -8..6 {
|
||||
canvas.map(Vec3::new(wpos2d.x, wpos2d.y, alt + z), |b| {
|
||||
if b.is_filled() {
|
||||
if underground {
|
||||
if underground && b.is_terrain() {
|
||||
Block::new(BlockKind::Earth, Rgb::new(0x6A, 0x47, 0x24))
|
||||
} else {
|
||||
b
|
||||
@ -781,7 +781,7 @@ impl Site {
|
||||
canvas.map(
|
||||
Vec3::new(wpos2d.x, wpos2d.y, alt + z),
|
||||
|b| if b.is_filled() {
|
||||
if underground {
|
||||
if underground && b.is_terrain() {
|
||||
Block::new(BlockKind::Earth, Rgb::new(0x6A, 0x47, 0x24))
|
||||
} else {
|
||||
b
|
||||
|
@ -856,6 +856,40 @@ impl Structure for House {
|
||||
painter.prim(Primitive::intersect(walls, windows)),
|
||||
Fill::Block(Block::air(SpriteKind::Window1).with_ori(2).unwrap()),
|
||||
);
|
||||
// Wall lamps
|
||||
if i == 1 {
|
||||
let mut torches_min = painter.prim(Primitive::Empty);
|
||||
let mut torches_max = painter.prim(Primitive::Empty);
|
||||
for y in self.tile_aabr.min.y..self.tile_aabr.max.y {
|
||||
let pos = site
|
||||
.tile_wpos(Vec2::new(self.tile_aabr.min.x, y))
|
||||
.with_z(alt + previous_height + 3)
|
||||
+ Vec3::new(-1, 0, 0);
|
||||
let torch = painter.prim(Primitive::Aabb(Aabb {
|
||||
min: pos,
|
||||
max: pos + 1,
|
||||
}));
|
||||
torches_min = painter.prim(Primitive::union(torches_min, torch));
|
||||
|
||||
let pos = site
|
||||
.tile_wpos(Vec2::new(self.tile_aabr.max.x, y + 1))
|
||||
.with_z(alt + previous_height + 3)
|
||||
+ Vec3::new(1, 0, 0);
|
||||
let torch = painter.prim(Primitive::Aabb(Aabb {
|
||||
min: pos,
|
||||
max: pos + 1,
|
||||
}));
|
||||
torches_max = painter.prim(Primitive::union(torches_max, torch));
|
||||
}
|
||||
painter.fill(
|
||||
torches_min,
|
||||
Fill::Block(Block::air(SpriteKind::WallLampSmall).with_ori(6).unwrap()),
|
||||
);
|
||||
painter.fill(
|
||||
torches_max,
|
||||
Fill::Block(Block::air(SpriteKind::WallLampSmall).with_ori(2).unwrap()),
|
||||
);
|
||||
}
|
||||
}
|
||||
// Windows y axis
|
||||
{
|
||||
@ -886,6 +920,40 @@ impl Structure for House {
|
||||
painter.prim(Primitive::intersect(walls, windows)),
|
||||
Fill::Block(Block::air(SpriteKind::Window1).with_ori(0).unwrap()),
|
||||
);
|
||||
// Wall lamps
|
||||
if i == 1 {
|
||||
let mut torches_min = painter.prim(Primitive::Empty);
|
||||
let mut torches_max = painter.prim(Primitive::Empty);
|
||||
for x in self.tile_aabr.min.x..self.tile_aabr.max.x {
|
||||
let pos = site
|
||||
.tile_wpos(Vec2::new(x + 1, self.tile_aabr.min.y))
|
||||
.with_z(alt + previous_height + 3)
|
||||
+ Vec3::new(0, -1, 0);
|
||||
let torch = painter.prim(Primitive::Aabb(Aabb {
|
||||
min: pos,
|
||||
max: pos + 1,
|
||||
}));
|
||||
torches_min = painter.prim(Primitive::union(torches_min, torch));
|
||||
|
||||
let pos = site
|
||||
.tile_wpos(Vec2::new(x, self.tile_aabr.max.y))
|
||||
.with_z(alt + previous_height + 3)
|
||||
+ Vec3::new(0, 1, 0);
|
||||
let torch = painter.prim(Primitive::Aabb(Aabb {
|
||||
min: pos,
|
||||
max: pos + 1,
|
||||
}));
|
||||
torches_max = painter.prim(Primitive::union(torches_max, torch));
|
||||
}
|
||||
painter.fill(
|
||||
torches_min,
|
||||
Fill::Block(Block::air(SpriteKind::WallLampSmall).with_ori(0).unwrap()),
|
||||
);
|
||||
painter.fill(
|
||||
torches_max,
|
||||
Fill::Block(Block::air(SpriteKind::WallLampSmall).with_ori(4).unwrap()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Shed roof on negative overhangs
|
||||
|
Loading…
Reference in New Issue
Block a user