aggressive ai stuck in loop

This commit is contained in:
Bluub
2021-06-17 14:52:57 +02:00
parent 80013ddb41
commit 0d5cfe109f
5 changed files with 94 additions and 284 deletions
@@ -2,6 +2,7 @@
// Created by Louis Auzuret on 06/07/21
//
#include "Component/Score/ScoreComponent.hpp"
#include "Component/Bomb/BasicBombComponent.hpp"
#include "Component/Tag/TagComponent.hpp"
#include "Component/Timer/TimerComponent.hpp"
@@ -19,15 +20,13 @@ namespace BBM
void IAControllableSystem::UpdateMapInfos(WAL::ViewEntity<PositionComponent, ControllableComponent, IAControllableComponent, BombHolderComponent> &entity)
{
_players.clear();
for (auto &[other, pos, _] : _wal.getScene()->view<PositionComponent, TagComponent<Player>>()) {
if (static_cast<WAL::Entity>(entity).getUid() == other.getUid())
continue;
if (!_wal.getScene())
return;
for (auto &[other, pos, _] : _wal.getScene()->view<PositionComponent, ScoreComponent>()) {
_players.push_back(MapInfo(pos.position, MapGenerator::NOTHING));
}
if (_cached)
return;
if (!_wal.getScene())
return;
for (auto &[other, pos, _] : _wal.getScene()->view<PositionComponent, TagComponent<Breakable>>())
_map.push_back(MapInfo(pos.position, MapGenerator::BREAKABLE));
for (auto &[other, pos, _] : _wal.getScene()->view<PositionComponent, TagComponent<Unbreakable>>())
@@ -142,12 +141,32 @@ namespace BBM
state.setTable();
}
void IAControllableSystem::pushInfoEnemies(LuaG::State &state)
{
int index = 1;
state.push("enemies");
state.newTable();
for (auto &player : _players) {
state.push(index++);
state.newTable();
state.push("x");
state.push(player.x);
state.setTable();
state.push("y");
state.push(player.z);
state.setTable();
state.setTable();
}
state.setTable();
}
void IAControllableSystem::pushInfo(LuaG::State &state, MapInfo &player, BombHolderComponent &bombHolder)
{
state.newTable();
pushInfoPlayer(state, player, bombHolder);
pushInfoRaw(state);
pushInfoDanger(state);
pushInfoEnemies(state);
}
void IAControllableSystem::onFixedUpdate(WAL::ViewEntity<PositionComponent, ControllableComponent, IAControllableComponent, BombHolderComponent> &entity)
@@ -45,6 +45,9 @@ namespace BBM
//! @brief push danger map info
void pushInfoDanger(LuaG::State &state);
//! @brief push info ennemies
void pushInfoEnemies(LuaG::State &state);
//! @brief push all the infos to the lua stack
void pushInfo(LuaG::State &state, MapInfo &player, BombHolderComponent &bombHolder);
public: