2025-08-24 20:13:22 -04:00
|
|
|
//bevy system signatures often violate these rules
|
|
|
|
|
#![allow(clippy::type_complexity)]
|
|
|
|
|
#![allow(clippy::too_many_arguments)]
|
|
|
|
|
|
|
|
|
|
use avian3d::prelude::*;
|
|
|
|
|
use bevy::prelude::*;
|
|
|
|
|
use building::Building;
|
|
|
|
|
use combat::{Defense, Health};
|
|
|
|
|
use state::GameSystemSet;
|
|
|
|
|
|
|
|
|
|
pub struct BuildingCorePlugin;
|
|
|
|
|
|
|
|
|
|
impl Plugin for BuildingCorePlugin {
|
|
|
|
|
fn build(&self, app: &mut App) {
|
|
|
|
|
app.add_event::<SpawnCore>()
|
|
|
|
|
.add_systems(FixedUpdate, spawn_core.in_set(GameSystemSet::PostTick));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
|
#[require(Building)]
|
2025-08-25 08:31:33 -04:00
|
|
|
pub struct Core;
|
2025-08-24 20:13:22 -04:00
|
|
|
|
|
|
|
|
#[derive(Event)]
|
|
|
|
|
pub struct SpawnCore {
|
|
|
|
|
pub transform: Transform,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn spawn_core(
|
|
|
|
|
mut reader: EventReader<SpawnCore>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
|
|
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
|
|
|
|
) {
|
|
|
|
|
for SpawnCore { transform } in reader.read() {
|
|
|
|
|
commands.spawn((
|
|
|
|
|
RigidBody::Static,
|
|
|
|
|
Collider::cuboid(2.0, 2.0, 2.0),
|
|
|
|
|
Mesh3d(meshes.add(Cuboid::from_length(2.0))),
|
|
|
|
|
MeshMaterial3d(materials.add(StandardMaterial {
|
|
|
|
|
base_color: Color::srgb_u8(166, 69, 16),
|
|
|
|
|
metallic: 0.0,
|
|
|
|
|
perceptual_roughness: 0.8,
|
|
|
|
|
..default()
|
|
|
|
|
})),
|
2025-08-25 08:31:33 -04:00
|
|
|
Core,
|
2025-08-24 20:13:22 -04:00
|
|
|
transform.clone(),
|
|
|
|
|
Health::new(100.0),
|
|
|
|
|
Defense::new(10.0),
|
|
|
|
|
Name::from("Core"),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|