2020-02-29 16:21:36 +00:00
|
|
|
#include "../../src/Library/CreatureData/SpeciesVariant.hpp"
|
2020-07-31 08:51:03 +00:00
|
|
|
#include "../Core.hpp"
|
2020-02-29 16:21:36 +00:00
|
|
|
|
|
|
|
using namespace CreatureLib::Library;
|
|
|
|
|
2022-03-23 12:56:45 +00:00
|
|
|
export SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
|
|
|
|
const char* name, float height, float weight, u32 baseExperience, u8 types[], size_t typeLength, u16 baseHealth,
|
|
|
|
u16 baseAttack, u16 baseDefense, u16 baseMagicalAttack, u16 baseMagicalDefense, u16 baseSpeed,
|
|
|
|
const Talent* talents[], size_t talentsLength, const Talent* secretTalents[], size_t secretTalentsLength,
|
|
|
|
const LearnableAttacks* attacks, const char* flags[], size_t flagsCount) {
|
2020-08-10 15:46:09 +00:00
|
|
|
|
2022-03-23 12:56:45 +00:00
|
|
|
std::unordered_set<u32> conversedFlags(flagsCount);
|
2020-08-10 15:46:09 +00:00
|
|
|
for (size_t i = 0; i < flagsCount; i++) {
|
|
|
|
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
|
|
|
|
}
|
2020-02-29 16:21:36 +00:00
|
|
|
|
2021-11-15 11:04:45 +00:00
|
|
|
auto talentsWrapped = ArbUt::List<ArbUt::BorrowedPtr<const Talent>>(talentsLength);
|
2020-02-29 16:21:36 +00:00
|
|
|
for (size_t i = 0; i < talentsLength; i++) {
|
2021-11-15 11:04:45 +00:00
|
|
|
talentsWrapped.Append(talents[i]);
|
2020-02-29 16:21:36 +00:00
|
|
|
}
|
2021-11-15 11:04:45 +00:00
|
|
|
auto secretTalentsWrapped = ArbUt::List<ArbUt::BorrowedPtr<const Talent>>(secretTalentsLength);
|
2020-02-29 16:21:36 +00:00
|
|
|
for (size_t i = 0; i < secretTalentsLength; i++) {
|
2021-11-15 11:04:45 +00:00
|
|
|
secretTalentsWrapped.Append(secretTalents[i]);
|
2020-02-29 16:21:36 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 12:56:45 +00:00
|
|
|
return new SpeciesVariant(ArbUt::StringView(name), height, weight, baseExperience,
|
|
|
|
ArbUt::List<u8>(types, types + typeLength),
|
|
|
|
CreatureLib::Library::StatisticSet<u16>(baseHealth, baseAttack, baseDefense,
|
|
|
|
baseMagicalAttack, baseMagicalDefense, baseSpeed),
|
|
|
|
talentsWrapped, secretTalentsWrapped, attacks, conversedFlags);
|
2020-02-29 16:21:36 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 12:59:49 +00:00
|
|
|
export void CreatureLib_SpeciesVariant_Destruct(SpeciesVariant* p) { delete p; }
|
|
|
|
|
|
|
|
export const char* CreatureLib_SpeciesVariant_GetName(SpeciesVariant* p) { return p->GetName().c_str(); }
|
|
|
|
SIMPLE_GET_FUNC(SpeciesVariant, GetHeight, float);
|
|
|
|
SIMPLE_GET_FUNC(SpeciesVariant, GetWeight, float);
|
2022-03-23 12:56:45 +00:00
|
|
|
SIMPLE_GET_FUNC(SpeciesVariant, GetBaseExperience, u32);
|
2020-03-02 12:59:49 +00:00
|
|
|
SIMPLE_GET_FUNC(SpeciesVariant, GetTypeCount, size_t);
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 CreatureLib_SpeciesVariant_GetType(SpeciesVariant* p, size_t index) { return p->GetType(index); }
|
|
|
|
export u16 CreatureLib_SpeciesVariant_GetStatistic(SpeciesVariant* p, CreatureLib::Library::Statistic stat) {
|
2020-03-02 12:59:49 +00:00
|
|
|
return p->GetStatistic(stat);
|
|
|
|
}
|
|
|
|
SIMPLE_GET_FUNC(SpeciesVariant, GetTalentCount, size_t);
|
|
|
|
SIMPLE_GET_FUNC(SpeciesVariant, GetSecretTalentCount, size_t);
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 CreatureLib_SpeciesVariant_GetTalent(SpeciesVariant* p, bool secret, u8 index, const Talent*& out) {
|
2021-11-15 11:04:45 +00:00
|
|
|
Try(out = p->GetTalent(TalentIndex(secret, index)).GetRaw();)
|
2020-03-02 13:01:56 +00:00
|
|
|
}
|
2020-03-27 19:46:44 +00:00
|
|
|
export const LearnableAttacks* CreatureLib_SpeciesVariant_GetLearnableAttacks(SpeciesVariant* p) {
|
2020-07-07 13:33:43 +00:00
|
|
|
return p->GetLearnableAttacks().GetRaw();
|
2020-03-27 19:46:44 +00:00
|
|
|
}
|
2022-03-23 12:56:45 +00:00
|
|
|
export u8 CreatureLib_SpeciesVariant_GetRandomTalent(SpeciesVariant* p, ArbUt::Random* rand) {
|
2020-07-18 10:20:47 +00:00
|
|
|
return p->GetRandomTalent(*rand).GetIndex();
|
|
|
|
}
|
2020-08-10 15:46:09 +00:00
|
|
|
export bool CreatureLib_SpeciesVariant_HasFlag(const SpeciesVariant* p, const char* key) {
|
|
|
|
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
|
|
|
|
}
|