diff --git a/assets/settings/input_map.ron b/assets/settings/input_map.ron index 954bb8b..b82ce27 100755 --- a/assets/settings/input_map.ron +++ b/assets/settings/input_map.ron @@ -1,11 +1,11 @@ ( map: { - KeyCode(ShiftLeft): [ - MultiPlaceTower, - ], MouseButton(Middle): [ CameraOrbitEnable, ], + KeyCode(ShiftLeft): [ + MultiPlaceTower, + ], KeyCode(F1): [ ToggleDebugUI, ], diff --git a/crates/inhabitant_coranth/src/lib.rs b/crates/inhabitant_coranth/src/lib.rs index 4658350..c817337 100755 --- a/crates/inhabitant_coranth/src/lib.rs +++ b/crates/inhabitant_coranth/src/lib.rs @@ -4,7 +4,7 @@ use avian3d::prelude::*; use bevy::prelude::*; -use building::Building; +use building::Core; use combat::{GaveDamage, Health, Team}; use combat_damagers::ContactDamage; use inhabitant::Inhabitant; @@ -15,6 +15,7 @@ pub struct InhabitantCoranthPlugin; impl Plugin for InhabitantCoranthPlugin { fn build(&self, app: &mut App) { app.add_event::() + .add_systems(Startup, init) .add_systems(FixedUpdate, tick.in_set(GameSystemSet::Execute)) .add_systems(FixedUpdate, spawn.in_set(GameSystemSet::PostTick)); } @@ -29,25 +30,42 @@ pub struct SpawnCoranth { pub transform: Transform, } -fn spawn( - mut reader: EventReader, +#[derive(Resource)] +struct CoranthResources { + material: Handle, + mesh: Handle, + charge_timer: Timer, +} + +fn init( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, +) { + commands.insert_resource(CoranthResources { + material: materials.add(StandardMaterial { + base_color: Color::srgb_u8(220, 156, 86), + metallic: 1.0, + perceptual_roughness: 0.3, + ..default() + }), + mesh: meshes.add(Sphere::new(0.25)), + charge_timer: Timer::from_seconds(1.5, TimerMode::Repeating), + }); +} +fn spawn( + mut reader: EventReader, + mut commands: Commands, phase: Res>, + res: Res, ) { for SpawnCoranth { transform } in reader.read() { commands .spawn(( RigidBody::Dynamic, - Collider::cuboid(0.5, 0.5, 0.5), - Mesh3d(meshes.add(Cuboid::from_length(0.5))), - MeshMaterial3d(materials.add(StandardMaterial { - base_color: Color::srgb_u8(220, 156, 86), - metallic: 1.0, - perceptual_roughness: 0.3, - ..default() - })), + Collider::sphere(0.25), + Mesh3d(res.mesh.clone()), + MeshMaterial3d(res.material.clone()), MaxLinearSpeed(25.), Coranth, transform.clone(), @@ -86,22 +104,32 @@ fn explode( fn tick( mut coranths: Query<(&GlobalTransform, &mut LinearVelocity), With>, - buildings: Query<&GlobalTransform, With>, + core_gtf: Single<&GlobalTransform, With>, + mut res: ResMut, + time: Res