Register GrowthRate Library in AngelScript.

This commit is contained in:
Deukhoofd 2020-01-13 19:55:18 +01:00
parent faf22c9562
commit a88e4a89e7
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 13 additions and 0 deletions

View File

@ -1,9 +1,11 @@
#include "RegisterGrowthRateTypes.hpp" #include "RegisterGrowthRateTypes.hpp"
#include <Library/GrowthRates/GrowthRate.hpp> #include <Library/GrowthRates/GrowthRate.hpp>
#include <Library/GrowthRates/GrowthRateLibrary.hpp>
#include <cassert> #include <cassert>
void RegisterGrowthRateTypes::Register(asIScriptEngine* engine) { void RegisterGrowthRateTypes::Register(asIScriptEngine* engine) {
RegisterGrowthRateType(engine); RegisterGrowthRateType(engine);
RegisterGrowthRateLibrary(engine);
} }
void RegisterGrowthRateTypes::RegisterGrowthRateType(asIScriptEngine* engine) { void RegisterGrowthRateTypes::RegisterGrowthRateType(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("GrowthRate", 0, asOBJ_REF | asOBJ_NOCOUNT); [[maybe_unused]] int r = engine->RegisterObjectType("GrowthRate", 0, asOBJ_REF | asOBJ_NOCOUNT);
@ -15,3 +17,13 @@ void RegisterGrowthRateTypes::RegisterGrowthRateType(asIScriptEngine* engine) {
asMETHOD(CreatureLib::Library::GrowthRate, CalculateExperience), asCALL_THISCALL); asMETHOD(CreatureLib::Library::GrowthRate, CalculateExperience), asCALL_THISCALL);
assert(r >= 0); assert(r >= 0);
} }
void RegisterGrowthRateTypes::RegisterGrowthRateLibrary(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("GrowthRateLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
r = engine->RegisterObjectMethod("GrowthRateLibrary", "uint8 CalculateLevel(const string &in growthRate, uint experience) const",
asMETHOD(CreatureLib::Library::GrowthRateLibrary, CalculateLevel), asCALL_THISCALL);
assert(r >= 0);
r = engine->RegisterObjectMethod("GrowthRateLibrary", "uint CalculateExperience(const string &in growthRate, uint8 experience) const",
asMETHOD(CreatureLib::Library::GrowthRateLibrary, CalculateExperience), asCALL_THISCALL);
assert(r >= 0);
}

View File

@ -4,6 +4,7 @@
class RegisterGrowthRateTypes { class RegisterGrowthRateTypes {
static void RegisterGrowthRateType(asIScriptEngine* engine); static void RegisterGrowthRateType(asIScriptEngine* engine);
static void RegisterGrowthRateLibrary(asIScriptEngine* engine);
public: public:
static void Register(asIScriptEngine* engine); static void Register(asIScriptEngine* engine);
}; };