Register GrowthRate in AngelScript.

This commit is contained in:
Deukhoofd 2020-01-13 19:52:32 +01:00
parent 797044aa8c
commit faf22c9562
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
9 changed files with 37 additions and 7 deletions

View File

@ -1,9 +1,10 @@
#include "AngelScripResolver.hpp"
#include "../../extern/angelscript_addons/scripthelper/scripthelper.h"
#include "../../extern/angelscript_addons/scriptstdstring/scriptstdstring.h"
#include "TypeRegistry/RegisterItemTypes.hpp"
#include "TypeRegistry/RegisterMoveTypes.hpp"
#include "TypeRegistry/RegisterPokemonTypes.hpp"
#include "TypeRegistry/Library/RegisterGrowthRateTypes.hpp"
#include "TypeRegistry/Library/RegisterItemTypes.hpp"
#include "TypeRegistry/Library/RegisterMoveTypes.hpp"
#include "TypeRegistry/Library/RegisterPokemonTypes.hpp"
CreatureLib::Battling::ScriptResolver* PkmnLib::Battling::BattleLibrary::CreateScriptResolver() {
return new AngelScripResolver();
@ -31,6 +32,7 @@ void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* librar
RegisterPokemonTypes::Register(_engine);
RegisterItemTypes::Register(_engine);
RegisterMoveTypes::Register(_engine);
RegisterGrowthRateTypes::Register(_engine);
_mainModule = _engine->GetModule("pkmn", asGM_ALWAYS_CREATE);

View File

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

View File

@ -0,0 +1,11 @@
#ifndef PKMNLIB_REGISTERGROWTHRATETYPES_HPP
#define PKMNLIB_REGISTERGROWTHRATETYPES_HPP
#include <angelscript.h>
class RegisterGrowthRateTypes {
static void RegisterGrowthRateType(asIScriptEngine* engine);
public:
static void Register(asIScriptEngine* engine);
};
#endif // PKMNLIB_REGISTERGROWTHRATETYPES_HPP

View File

@ -1,6 +1,6 @@
#include "RegisterItemTypes.hpp"
#include <cassert>
#include "../../Library/Items/Item.hpp"
#include "../../../Library/Items/Item.hpp"
void RegisterItemTypes::Register(asIScriptEngine* engine) {
RegisterItemCategoryEnum(engine);

View File

@ -1,6 +1,6 @@
#include "RegisterMoveTypes.hpp"
#include <cassert>
#include "../../Library/Moves/MoveData.hpp"
#include "../../../Library/Moves/MoveData.hpp"
void RegisterMoveTypes::Register(asIScriptEngine* engine) {
RegisterMoveCategory(engine);

View File

@ -1,7 +1,7 @@
#include "RegisterPokemonTypes.hpp"
#include <cassert>
#include "../../Library/Species/PokemonSpecies.hpp"
#include "../../Library/Statistic.hpp"
#include "../../../Library/Species/PokemonSpecies.hpp"
#include "../../../Library/Statistic.hpp"
void RegisterPokemonTypes::Register(asIScriptEngine* engine) {
RegisterGenderEnum(engine);