try to balance a bit
This commit is contained in:
parent
6cea0e97e9
commit
d35344f910
10 changed files with 141 additions and 48 deletions
|
|
@ -9,6 +9,7 @@ bevy = { workspace = true }
|
|||
state = { path = "../state" }
|
||||
resources = { path = "../resources" }
|
||||
input = { path = "../input" }
|
||||
combat = { path = "../combat" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use bevy::{
|
|||
platform::collections::HashSet,
|
||||
prelude::*,
|
||||
};
|
||||
use combat::Health;
|
||||
use input::Selectable;
|
||||
use resources::Quantity;
|
||||
|
||||
|
|
@ -91,17 +92,20 @@ fn populate_initial_upgrades(mut world: DeferredWorld, context: HookContext) {
|
|||
fn activate_upgrade(
|
||||
trigger: Trigger<UnlockUpgrade>,
|
||||
upgrade_query: Query<&Upgrade>,
|
||||
mut building_query: Query<&mut Upgradable>,
|
||||
mut building_query: Query<(&mut Upgradable, Option<&mut Health>)>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
let Ok(upgrade) = upgrade_query.get(trigger.target()) else {
|
||||
error!("activated upgrade on thing that was not an upgrade");
|
||||
return;
|
||||
};
|
||||
let Ok(mut building) = building_query.get_mut(trigger.event().building) else {
|
||||
let Ok((mut building, opt_health)) = building_query.get_mut(trigger.event().building) else {
|
||||
error!("applying upgrade to non-upgradable thing");
|
||||
return;
|
||||
};
|
||||
if let Some(mut health) = opt_health {
|
||||
health.max_out();
|
||||
}
|
||||
building.available_upgrades.remove(&trigger.target());
|
||||
building.active_upgrades.insert(trigger.target());
|
||||
for unlock in upgrade.unlocks.iter() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue