mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 13:43:41 +00:00
fix errors when building
This commit is contained in:
parent
7e0a2422bd
commit
b07d68b84b
@ -4,6 +4,7 @@
|
|||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
class InteractionComponent : public Component
|
class InteractionComponent : public Component
|
||||||
{
|
{
|
||||||
@ -12,7 +13,7 @@ public:
|
|||||||
~InteractionComponent();
|
~InteractionComponent();
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
void update() override;
|
void update();
|
||||||
|
|
||||||
bool interact(Entity* interactor, Entity* interactee);
|
bool interact(Entity* interactor, Entity* interactee);
|
||||||
|
|
||||||
|
|||||||
@ -44,18 +44,18 @@ Entity* InteractionComponent::findClosestEntity(std::vector<Entity*>& entities,
|
|||||||
auto isInDirection = getDirectionalCheck(direction, interactorT);
|
auto isInDirection = getDirectionalCheck(direction, interactorT);
|
||||||
|
|
||||||
entities.erase(std::remove_if(entities.begin(), entities.end(), [&](Entity* e){
|
entities.erase(std::remove_if(entities.begin(), entities.end(), [&](Entity* e){
|
||||||
auto& entityT = entity->getComponent<TransformComponent>();
|
auto& entityT = e->getComponent<TransformComponent>();
|
||||||
return !isInDirection(entityT) || !isEntityCloseEnough(interactorT, entityT, direction);
|
return !isInDirection(entityT) || !isEntityCloseEnough(interactorT, entityT, direction);
|
||||||
}), entities.end());
|
}), entities.end());
|
||||||
|
|
||||||
for(auto e : entities)
|
for(auto e : entities)
|
||||||
{
|
{
|
||||||
auto& entityT = entity->getComponent<TransformComponent>();
|
auto& entityT = e->getComponent<TransformComponent>();
|
||||||
float distance = calculateDistance(interactorT.position, entityT.position);
|
float distance = calculateDistance(interactorT.position, entityT.position);
|
||||||
|
|
||||||
if (distance < closestDistance) {
|
if (distance < closestDistance) {
|
||||||
closestDistance = distance;
|
closestDistance = distance;
|
||||||
closestEntity = entity;
|
closestEntity = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user