CreatureLib/CInterface/Library/CreatureSpecies.cpp

57 lines
2.8 KiB
C++
Raw Normal View History

#include "../../src/Library/CreatureData/CreatureSpecies.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Library;
export uint8_t CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, uint16_t id, const char* name,
SpeciesVariant* defaultVariant, float genderRatio,
const char* growthRate, uint8_t captureRate) {
2020-06-26 15:08:23 +00:00
Try(out = new CreatureSpecies(id, ArbUt::StringView(name), defaultVariant, genderRatio,
ArbUt::StringView(growthRate), captureRate);)
}
export void CreatureLib_CreatureSpecies_Destruct(const CreatureSpecies* p) { delete p; }
SIMPLE_GET_FUNC(CreatureSpecies, GetId, uint16_t);
SIMPLE_GET_FUNC(CreatureSpecies, GetGenderRate, float);
SIMPLE_GET_FUNC(CreatureSpecies, GetCaptureRate, uint8_t);
export const char* CreatureLib_CreatureSpecies_GetName(const CreatureSpecies* p) { return p->GetName().c_str(); }
export const char* CreatureLib_CreatureSpecies_GetGrowthRate(const CreatureSpecies* p) {
return p->GetGrowthRate().c_str();
}
export 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));
}
export bool CreatureLib_CreatureSpecies_HasVariantWithHash(const CreatureSpecies* p, uint32_t hash) {
return p->HasVariant(hash);
}
export bool CreatureLib_CreatureSpecies_TryGetVariant(const CreatureSpecies* p, const char* name,
const SpeciesVariant*& out) {
2020-05-26 16:31:06 +00:00
ArbUt::BorrowedPtr<const SpeciesVariant> o;
2020-06-26 15:08:23 +00:00
auto res = p->TryGetVariant(ArbUt::StringView::CalculateHash(name), o);
2020-05-26 12:35:18 +00:00
out = o.GetRaw();
return res;
}
export bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpecies* p, uint32_t hash,
2020-04-06 15:05:32 +00:00
const SpeciesVariant*& out) {
2020-05-26 16:31:06 +00:00
ArbUt::BorrowedPtr<const SpeciesVariant> o;
2020-05-26 12:35:18 +00:00
auto res = p->TryGetVariant(hash, o);
out = o.GetRaw();
return res;
}
export uint8_t 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-07-17 11:12:21 +00:00
export uint8_t CreatureLib_CreatureSpecies_GetVariantWithHash(const SpeciesVariant*& out, const CreatureSpecies* p,
uint32_t hash) {
2020-05-26 12:35:18 +00:00
Try(out = p->GetVariant(hash).GetRaw();)
}
2020-05-04 18:40:45 +00:00
export uint8_t 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
}
export Gender CreatureLib_CreatureSpecies_GetRandomGender(CreatureSpecies* p, ArbUt::Random* random) {
return p->GetRandomGender(*random);
}