Compare commits
2 Commits
4ecacb73ad
...
b1254d9029
Author | SHA1 | Date | |
---|---|---|---|
b1254d9029 | |||
a4908fda80 |
|
@ -38,6 +38,5 @@ maze_generator = "2"
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
pathfinding = "4"
|
pathfinding = "4"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
sentry = "0.29"
|
|
||||||
serde = "1"
|
serde = "1"
|
||||||
shadowcast = "0.8"
|
shadowcast = "0.8"
|
24
src/error.rs
24
src/error.rs
|
@ -4,9 +4,6 @@ use std::{panic, thread};
|
||||||
use backtrace::Backtrace;
|
use backtrace::Backtrace;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
#[derive(Resource)]
|
|
||||||
struct Guard(sentry::ClientInitGuard);
|
|
||||||
|
|
||||||
pub fn error_handler(In(result): In<Result<(), Box<dyn Error>>>) {
|
pub fn error_handler(In(result): In<Result<(), Box<dyn Error>>>) {
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
error!("{}", e);
|
error!("{}", e);
|
||||||
|
@ -47,29 +44,10 @@ fn init_panic_handler() {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource, Clone, Debug, Default)]
|
|
||||||
pub struct ErrorConfig {
|
|
||||||
pub sentry_dsn: Option<String>,
|
|
||||||
pub version: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ErrorPlugin;
|
pub struct ErrorPlugin;
|
||||||
|
|
||||||
impl Plugin for ErrorPlugin {
|
impl Plugin for ErrorPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, _app: &mut App) {
|
||||||
init_panic_handler();
|
init_panic_handler();
|
||||||
if let Some(config) = app.world.get_resource::<ErrorConfig>() {
|
|
||||||
if let Some(dsn) = &config.sentry_dsn {
|
|
||||||
let release = config.version.clone().unwrap_or_default();
|
|
||||||
let guard = sentry::init((
|
|
||||||
dsn.as_str(),
|
|
||||||
sentry::ClientOptions {
|
|
||||||
release: Some(release.into()),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
));
|
|
||||||
app.insert_resource(Guard(guard));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ pub enum NavigationAction {
|
||||||
SnapRight,
|
SnapRight,
|
||||||
SnapCardinal,
|
SnapCardinal,
|
||||||
SnapReverse,
|
SnapReverse,
|
||||||
Sprint,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)]
|
#[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)]
|
||||||
|
@ -78,7 +77,6 @@ fn movement_controls<State>(
|
||||||
for (entity, mut actions, mut velocity, mut speed, max_speed, rotation_speed, transform) in
|
for (entity, mut actions, mut velocity, mut speed, max_speed, rotation_speed, transform) in
|
||||||
&mut query
|
&mut query
|
||||||
{
|
{
|
||||||
let sprinting = actions.pressed(NavigationAction::Sprint);
|
|
||||||
let mut cleanup = false;
|
let mut cleanup = false;
|
||||||
if actions.pressed(NavigationAction::Move) {
|
if actions.pressed(NavigationAction::Move) {
|
||||||
if let Some(pair) = actions.clamped_axis_pair(NavigationAction::Move) {
|
if let Some(pair) = actions.clamped_axis_pair(NavigationAction::Move) {
|
||||||
|
@ -100,11 +98,7 @@ fn movement_controls<State>(
|
||||||
} else {
|
} else {
|
||||||
forward_backward_movement_factor
|
forward_backward_movement_factor
|
||||||
};
|
};
|
||||||
let mut s = if sprinting {
|
let mut s = **max_speed;
|
||||||
**max_speed
|
|
||||||
} else {
|
|
||||||
**max_speed / config.sprint_movement_factor
|
|
||||||
};
|
|
||||||
s *= movement_factor;
|
s *= movement_factor;
|
||||||
**speed = s;
|
**speed = s;
|
||||||
let mut v = direction * **speed;
|
let mut v = direction * **speed;
|
||||||
|
@ -340,7 +334,6 @@ pub struct NavigationPlugin<State> {
|
||||||
pub forward_movement_factor: f32,
|
pub forward_movement_factor: f32,
|
||||||
pub backward_movement_factor: f32,
|
pub backward_movement_factor: f32,
|
||||||
pub strafe_movement_factor: f32,
|
pub strafe_movement_factor: f32,
|
||||||
pub sprint_movement_factor: f32,
|
|
||||||
pub states: Vec<State>,
|
pub states: Vec<State>,
|
||||||
pub describe_undescribed_areas: bool,
|
pub describe_undescribed_areas: bool,
|
||||||
pub log_area_descriptions: bool,
|
pub log_area_descriptions: bool,
|
||||||
|
@ -352,7 +345,6 @@ impl<State> Default for NavigationPlugin<State> {
|
||||||
forward_movement_factor: 1.,
|
forward_movement_factor: 1.,
|
||||||
backward_movement_factor: 1.,
|
backward_movement_factor: 1.,
|
||||||
strafe_movement_factor: 1.,
|
strafe_movement_factor: 1.,
|
||||||
sprint_movement_factor: 3.,
|
|
||||||
states: vec![],
|
states: vec![],
|
||||||
describe_undescribed_areas: false,
|
describe_undescribed_areas: false,
|
||||||
log_area_descriptions: true,
|
log_area_descriptions: true,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user