Skip to content
Snippets Groups Projects
Commit cc4ab57c authored by KosmX's avatar KosmX
Browse files

use modern functional instead of c style function pointer

parent b7281f89
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ namespace weapons {
{
return victim->damage(this->getDamage(), *victim);
}
bool MeleeWeapon::damageIf(std::shared_ptr<LivingEntity>& user, bool(*predicate)(std::shared_ptr<Entity> self, std::shared_ptr<Entity> other))
bool MeleeWeapon::damageIf(std::shared_ptr<LivingEntity>& user, std::function<bool(std::shared_ptr<Entity>, std::shared_ptr<Entity>)> predicate)
{
bool bl = false;
for(auto& entity : GameClient::getInstance().getEntities()){
......@@ -28,6 +28,7 @@ namespace weapons {
{
if (this->cooldown != 0) return false;
this->cooldown = this->cooldownTime;
damageIf()
}
void MeleeWeapon::setPos(const olc::vf2d& newPos)
{
......
......@@ -9,7 +9,7 @@ namespace weapons {
protected:
virtual int getDamage() const;
virtual bool damageEntity(std::shared_ptr<LivingEntity> user, std::shared_ptr<Entity>& victim);
virtual bool damageIf(std::shared_ptr<LivingEntity>& user, bool(*predicate)(std::shared_ptr<Entity> self, std::shared_ptr<Entity> other));
virtual bool damageIf(std::shared_ptr<LivingEntity>& user, std::function<bool(std::shared_ptr<Entity> self, std::shared_ptr<Entity> other)> predicate);
//virtual bool(*getPredicator())(std::shared_ptr<Entity>, std::shared_ptr<Entity>) = 0;
virtual std::function<bool(std::shared_ptr<Entity>, std::shared_ptr<Entity>)> getPredicator() = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment