add souls and bones + tower cost and enemy drops
This commit is contained in:
parent
bc02db7b26
commit
138a524abd
18 changed files with 151 additions and 14 deletions
|
|
@ -8,6 +8,7 @@ bevy = { workspace = true }
|
|||
avian3d = { workspace = true }
|
||||
combat = { path = "../combat" }
|
||||
state = { path = "../state" }
|
||||
resources = { path = "../resources" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -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((
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue