diff --git a/assets/world/style/colors.ron b/assets/world/style/colors.ron index b46018a8c7..78e282b410 100644 --- a/assets/world/style/colors.ron +++ b/assets/world/style/colors.ron @@ -64,6 +64,7 @@ cave_roof: (38, 21, 79), dirt: (69, 48, 15), scaffold: (195, 190, 212), + lava: (184, 39, 0), vein: (222, 140, 39), ), site: ( diff --git a/common/src/terrain/block.rs b/common/src/terrain/block.rs index bdeb0d6b28..4327137fda 100644 --- a/common/src/terrain/block.rs +++ b/common/src/terrain/block.rs @@ -30,13 +30,13 @@ make_case_elim!( pub enum BlockKind { Air = 0x00, // Air counts as a fluid Water = 0x01, - Lava = 0x02, // 0x02 <= x < 0x10 are reserved for other fluids. These are 2^n aligned to allow bitwise // checking of common conditions. For example, `is_fluid` is just `block_kind & // 0x0F == 0` (this is a very common operation used in meshing that could do with // being *very* fast). Rock = 0x10, WeakRock = 0x11, // Explodable + Lava = 0x12, // 0x12 <= x < 0x20 is reserved for future rocks Grass = 0x20, // Note: *not* the same as grass sprites Snow = 0x21, @@ -181,6 +181,9 @@ impl Block { #[inline] pub fn get_glow(&self) -> Option { + if matches!(self.kind, BlockKind::Lava) { + return Some(24); + } match self.get_sprite()? { SpriteKind::StreetLamp | SpriteKind::StreetLampTall => Some(24), SpriteKind::Ember => Some(20), @@ -230,7 +233,7 @@ impl Block { pub fn is_solid(&self) -> bool { self.get_sprite() .map(|s| s.solid_height().is_some()) - .unwrap_or(true) + .unwrap_or(!matches!(self.kind, BlockKind::Lava)) } /// Can this block be exploded? If so, what 'power' is required to do so? diff --git a/common/systems/src/buff.rs b/common/systems/src/buff.rs index b2d50da3dc..20e8a0c612 100644 --- a/common/systems/src/buff.rs +++ b/common/systems/src/buff.rs @@ -1,8 +1,8 @@ use common::{ comp::{ - fluid_dynamics::{LiquidKind, Fluid}, Buff, BuffCategory, BuffChange, BuffData, BuffEffect, BuffId, - BuffKind, BuffSource, Buffs, Energy, Health, HealthChange, HealthSource, Inventory, - ModifierKind, PhysicsState, Stats, + fluid_dynamics::{Fluid, LiquidKind}, + Buff, BuffCategory, BuffChange, BuffData, BuffEffect, BuffId, BuffKind, BuffSource, Buffs, + Energy, Health, HealthChange, HealthSource, Inventory, ModifierKind, PhysicsState, Stats, }, event::{EventBus, ServerEvent}, resources::DeltaTime, @@ -57,15 +57,20 @@ impl<'a> System<'a> for Sys { { let in_fluid = physics_state.and_then(|p| p.in_fluid); - if matches!(in_fluid, Some(Fluid::Liquid { kind: LiquidKind::Lava, .. })) { - if !buff_comp.contains(BuffKind::Burning) { - buff_comp.insert(Buff::new( - BuffKind::Burning, - BuffData::new(200.0, None), - vec![BuffCategory::Natural], - BuffSource::World, - )); - } + if matches!( + in_fluid, + Some(Fluid::Liquid { + kind: LiquidKind::Lava, + .. + }) + ) && !buff_comp.contains(BuffKind::Burning) + { + buff_comp.insert(Buff::new( + BuffKind::Burning, + BuffData::new(200.0, None), + vec![BuffCategory::Natural], + BuffSource::World, + )); } let (buff_comp_kinds, buff_comp_buffs): ( @@ -262,7 +267,15 @@ fn tick_buff( } if let Some(remaining_time) = &mut buff.time { // Extinguish Burning buff when in water - if matches!(buff.kind, BuffKind::Burning) && matches!(in_fluid, Some(Fluid::Liquid { kind: LiquidKind::Water, .. })) { + if matches!(buff.kind, BuffKind::Burning) + && matches!( + in_fluid, + Some(Fluid::Liquid { + kind: LiquidKind::Water, + .. + }) + ) + { *remaining_time = Duration::default(); } diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index 5e62cbbdf3..81d1cec1c5 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -1558,9 +1558,10 @@ fn box_voxel_collision<'a, T: BaseVol + ReadVol>( }; if player_aabb.collides_with_aabb(liquid_aabb) { liquid = match liquid { - Some((kind, max_liquid_z)) => { - Some((kind.merge(block_liquid), max_liquid_z.max(liquid_aabb.max.z))) - }, + Some((kind, max_liquid_z)) => Some(( + kind.merge(block_liquid), + max_liquid_z.max(liquid_aabb.max.z), + )), None => Some((block_liquid, liquid_aabb.max.z)), }; } diff --git a/world/src/layer/mod.rs b/world/src/layer/mod.rs index ee7545fbbe..56592205df 100644 --- a/world/src/layer/mod.rs +++ b/world/src/layer/mod.rs @@ -34,6 +34,7 @@ pub struct Colors { pub cave_roof: (u8, u8, u8), pub dirt: (u8, u8, u8), pub scaffold: (u8, u8, u8), + pub lava: (u8, u8, u8), pub vein: (u8, u8, u8), } @@ -217,10 +218,7 @@ pub fn apply_caves_to(canvas: &mut Canvas, rng: &mut impl Rng) { }; canvas.set( Vec3::new(wpos2d.x, wpos2d.y, z), - Block::new( - kind, - noisy_color(info.index().colors.layer.scaffold.into(), 8), - ), + Block::new(kind, noisy_color(info.index().colors.layer.lava.into(), 8)), ); } }