Added the still empty level gen plugin
parent
5f72edba96
commit
92d37cbfcf
|
@ -0,0 +1,17 @@
|
|||
|
||||
# Enemies can only be set if they exist in data/enemies/
|
||||
# for example data/enemies/grunt.yml
|
||||
enemies: [
|
||||
grunt
|
||||
]
|
||||
# 0 means no enemies
|
||||
waves: 0
|
||||
# 0 is no treasure
|
||||
treasure: 0
|
||||
doors: [
|
||||
true, # North
|
||||
true, # East
|
||||
true, # South
|
||||
true, # West
|
||||
]
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
use bevy::prelude::*;
|
||||
use serde::{Serialize, Deserialze};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use crate::load_yaml_folder;
|
||||
|
||||
pub struct LevelgenPlugin;
|
||||
|
||||
|
@ -34,14 +35,14 @@ pub struct LevelGenerator {
|
|||
|
||||
|
||||
fn setup_levels(mut commands: Commands) {
|
||||
let mut initial_level: String = "
|
||||
let default_level: String = "
|
||||
# Enemies can only be set if they exist in data/enemies/
|
||||
# for example data/enemies/grunt.yml
|
||||
enemies: [
|
||||
grunt
|
||||
]
|
||||
# 0 means no enemies
|
||||
waves: 1
|
||||
waves: 0
|
||||
# 0 is no treasure
|
||||
treasure: 0
|
||||
doors: [
|
||||
|
@ -51,22 +52,10 @@ fn setup_levels(mut commands: Commands) {
|
|||
true, # West
|
||||
]
|
||||
".to_string();
|
||||
let initial_level_path = Path::new("./data/levels/initial_level.yml");
|
||||
if initial_level_path.exists() {
|
||||
initial_level =
|
||||
fs::read_to_string("./data/levels/initial_level.yml").expect("Error reading data/levels/initial_level.yml");
|
||||
} else {
|
||||
fs::write("./data/levels/initial_level.yml", initial_level.clone())
|
||||
.expect("Error writing data/levels/initial_level.yml");
|
||||
}
|
||||
let paths = fs::read_dir("./data/levels/").unwrap();
|
||||
|
||||
for path in paths {
|
||||
}
|
||||
commands.spawn((
|
||||
LevelGenerator {
|
||||
},
|
||||
));
|
||||
let level_yaml: Vec<String> = load_yaml_folder(default_level, Path::new("./data/levels"));
|
||||
|
||||
let starting_level_data = serde_yaml::from_str::<Level>(&fs::read_to_string("./data/levels/default.yml").expect("Error reading data/levels/default.yml"));
|
||||
}
|
||||
|
||||
fn level_generation() {
|
||||
|
|
|
@ -3,6 +3,7 @@ use player::PlayerPlugin;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::path::Path;
|
||||
use crate::player::Player;
|
||||
use crate::levelgen::LevelgenPlugin;
|
||||
use crate::setup::config_loader::load_yaml_folder;
|
||||
|
||||
#[derive(Component, Serialize, Deserialize)]
|
||||
|
@ -24,6 +25,7 @@ pub struct InputVisual {
|
|||
|
||||
pub mod setup;
|
||||
mod player;
|
||||
mod levelgen;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
|
@ -42,6 +44,7 @@ fn main() {
|
|||
.build(),
|
||||
)
|
||||
.add_plugins(PlayerPlugin)
|
||||
.add_plugins(LevelgenPlugin)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, get_input)
|
||||
.add_systems(Update, draw_input)
|
||||
|
|
Loading…
Reference in New Issue