VEGO-Engine  0.1
Loading...
Searching...
No Matches
InteractionManager.h
1#pragma once
2
3#include "InteractionListener.h"
4
5#include "SDL3/SDL_events.h"
6#include "SDL3/SDL_init.h"
7#include <cstdint>
8#include <functional>
9#include <memory>
10#include <vector>
11#include <ranges>
12
13// TODO: ranges concept to avoid to<vector> in cpp
14typedef std::function<std::shared_ptr<InteractionListener>(Vector2D*, std::vector<std::shared_ptr<InteractionListener>>)> TargetingFunc;
15
16class InteractionManager {
17public:
18 InteractionManager();
19 InteractionManager (const InteractionManager&) = delete;
20 InteractionManager& operator= (const InteractionManager&) = delete;
21
22 enum class TargetingStrategy : uint8_t {
23 none = 0,
24 closest,
25 manhattenDistance
26 };
27
28 SDL_AppResult handleInteract(SDL_EventType type, SDL_Event* const event);
29 void registerListener(std::weak_ptr<InteractionListener> listener);
30 uint8_t registerTargetingFunc(TargetingFunc func);
31private:
32
33 std::vector<std::weak_ptr<InteractionListener>> listeners;
34 std::array<TargetingFunc, 256> targetingFuncs;
35};