Make Entity::Update call UpdateComponents by default instead of an event
This commit is contained in:
parent
f639894a0d
commit
5bedd85584
|
@ -84,10 +84,6 @@ public:
|
|||
shape.move(offset);
|
||||
}
|
||||
|
||||
void Update(const float& delta_time) override {
|
||||
|
||||
}
|
||||
|
||||
void Render(sf::RenderTarget* target) override {
|
||||
target->draw(shape);
|
||||
}
|
||||
|
|
|
@ -28,19 +28,19 @@ namespace simpleengine {
|
|||
virtual void Move(const float& delta_time, const float& dir_x, const float& dir_y) {};
|
||||
virtual void Move(const float& delta_time, const sf::Vector2f& offset) {};
|
||||
virtual void Move(const sf::Vector2f& offset) {};
|
||||
virtual void Update(const float& delta_time) = 0;
|
||||
|
||||
virtual void Render(sf::RenderTarget* target) = 0;
|
||||
virtual void Update(const float& delta_time) {
|
||||
UpdateComponents(delta_time);
|
||||
};
|
||||
|
||||
// Called when the entity is about to be destroyed.
|
||||
// Make sure to call this in your extending Entity.
|
||||
virtual void Destroying();
|
||||
|
||||
void DestroyLater(); // In most cases, this will be ran next EntityEvent::Update()
|
||||
const bool& IsGettingDestroyed() const;
|
||||
|
||||
// If your event does not extend from EntityEvent, you will need to execute this yourself inside Event::Update.
|
||||
void UpdateComponents(const float& delta_time);
|
||||
|
||||
void AddComponent(std::unique_ptr<Component> component);
|
||||
|
||||
std::shared_ptr<Entity> GetShared() {
|
||||
|
|
|
@ -18,16 +18,13 @@ namespace simpleengine {
|
|||
}
|
||||
|
||||
void CheckForQuit() override {
|
||||
|
||||
if (entity->IsGettingDestroyed()) {
|
||||
quit = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Update(const float& delta_time) override {
|
||||
entity->Update(delta_time);
|
||||
entity->UpdateComponents(delta_time);
|
||||
|
||||
if (entity->IsGettingDestroyed()) {
|
||||
quit = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Render(sf::RenderTarget* target) override {
|
||||
|
|
Loading…
Reference in New Issue