mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added a spacing_radius method to body to make it possible to sett different spacing for different entities
This commit is contained in:
parent
1e3cc3442f
commit
171113ea74
@ -412,6 +412,27 @@ impl Body {
|
||||
dim.x.max(dim.y) / 2.0
|
||||
}
|
||||
|
||||
// How far away other entities should try to be. Will be added uppon the other
|
||||
// entitys spacing_radius. So an entity with 2.0 and an entity with 3.0 will lead
|
||||
// to that both entities will try to keep 5.0 units away from each other.
|
||||
pub fn spacing_radius(&self) -> f32 {
|
||||
self.radius() + match self {
|
||||
Body::QuadrupedSmall(body) => match body.species {
|
||||
quadruped_small::Species::Rat => 0.0,
|
||||
_ => 2.0,
|
||||
},
|
||||
Body::QuadrupedLow(body) => match body.species {
|
||||
quadruped_low::Species::Hakulaq => 0.0,
|
||||
_ => 2.0,
|
||||
}
|
||||
Body::BipedSmall(body) => match body.species {
|
||||
biped_small::Species::Husk => 3.0,
|
||||
_ => 2.0,
|
||||
}
|
||||
_ => 2.0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn height(&self) -> f32 { self.dimensions().z }
|
||||
|
||||
pub fn base_energy(&self) -> u32 {
|
||||
|
@ -168,7 +168,7 @@ const FLEE_DURATION: f32 = 3.0;
|
||||
const MAX_FOLLOW_DIST: f32 = 12.0;
|
||||
const MAX_PATH_DIST: f32 = 170.0;
|
||||
const PARTIAL_PATH_DIST: f32 = 50.0;
|
||||
const SEPARATION_DIST: f32 = 4.0;
|
||||
const SEPARATION_DIST: f32 = 10.0;
|
||||
const SEPARATION_BIAS: f32 = 0.8;
|
||||
const MAX_FLEE_DIST: f32 = 20.0;
|
||||
const SEARCH_DIST: f32 = 48.0;
|
||||
@ -4050,6 +4050,7 @@ impl<'a> AgentData<'a> {
|
||||
/// multiplies the movement speed by a value less than 1.0.
|
||||
/// A `None` value implies a multiplier of 1.0.
|
||||
/// Returns `false` if the pathfinding algorithm fails to return a path
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn path_toward_target(
|
||||
&self,
|
||||
agent: &mut Agent,
|
||||
@ -4078,14 +4079,14 @@ impl<'a> AgentData<'a> {
|
||||
read_data.bodies.get(entity),
|
||||
) {
|
||||
if self.pos.0.xy().distance(pos.0.xy())
|
||||
< SEPARATION_DIST + body.radius() + other_body.radius()
|
||||
< body.spacing_radius() + other_body.spacing_radius()
|
||||
{
|
||||
sep_vec += (self.pos.0.xy() - pos.0.xy())
|
||||
.try_normalized()
|
||||
.unwrap_or_else(Vec2::zero)
|
||||
* (((SEPARATION_DIST + body.radius() + other_body.radius())
|
||||
* (((body.spacing_radius() + other_body.spacing_radius())
|
||||
- self.pos.0.xy().distance(pos.0.xy()))
|
||||
/ SEPARATION_DIST);
|
||||
/ (body.spacing_radius() + other_body.spacing_radius()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user