Simple ai shooting PoC (#23)

This commit is contained in:
extrawurst
2025-04-04 23:00:15 +02:00
committed by GitHub
parent 145c30663e
commit e49373061e
11 changed files with 258 additions and 120 deletions

View File

@@ -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);
}
}