Adds a bunch of helpers for evolution, as well as custom script evolution methods.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#ifndef PKMNLIB_ANGELSCRIPTEVOLUTIONSCRIPT_HPP
|
||||
#define PKMNLIB_ANGELSCRIPTEVOLUTIONSCRIPT_HPP
|
||||
#include "../../Battling/Pokemon/Pokemon.hpp"
|
||||
#include "../../Library/Evolutions/EvolutionData.hpp"
|
||||
#include "AngelScriptFunctionCall.hpp"
|
||||
|
||||
class AngelScriptResolver;
|
||||
|
||||
class AngelScriptEvolutionScript final : public PkmnLib::Battling::EvolutionScript {
|
||||
asIScriptObject* _scriptObject;
|
||||
AngelScriptResolver* _resolver;
|
||||
|
||||
struct FunctionInfo {
|
||||
bool Exists = false;
|
||||
asIScriptFunction* Function = nullptr;
|
||||
};
|
||||
|
||||
#define EVO_SCRIPT_HOOK_FUNCTION(name, decl) FunctionInfo __##name = Initialize(decl);
|
||||
|
||||
FunctionInfo Initialize(const std::string& decl) {
|
||||
auto val = _scriptObject->GetObjectType()->GetMethodByDecl(decl.c_str(), false);
|
||||
if (val == nullptr) {
|
||||
return FunctionInfo{.Exists = false, .Function = nullptr};
|
||||
}
|
||||
return FunctionInfo{.Exists = true, .Function = val};
|
||||
}
|
||||
|
||||
EVO_SCRIPT_HOOK_FUNCTION(DoesEvolveFromLevelUp,
|
||||
"void DoesEvolveFromLevelUp(bool& out, const EvolutionData@ evoData,"
|
||||
"const Pokemon@ pokemon)");
|
||||
|
||||
public:
|
||||
AngelScriptEvolutionScript(asIScriptObject* scriptObject, AngelScriptResolver* resolver)
|
||||
: _scriptObject(scriptObject), _resolver(resolver) {}
|
||||
|
||||
~AngelScriptEvolutionScript() {
|
||||
if (_scriptObject != nullptr) {
|
||||
_scriptObject->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void DoesEvolveFromLevelUp(const ArbUt::BorrowedPtr<const PkmnLib::Library::EvolutionData>& evolution,
|
||||
const ArbUt::BorrowedPtr<const PkmnLib::Battling::Pokemon>& pokemon,
|
||||
bool* out) const override;
|
||||
};
|
||||
|
||||
#endif // PKMNLIB_ANGELSCRIPTEVOLUTIONSCRIPT_HPP
|
||||
Reference in New Issue
Block a user