Implements extern growthrate that uses function pointers.
This commit is contained in:
19
src/Library/GrowthRates/ExternGrowthRate.hpp
Normal file
19
src/Library/GrowthRates/ExternGrowthRate.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef CREATURELIB_EXTERNGROWTHRATE_HPP
|
||||
#define CREATURELIB_EXTERNGROWTHRATE_HPP
|
||||
|
||||
#include "GrowthRate.hpp"
|
||||
namespace CreatureLib::Library {
|
||||
class ExternGrowthRate : public GrowthRate {
|
||||
uint8_t (*_calcLevel)(uint32_t experience);
|
||||
uint32_t (*_calcExperience)(uint8_t level);
|
||||
|
||||
public:
|
||||
ExternGrowthRate(uint8_t (*calcLevel)(uint32_t), uint32_t (*calcExperience)(uint8_t level))
|
||||
: _calcLevel(calcLevel), _calcExperience(calcExperience) {}
|
||||
|
||||
uint8_t CalculateLevel(uint32_t experience) const override { return _calcLevel(experience); }
|
||||
uint32_t CalculateExperience(uint8_t level) const override { return _calcExperience(level); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CREATURELIB_EXTERNGROWTHRATE_HPP
|
||||
@@ -1 +0,0 @@
|
||||
#include "GrowthRate.hpp"
|
||||
Reference in New Issue
Block a user