Skip to content

File SignalConnections.hpp

File List > Components > SignalConnections.hpp

Go to the documentation of this file

#ifndef ENGINE_COMPONENTS_SIGNALCONNECTIONS_HPP_
#define ENGINE_COMPONENTS_SIGNALCONNECTIONS_HPP_

#include "ECS/Entity.hpp"

#include <array>
#include <string>
#include <string_view>
#include <vector>

namespace Engine {

inline constexpr std::array<std::string_view, 6> kCollisionSignals = {
    "onCollisionEnter", "onCollisionStay", "onCollisionExit",
    "onTriggerEnter",   "onTriggerStay",   "onTriggerExit",
};

inline bool IsKnownSignal(std::string_view signal) {
    for (const auto& known : kCollisionSignals) {
        if (known == signal) {
            return true;
        }
    }
    return false;
}

struct SignalConnection {
    std::string signal;
    Entity target = static_cast<Entity>(-1);
    std::string method;
};

struct SignalConnections {
    std::vector<SignalConnection> connections;
};

} // namespace Engine

#endif // ENGINE_COMPONENTS_SIGNALCONNECTIONS_HPP_