mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 09:03:42 +00:00
34 lines
992 B
C++
34 lines
992 B
C++
#pragma once
|
|
|
|
#include "Component.h"
|
|
#include "Entity.h"
|
|
|
|
#include <vector>
|
|
#include <functional>
|
|
|
|
class InteractionComponent : public Component
|
|
{
|
|
public:
|
|
InteractionComponent(bool canInteract, bool isInteractable, int reach);
|
|
~InteractionComponent();
|
|
|
|
void init() override;
|
|
void update();
|
|
|
|
bool interact(Entity* interactor, Entity* interactee);
|
|
|
|
Entity* getClosestInteractableEntity(Direction direction, Entity* interactor, std::vector<Entity*> entities);
|
|
|
|
private:
|
|
bool canInteract;
|
|
bool isInteractable;
|
|
|
|
int reach;
|
|
|
|
Entity* findClosestEntity(std::vector<Entity*>& entities, TransformComponent& interactorT, Direction direction);
|
|
std::function<bool(const TransformComponent&)> getDirectionalCheck(Direction direction, const TransformComponent& interactorT);
|
|
bool isEntityCloseEnough(const TransformComponent& interactorT, const TransformComponent& entityT, Direction direction);
|
|
|
|
float calculateDistance(Vector2D iPos, Vector2D ePos);
|
|
|
|
}; |