2020-02-29 16:00:29 +00:00
|
|
|
#include "../../src/Library/CreatureData/CreatureSpecies.hpp"
|
2020-07-31 08:51:03 +00:00
|
|
|
#include "../Core.hpp"
|
2020-02-29 16:21:36 +00:00
|
|
|
using namespace CreatureLib::Library;
|
2020-02-29 16:00:29 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, u16 id, const char* name,
|
|
|
|
SpeciesVariant* defaultVariant, float genderRatio,
|
|
|
|
const char* growthRate, u8 captureRate, const char* flags[],
|
|
|
|
size_t flagsCount) {
|
2020-03-25 18:07:36 +00:00
|
|
|
|
2022-03-23 12:56:45 +00:00
|
|
|
Try(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])); }
|
|
|
|
|
|
|
|
out = new CreatureSpecies(id, ArbUt::StringView(name), defaultVariant, genderRatio,
|
|
|
|
ArbUt::StringView(growthRate), captureRate, conversedFlags);)
|
2020-02-29 16:00:29 +00:00
|
|
|
}
|
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func void CreatureLib_CreatureSpecies_Destruct(const CreatureSpecies* p) { delete p; }
|
2020-02-29 16:00:29 +00:00
|
|
|
|
2022-03-23 12:56:45 +00:00
|
|
|
SIMPLE_GET_FUNC(CreatureSpecies, GetId, u16);
|
2020-02-29 16:00:29 +00:00
|
|
|
SIMPLE_GET_FUNC(CreatureSpecies, GetGenderRate, float);
|
2022-03-23 12:56:45 +00:00
|
|
|
SIMPLE_GET_FUNC(CreatureSpecies, GetCaptureRate, u8);
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func const char* CreatureLib_CreatureSpecies_GetName(const CreatureSpecies* p) { return p->GetName().c_str(); }
|
|
|
|
export_func const char* CreatureLib_CreatureSpecies_GetGrowthRate(const CreatureSpecies* p) {
|
2020-02-29 16:00:29 +00:00
|
|
|
return p->GetGrowthRate().c_str();
|
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func bool CreatureLib_CreatureSpecies_HasVariant(const CreatureSpecies* p, const char* name) {
|
2020-06-26 15:08:23 +00:00
|
|
|
return p->HasVariant(ArbUt::StringView::CalculateHash(name));
|
2020-02-29 16:00:29 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func bool CreatureLib_CreatureSpecies_HasVariantWithHash(const CreatureSpecies* p, u32 hash) {
|
2020-02-29 16:00:29 +00:00
|
|
|
return p->HasVariant(hash);
|
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func bool CreatureLib_CreatureSpecies_TryGetVariant(const CreatureSpecies* p, const char* name,
|
|
|
|
const SpeciesVariant*& out) {
|
2020-12-12 13:12:50 +00:00
|
|
|
auto res = p->TryGetVariant(ArbUt::StringView::CalculateHash(name));
|
|
|
|
if (!res.has_value())
|
|
|
|
return false;
|
|
|
|
out = res.value();
|
|
|
|
return true;
|
2020-02-29 16:00:29 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpecies* p, u32 hash,
|
|
|
|
const SpeciesVariant*& out) {
|
2020-12-12 13:12:50 +00:00
|
|
|
auto res = p->TryGetVariant(hash);
|
|
|
|
if (!res.has_value())
|
|
|
|
return false;
|
|
|
|
out = res.value();
|
|
|
|
return true;
|
2020-02-29 16:00:29 +00:00
|
|
|
}
|
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_CreatureSpecies_GetVariant(const SpeciesVariant*& out, const CreatureSpecies* p,
|
|
|
|
const char* name) {
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(out = p->GetVariant(ArbUt::StringView::CalculateHash(name)).GetRaw();)
|
2020-02-29 16:00:29 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_CreatureSpecies_GetVariantWithHash(const SpeciesVariant*& out, const CreatureSpecies* p,
|
|
|
|
u32 hash) {
|
2020-05-26 12:35:18 +00:00
|
|
|
Try(out = p->GetVariant(hash).GetRaw();)
|
2020-02-29 16:00:29 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_CreatureSpecies_SetVariant(CreatureSpecies* p, const char* name, SpeciesVariant* variant) {
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(p->SetVariant(ArbUt::StringView(name), variant);)
|
2020-05-04 18:40:45 +00:00
|
|
|
}
|
2020-07-17 12:43:04 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func Gender CreatureLib_CreatureSpecies_GetRandomGender(CreatureSpecies* p, ArbUt::Random* random) {
|
2020-07-17 12:43:04 +00:00
|
|
|
return p->GetRandomGender(*random);
|
2020-08-08 16:56:00 +00:00
|
|
|
}
|
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func size_t CreatureLib_CreatureSpecies_GetVariantsCount(CreatureSpecies* p) {
|
2020-08-08 17:08:24 +00:00
|
|
|
return p->GetVariantsIterator().Count();
|
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func const SpeciesVariant* const* CreatureLib_CreatureSpecies_GetVariants(CreatureSpecies* p) {
|
2020-08-08 16:56:00 +00:00
|
|
|
return reinterpret_cast<const SpeciesVariant* const*>(p->GetVariantsIterator().RawData());
|
2020-08-10 15:46:09 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func bool CreatureLib_CreatureSpecies_HasFlag(const CreatureSpecies* p, const char* key) {
|
2020-08-10 15:46:09 +00:00
|
|
|
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
|
2020-07-17 12:43:04 +00:00
|
|
|
}
|