Simple C++ Game
EnemyAISystem.hpp
1 #pragma once
2 
3 #include <IteratingSystem.hpp>
4 #include <ComponentFamily.hpp>
5 #include <Components.hpp>
6 
12 {
13 public:
20 
21 protected:
28  void process(std::shared_ptr<Entity> &ai, const sf::Time deltaTime);
29 
30 private:
31  Entity &_ball;
32  float predictImpactPosition(sf::FloatRect &paddlePosition, sf::FloatRect &ballPosition, sf::Vector2f &ballVelocity, float uncertaintyScale);
33 };
34 
42 {
43 public:
47  static const std::string ENEMY_ID;
48 
52  static const sf::Time REACTION_TIME;
53  static const float ENEMY_ERROR_SCALE;
54 
58  enum class AIState
59  {
63  Reacting,
67  MovingDown,
71  MovingUp,
76  };
77 
84 
90 
95 
101 
107 };
A system that performs the AI for the enemy player.
Definition: EnemyAISystem.hpp:12
void process(std::shared_ptr< Entity > &ai, const sf::Time deltaTime)
Processes the enemy AI for a single paddle.
EnemyAISystem(Entity &ball)
Construct a new Enemy AI System object.
A Component for enemy AI paddles.
Definition: EnemyAISystem.hpp:42
AIState
An enumeration of the states of the enemy paddle AI.
Definition: EnemyAISystem.hpp:59
@ WaitingForPlayer
The AI has hit the ball and is waiting for the player to respond.
@ MovingUp
The AI is moving up to intercept the ball.
@ Reacting
The player has hit the ball and the AI is reacting.
@ MovingDown
The AI is moving down to intercept the ball.
bool predictionValid
Whether or not the current prediction is a valid prediction that should be tracked to....
Definition: EnemyAISystem.hpp:106
AIState aiState
The current state of the paddle's AI.
Definition: EnemyAISystem.hpp:94
sf::Time reactionElapsedTime
The amount of time that the AI has spent waiting after the player took an action to respond....
Definition: EnemyAISystem.hpp:89
static const std::string ENEMY_ID
The ID for EnemyCompnent.
Definition: EnemyAISystem.hpp:47
EnemyComponent()
Construct a new Enemy Component object.
static const sf::Time REACTION_TIME
The reaction time of an enemy AI after the player hits the ball.
Definition: EnemyAISystem.hpp:52
float predictedBallPosition
The current predicted impact position of the next ball that the paddle will try to intercept and boun...
Definition: EnemyAISystem.hpp:100
A component of an entity in the game's component entity system.
Definition: Entity.hpp:27
An entity in the game's component entity system.
Definition: Entity.hpp:14
An implementation of EntitySystem that iterates through all Entity objects in EntitySystem::getEntiti...
Definition: IteratingSystem.hpp:10