Autowalker is working way better and now I have a plan for using the AI in the System.
This commit is contained in:
parent
0623170dbc
commit
ee804581a8
11 changed files with 197 additions and 127 deletions
17
systems.cpp
17
systems.cpp
|
@ -34,18 +34,28 @@ void System::lighting(GameLevel &level) {
|
|||
});
|
||||
}
|
||||
|
||||
void System::enemy_ai(GameLevel &level) {
|
||||
(void)level;
|
||||
// AI: look up Enemy::actions in ai.json
|
||||
// AI: setup the state
|
||||
// AI: process it and keep the next action in the world
|
||||
}
|
||||
|
||||
void System::enemy_pathing(GameLevel &level) {
|
||||
auto &world = *level.world;
|
||||
auto &map = *level.map;
|
||||
auto player = world.get_the<Player>();
|
||||
|
||||
// TODO: this will be on each enemy not a global thing
|
||||
const auto &player_position = world.get<Position>(player.entity);
|
||||
map.set_target(player_position.location);
|
||||
map.make_paths();
|
||||
|
||||
world.query<Position, Motion>([&](auto ent, auto &position, auto &motion) {
|
||||
if(ent != player.entity) {
|
||||
// AI: EnemyConfig can be replaced with an AI thing
|
||||
// AI: after the enemy_ai systems are run we can then look at what
|
||||
// AI: their next actions is, and if it's pathing do that
|
||||
|
||||
dbc::check(world.has<EnemyConfig>(ent), "enemy is missing config");
|
||||
const auto &config = world.get<EnemyConfig>(ent);
|
||||
|
||||
|
@ -159,8 +169,11 @@ void System::combat(GameLevel &level) {
|
|||
// this is guaranteed to not return the given position
|
||||
auto [found, nearby] = collider.neighbors(player_position.location);
|
||||
|
||||
|
||||
if(found) {
|
||||
for(auto entity : nearby) {
|
||||
// AI: process AI combat actions here
|
||||
|
||||
if(world.has<Combat>(entity)) {
|
||||
auto& enemy_combat = world.get<Combat>(entity);
|
||||
|
||||
|
@ -196,6 +209,8 @@ void System::collision(GameLevel &level) {
|
|||
auto [found, nearby] = collider.neighbors(player_position.location);
|
||||
int combat_count = 0;
|
||||
|
||||
// AI: I think also this would a possible place to run AI decisions
|
||||
|
||||
// BUG: this logic is garbage, needs a refactor
|
||||
for(auto entity : nearby) {
|
||||
if(world.has<Combat>(entity)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue