ammo system

* heads have abilities
* health and ammo shows in ui
This commit is contained in:
2025-04-02 01:35:02 +08:00
parent 8187eb58a9
commit 01e6e944d3
13 changed files with 360 additions and 234 deletions

View File

@@ -1,4 +1,4 @@
use super::{BackbackSwapEvent, Backpack, BackpackHead};
use super::{BackbackSwapEvent, Backpack, UiHeadState};
use crate::{GameState, heads_ui::HeadsImages, loading_assets::UIAssets, sounds::PlaySound};
use bevy::prelude::*;
@@ -29,7 +29,7 @@ struct HeadDamage(pub usize);
#[derive(Resource, Default, Debug)]
struct BackpackUiState {
heads: [Option<BackpackHead>; 5],
heads: [Option<UiHeadState>; 5],
scroll: usize,
count: usize,
current_slot: usize,
@@ -316,7 +316,7 @@ fn sync(backpack: &Res<Backpack>, state: &mut ResMut<BackpackUiState>) {
for i in 0..HEAD_SLOTS {
if let Some(head) = backpack.heads.get(i + state.scroll) {
state.heads[i] = Some(*head);
state.heads[i] = Some(UiHeadState::from(*head));
} else {
state.heads[i] = None;
}