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

30 lines
775 B
C++

#include "PickupComponent.h"
#include "GameInternal.h"
#include "CollisionHandler.h"
#include "Entity.h"
#include "HealthComponent.h"
#include "SpriteComponent.h"
#include "StatEffectsComponent.h"
#include "Constants.h"
#include "TextureManager.h"
#include "TransformComponent.h"
#include <cstdint>
#include "VEGO.h"
PickupComponent::PickupComponent(std::function<void (Entity*)> func)
{
this->pickupFunc = func;
}
void PickupComponent::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();
}
}