Simple ai shooting PoC (#23)
This commit is contained in:
14
src/npc.rs
14
src/npc.rs
@@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
GameState,
|
||||
heads::HEAD_COUNT,
|
||||
ai::Ai,
|
||||
heads::{HEAD_COUNT, HeadState},
|
||||
hitpoints::{Hitpoints, Kill},
|
||||
keys::KeySpawn,
|
||||
player::head_id_to_str,
|
||||
@@ -9,8 +10,9 @@ use crate::{
|
||||
use bevy::prelude::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct NpcHead(pub usize);
|
||||
#[derive(Component, Reflect, Deref, DerefMut)]
|
||||
#[reflect(Component)]
|
||||
pub struct Npc(HeadState);
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_systems(OnEnter(GameState::Playing), init);
|
||||
@@ -25,7 +27,11 @@ fn init(mut commands: Commands, query: Query<(Entity, &EnemySpawn)>) {
|
||||
let id = names[&spawn.head];
|
||||
commands
|
||||
.entity(e)
|
||||
.insert((Hitpoints::new(100), NpcHead(id)))
|
||||
.insert((
|
||||
Hitpoints::new(100),
|
||||
Npc(HeadState::new(id, 10).with_ability(crate::abilities::HeadAbility::Thrown)),
|
||||
Ai,
|
||||
))
|
||||
.observe(on_kill);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user