Switched light map iteration order, fire bowls in dungeons

This commit is contained in:
Joshua Barretto 2020-11-22 21:56:09 +00:00
parent a1236d4da0
commit 765a1ca17b
4 changed files with 15 additions and 13 deletions

View File

@ -171,6 +171,7 @@ impl Block {
SpriteKind::StreetLamp | SpriteKind::StreetLampTall => Some(24),
SpriteKind::Ember => Some(20),
SpriteKind::WallLamp => Some(16),
SpriteKind::FireBowlGround => Some(16),
SpriteKind::Velorite | SpriteKind::VeloriteFrag => Some(6),
_ => None,
}

View File

@ -95,7 +95,7 @@ impl<'a> System<'a> for Sys {
let body = entity.get_body();
server_emitter.emit(ServerEvent::CreateNpc {
pos: comp::Pos(spawn_pos),
stats: comp::Stats::new("Traveller [rt]".to_string(), body)
stats: comp::Stats::new("Traveller".to_string(), body)
.with_level(entity.get_level()),
health: comp::Health::new(body, 10),
loadout: entity.get_loadout(&ability_map),

View File

@ -54,8 +54,8 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
let mut light_map = vec![UNKNOWN; outer.size().product() as usize];
let lm_idx = {
let (w, h, _) = outer.clone().size().into_tuple();
move |x, y, z| (z * h * w + x * h + y) as usize
let (_, h, d) = outer.clone().size().into_tuple();
move |x, y, z| (h * d * x + d * y + z) as usize
};
// Light propagation queue
let mut prop_que = lit_blocks
@ -67,8 +67,8 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
.collect::<VecDeque<_>>();
// Start sun rays
if is_sunlight {
for y in 0..outer.size().h {
for x in 0..outer.size().w {
for x in 0..outer.size().w {
for y in 0..outer.size().h {
let z = outer.size().d - 1;
let is_air = vol_cached
.get(outer.min + Vec3::new(x, y, z))
@ -209,20 +209,20 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
}
let min_bounds = Aabb {
min: bounds.min - Vec3::unit_z(),
max: bounds.max + Vec3::unit_z(),
min: bounds.min - 1,
max: bounds.max + 1,
};
// Minimise light map to reduce duplication. We can now discard light info
// for blocks outside of the chunk borders.
let mut light_map2 = vec![UNKNOWN; min_bounds.size().product() as usize];
let lm_idx2 = {
let (w, h, _) = min_bounds.clone().size().into_tuple();
move |x, y, z| (z * h * w + x * h + y) as usize
let (_, h, d) = min_bounds.clone().size().into_tuple();
move |x, y, z| (h * d * x + d * y + z) as usize
};
for z in 0..min_bounds.size().d {
for x in 0..min_bounds.size().w {
for y in 0..min_bounds.size().h {
for x in 0..min_bounds.size().w {
for z in 0..min_bounds.size().d {
let off = min_bounds.min - outer.min;
light_map2[lm_idx2(x, y, z)] = light_map[lm_idx(x + off.x, y + off.y, z + off.z)];
}

View File

@ -1032,14 +1032,15 @@ impl Floor {
let tunnel_dist =
1.0 - (dist_to_wall - wall_thickness).max(0.0) / (TILE_SIZE as f32 - wall_thickness);
let floor_sprite = if RandomField::new(7331).chance(Vec3::from(pos), 0.00005) {
let floor_sprite = if RandomField::new(7331).chance(Vec3::from(pos), 0.001) {
BlockMask::new(
with_sprite(
match (RandomField::new(1337).get(Vec3::from(pos)) / 2) % 20 {
match (RandomField::new(1337).get(Vec3::from(pos)) / 2) % 30 {
0 => SpriteKind::Apple,
1 => SpriteKind::VeloriteFrag,
2 => SpriteKind::Velorite,
3..=8 => SpriteKind::Mushroom,
9..=15 => SpriteKind::FireBowlGround,
_ => SpriteKind::ShortGrass,
},
),