#include "components/CollectibleComponent.hpp" #include "Entity.hpp" #include "components/ColliderComponent.hpp" #include "components/StatsComponent.hpp" void CollectibleComponent::Setup() { auto selfCollider = entity->GetComponent(); if (!selfCollider) { return; } selfCollider->get().monitoring = true; selfCollider->get().AddCollisionListener([this](Entity &other) { if (entity->queuedForFree || !context || !context->probeEntity || &other != context->probeEntity) { return; } context->EmitCollectiblePicked(*entity); entity->QueueFree(); if (context->statsEntity) { auto stats = context->statsEntity->GetComponent(); if (stats) { stats->get().AddValue(stats->get().gainPerStar); stats->get().AddStar(); } } }); } void CollectibleComponent::Update(float) {} void CollectibleComponent::Cleanup() {}