0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 07:53:43 +00:00
SDL_Minigame/src/PickupComponent.cpp
Nimac0 325f6e8e8d ref: powerup component now pickup component, assetmanager removed
assetmanager was redundant therefore any traces and usages were removed
2025-03-22 12:45:28 +01:00

26 lines
669 B
C++

#include "PickupComponent.h"
#include "GameInternal.h"
#include "CollisionHandler.h"
#include "Entity.h"
#include "HealthComponent.h"
#include "StatEffectsComponent.h"
#include "Constants.h"
#include <cstdint>
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();
}
}