CS4850 Final Project
Loading...
Searching...
No Matches
Component.hpp
1#pragma once
2
3#include <SDL2/SDL.h>
4#include <memory>
5
6#include "ComponentType.hpp"
7
8// Forward declaration
9struct GameEntity;
10
15struct Component {
16
17 Component() {}
18
19 virtual ~Component() {}
20
26 virtual void Input(float deltaTime) {}
27
33 virtual void Update(float deltaTime) {}
34
40 virtual void Render(SDL_Renderer* renderer) {}
41
47 virtual ComponentType GetType() = 0;
48
54 void SetGameEntity(std::shared_ptr<GameEntity> gameEntity) {
55 mGameEntity = gameEntity;
56 }
57
63 std::shared_ptr<GameEntity> GetGameEntity() {
64 return mGameEntity;
65 }
66
67 protected:
68 std::shared_ptr<GameEntity> mGameEntity;
69};
Base class for all components.
Definition Component.hpp:15
virtual void Render(SDL_Renderer *renderer)
Render the game.
Definition Component.hpp:40
virtual ComponentType GetType()=0
Get the type of the component.
virtual void Update(float deltaTime)
Update the game state.
Definition Component.hpp:33
virtual void Input(float deltaTime)
Handle input.
Definition Component.hpp:26
void SetGameEntity(std::shared_ptr< GameEntity > gameEntity)
Set the game entity that the component is attached to.
Definition Component.hpp:54
std::shared_ptr< GameEntity > GetGameEntity()
Get the game entity that the component is attached to.
Definition Component.hpp:63
GameEntity class that represents an entity in the game.
Definition GameEntity.hpp:19