CreatureLib/CInterface/Library/GrowthRate.cpp

27 lines
1.3 KiB
C++

#include "../../src/Library/GrowthRates/GrowthRate.hpp"
#include "../../src/Library/GrowthRates/ExternGrowthRate.hpp"
#include "../../src/Library/GrowthRates/LookupGrowthRate.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Library;
export GrowthRate* CreatureLib_LookupGrowthRate_Construct(uint32_t experiencePerLevel[], size_t count) {
ArbUt::List<uint32_t> exp(experiencePerLevel, experiencePerLevel + count);
return new LookupGrowthRate(exp);
};
export uint8_t CreatureLib_ExternGrowthRate_Construct(GrowthRate*& out, level_int_t (*calcLevel)(uint32_t),
uint32_t (*calcExperience)(level_int_t)) {
Try(out = new ExternGrowthRate(calcLevel, calcExperience);)
};
export void CreatureLib_GrowthRate_Destruct(const GrowthRate* p) { delete p; }
export void CreatureLib_LookupGrowthRate_Destruct(const LookupGrowthRate* p) { delete p; }
export void CreatureLib_ExternGrowthRate_Destruct(const ExternGrowthRate* p) { delete p; }
export uint8_t CreatureLib_GrowthRate_CalculateLevel(level_int_t& out, const GrowthRate* p, uint32_t experience) {
Try(out = p->CalculateLevel(experience);)
}
export uint8_t CreatureLib_GrowthRate_CalculateExperience(uint32_t& out, const GrowthRate* p, level_int_t level) {
Try(out = p->CalculateExperience(level);)
}