mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make lava solid w.r.t. rendering while still being liquid w.r.t. physics.
This commit is contained in:
parent
2226a4c6a9
commit
f1a1160b80
@ -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: (
|
||||
|
@ -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<u8> {
|
||||
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?
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -1558,9 +1558,10 @@ fn box_voxel_collision<'a, T: BaseVol<Vox = Block> + 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)),
|
||||
};
|
||||
}
|
||||
|
@ -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)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user