R-Type  2
Doom but in better
Loading...
Searching...
No Matches
AISystem.cpp
Go to the documentation of this file.
1#include "AISystem.hpp"
2
3#include "Time.hpp"
4#include "Zipper.hpp"
5
7{
8 for (auto &&[beh, vel] : Zipper(behaviours, velocities)) {
9 if (!beh || !vel) continue;
10
11 switch (beh->type) {
13 continue;
15 beh->timer += Time::deltaTime;
16 if (beh->timer >= AI_TIMER) {
17 vel->vY *= -1;
18 beh->timer = 0;
19 }
20 break;
22 continue;
23 }
24 }
25}
void ai_system(Registry &r, ComponentContainer< Behaviour > &behaviours, ComponentContainer< Velocity > &velocities)
AI system that updates the behaviour and velocity of entities.
Definition AISystem.cpp:6
#define AI_TIMER
Definition AISystem.hpp:7
@ DEFAULT
Definition Behaviour.hpp:8
@ UP_DOWN
Definition Behaviour.hpp:9
@ FOLLOW
Definition Behaviour.hpp:10
Registry * r
Definition Tests.cpp:4
Manages a collection of components associated with entities in an ECS (Entity-Component-System) archi...
Manages entities and their associated components, enabling the creation, deletion,...
Definition Registry.hpp:23
Combines multiple containers into a single iterable unit, iterating over corresponding elements from ...
Definition Zipper.hpp:15
float deltaTime
The time difference between the current frame and the last frame.
Definition Time.cpp:4