add impaler scaffolding and teams
This commit is contained in:
parent
af45237701
commit
6659fe8e5a
12 changed files with 151 additions and 21 deletions
53
crates/building_impaler/src/lib.rs
Normal file
53
crates/building_impaler/src/lib.rs
Normal 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"),
|
||||
));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue