head database for aim and ai
This commit is contained in:
@@ -2,11 +2,11 @@ mod heads_ui;
|
||||
|
||||
use crate::{
|
||||
GameState,
|
||||
abilities::HeadAbility,
|
||||
backpack::{BackbackSwapEvent, Backpack},
|
||||
global_observer,
|
||||
head_asset::HeadsDatabase,
|
||||
hitpoints::Hitpoints,
|
||||
player::{Player, head_id_to_str},
|
||||
player::Player,
|
||||
sounds::PlaySound,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
@@ -22,7 +22,6 @@ pub struct HeadsImages {
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Reflect)]
|
||||
pub struct HeadState {
|
||||
pub head: usize,
|
||||
pub ability: HeadAbility,
|
||||
pub health: u32,
|
||||
pub health_max: u32,
|
||||
pub ammo: u32,
|
||||
@@ -39,17 +38,11 @@ impl HeadState {
|
||||
health_max: 100,
|
||||
ammo,
|
||||
ammo_max: ammo,
|
||||
ability: HeadAbility::None,
|
||||
reload_duration: 5.,
|
||||
last_use: 0.,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_ability(mut self, ability: HeadAbility) -> Self {
|
||||
self.ability = ability;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn has_ammo(&self) -> bool {
|
||||
self.ammo > 0
|
||||
}
|
||||
@@ -119,11 +112,11 @@ pub fn plugin(app: &mut App) {
|
||||
|
||||
app.insert_resource(ActiveHeads {
|
||||
heads: [
|
||||
Some(HeadState::new(0, 10).with_ability(HeadAbility::Thrown)),
|
||||
Some(HeadState::new(3, 10).with_ability(HeadAbility::Gun)),
|
||||
Some(HeadState::new(6, 10).with_ability(HeadAbility::Arrow)),
|
||||
Some(HeadState::new(8, 10).with_ability(HeadAbility::Thrown)),
|
||||
Some(HeadState::new(9, 10).with_ability(HeadAbility::Gun)),
|
||||
Some(HeadState::new(0, 10)),
|
||||
Some(HeadState::new(3, 10)),
|
||||
Some(HeadState::new(6, 10)),
|
||||
Some(HeadState::new(8, 10)),
|
||||
Some(HeadState::new(9, 10)),
|
||||
],
|
||||
current_slot: 0,
|
||||
});
|
||||
@@ -138,10 +131,10 @@ pub fn plugin(app: &mut App) {
|
||||
global_observer!(app, on_swap_backpack);
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>, heads: Res<HeadsDatabase>) {
|
||||
// TODO: load via asset loader
|
||||
let heads = (0usize..HEAD_COUNT)
|
||||
.map(|i| asset_server.load(format!("ui/heads/{}.png", head_id_to_str(i))))
|
||||
.map(|i| asset_server.load(format!("ui/heads/{}.png", heads.head_key(i))))
|
||||
.collect();
|
||||
|
||||
commands.insert_resource(HeadsImages { heads });
|
||||
|
||||
Reference in New Issue
Block a user