use gamestates and assetloader
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
use crate::{
|
||||
GameState,
|
||||
alien::{ALIEN_ASSET_PATH, Animations},
|
||||
camera::{CameraArmRotation, CameraTarget},
|
||||
cash::{Cash, CashCollectEvent},
|
||||
control::Controls,
|
||||
control::controller::{CharacterControllerBundle, PlayerMovement},
|
||||
control::{
|
||||
Controls,
|
||||
controller::{CharacterControllerBundle, PlayerMovement},
|
||||
},
|
||||
heads_ui::HeadChanged,
|
||||
physics_layers::GameLayer,
|
||||
tb_entities::SpawnPoint,
|
||||
@@ -40,18 +43,22 @@ struct PlayerSpawned {
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.init_resource::<PlayerSpawned>();
|
||||
app.add_systems(Startup, (toggle_cursor_system, cursor_recenter));
|
||||
app.add_systems(OnEnter(GameState::Playing), spawn);
|
||||
app.add_systems(
|
||||
Update,
|
||||
(
|
||||
spawn,
|
||||
collect_cash,
|
||||
toggle_animation,
|
||||
setup_animations_marker_for_player,
|
||||
toggle_cursor_system.run_if(input_just_pressed(KeyCode::Escape)),
|
||||
),
|
||||
)
|
||||
.run_if(in_state(GameState::Playing)),
|
||||
);
|
||||
|
||||
app.add_systems(Update, (rotate_view_keyboard, rotate_view_gamepad));
|
||||
app.add_systems(
|
||||
Update,
|
||||
(rotate_view_keyboard, rotate_view_gamepad).run_if(in_state(GameState::Playing)),
|
||||
);
|
||||
|
||||
app.add_observer(update_head);
|
||||
}
|
||||
@@ -259,6 +266,7 @@ fn update_head(
|
||||
|
||||
let head_str = head_id_to_str(trigger.0);
|
||||
|
||||
//TODO: use asset loader
|
||||
commands.spawn((
|
||||
AudioPlayer::new(asset_server.load(format!("sfx/heads/{}.ogg", head_str))),
|
||||
PlaybackSettings::DESPAWN,
|
||||
|
||||
Reference in New Issue
Block a user