Skip to content

Commit

Permalink
Add spawners to blenvy, make little spawn areas for consorts and imps
Browse files Browse the repository at this point in the history
Closes #213
  • Loading branch information
jwright159 committed Jan 5, 2025
1 parent a981784 commit d54e649
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 27 deletions.
Binary file modified sbepis/art/assets.blend
Binary file not shown.
Binary file added sbepis/assets/blueprints/rock.glb
Binary file not shown.
5 changes: 5 additions & 0 deletions sbepis/assets/blueprints/rock.meta.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(
assets:
[
]
)
Binary file modified sbepis/assets/levels/World.glb
Binary file not shown.
2 changes: 2 additions & 0 deletions sbepis/assets/levels/World.meta.ron
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
("Planet", File ( path: "materials/Planet.glb" )),
("Cube", File ( path: "blueprints/Cube.glb" )),
("Cube", File ( path: "materials/Cube.glb" )),
("rock", File ( path: "blueprints/rock.glb" )),
("Material", File ( path: "materials/Material.glb" )),
]
)
Binary file added sbepis/assets/materials/Material.glb
Binary file not shown.
47 changes: 45 additions & 2 deletions sbepis/src/blenvy.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::time::Duration;

use bevy::prelude::*;
use bevy_rapier3d::prelude::*;

use crate::entity::spawner::Spawner;
use crate::entity::GelViscosity;
use crate::gravity::{AffectedByGravity, GravityPoint, GravityPriority};
use crate::npcs::{ConsortSpawner, ImpSpawner};
use crate::{ok_or_continue, some_or_continue};

pub struct BlenvyPlugin;
Expand All @@ -13,9 +17,18 @@ impl Plugin for BlenvyPlugin {

app.register_type::<MeshColliderBlundle>()
.register_type::<PlanetBlundle>()
.register_type::<BoxBlundle>();
.register_type::<BoxBlundle>()
.register_type::<SpawnerBlundle>();

app.add_systems(PreUpdate, (create_mesh_collider, create_planet, create_box));
app.add_systems(
PreUpdate,
(
create_mesh_collider,
create_planet,
create_box,
create_spawner,
),
);
}
}

Expand Down Expand Up @@ -87,3 +100,33 @@ pub fn create_box(scenes: Query<Entity, With<BoxBlundle>>, mut commands: Command
));
}
}

#[derive(Component, Reflect)]
#[reflect(Component)]
pub enum SpawnerBlundle {
Imp,
Consort,
}

pub fn create_spawner(scenes: Query<(Entity, &SpawnerBlundle)>, mut commands: Commands) {
for (scene, spawner) in scenes.iter() {
let mut spawner_commands = commands.entity(scene);

spawner_commands
.remove::<SpawnerBlundle>()
.insert((Spawner {
max_amount: 5,
spawn_delay: Duration::from_secs_f32(5.),
spawn_timer: Duration::ZERO,
},));

match spawner {
SpawnerBlundle::Imp => {
spawner_commands.insert(ImpSpawner);
}
SpawnerBlundle::Consort => {
spawner_commands.insert(ConsortSpawner);
}
}
}
}
27 changes: 2 additions & 25 deletions sbepis/src/npcs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::time::Duration;

use bevy::prelude::*;
use bevy::render::mesh::CapsuleUvProfile;
use bevy_common_assets::ron::RonAssetPlugin;
use bevy_rapier3d::geometry::Collider;
use name_tags::*;

use crate::entity::spawner::{spawn_entities, SpawnEntityInformation, SpawnedEntity, Spawner};
use crate::entity::spawner::{spawn_entities, SpawnEntityInformation, SpawnedEntity};
use crate::entity::{Healing, RandomInput, RotateTowardMovement, SpawnHealthBar, TargetPlayer};
use crate::main_bundles::EntityBundle;
use crate::questing::{QuestGiver, SpawnQuestMarker};
Expand All @@ -19,7 +17,7 @@ impl Plugin for NpcPlugin {
fn build(&self, app: &mut App) {
app.add_plugins(RonAssetPlugin::<AvailableNames>::new(&["names.ron"]))
.init_resource::<FontMeshGenerator>()
.add_systems(Startup, (setup, load_names))
.add_systems(Startup, (load_names,))
.add_systems(
Update,
(
Expand All @@ -43,27 +41,6 @@ pub struct Imp;
#[derive(Component)]
pub struct ImpSpawner;

fn setup(mut commands: Commands) {
commands.spawn((
ConsortSpawner,
Spawner {
max_amount: 5,
spawn_delay: Duration::from_secs_f32(5.),
spawn_timer: Duration::ZERO,
},
Transform::from_xyz(-20., 1., 0.),
));
commands.spawn((
ImpSpawner,
Spawner {
max_amount: 5,
spawn_delay: Duration::from_secs_f32(5.),
spawn_timer: Duration::ZERO,
},
Transform::from_xyz(20., 1., 0.),
));
}

fn spawn_consort(
In(spawn_info): In<Option<SpawnEntityInformation>>,
mut commands: Commands,
Expand Down

0 comments on commit d54e649

Please sign in to comment.