add souls and bones + tower cost and enemy drops

This commit is contained in:
Jim 2025-08-30 23:39:18 -04:00
parent bc02db7b26
commit 138a524abd
Signed by: jim
GPG key ID: 3D7D94BA53088BF4
18 changed files with 151 additions and 14 deletions

View file

@ -9,6 +9,7 @@ use bevy::{
prelude::*,
};
use combat::{Health, Team};
use resources::{Cost, Resources};
use state::GameSystemSet;
pub struct BuildingPlugin;
@ -54,7 +55,7 @@ fn on_building_removed(mut world: DeferredWorld, context: HookContext) {
}
#[derive(Component, Clone)]
#[require(Name)]
#[require(Name, Cost)]
#[component(on_add = register_building_info)]
#[component(on_remove = unregister_building_info)]
#[component(immutable)]
@ -197,14 +198,15 @@ fn place_building(
mut reader: EventReader<PlaceBuilding>,
mut building_map: ResMut<PlacedBuildings>,
mut commands: Commands,
info_query: Query<&BuildingInfo>,
mut resources: ResMut<Resources>,
info_query: Query<(&BuildingInfo, &Cost)>,
) {
for PlaceBuilding {
info: info_entity,
location,
} in reader.read()
{
let Ok(info) = info_query.get(*info_entity) else {
let Ok((info, cost)) = info_query.get(*info_entity) else {
error!("tried to place building without info!");
continue;
};
@ -212,6 +214,10 @@ fn place_building(
error!("invalid building placement at {:?}, rejecting", location);
continue;
}
if !resources.buy(&cost) {
info!("not enough money to buy tower!");
continue;
}
let size_v3 = info.size.as_vec3();
let instance = commands
.spawn((