use bevy::prelude::*;
pub mod app;
mod assets;
mod components;
pub mod ldtk;
mod level;
mod resources;
pub mod systems;
mod tile_makers;
pub mod utils;
pub use assets::*;
pub use components::*;
pub use plugin::*;
pub use resources::*;
#[cfg(feature = "derive")]
pub use bevy_ecs_ldtk_macros::*;
mod plugin {
use super::*;
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, SystemLabel)]
pub enum LdtkSystemLabel {
ProcessAssets,
LevelSelection,
LevelSet,
LevelSpawning,
Other,
}
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, StageLabel)]
pub enum LdtkStage {
ProcessApi,
}
#[derive(Copy, Clone, Debug, Default)]
pub struct LdtkPlugin;
impl Plugin for LdtkPlugin {
fn build(&self, mut app: &mut App) {
if !app.is_plugin_added::<bevy_ecs_tilemap::TilemapPlugin>() {
app = app.add_plugin(bevy_ecs_tilemap::TilemapPlugin);
}
app.add_stage_after(
CoreStage::Update,
LdtkStage::ProcessApi,
SystemStage::parallel(),
)
.init_non_send_resource::<app::LdtkEntityMap>()
.init_non_send_resource::<app::LdtkIntCellMap>()
.init_resource::<resources::LdtkSettings>()
.add_asset::<assets::LdtkAsset>()
.init_asset_loader::<assets::LdtkLoader>()
.add_asset::<assets::LdtkLevel>()
.init_asset_loader::<assets::LdtkLevelLoader>()
.add_event::<resources::LevelEvent>()
.add_system_to_stage(
CoreStage::PreUpdate,
systems::process_ldtk_assets.label(LdtkSystemLabel::ProcessAssets),
)
.add_system_to_stage(
CoreStage::PreUpdate,
systems::process_ldtk_levels.label(LdtkSystemLabel::LevelSpawning),
)
.add_system_to_stage(
LdtkStage::ProcessApi,
systems::worldly_adoption.label(LdtkSystemLabel::Other),
)
.add_system_to_stage(
LdtkStage::ProcessApi,
systems::apply_level_selection.label(LdtkSystemLabel::LevelSelection),
)
.add_system_to_stage(
LdtkStage::ProcessApi,
systems::apply_level_set
.label(LdtkSystemLabel::LevelSet)
.after(LdtkSystemLabel::LevelSelection),
)
.add_system_to_stage(
LdtkStage::ProcessApi,
systems::clean_respawn_entities.at_end(),
)
.add_system_to_stage(
CoreStage::PostUpdate,
systems::detect_level_spawned_events
.pipe(systems::fire_level_transformed_events)
.label(LdtkSystemLabel::Other),
);
}
}
}
pub mod prelude {
pub use crate::{
app::{LdtkEntity, LdtkIntCell, RegisterLdtkObjects},
assets::{LdtkAsset, LdtkLevel},
components::{
EntityInstance, GridCoords, IntGridCell, LayerMetadata, LdtkWorldBundle, LevelSet,
Respawn, TileEnumTags, TileMetadata, Worldly,
},
ldtk::{self, FieldValue, LayerInstance, TilesetDefinition},
plugin::LdtkPlugin,
resources::{
IntGridRendering, LdtkSettings, LevelBackground, LevelEvent, LevelSelection,
LevelSpawnBehavior, SetClearColor,
},
};
#[cfg(feature = "derive")]
pub use crate::{LdtkEntity, LdtkIntCell};
}