Large cleanup of type registration, added new "NativeArray" (or narray in angelscript) type that simply holds a pointer to a native list, to prevent copies we don't need
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:
@@ -3,28 +3,20 @@
|
||||
#include "AngelScriptResolver.hpp"
|
||||
#include "AngelscriptUserdata.hpp"
|
||||
|
||||
CScriptArray*
|
||||
NativeArray<ArbUt::List<CreatureLib::Library::EffectParameter*>>*
|
||||
AngelScriptItemUseScript::GetEffectParameters(const ArbUt::List<CreatureLib::Library::EffectParameter*>& ls) {
|
||||
auto* ud = _resolver->GetUserdata();
|
||||
auto* arr = ud->CreateArray("array<EffectParameter@>"_cnc, ls.Count());
|
||||
for (size_t i = 0; i < ls.Count(); i++) {
|
||||
arr->SetValue(i, (void**)&ls[i]);
|
||||
}
|
||||
return arr;
|
||||
return new NativeArray<ArbUt::List<CreatureLib::Library::EffectParameter*>>(&ls);
|
||||
}
|
||||
|
||||
void AngelScriptItemUseScript::OnInitialize(const ArbUt::List<CreatureLib::Library::EffectParameter*>& parameters) {
|
||||
if (__OnInitialize.Exists) {
|
||||
CScriptArray* arr = nullptr;
|
||||
AngelScriptUtils::AngelscriptFunctionCall(
|
||||
__OnInitialize.Function, _resolver->GetContextPool(), _scriptObject, _resolver, ""_cnc,
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {
|
||||
arr = GetEffectParameters(parameters);
|
||||
auto* arr = GetEffectParameters(parameters);
|
||||
ctx->SetArgAddress(0, arr);
|
||||
},
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {});
|
||||
|
||||
arr->Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user