Adds some more Angelscript functionality for the BattleSide.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
41475fcb2f
commit
bee9170603
|
@ -91,7 +91,6 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg,
|
||||||
|
|
||||||
_contextPool = new ContextPool(_engine);
|
_contextPool = new ContextPool(_engine);
|
||||||
}
|
}
|
||||||
OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::Battle, GetBattle);
|
|
||||||
|
|
||||||
void AngelScriptResolver::RegisterTypes() {
|
void AngelScriptResolver::RegisterTypes() {
|
||||||
// Register static library types
|
// Register static library types
|
||||||
|
@ -104,14 +103,17 @@ void AngelScriptResolver::RegisterTypes() {
|
||||||
RegisterEffectParameter::Register(_engine);
|
RegisterEffectParameter::Register(_engine);
|
||||||
|
|
||||||
// Register battle types
|
// Register battle types
|
||||||
|
// Predeclare these two types, and declare their implementation later.
|
||||||
|
[[maybe_unused]] int r = _engine->RegisterObjectType("Battle", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
Ensure(r >= 0);
|
||||||
|
r = _engine->RegisterObjectType("BattleSide", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
Ensure(r >= 0);
|
||||||
|
|
||||||
RegisterPokemonClass::Register(_engine);
|
RegisterPokemonClass::Register(_engine);
|
||||||
RegisterExecutingAttack::Register(_engine);
|
RegisterExecutingAttack::Register(_engine);
|
||||||
RegisterTurnChoices::Register(_engine);
|
RegisterTurnChoices::Register(_engine);
|
||||||
RegisterBattleLibrary::Register(_engine);
|
RegisterBattleLibrary::Register(_engine);
|
||||||
RegisterBattleClass::Register(_engine);
|
RegisterBattleClass::Register(_engine);
|
||||||
[[maybe_unused]] int r = _engine->RegisterObjectMethod("Pokemon", "const Battle@ get_Battle() const property",
|
|
||||||
asFUNCTION(GetBattleWrapper), asCALL_CDECL_OBJFIRST);
|
|
||||||
Ensure(r >= 0);
|
|
||||||
|
|
||||||
// Register base script
|
// Register base script
|
||||||
BasicScriptClass::Register(_engine);
|
BasicScriptClass::Register(_engine);
|
||||||
|
|
|
@ -51,19 +51,23 @@ CreatureLib::Battling::BattleSide* GetBattleSideWrapper(PkmnLib::Battling::Battl
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) {
|
void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) {
|
||||||
int r = engine->RegisterObjectType("BattleSide", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
int r = engine->RegisterObjectMethod(
|
||||||
|
"BattleSide", "bool SwapPositions(uint8 a, uint8 b)",
|
||||||
|
asMETHODPR(CreatureLib::Battling::BattleSide, SwapPositions, (u8 a, u8 b), bool), asCALL_THISCALL);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("BattleSide", "bool SwapPositions(uint8 a, uint8 b)",
|
r = engine->RegisterObjectMethod("BattleSide", "uint8 get_SideIndex() const property",
|
||||||
asMETHODPR(CreatureLib::Battling::BattleSide, SwapPositions, (u8 a, u8 b), bool),
|
asMETHOD(CreatureLib::Battling::BattleSide, GetSideIndex), asCALL_THISCALL);
|
||||||
|
Ensure(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("BattleSide", "uint8 GetPokemonIndex(const Pokemon@ pokemon) const",
|
||||||
|
asMETHODPR(CreatureLib::Battling::BattleSide, GetCreatureIndex,
|
||||||
|
(const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>& c), u8),
|
||||||
asCALL_THISCALL);
|
asCALL_THISCALL);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("Battle", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
int r = engine->RegisterObjectMethod("Battle", "const BattleLibrary@ get_Library() const property",
|
||||||
Ensure(r >= 0);
|
asMETHOD(PkmnLib::Battling::Battle, GetLibrary), asCALL_THISCALL);
|
||||||
r = engine->RegisterObjectMethod("Battle", "const BattleLibrary@ get_Library() const property",
|
|
||||||
asMETHOD(PkmnLib::Battling::Battle, GetLibrary), asCALL_THISCALL);
|
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("Battle", "bool CanUse(BaseTurnChoice@ choice)",
|
r = engine->RegisterObjectMethod("Battle", "bool CanUse(BaseTurnChoice@ choice)",
|
||||||
asMETHOD(PkmnLib::Battling::Battle, CanUse), asCALL_THISCALL);
|
asMETHOD(PkmnLib::Battling::Battle, CanUse), asCALL_THISCALL);
|
||||||
|
|
|
@ -84,6 +84,8 @@ static std::string NicknameWrapper(const PkmnLib::Battling::Pokemon* obj) { retu
|
||||||
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::CreatureSpecies, GetSpecies);
|
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::CreatureSpecies, GetSpecies);
|
||||||
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const PkmnLib::Library::PokemonForme, GetForme);
|
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const PkmnLib::Library::PokemonForme, GetForme);
|
||||||
OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::Item, GetHeldItem);
|
OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::Item, GetHeldItem);
|
||||||
|
OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::Battle, GetBattle);
|
||||||
|
OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::BattleSide, GetBattleSide);
|
||||||
|
|
||||||
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
@ -184,4 +186,11 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||||
asMETHODPR(PkmnLib::Battling::Pokemon, RemoveVolatileScript, (const ArbUt::BasicStringView&), void),
|
asMETHODPR(PkmnLib::Battling::Pokemon, RemoveVolatileScript, (const ArbUt::BasicStringView&), void),
|
||||||
asCALL_THISCALL);
|
asCALL_THISCALL);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
|
||||||
|
r = engine->RegisterObjectMethod("Pokemon", "const Battle@ get_Battle() const property",
|
||||||
|
asFUNCTION(GetBattleWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
|
Ensure(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("Pokemon", "const BattleSide@ get_BattleSide() const property",
|
||||||
|
asFUNCTION(GetBattleSideWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
|
Ensure(r >= 0);
|
||||||
}
|
}
|
Loading…
Reference in New Issue