various small fixes

This commit is contained in:
Isse 2023-05-05 20:32:41 +02:00
parent f6f332af6a
commit 61ecd2c178
5 changed files with 8 additions and 20 deletions

View File

@ -9,7 +9,7 @@ pub use self::{
};
use crate::{
terrain::{Block, BlockKind},
terrain::{Block, BlockKind, SpriteKind},
vol::{IntoFullPosIterator, IntoFullVolIterator, ReadVol, SizedVol, Vox, WriteVol},
volumes::dyna::Dyna,
};
@ -24,7 +24,7 @@ impl From<Segment> for TerrainSegment {
Err(_) | Ok(Cell::Empty) => Block::empty(),
Ok(cell) => {
if cell.is_hollow() {
Block::empty()
Block::air(SpriteKind::Empty)
} else if cell.is_glowy() {
Block::new(BlockKind::GlowingRock, cell.get_color().unwrap())
} else {

View File

@ -854,7 +854,7 @@ pub fn attempt_swap_equipped_weapons(data: &JoinData<'_>, update: &mut StateUpda
}
}
fn reach_block(
fn can_reach_block(
player_pos: Vec3<f32>,
block_pos: Vec3<i32>,
range: f32,
@ -975,7 +975,7 @@ pub fn handle_manipulate_loadout(
let sprite_interact =
sprite_at_pos.and_then(Option::<sprite_interact::SpriteInteractKind>::from);
if let Some(sprite_interact) = sprite_interact {
if reach_block(
if can_reach_block(
data.pos.0,
sprite_pos,
MAX_PICKUP_RANGE,

View File

@ -119,7 +119,7 @@ pub struct Block {
}
impl Vox for Block {
fn empty() -> Self { Block::empty() }
fn empty() -> Self { Block::air(SpriteKind::Empty) }
fn is_empty(&self) -> bool { self.is_air() && self.get_sprite().is_none() }
}

View File

@ -161,7 +161,7 @@ pub fn handle_mount_volume(server: &mut Server, rider: EcsEntity, volume_pos: Vo
let mount_pos = (mat * mount_offset.0.with_w(1.0)).xyz();
let within_range = {
let positions = state.ecs().read_storage::<Pos>();
positions.get(rider).map_or(false, |pos| pos.0.distance_squared(mount_pos) < MAX_SPRITE_MOUNT_RANGE * MAX_SPRITE_MOUNT_RANGE)
positions.get(rider).map_or(false, |pos| pos.0.distance_squared(mount_pos) < MAX_SPRITE_MOUNT_RANGE.powi(2))
};
let maybe_uid = state.ecs().read_storage::<Uid>().get(rider).copied();

View File

@ -157,20 +157,8 @@ where
let greedy_size_cross = greedy_size;
let draw_delta = lower_bound;
let get_light = |vol: &mut V, pos: Vec3<i32>| {
if vol.get(pos).map_or(true, |vox| vox.is_fluid()) {
1.0
} else {
0.0
}
};
let get_ao = |vol: &mut V, pos: Vec3<i32>| {
if vol.get(pos).map_or(false, |vox| vox.is_opaque()) {
0.0
} else {
1.0
}
};
let get_light = |vol: &mut V, pos: Vec3<i32>| vol.get(pos).map_or(true, |vox| vox.is_fluid()) as i32 as f32;
let get_ao = |vol: &mut V, pos: Vec3<i32>| vol.get(pos).map_or(false, |vox| vox.is_opaque()) as i32 as f32;
let get_glow = |vol: &mut V, pos: Vec3<i32>| {
vol.get(pos)
.ok()