simple hitpoint mechanic
This commit is contained in:
@@ -6,11 +6,15 @@ use crate::{
|
||||
camera::GameCameraRig,
|
||||
cash::{Cash, CashCollectEvent},
|
||||
heads_ui::HeadChanged,
|
||||
shooting::TriggerState,
|
||||
tb_entities::SpawnPoint,
|
||||
};
|
||||
use avian3d::prelude::*;
|
||||
use bevy::{
|
||||
input::mouse::MouseMotion,
|
||||
input::{
|
||||
ButtonState,
|
||||
mouse::{MouseButtonInput, MouseMotion},
|
||||
},
|
||||
prelude::*,
|
||||
window::{CursorGrabMode, PrimaryWindow},
|
||||
};
|
||||
@@ -49,7 +53,6 @@ pub fn plugin(app: &mut App) {
|
||||
(
|
||||
spawn,
|
||||
update_camera,
|
||||
mouse_rotate,
|
||||
collect_cash,
|
||||
toggle_animation,
|
||||
setup_animations_marker_for_player,
|
||||
@@ -60,6 +63,9 @@ pub fn plugin(app: &mut App) {
|
||||
apply_controls.in_set(TnuaUserControlsSystemSet),
|
||||
);
|
||||
|
||||
app.add_systems(Update, mouse_rotate.run_if(on_event::<MouseMotion>));
|
||||
app.add_systems(Update, mouse_click.run_if(on_event::<MouseButtonInput>));
|
||||
|
||||
app.add_observer(updaate_head);
|
||||
}
|
||||
|
||||
@@ -131,6 +137,28 @@ fn mouse_rotate(
|
||||
}
|
||||
}
|
||||
|
||||
fn mouse_click(mut events: EventReader<MouseButtonInput>, mut commands: Commands) {
|
||||
for ev in events.read() {
|
||||
match ev {
|
||||
MouseButtonInput {
|
||||
button: MouseButton::Left,
|
||||
state: ButtonState::Pressed,
|
||||
..
|
||||
} => {
|
||||
commands.trigger(TriggerState::Active);
|
||||
}
|
||||
MouseButtonInput {
|
||||
button: MouseButton::Left,
|
||||
state: ButtonState::Released,
|
||||
..
|
||||
} => {
|
||||
commands.trigger(TriggerState::Inactive);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_grab_cursor(window: &mut Window) {
|
||||
match window.cursor_options.grab_mode {
|
||||
CursorGrabMode::None => {
|
||||
|
||||
Reference in New Issue
Block a user