add impaler scaffolding and teams

This commit is contained in:
Jim 2025-08-25 08:31:33 -04:00
parent af45237701
commit 6659fe8e5a
Signed by: jim
GPG key ID: 3236D2F059A7C0AC
12 changed files with 151 additions and 21 deletions

View file

@ -0,0 +1,53 @@
//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 BuildingImpalerPlugin;
impl Plugin for BuildingImpalerPlugin {
fn build(&self, app: &mut App) {
app.add_event::<SpawnImpaler>()
.add_systems(FixedUpdate, spawn.in_set(GameSystemSet::PostTick));
}
}
#[derive(Component)]
#[require(Building)]
pub struct Impaler;
#[derive(Event)]
pub struct SpawnImpaler {
pub transform: Transform,
}
fn spawn(
mut reader: EventReader<SpawnImpaler>,
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
for SpawnImpaler { transform } in reader.read() {
commands.spawn((
RigidBody::Static,
Collider::cuboid(1.0, 1.0, 1.0),
Mesh3d(meshes.add(Cuboid::from_length(1.0))),
MeshMaterial3d(materials.add(StandardMaterial {
base_color: Color::srgb_u8(0xd6, 0x50, 0x61),
metallic: 0.2,
perceptual_roughness: 0.6,
..default()
})),
Impaler,
transform.clone(),
Health::new(20.0),
Defense::new(5.0),
Name::from("Impaler"),
));
}
}