0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 12:33:43 +00:00
SDL_Minigame/src/PowerupComponent.cpp

26 lines
673 B
C++

#include "PowerupComponent.h"
#include "GameInternal.h"
#include "CollisionHandler.h"
#include "Entity.h"
#include "HealthComponent.h"
#include "StatEffectsComponent.h"
#include "Constants.h"
#include <cstdint>
PowerupComponent::PowerupComponent(std::function<void (Entity*)> func)
{
this->pickupFunc = func;
}
void PowerupComponent::update(uint_fast16_t diffTime)
{
Entity* player;
if ((player = this->entity->getManager().getGame()->collisionHandler->getAnyIntersection<Entity*>(
entity,
Vector2D(0, 0),
{ Entity::GroupLabel::PLAYERS })) != nullptr)
{
(this->pickupFunc)(player);
this->entity->destroy();
}
}