Entity update + components

This commit is contained in:
2026-03-24 09:00:23 +01:00
parent 0c0e7c41af
commit 8f2a4e9ecb
11 changed files with 197 additions and 7 deletions

View File

@@ -0,0 +1,36 @@
#pragma once
#include <utils.hpp>
#include <string>
namespace Game::Object {
class Entity;
}
namespace Game::Object::Components {
class Component {
public:
Component() = default;
// Declare copy and move; in case components declare some other things, we want to make sure those are properly copied/moved as well, so we'll just define these as virtual and implement them in the .cpp file
Component(const Component&);
Component& operator=(const Component&);
Component(Component&&) noexcept;
Component& operator=(Component&&) noexcept;
virtual ~Component() = 0;
virtual void start() = 0;
virtual void update(float deltaTime, Object::Entity* thisEntity) = 0;
// Getters and setters
void setName(const std::string& name);
std::string getName();
void setActive(bool active);
bool isActive();
protected:
// Uniqueness is NOT enforced; be careful when naming!
std::string mName;
bool mIsActive = true;
};
}