-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCultureManager.cpp
46 lines (35 loc) · 1.49 KB
/
CultureManager.cpp
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
37
38
39
40
41
42
43
44
45
46
#include "CultureManager.h"
#include "Runtime.h"
namespace CultureManager {
Types::Get Get;
Types::FindOrAddGreatWork FindOrAddGreatWork;
Types::SetGreatWorkPlayer SetGreatWorkPlayer;
int lFindOrAddGreatWork(hks::lua_State* L) {
Culture* culture = Get();
unsigned int greatWorkIndex = hks::checkinteger(L, 1);
int greatWorkListIndex = FindOrAddGreatWork(culture, greatWorkIndex);
hks::pushinteger(L, greatWorkListIndex);
return 1;
}
int lSetGreatWorkPlayer(hks::lua_State* L) {
Culture* culture = Get();
int greatWorkListIndex = hks::checkinteger(L, 1);
int playerId = hks::checkinteger(L, 2);
SetGreatWorkPlayer(culture, greatWorkListIndex, playerId);
return 0;
}
int Register(hks::lua_State* L) {
std::cout << "Registering CultureManager!\n";
hks::createtable(L, 0, 2);
PushLuaMethod(L, lFindOrAddGreatWork, "lFindOrAddGreatWork", -2, "FindOrAddGreatWork");
PushLuaMethod(L, lSetGreatWorkPlayer, "lSetGreatWorkPlayer", -2, "SetGreatWorkPlayer");
hks::setfield(L, hks::LUA_GLOBAL, "CultureManager");
return 0;
}
void Create() {
using namespace Runtime;
Get = GetGameCoreGlobalAt<Types::Get>(GET_OFFSET);
FindOrAddGreatWork = GetGameCoreGlobalAt<Types::FindOrAddGreatWork>(FIND_OR_ADD_GREAT_WORK_OFFSET);
SetGreatWorkPlayer = GetGameCoreGlobalAt<Types::SetGreatWorkPlayer>(SET_GREAT_WORK_PLAYER_OFFSET);
}
}