A bunch of work on the concept of script owners.
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:
@@ -11,6 +11,7 @@
|
||||
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
|
||||
#include <Arbutils/StringView.hpp>
|
||||
#include <angelscript.h>
|
||||
#include "../../Battling/PkmnScriptCategory.hpp"
|
||||
#include "AngelScriptItemUseScript.hpp"
|
||||
#include "AngelScriptScript.hpp"
|
||||
#include "AngelScriptTypeInfo.hpp"
|
||||
@@ -35,6 +36,7 @@ private:
|
||||
ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> _evolutionTypes;
|
||||
ArbUt::Dictionary<const CreatureLib::Library::Item*, AngelScriptItemUseScript*> _itemUseScripts;
|
||||
ArbUt::Dictionary<ArbUt::StringView, AngelScriptEvolutionScript*> _evolutionScripts;
|
||||
ArbUt::Dictionary<ScriptCategory, asITypeInfo*> _scriptOwnerTypes;
|
||||
|
||||
static void MessageCallback(const asSMessageInfo* msg, void* param);
|
||||
static void Print(const std::string& str) { std::cout << str << std::endl; }
|
||||
@@ -60,7 +62,8 @@ public:
|
||||
|
||||
void DefineWord(const std::string& word) { _builder.DefineWord(word.c_str()); }
|
||||
|
||||
CreatureLib::Battling::BattleScript* LoadScript(ScriptCategory category,
|
||||
CreatureLib::Battling::BattleScript* LoadScript(const ArbUt::OptionalBorrowedPtr<void>& owner,
|
||||
ScriptCategory category,
|
||||
const ArbUt::StringView& scriptName) override;
|
||||
CreatureLib::Battling::ItemUseScript* LoadItemScript(const CreatureLib::Library::Item* item) override;
|
||||
|
||||
@@ -112,5 +115,27 @@ public:
|
||||
inline AngelscriptUserdata* GetUserdata() const noexcept { return _userData; }
|
||||
inline ArbUt::OptionalBorrowedPtr<AngelscriptDebugger> GetDebugger() const noexcept { return _debugger.GetValue(); }
|
||||
inline void SetDebugger(AngelscriptDebugger* debugger) noexcept { _debugger = debugger; }
|
||||
|
||||
inline asITypeInfo* GetScriptOwnerType(ScriptCategory category) {
|
||||
auto tryget = _scriptOwnerTypes.TryGet(category);
|
||||
if (tryget.has_value()) {
|
||||
return tryget.value();
|
||||
}
|
||||
|
||||
asITypeInfo* t = nullptr;
|
||||
switch (category) {
|
||||
case ScriptCategory::Attack: t = _engine->GetTypeInfoByName("ExecutingMove"); break;
|
||||
case ScriptCategory::Talent: t = _engine->GetTypeInfoByName("Pokemon"); break;
|
||||
case ScriptCategory::Status: t = _engine->GetTypeInfoByName("Pokemon"); break;
|
||||
case ScriptCategory::Creature: t = _engine->GetTypeInfoByName("Pokemon"); break;
|
||||
case ScriptCategory::Battle: t = _engine->GetTypeInfoByName("Battle"); break;
|
||||
case ScriptCategory::Side: t = _engine->GetTypeInfoByName("BattleSide"); break;
|
||||
}
|
||||
switch (static_cast<PkmnScriptCategory>(category)) {
|
||||
case PkmnScriptCategory::Weather: t = _engine->GetTypeInfoByName("Battle"); break;
|
||||
}
|
||||
_scriptOwnerTypes.Set(category, t);
|
||||
return t;
|
||||
}
|
||||
};
|
||||
#endif // PKMNLIB_ANGELSCRIPRESOLVER_HPP
|
||||
|
||||
Reference in New Issue
Block a user