use crate::ldtk::Level;
use bevy::prelude::*;
#[allow(unused_imports)]
use crate::components::{LdtkWorldBundle, LevelSet};
#[derive(Clone, Eq, PartialEq, Debug, Resource)]
pub enum LevelSelection {
Identifier(String),
Index(usize),
Iid(String),
Uid(i32),
}
impl Default for LevelSelection {
fn default() -> Self {
LevelSelection::Index(0)
}
}
impl LevelSelection {
pub fn is_match(&self, index: &usize, level: &Level) -> bool {
match self {
LevelSelection::Identifier(s) => *s == level.identifier,
LevelSelection::Index(i) => *i == *index,
LevelSelection::Iid(i) => *i == level.iid,
LevelSelection::Uid(u) => *u == level.uid,
}
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum SetClearColor {
No,
FromLevelBackground,
FromEditorBackground,
}
impl Default for SetClearColor {
fn default() -> Self {
Self::No
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum LevelSpawnBehavior {
UseZeroTranslation,
UseWorldTranslation {
load_level_neighbors: bool,
},
}
impl Default for LevelSpawnBehavior {
fn default() -> Self {
LevelSpawnBehavior::UseZeroTranslation
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum IntGridRendering {
Colorful,
Invisible,
}
impl Default for IntGridRendering {
fn default() -> Self {
IntGridRendering::Colorful
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum LevelBackground {
Rendered,
Nonexistent,
}
impl Default for LevelBackground {
fn default() -> Self {
LevelBackground::Rendered
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default, Resource)]
pub struct LdtkSettings {
pub level_spawn_behavior: LevelSpawnBehavior,
pub set_clear_color: SetClearColor,
pub int_grid_rendering: IntGridRendering,
pub level_background: LevelBackground,
}
#[derive(Clone, Eq, PartialEq, Debug, Hash)]
pub enum LevelEvent {
SpawnTriggered(String),
Spawned(String),
Transformed(String),
Despawned(String),
}