Entity update + components
This commit is contained in:
36
include/object/components/component.hpp
Normal file
36
include/object/components/component.hpp
Normal 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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user