convert core to new format, improve tower placement
This commit is contained in:
parent
2808f6dd2c
commit
bc02db7b26
12 changed files with 250 additions and 107 deletions
|
|
@ -11,8 +11,7 @@ state = { path = "../state" }
|
|||
camera = { path = "../camera" }
|
||||
combat = { path = "../combat" }
|
||||
physics = { path = "../physics" }
|
||||
building_core = { path = "../building_core" }
|
||||
building_impaler = { path = "../building_impaler" }
|
||||
building = { path = "../building" }
|
||||
inhabitant_coranth = { path = "../inhabitant_coranth" }
|
||||
|
||||
[lints]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#![allow(clippy::type_complexity)]
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use avian3d::prelude::*;
|
||||
use bevy::{
|
||||
core_pipeline::{bloom::Bloom, experimental::taa::TemporalAntiAliasing},
|
||||
|
|
@ -9,17 +11,18 @@ use bevy::{
|
|||
prelude::*,
|
||||
render::camera::Exposure,
|
||||
};
|
||||
use building_core::SpawnCore;
|
||||
use building::{BuildingTypes, PlaceBuilding};
|
||||
use camera::ControlledCamera;
|
||||
use inhabitant_coranth::SpawnCoranth;
|
||||
use physics::Ground;
|
||||
use state::AppState;
|
||||
use state::{AppState, GameSystemSet};
|
||||
|
||||
pub struct LevelPlugin;
|
||||
|
||||
impl Plugin for LevelPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(OnEnter(AppState::Game), setup);
|
||||
app.add_systems(OnEnter(AppState::Game), setup)
|
||||
.add_systems(FixedUpdate, spawn_enemies.in_set(GameSystemSet::Execute));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +30,8 @@ fn setup(
|
|||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
mut core_writer: EventWriter<SpawnCore>,
|
||||
buildings: Res<BuildingTypes>,
|
||||
mut place_writer: EventWriter<PlaceBuilding>,
|
||||
mut coranth_writer: EventWriter<SpawnCoranth>,
|
||||
) {
|
||||
let level_size = 50.0;
|
||||
|
|
@ -51,9 +55,9 @@ fn setup(
|
|||
transform: Transform::from_xyz(y as f32 * 0.25, y as f32 * 1.1, 0.0),
|
||||
});
|
||||
}
|
||||
|
||||
core_writer.write(SpawnCore {
|
||||
transform: Transform::from_xyz(5.0, 1.0, 5.0),
|
||||
place_writer.write(PlaceBuilding {
|
||||
info: buildings.info.get("Core").unwrap().0,
|
||||
location: IVec3 { x: 5, y: 0, z: 5 },
|
||||
});
|
||||
|
||||
// Light
|
||||
|
|
@ -85,3 +89,23 @@ fn setup(
|
|||
Transform::from_xyz(-2.5, 9.5, 9.0).looking_at(Vec3::ZERO, Dir3::Y),
|
||||
));
|
||||
}
|
||||
|
||||
fn spawn_enemies(
|
||||
mut writer: EventWriter<SpawnCoranth>,
|
||||
time: Res<Time>,
|
||||
mut setup: Local<bool>,
|
||||
mut timer: Local<Timer>,
|
||||
) {
|
||||
if !*setup {
|
||||
*timer = Timer::new(Duration::from_secs(1), TimerMode::Repeating);
|
||||
*setup = true;
|
||||
}
|
||||
timer.tick(time.delta());
|
||||
if timer.just_finished() {
|
||||
for _ in 0..3 {
|
||||
writer.write(SpawnCoranth {
|
||||
transform: Transform::from_xyz(0.0, 2.0, 0.0),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue