From 1c51edb2b9b1d74eb2a99b091c30266a6b07c330 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 27 Nov 2021 10:37:12 +0100 Subject: [PATCH] Adds C Interface for Talent + TalentLibrary --- CInterface/Library/Talent.cpp | 17 +++++++++++++++++ CInterface/Library/TalentLibrary.cpp | 13 +++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 CInterface/Library/Talent.cpp create mode 100644 CInterface/Library/TalentLibrary.cpp diff --git a/CInterface/Library/Talent.cpp b/CInterface/Library/Talent.cpp new file mode 100644 index 0000000..3dac9c0 --- /dev/null +++ b/CInterface/Library/Talent.cpp @@ -0,0 +1,17 @@ +#include "../../src/Library/CreatureData/Talent.hpp" +#include "../Core.hpp" +using namespace CreatureLib::Library; + +export Talent* CreatureLib_Talent_Construct(const char* name, const char* effect, EffectParameter* effectParameters[], + size_t effectParameterCount) { + ArbUt::List effectParameterList(effectParameterCount); + for (size_t i = 0; i < effectParameterCount; i++) { + effectParameterList.Append(effectParameters[i]); + } + return new Talent(ArbUt::StringView(name), ArbUt::StringView(effect), effectParameterList); +} +export void CreatureLib_Talent_Destruct(const Talent* p) { delete p; } + +export const char* CreatureLib_Talent_GetName(const Talent* talent) { return talent->GetName().c_str(); } + +export const char* CreatureLib_Talent_GetEffect(const Talent* talent) { return talent->GetEffect().c_str(); } diff --git a/CInterface/Library/TalentLibrary.cpp b/CInterface/Library/TalentLibrary.cpp new file mode 100644 index 0000000..94c59df --- /dev/null +++ b/CInterface/Library/TalentLibrary.cpp @@ -0,0 +1,13 @@ +#include "../../src/Library/TalentLibrary.hpp" +#include "../Core.hpp" +#include "BaseLibrary.cpp" + +using namespace CreatureLib::Library; + +export uint8_t CreatureLib_TalentLibrary_Construct(TalentLibrary*& library, size_t initialCapacity = 32) { + Try(library = new TalentLibrary(initialCapacity);) +}; + +export void CreatureLib_TalentLibrary_Destruct(const TalentLibrary* p) { delete p; } + +BASELIBRARY(CreatureLib_TalentLibrary, TalentLibrary, Talent); \ No newline at end of file