generated from 2ndbeam/bevy-template
feat: Level loading from TOML asset
- Fixed detect_interactions system - Added test for deserializing asset with plugin
This commit is contained in:
parent
0ab2620724
commit
79fe190b6b
9 changed files with 124 additions and 97 deletions
14
src/lib.rs
14
src/lib.rs
|
|
@ -2,6 +2,7 @@ use bevy::{
|
|||
prelude::*,
|
||||
ui_widgets::ScrollbarPlugin,
|
||||
};
|
||||
use bevy_common_assets::toml::TomlAssetPlugin;
|
||||
use bevy_rapier2d::{
|
||||
prelude::*,
|
||||
rapier::prelude::IntegrationParameters,
|
||||
|
|
@ -28,6 +29,14 @@ pub enum GameState {
|
|||
Inventory,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default, States, Reflect)]
|
||||
#[reflect(Clone, PartialEq, Debug, Default, Hash, State)]
|
||||
pub enum LoadingState {
|
||||
#[default]
|
||||
Loading,
|
||||
Ready,
|
||||
}
|
||||
|
||||
fn camera_bundle() -> impl Bundle {
|
||||
(
|
||||
Camera2d,
|
||||
|
|
@ -81,9 +90,11 @@ impl Plugin for ExpeditionPlugin {
|
|||
RapierPhysicsPlugin::<()>::default()
|
||||
.with_custom_initialization(rapier_init),
|
||||
ScrollbarPlugin,
|
||||
TomlAssetPlugin::<layout::asset::structs::LevelAsset>::new(&["toml"]),
|
||||
input::plugin::InputAssetPlugin::<input::InputAction>::default(),
|
||||
input::plugin::InputAssetPlugin::<input::UiAction>::default(),
|
||||
))
|
||||
.init_state::<LoadingState>()
|
||||
.init_state::<GameState>()
|
||||
.insert_resource(ui::WindowSize::default())
|
||||
.add_systems(Startup, (
|
||||
|
|
@ -92,12 +103,15 @@ impl Plugin for ExpeditionPlugin {
|
|||
))
|
||||
.add_systems(Update, (
|
||||
insert_entity_name,
|
||||
layout::asset::check_loading
|
||||
.run_if(|state: Res<State<LoadingState>>| *state == LoadingState::Loading),
|
||||
layout::systems::detect_interact_collisions,
|
||||
layout::systems::lock_door,
|
||||
player::systems::handle_input,
|
||||
ui::update_window_size,
|
||||
ui::handle_input,
|
||||
))
|
||||
.add_systems(OnEnter(LoadingState::Ready), layout::asset::load_level)
|
||||
.add_systems(OnEnter(GameState::Inventory), ui::inventory::systems::setup_ui_inventory)
|
||||
.add_systems(OnExit(GameState::Inventory), ui::inventory::systems::clear_ui_inventory)
|
||||
.add_observer(ui::inventory::observers::on_ui_rotate)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue