blob: 12da3d9c9b40ba495f980961c8ca66f5395c0899 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "../ComponentManager.h"
#include "AISystem.h"
using namespace crepe;
void AISystem::update() {
ComponentManager & mgr = this->component_manager;
RefVector<AI> ai_components = mgr.get_components_by_type<AI>();
for (AI & ai : ai_components) {
vec2 force = this->calculate(ai);
//...
}
}
vec2 AISystem::calculate(AI & ai) {
vec2 force;
if (ai.on(AI::BehaviorType::SEEK)) {
// Seek the target
}
if (ai.on(AI::BehaviorType::FLEE)) {
// Flee from the target
}
if (ai.on(AI::BehaviorType::ARRIVE)) {
// Arrive at the target
}
if (ai.on(AI::BehaviorType::PATH_FOLLOW)) {
// Follow the path
}
return force;
}
|