add soul spot resource deposit and fix core placement bug

This commit is contained in:
Jim 2025-09-02 13:55:14 -04:00
parent 52da1f8acb
commit 68f4b0d8a0
Signed by: jim
GPG key ID: 3D7D94BA53088BF4
13 changed files with 171 additions and 27 deletions

View file

@ -19,6 +19,7 @@ inhabitant_coranth = { path = "../inhabitant_coranth" }
inhabitant_simbert = { path = "../inhabitant_simbert" }
inhabitant_endrake = { path = "../inhabitant_endrake" }
resource_graveyard = { path = "../resource_graveyard" }
resource_soul_spot = { path = "../resource_soul_spot" }
[lints]
workspace = true

View file

@ -23,6 +23,7 @@ use inhabitant_simbert::SpawnSimbert;
use physics::{Ground, PhysicsLayers};
use rand::{Rng, thread_rng};
use resource_graveyard::PlaceGraveyard;
use resource_soul_spot::PlaceSoulSpot;
use state::{AppState, BasePhaseState, GameSystemSet, Phase};
pub struct LevelPlugin;
@ -62,6 +63,7 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut graveyard_writer: EventWriter<PlaceGraveyard>,
mut soul_spot_writer: EventWriter<PlaceSoulSpot>,
) {
// Static physics object with a collision shape
commands.spawn((
@ -82,17 +84,17 @@ fn setup(
let mut rng = thread_rng();
// place graveyards
let mut graveyards = Vec::new();
for _ in 0..rng.gen_range(3..=5) {
// place resources
let mut resource_positions = Vec::new();
for i in 0..rng.gen_range(4..=6) {
for _ in 0..10 {
let bounds = LEVEL_SIZE / 2. - 3.;
let bounds = LEVEL_SIZE / 3. - 3.;
let pos = Vec3::new(
rng.gen_range(-bounds..=bounds).round(),
0.25,
rng.gen_range(-bounds..=bounds).round(),
);
if graveyards
if resource_positions
.iter()
.any(|loc: &Vec3| loc.distance_squared(pos) < 4.)
{
@ -100,8 +102,12 @@ fn setup(
info!("too close! {:?}", pos);
continue;
}
graveyards.push(pos);
graveyard_writer.write(PlaceGraveyard(pos));
resource_positions.push(pos);
if i == 0 {
soul_spot_writer.write(PlaceSoulSpot(pos));
} else {
graveyard_writer.write(PlaceGraveyard(pos));
}
break;
}
}
@ -198,7 +204,7 @@ fn spawn_enemies(
2.0 + y as f32 * 0.5,
spawn_origin.z,
),
mega: clump_size > 1 && y == 0,
mega: clump_size > 2 && y == 0,
});
// writer.write(SpawnCoranth {
// transform: Transform::from_xyz(