diff --git a/Cargo.lock b/Cargo.lock index 30ed76f..54a0a14 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -2009,6 +2009,8 @@ dependencies = [ "combat_damagers", "inhabitant", "inhabitant_coranth", + "inhabitant_endrake", + "inhabitant_simbert", "input", "level", "physics", @@ -3048,6 +3050,34 @@ dependencies = [ "state", ] +[[package]] +name = "inhabitant_endrake" +version = "0.1.0" +dependencies = [ + "avian3d", + "bevy", + "building", + "combat", + "combat_damagers", + "inhabitant", + "inhabitant_simbert", + "state", + "ui_health_bar", +] + +[[package]] +name = "inhabitant_simbert" +version = "0.1.0" +dependencies = [ + "avian3d", + "bevy", + "building", + "combat", + "combat_damagers", + "inhabitant", + "state", +] + [[package]] name = "inotify" version = "0.11.0" @@ -3205,6 +3235,8 @@ dependencies = [ "combat", "inhabitant", "inhabitant_coranth", + "inhabitant_endrake", + "inhabitant_simbert", "physics", "rand", "resource_graveyard", diff --git a/Cargo.toml b/Cargo.toml index 02dfe34..f437731 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,4 +58,6 @@ resource_graveyard = { path = "crates/resource_graveyard" } upgrade = { path = "crates/upgrade" } ui_health_bar = { path = "crates/ui_health_bar" } ui_range_indicator = { path = "crates/ui_range_indicator" } +inhabitant_simbert = { path = "crates/inhabitant_simbert" } +inhabitant_endrake = { path = "crates/inhabitant_endrake" } #new internal crates go here diff --git a/crates/building_core/src/lib.rs b/crates/building_core/src/lib.rs index 75876e4..bed2476 100755 --- a/crates/building_core/src/lib.rs +++ b/crates/building_core/src/lib.rs @@ -120,7 +120,7 @@ fn get_upgrades(commands: &mut Commands) -> Vec { "Forms a new worker, useful for harvesting resource deposits. Increases the Core's domain.", Quantity { souls: 25 * 2_u32.pow(i - 1), - bones: 20 * 2_u32.pow(i - 1), + bones: 15 * 2_u32.pow(i - 1), }, unlocks, )); diff --git a/crates/building_impaler/src/lib.rs b/crates/building_impaler/src/lib.rs index 60f24ee..6a52791 100755 --- a/crates/building_impaler/src/lib.rs +++ b/crates/building_impaler/src/lib.rs @@ -64,7 +64,6 @@ fn register( }, Cost(Quantity { souls: 5, bones: 0 }), Health::new(20.0), - Defense::new(5.0), Name::new("Impaler"), )); commands.insert_resource(ImpalerResources { diff --git a/crates/building_placement/src/lib.rs b/crates/building_placement/src/lib.rs index fc2ab49..416dbd0 100644 --- a/crates/building_placement/src/lib.rs +++ b/crates/building_placement/src/lib.rs @@ -124,7 +124,6 @@ fn move_preview( .ok() .map(|(gtf, r)| (gtf.translation(), r.0)), ) { - info!("invalid placement!!!!!"); return; } active.0 = loc.as_ivec3(); diff --git a/crates/inhabitant_endrake/Cargo.toml b/crates/inhabitant_endrake/Cargo.toml new file mode 100644 index 0000000..1f4e64e --- /dev/null +++ b/crates/inhabitant_endrake/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "inhabitant_endrake" +version = "0.1.0" +edition = "2024" + +[dependencies] +bevy = { workspace = true } +avian3d = { workspace = true } + +state = { path = "../state" } +combat = { path = "../combat" } +building = { path = "../building" } +inhabitant = { path = "../inhabitant" } +combat_damagers = { path = "../combat_damagers" } +ui_health_bar = { path = "../ui_health_bar" } +inhabitant_simbert = { path = "../inhabitant_simbert" } + +[lints] +workspace = true diff --git a/crates/inhabitant_endrake/src/lib.rs b/crates/inhabitant_endrake/src/lib.rs new file mode 100644 index 0000000..b3815f1 --- /dev/null +++ b/crates/inhabitant_endrake/src/lib.rs @@ -0,0 +1,125 @@ +//bevy system signatures often violate these rules +#![allow(clippy::type_complexity)] +#![allow(clippy::too_many_arguments)] + +use avian3d::prelude::*; +use bevy::prelude::*; +use building::Core; +use combat::{Health, Team}; +use combat_damagers::ContactDamage; +use inhabitant::Inhabitant; +use inhabitant_simbert::SpawnSimbert; +use state::{BasePhaseState, GameSystemSet}; +use ui_health_bar::BarSettings; + +pub struct InhabitantEndrakePlugin; + +impl Plugin for InhabitantEndrakePlugin { + 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)); + } +} + +#[derive(Component)] +#[require(Inhabitant)] +pub struct Endrake { + spawn_timer: Timer, + spawn_count: u32, +} + +#[derive(Event)] +pub struct SpawnEndrake { + pub transform: Transform, +} + +#[derive(Resource)] +struct EndrakeResources { + material: Handle, + mesh: Handle, +} + +const BASE_RADIUS: f32 = 3.; +const HEIGHT: f32 = 4.; +const TOP_RADIUS: f32 = 2.; + +fn init( + mut commands: Commands, + mut meshes: ResMut>, + mut materials: ResMut>, +) { + commands.insert_resource(EndrakeResources { + material: materials.add(StandardMaterial { + base_color: Color::srgb_u8(247, 187, 119), + emissive: Color::srgb_u8(242, 227, 206).to_linear() * 0.5, + metallic: 0.0, + perceptual_roughness: 1.0, + ..default() + }), + mesh: meshes.add(ConicalFrustum { + radius_top: TOP_RADIUS, + radius_bottom: BASE_RADIUS, + height: HEIGHT, + }), + }); +} +fn spawn( + mut reader: EventReader, + mut commands: Commands, + phase: Res>, + res: Res, +) { + for SpawnEndrake { transform } in reader.read() { + commands.spawn(( + RigidBody::Dynamic, + Collider::cuboid(TOP_RADIUS * 2., HEIGHT, TOP_RADIUS * 2.), + Mesh3d(res.mesh.clone()), + MeshMaterial3d(res.material.clone()), + MaxLinearSpeed(0.5), + Mass(10.), + Endrake { + spawn_timer: Timer::from_seconds(2.0, TimerMode::Repeating), + spawn_count: 10, + }, + transform.clone(), + Health::new(2000.0 + 100. * phase.get().phase_count() as f32), + // todo: change enemy health bar color to differentiate from buildings + BarSettings { + offset: HEIGHT + 0.5, + width: 24, + ..default() + }, + ContactDamage::new(5.0), + Name::from("Endrake"), + Team::Inhabitant.collision_layers(), + )); + } +} + +fn tick( + mut endrakes: Query<(&GlobalTransform, &mut LinearVelocity, &mut Endrake)>, + core_gtf: Single<&GlobalTransform, With>, + mut spawn_writer: EventWriter, + time: Res