Register many new types and properties in AngelScript.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-02-16 16:43:37 +01:00
parent 0147515ffb
commit 98c3bdea1a
9 changed files with 186 additions and 7 deletions

View File

@@ -1,12 +1,16 @@
#include "AngelScripResolver.hpp"
#include <CreatureLib/Battling/Models/Creature.hpp>
#include <cassert>
#include "../../../extern/angelscript_addons/scriptarray/scriptarray.h"
#include "../../../extern/angelscript_addons/scripthandle/scripthandle.h"
#include "../../../extern/angelscript_addons/scripthelper/scripthelper.h"
#include "../../../extern/angelscript_addons/scriptstdstring/scriptstdstring.h"
#include <cassert>
#include "TypeRegistry/BasicScriptClass.hpp"
#include "TypeRegistry/Battling/RegisterBattleClass.hpp"
#include "TypeRegistry/Battling/RegisterBattleLibrary.hpp"
#include "TypeRegistry/Battling/RegisterExecutingAttack.hpp"
#include "TypeRegistry/Battling/RegisterPokemonClass.hpp"
#include "TypeRegistry/Battling/RegisterTurnChoices.hpp"
#include "TypeRegistry/Library/RegisterGrowthRateTypes.hpp"
#include "TypeRegistry/Library/RegisterItemTypes.hpp"
#include "TypeRegistry/Library/RegisterMoveTypes.hpp"
@@ -33,8 +37,7 @@ void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) {
_engine->SetEngineProperty(asEP_AUTO_GARBAGE_COLLECT, false);
_engine->SetEngineProperty(asEP_REQUIRE_ENUM_SCOPE, true);
_engine->SetEngineProperty(asEP_PROPERTY_ACCESSOR_MODE, 2);
_engine->SetEngineProperty(asEP_COMPILER_WARNINGS , 2);
_engine->SetEngineProperty(asEP_COMPILER_WARNINGS, 2);
RegisterStdString(_engine);
@@ -69,6 +72,13 @@ void AngelScripResolver::RegisterTypes() {
// Register battle types
RegisterPokemonClass::Register(_engine);
RegisterExecutingAttack::Register(_engine);
RegisterTurnChoices::Register(_engine);
RegisterBattleLibrary::Register(_engine);
RegisterBattleClass::Register(_engine);
[[maybe_unused]] int r =
_engine->RegisterObjectMethod("Pokemon", "const Battle@ get_Battle() const property",
asMETHOD(CreatureLib::Battling::Creature, GetBattle), asCALL_THISCALL);
assert(r >= 0);
// Register base script
BasicScriptClass::Register(_engine);
@@ -97,8 +107,8 @@ void AngelScripResolver::MessageCallback(const asSMessageInfo* msg, void* param)
printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message);
}
static constexpr const char* GetCategoryNamespace(AngelScripResolver::ScriptCategory category){
switch (category){
static constexpr const char* GetCategoryNamespace(AngelScripResolver::ScriptCategory category) {
switch (category) {
case CreatureLib::Battling::ScriptResolver::ScriptCategory::Attack: return "Moves";
case CreatureLib::Battling::ScriptResolver::ScriptCategory::Talent: return "Abilities";
case CreatureLib::Battling::ScriptResolver::ScriptCategory::Status: return "Status";