mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Refactor, addresses more comments
This commit is contained in:
parent
477bdfdfe7
commit
6ac52daeae
@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Poise system (not currently accessible to players for balancing reasons)
|
||||
- Snow particles
|
||||
- Basic NPC interaction
|
||||
- Lights in dungeons
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -1117,16 +1117,13 @@ impl Floor {
|
||||
.min_by_key(|nearest| rpos.distance_squared(*nearest))
|
||||
}
|
||||
|
||||
// Find relative orientation of a position relative to another position
|
||||
// Find orientation of a position relative to another position
|
||||
#[allow(clippy::collapsible_if)]
|
||||
fn relative_ori(pos1: Vec2<i32>, pos2: Vec2<i32>) -> u8 {
|
||||
if pos1.x == pos2.x && pos1.y < pos2.y {
|
||||
4
|
||||
} else if pos1.x > pos2.x && pos1.y == pos2.y {
|
||||
6
|
||||
} else if pos1.x == pos2.x && pos1.y > pos2.y {
|
||||
8
|
||||
if (pos1.x - pos2.x).abs() < (pos1.y - pos2.y).abs() {
|
||||
if pos1.y > pos2.y { 4 } else { 8 }
|
||||
} else {
|
||||
2
|
||||
if pos1.x > pos2.x { 2 } else { 6 }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1203,19 +1200,18 @@ impl Floor {
|
||||
};
|
||||
|
||||
let tunnel_height = if self.final_level { 16.0 } else { 8.0 };
|
||||
let pillar_thickness: i32 = 4;
|
||||
|
||||
move |z| match self.tiles.get(tile_pos) {
|
||||
Some(Tile::Solid) => BlockMask::nothing(),
|
||||
Some(Tile::Tunnel) => {
|
||||
let light_offset: i32 = 7;
|
||||
if (dist_to_wall - wall_thickness) as i32 == 1
|
||||
&& rtile_pos
|
||||
.map(|e| e % light_offset == 0)
|
||||
.reduce(|x, y| x ^ y)
|
||||
&& rtile_pos.map(|e| e % light_offset == 0).reduce_bitxor()
|
||||
&& z == 1
|
||||
{
|
||||
let ori =
|
||||
Floor::relative_ori(self.nearest_wall(rpos).unwrap_or_default(), rpos);
|
||||
Floor::relative_ori(rpos, self.nearest_wall(rpos).unwrap_or_default());
|
||||
let furniture = SpriteKind::WallSconce;
|
||||
BlockMask::new(Block::air(furniture).with_ori(ori).unwrap(), 1)
|
||||
} else if dist_to_wall >= wall_thickness
|
||||
@ -1241,19 +1237,18 @@ impl Floor {
|
||||
tile_pos
|
||||
.map(|e| e.rem_euclid(pillar_space) == 0)
|
||||
.reduce_and()
|
||||
&& rtile_pos.map(|e| e as f32).magnitude_squared() < 3.5f32.powi(2)
|
||||
&& rtile_pos.map(|e| e as f32).magnitude_squared()
|
||||
< (pillar_thickness as f32 + 0.5).powi(2)
|
||||
})
|
||||
.unwrap_or(false) =>
|
||||
{
|
||||
if z == 1 && rtile_pos.map(|e| e as f32).magnitude_squared() > 3.0f32.powi(2) {
|
||||
let ori = Floor::relative_ori(
|
||||
self.nearest_wall(rtile_pos).unwrap_or_default(),
|
||||
rtile_pos,
|
||||
);
|
||||
if z == 1 && rtile_pos.product() == 0 && rtile_pos.sum().abs() == pillar_thickness {
|
||||
let ori = Floor::relative_ori(rtile_pos, Vec2::zero());
|
||||
let furniture = SpriteKind::WallSconce;
|
||||
BlockMask::new(Block::air(furniture).with_ori(ori).unwrap(), 1)
|
||||
} else if z < self.rooms[*room].height
|
||||
&& rtile_pos.map(|e| e as f32).magnitude_squared() > 3.0f32.powi(2)
|
||||
&& rtile_pos.map(|e| e as f32).magnitude_squared()
|
||||
> (pillar_thickness as f32 - 0.5).powi(2)
|
||||
{
|
||||
vacant
|
||||
} else {
|
||||
@ -1262,18 +1257,16 @@ impl Floor {
|
||||
}
|
||||
|
||||
Some(Tile::Room(_)) => {
|
||||
let light_offset: i32 = 7;
|
||||
let light_offset = 7;
|
||||
if z == 0 {
|
||||
floor_sprite
|
||||
} else if (dist_to_wall - 4.0).abs() < f32::EPSILON
|
||||
&& rtile_pos
|
||||
.map(|e| e % light_offset == 0)
|
||||
.reduce(|x, y| x ^ y)
|
||||
} else if dist_to_wall as i32 == 4
|
||||
&& rtile_pos.map(|e| e % light_offset == 0).reduce_bitxor()
|
||||
&& z == 1
|
||||
{
|
||||
let ori = Floor::relative_ori(
|
||||
self.nearest_wall(rpos).unwrap_or_else(Vec2::zero),
|
||||
rpos,
|
||||
self.nearest_wall(rpos).unwrap_or_else(Vec2::zero),
|
||||
);
|
||||
let furniture = SpriteKind::WallSconce;
|
||||
BlockMask::new(Block::air(furniture).with_ori(ori).unwrap(), 1)
|
||||
@ -1287,31 +1280,28 @@ impl Floor {
|
||||
},
|
||||
Some(Tile::UpStair(room)) => {
|
||||
let inner_radius: f32 = 0.5;
|
||||
let stretch: f32 = 9.0;
|
||||
let stretch = 9;
|
||||
let block = make_staircase(
|
||||
Vec3::new(rtile_pos.x, rtile_pos.y, z),
|
||||
TILE_SIZE as f32 / 2.0,
|
||||
inner_radius,
|
||||
stretch,
|
||||
stretch as f32,
|
||||
);
|
||||
let furniture = SpriteKind::WallLampSmall;
|
||||
let furniture = SpriteKind::WallSconce;
|
||||
let ori = Floor::relative_ori(
|
||||
self.nearest_wall(rtile_pos).unwrap_or_else(Vec2::zero),
|
||||
rpos,
|
||||
self.nearest_wall(rtile_pos).unwrap_or_else(Vec2::zero),
|
||||
);
|
||||
if z < self.rooms[*room].height {
|
||||
block.resolve_with(vacant)
|
||||
} else if z as f32 % stretch == 0.0
|
||||
&& rtile_pos.x == -TILE_SIZE / 2
|
||||
&& rtile_pos.y == 0
|
||||
{
|
||||
} else if z % stretch == 0 && rtile_pos.x == -TILE_SIZE / 2 && rtile_pos.y == 0 {
|
||||
BlockMask::new(Block::air(furniture).with_ori(ori).unwrap(), 1)
|
||||
} else {
|
||||
make_staircase(
|
||||
Vec3::new(rtile_pos.x, rtile_pos.y, z),
|
||||
TILE_SIZE as f32 / 2.0,
|
||||
inner_radius,
|
||||
stretch,
|
||||
stretch as f32,
|
||||
)
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user