mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix captain dismounting and don't panic in RandomField::choose
This commit is contained in:
parent
8569f30336
commit
96a3c81cbb
@ -237,7 +237,13 @@ impl<'a> AgentData<'a> {
|
||||
'activity: {
|
||||
match agent.rtsim_controller.activity {
|
||||
Some(NpcActivity::Goto(travel_to, speed_factor)) => {
|
||||
self.dismount(controller, read_data);
|
||||
if read_data
|
||||
.is_volume_riders
|
||||
.get(*self.entity)
|
||||
.map_or(false, |r| !r.is_steering_entity())
|
||||
{
|
||||
controller.push_event(ControlEvent::Unmount);
|
||||
}
|
||||
|
||||
// If it has an rtsim destination and can fly, then it should.
|
||||
// If it is flying and bumps something above it, then it should move down.
|
||||
|
@ -2146,7 +2146,7 @@ impl FigureMgr {
|
||||
active_tool_kind,
|
||||
second_tool_kind,
|
||||
character_activity
|
||||
.and_then(|a| a.steer_dir)
|
||||
.map(|a| a.steer_dir)
|
||||
.unwrap_or(0.0),
|
||||
time,
|
||||
),
|
||||
|
@ -942,7 +942,7 @@ impl Structure for Tavern {
|
||||
let mut offset = 0;
|
||||
let mut choose = |slice: &[Rgb<u8>]| -> Rgb<u8> {
|
||||
offset += 1;
|
||||
*field.choose(self.door_wpos + offset, slice)
|
||||
*field.choose(self.door_wpos + offset, slice).unwrap()
|
||||
};
|
||||
|
||||
let detail_fill = Fill::Brick(
|
||||
|
@ -16,14 +16,13 @@ impl RandomField {
|
||||
(self.get(pos) % (1 << 16)) as f32 / ((1 << 16) as f32)
|
||||
}
|
||||
|
||||
/// # Panics
|
||||
/// Panics if the slice is empty.
|
||||
pub fn choose<'a, T>(&self, pos: Vec3<i32>, slice: &'a [T]) -> &'a T {
|
||||
assert!(!slice.is_empty());
|
||||
pub fn choose<'a, T>(&self, pos: Vec3<i32>, slice: &'a [T]) -> Option<&'a T> {
|
||||
if slice.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let i = self.get(pos) as usize;
|
||||
|
||||
&slice[i % slice.len()]
|
||||
slice.get(i % slice.len())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user