Simple C++ Game
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
EnemyComponent Class Reference

A Component for enemy AI paddles. More...

#include <EnemyAISystem.hpp>

Inheritance diagram for EnemyComponent:
Inheritance graph
[legend]
Collaboration diagram for EnemyComponent:
Collaboration graph
[legend]

Public Types

enum class  AIState { Reacting , MovingDown , MovingUp , WaitingForPlayer }
 An enumeration of the states of the enemy paddle AI. More...
 

Public Member Functions

 EnemyComponent ()
 Construct a new Enemy Component object. More...
 
- Public Member Functions inherited from Entity::Component
 Component (const std::string id)
 Construct a new Component object. More...
 
virtual ~Component ()
 This is only declared to make the class polymorphic so that dymaic_cast between Component types works.
 
const std::string getId () const
 Get the ID of the component. This will return the same value for all instances of a class of Component.
 

Public Attributes

sf::Time reactionElapsedTime
 The amount of time that the AI has spent waiting after the player took an action to respond. When this is greater than or equal to EnemyComponent::REACTION_TIME, the AI paddle can respond, simulating human reaction.
 
AIState aiState
 The current state of the paddle's AI.
 
float predictedBallPosition
 The current predicted impact position of the next ball that the paddle will try to intercept and bounce back. This, combined with EnemyComponent::predictionValid, form a pseudo-Optional<float>.
 
bool predictionValid
 Whether or not the current prediction is a valid prediction that should be tracked to. This, combined with EnemyComponent::predictedBallPosition, form a pseudo-Optional<float>.
 

Static Public Attributes

static const std::string ENEMY_ID
 The ID for EnemyCompnent.
 
static const sf::Time REACTION_TIME
 The reaction time of an enemy AI after the player hits the ball.
 
static const float ENEMY_ERROR_SCALE
 

Detailed Description

A Component for enemy AI paddles.

The component marks an entity as an enemy AI paddle and stores related state, such as AI information.

Member Enumeration Documentation

◆ AIState

An enumeration of the states of the enemy paddle AI.

Enumerator
Reacting 

The player has hit the ball and the AI is reacting.

MovingDown 

The AI is moving down to intercept the ball.

MovingUp 

The AI is moving up to intercept the ball.

WaitingForPlayer 

The AI has hit the ball and is waiting for the player to respond.

Constructor & Destructor Documentation

◆ EnemyComponent()

EnemyComponent::EnemyComponent ( )

Construct a new Enemy Component object.

The state information (e.g. AI) is unitialized and will need to be provided by the caller of the constructor.


The documentation for this class was generated from the following file: