mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Rename find_space_opt
to try_find_space
.
This commit is contained in:
parent
ca10d89068
commit
5dd56b724c
@ -159,10 +159,10 @@ impl TerrainGrid {
|
||||
/// Find a location suitable for spawning an entity near the given
|
||||
/// position (but in the same chunk).
|
||||
pub fn find_space(&self, pos: Vec3<i32>) -> Vec3<i32> {
|
||||
self.find_space_opt(pos).unwrap_or(pos)
|
||||
self.try_find_space(pos).unwrap_or(pos)
|
||||
}
|
||||
|
||||
pub fn find_space_opt(&self, pos: Vec3<i32>) -> Option<Vec3<i32>> {
|
||||
pub fn try_find_space(&self, pos: Vec3<i32>) -> Option<Vec3<i32>> {
|
||||
const SEARCH_DIST: i32 = 63;
|
||||
(0..SEARCH_DIST * 2 + 1)
|
||||
.map(|i| if i % 2 == 0 { i } else { -i } / 2)
|
||||
|
@ -336,7 +336,7 @@ impl<'a> System<'a> for Sys {
|
||||
let chunk_pos = terrain.pos_key(pos.0.map(|e| e as i32));
|
||||
if let Some(chunk) = terrain.get_key(chunk_pos) {
|
||||
pos.0 = terrain
|
||||
.find_space_opt(pos.0.as_::<i32>())
|
||||
.try_find_space(pos.0.as_::<i32>())
|
||||
.map(|x| x.as_::<f32>())
|
||||
.unwrap_or_else(|| chunk.find_accessible_pos(pos.0.xy().as_::<i32>(), false));
|
||||
repositioned.push(entity);
|
||||
|
Loading…
Reference in New Issue
Block a user