aboutsummaryrefslogtreecommitdiff
path: root/extension/src/TestSingleton.cpp
blob: d9e2b03674663533983ef1a5b8e429f336e2da2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "TestSingleton.hpp"

#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/variant/utility_functions.hpp>

using namespace godot;
using namespace OpenVic2;

TestSingleton* TestSingleton::singleton = nullptr;

void TestSingleton::_bind_methods()
{
   ClassDB::bind_method(D_METHOD("hello_singleton"), &TestSingleton::hello_singleton);
}

TestSingleton* TestSingleton::get_singleton()
{
   return singleton;
}

TestSingleton::TestSingleton()
{
   ERR_FAIL_COND(singleton != nullptr);
   singleton = this;
}

TestSingleton::~TestSingleton()
{
   ERR_FAIL_COND(singleton != this);
   singleton = nullptr;
}

void TestSingleton::hello_singleton()
{
   UtilityFunctions::print("Hello GDExtension Singleton!");
}