8#include "game/GameManager.h"
11 template <
typename FunctionReturnType,
typename... FunctionArgs>
class NodeFunction;
20 template <
typename FunctionReturnType,
typename... FunctionArgs>
34 NodeFunction(
size_t iNodeId,
const std::function<FunctionReturnType(FunctionArgs...)>& callback) {
36 std::is_same_v<FunctionReturnType, void>,
37 "return type must be `void` - this is a current limitation");
39 this->iNodeId = iNodeId;
40 this->callback = callback;
92 if (isNodeSpawned()) {
93 callback(std::forward<FunctionArgs>(args)...);
111 if (pGameManager ==
nullptr) [[unlikely]] {
116 if (pGameManager->isBeingDestroyed()) [[unlikely]] {
121 return pGameManager->isNodeSpawned(iNodeId);
126 std::function<FunctionReturnType(FunctionArgs...)>
callback;
static GameManager * get()
Definition: GameManager.cpp:299
NodeFunction(const NodeFunction &other)=default
bool operator()(FunctionArgs &&... args)
Definition: NodeFunction.hpp:91
std::function< FunctionReturnType(FunctionArgs...)> callback
Definition: NodeFunction.hpp:126
NodeFunction(size_t iNodeId, const std::function< FunctionReturnType(FunctionArgs...)> &callback)
Definition: NodeFunction.hpp:34
NodeFunction & operator=(const NodeFunction &other)=default
NodeFunction(NodeFunction &&other) noexcept=default
NodeFunction & operator=(NodeFunction &&other) noexcept=default
bool isNodeSpawned()
Definition: NodeFunction.hpp:108
Definition: NodeFunction.hpp:11