From 2914143ad3ed14fc58a49dedbbe4fa1992b526ef Mon Sep 17 00:00:00 2001 From: silverweed Date: Thu, 22 Aug 2024 15:50:37 +0200 Subject: [PATCH] remove another bunch of lifish-specific components --- src/core/components/GuidedMoving.cpp | 74 --------------------------- src/core/components/GuidedMoving.hpp | 67 ------------------------ src/lifish/components/Absorbable.hpp | 17 ------ src/lifish/components/LightSource.cpp | 51 ------------------ src/lifish/components/LightSource.hpp | 39 -------------- src/lifish/entities/AbsorbFX.cpp | 54 ------------------- src/lifish/entities/AbsorbFX.hpp | 26 ---------- src/lifish/entities/ArmorFX.hpp | 22 -------- src/lifish/entities/Bomb.cpp | 2 - src/lifish/entities/Boss.cpp | 2 - src/lifish/entities/Enemy.cpp | 5 -- src/lifish/entities/Explosion.cpp | 4 -- src/lifish/entities/Explosion.hpp | 2 - src/lifish/entities/Grenade.cpp | 47 ----------------- src/lifish/entities/Grenade.hpp | 16 ------ src/lifish/entities/GuidedBullet.cpp | 13 ----- src/lifish/entities/GuidedBullet.hpp | 17 ------ src/lifish/entities/Player.cpp | 11 +--- src/lifish/entities/Player.hpp | 2 +- src/lifish/game_logic.cpp | 17 ------ 20 files changed, 3 insertions(+), 485 deletions(-) delete mode 100644 src/core/components/GuidedMoving.cpp delete mode 100644 src/core/components/GuidedMoving.hpp delete mode 100644 src/lifish/components/Absorbable.hpp delete mode 100644 src/lifish/components/LightSource.cpp delete mode 100644 src/lifish/components/LightSource.hpp delete mode 100644 src/lifish/entities/AbsorbFX.cpp delete mode 100644 src/lifish/entities/AbsorbFX.hpp delete mode 100644 src/lifish/entities/ArmorFX.hpp delete mode 100644 src/lifish/entities/Grenade.cpp delete mode 100644 src/lifish/entities/Grenade.hpp delete mode 100644 src/lifish/entities/GuidedBullet.cpp delete mode 100644 src/lifish/entities/GuidedBullet.hpp diff --git a/src/core/components/GuidedMoving.cpp b/src/core/components/GuidedMoving.cpp deleted file mode 100644 index 96a03571..00000000 --- a/src/core/components/GuidedMoving.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "GuidedMoving.hpp" -#include "Time.hpp" -#include "utils.hpp" -#include - -using lif::GuidedMoving; - -GuidedMoving::GuidedMoving(lif::Entity& owner, - const sf::Vector2f& start, const sf::Vector2f& end, sf::Time timeTaken, - std::initializer_list modfuncs) - : lif::Moving(owner, 0) - , start(start) - , end(end) - , timeTaken(timeTaken) - , modfuncs(modfuncs) - , tPerc(0) -{ - _declComponent(); - - _updatePosition(); -} - -GuidedMoving::GuidedMoving(lif::Entity& owner, - const sf::Vector2f& start, const sf::Vector2f& end, sf::Time timeTaken, - GuidedMoving::ModFunc modfunc) - : GuidedMoving(owner, start, end, timeTaken, { modfunc }) -{} - -void GuidedMoving::update() { - lif::Component::update(); - - // Calculate this once here - tPerc += lif::time.getDelta() / timeTaken; - - _updatePosition(); -} - -void GuidedMoving::_updatePosition() { - owner.setPosition(std::accumulate(modfuncs.begin(), modfuncs.end(), _calcPathPos(tPerc), - [this] (const auto& pos, const auto& pair) - { - return pos + this->_calcModFunc( - std::get<0>(pair), - std::get<1>(pair) ? tPerc : std::min(1.0f, tPerc), - std::get<2>(pair)); - })); -} - -sf::Vector2f GuidedMoving::_calcPathPos(float perc) const { - return perc > 1 ? end : start + (end - start) * perc; -} - -sf::Vector2f GuidedMoving::_calcModFunc(const GuidedMoving::_ModFunc& f, float perc, bool useRelative) const { - const auto v = f(perc); - - if (!useRelative) - return v; - - // Angle between (end - start) and x axis - const auto angle = lif::normalized(end - start).x; - const float c = std::cos(angle), - s = std::sin(angle); - - // Tilt the resulting vector to use (end - start) as the horizontal axis - return sf::Vector2f(v.x * c - v.y * s, v.x * s + v.y * c); -} - -void GuidedMoving::reset() { - tPerc = 0; -} - -bool GuidedMoving::isAtEnd() const { - return tPerc > 1; -} diff --git a/src/core/components/GuidedMoving.hpp b/src/core/components/GuidedMoving.hpp deleted file mode 100644 index 2dc42639..00000000 --- a/src/core/components/GuidedMoving.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -#include "Moving.hpp" -#include -#include -#include - -namespace lif { - -/** - * A GuidedMoving has a starting and an ending position, and will travel from the first - * to the second one in the given time. - * It may optionally have one or more "path modifier functions" which alter the way it travels from point - * `start` to `end`. - * Such functions have the signature float -> sf::Vector2f, where the input `float` is the percentage of - * the original path travelled so far, and the output `sf::Vector2f` is the offset to be added to that path. - * Note that the x and y of such offset can be either _relative to the path_ (so an offset of (0, 1) shifts the - * bullet of 1 unit orthogonally to the line linking `start` to `end`), or _absolute_, depending on the 3rd - * argument of the tuple given as a ModFunc. - */ -class GuidedMoving : public lif::Moving { - using _ModFunc = std::function; -public: - /** { function, accept inputs > 1, use relative coordinates } */ - using ModFunc = std::tuple<_ModFunc, bool, bool>; - -private: - sf::Vector2f _calcPathPos(float perc) const; - sf::Vector2f _calcModFunc(const _ModFunc& f, float perc, bool useRelative) const; - void _updatePosition(); - -protected: - const sf::Vector2f start; - const sf::Vector2f end; - const sf::Time timeTaken; - std::vector modfuncs; - float tPerc; - -public: - explicit GuidedMoving(lif::Entity& owner, - const sf::Vector2f& start, const sf::Vector2f& end, sf::Time timeTaken, - std::initializer_list modfuncs = {}); - - /** This constructor enables forwarding of the modfunc parameter from `addComponent` and similar. - * Since it's a pretty common case to have only one modfunc, it serves the practical purpose - * of adding a component without ugly workarounds. - */ - explicit GuidedMoving(lif::Entity& owner, - const sf::Vector2f& start, const sf::Vector2f& end, sf::Time timeTaken, - lif::GuidedMoving::ModFunc modfunc); - - template - void addModFunc(const T& func, bool a, bool b) { - modfuncs.emplace_back(func, a, b); - } - - bool isAtEnd() const; - - void reset(); - - void update() override; - - /** @return The current time, in percentage [0-inf) */ - float getPerc() const { return tPerc; } -}; - -} diff --git a/src/lifish/components/Absorbable.hpp b/src/lifish/components/Absorbable.hpp deleted file mode 100644 index 904a8829..00000000 --- a/src/lifish/components/Absorbable.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Component.hpp" - -namespace lif { - -/** Tagging component used for entities which grant life when killed - * by a Player with the `absorb` power. - */ -class Absorbable : public lif::Component { -public: - explicit Absorbable(lif::Entity& owner) : lif::Component(owner) { - _declComponent(); - } -}; - -} diff --git a/src/lifish/components/LightSource.cpp b/src/lifish/components/LightSource.cpp deleted file mode 100644 index f4e52ef5..00000000 --- a/src/lifish/components/LightSource.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "LightSource.hpp" -#include "core.hpp" -#include - -using lif::LightSource; - -LightSource::LightSource(lif::Entity& owner, float radius, sf::Color color, float flickerIntensity, - unsigned short flickerLen) - : lif::Component(owner) - , smoothing(flickerLen) - , radius(radius) - , color(color) - , flickerLen(flickerLen) -{ - _declComponent(); - if (flickerIntensity > 0) { - _fillRandomPool(flickerIntensity); - for (unsigned i = 0; i < flickerLen; ++i) - _flickerStep(); - } -} - -void LightSource::update() { - lif::Component::update(); - - if (flickerLen > 0) { - const float f = _flickerStep(); - color.a = 255 * f; - } -} - -void LightSource::_fillRandomPool(float flickerAmount) { - std::uniform_real_distribution dist(0, 1); - for (unsigned i = 0; i < randomPool.size(); ++i) { - randomPool[i] = (1 - flickerAmount) + flickerAmount * dist(lif::rng); - } -} - -float LightSource::_flickerStep() { - const unsigned len = smoothing.size(); - static int j = 0; - float sum = 0; - for (unsigned i = 1; i < len; ++i) { - smoothing[i-1] = smoothing[i]; - sum += smoothing[i-1]; - } - smoothing[len-1] = randomPool[j]; - j = (j + 1) % randomPool.size(); - sum += smoothing[len-1]; - return sum / len; -} diff --git a/src/lifish/components/LightSource.hpp b/src/lifish/components/LightSource.hpp deleted file mode 100644 index 6aaee51f..00000000 --- a/src/lifish/components/LightSource.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include -#include -#include -#include "Component.hpp" - -namespace lif { - -/** - * An Entity with a LightSource emits circular light in a Dark level. - * It can optionally flicker. - */ -class LightSource : public lif::Component { - std::array randomPool; - std::vector smoothing; - - float radius; - sf::Color color; - unsigned short flickerLen = 0; - - void _fillRandomPool(float flickerAmount); - float _flickerStep(); -public: - explicit LightSource(lif::Entity& owner, float radius, - sf::Color color = sf::Color::White, - float flickerIntensity = 0, // range [0, 1] - unsigned short flickerLen = 0); - - float getRadius() const { return radius; } - void setRadius(float r) { radius = r; } - - sf::Color getColor() const { return color; } - void setColor(const sf::Color& c) { color = c; } - - void update() override; -}; - -} diff --git a/src/lifish/entities/AbsorbFX.cpp b/src/lifish/entities/AbsorbFX.cpp deleted file mode 100644 index 65cd1fbe..00000000 --- a/src/lifish/entities/AbsorbFX.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "AbsorbFX.hpp" -#include "Drawable.hpp" -#include "Sprite.hpp" -#include "Temporary.hpp" -#include "Time.hpp" -#include "ZIndexed.hpp" -#include "conf/zindex.hpp" -#include "utils.hpp" - -using lif::AbsorbFX; - -constexpr static float SPEED = 350; - -AbsorbFX::AbsorbFX(const sf::Vector2f& pos, std::weak_ptr target) - : lif::Entity(pos) - , target(target) -{ - for (unsigned i = 0; i < sprites.size(); ++i) { - sprites[i] = addComponent(*this, - lif::getAsset("graphics", "absorb.png"), sf::IntRect(0, 0, 16, 16)); - sprites[i]->getSprite().setScale(1 - i * 0.15, 1 - i * 0.15); - sprites[i]->getSprite().setColor(sf::Color(255, 255, 255, 180)); - sprites[i]->setPosition(sf::Vector2f(pos.x + (i % 2) * lif::TILE_SIZE / 2.5, - pos.y + (i / 2) * lif::TILE_SIZE / 2.5)); - } - addComponent(*this, *this); - addComponent(*this, lif::conf::zindex::FLASHES); - addComponent(*this, [this] () { return expired; }); -} - -void AbsorbFX::update() { - lif::Entity::update(); - if (target.expired()) { - expired = true; - return; - } - const auto dt = lif::time.getDelta().asSeconds(); - const auto& trg = target.lock(); - if (lif::sqrDistance(trg->getPosition(), position) < lif::TILE_SIZE / 10.0) { - expired = true; - return; - } - const auto dir = lif::normalized(trg->getPosition() - position); - position += dt * SPEED * dir; - for (unsigned i = 0; i < sprites.size(); ++i) { - sprites[i]->setPosition(sf::Vector2f(position.x + (i % 2) * lif::TILE_SIZE / 2.5, - position.y + (i / 2) * lif::TILE_SIZE / 2.5)); - } -} - -void AbsorbFX::draw(sf::RenderTarget& target, sf::RenderStates states) const { - for (const auto s : sprites) - target.draw(*s, states); -} diff --git a/src/lifish/entities/AbsorbFX.hpp b/src/lifish/entities/AbsorbFX.hpp deleted file mode 100644 index e4b13cc9..00000000 --- a/src/lifish/entities/AbsorbFX.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "Entity.hpp" -#include -#include -#include - -namespace lif { - -class Sprite; - -class AbsorbFX : public lif::Entity, public sf::Drawable { - - std::weak_ptr target; - bool expired = false; - - std::array sprites; - -public: - explicit AbsorbFX(const sf::Vector2f& pos, std::weak_ptr target); - - void update() override; - void draw(sf::RenderTarget& target, sf::RenderStates states) const override; -}; - -} diff --git a/src/lifish/entities/ArmorFX.hpp b/src/lifish/entities/ArmorFX.hpp deleted file mode 100644 index 99aacbd3..00000000 --- a/src/lifish/entities/ArmorFX.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "OneShotFX.hpp" - -namespace lif { - -class ArmorFX : public lif::OneShotFX { -public: - explicit ArmorFX(const sf::Vector2f& pos) - : lif::OneShotFX(pos, "armor.png", { - sf::IntRect(0 * lif::TILE_SIZE, 0, lif::TILE_SIZE, lif::TILE_SIZE), - sf::IntRect(1 * lif::TILE_SIZE, 0, lif::TILE_SIZE, lif::TILE_SIZE), - sf::IntRect(2 * lif::TILE_SIZE, 0, lif::TILE_SIZE, lif::TILE_SIZE), - sf::IntRect(3 * lif::TILE_SIZE, 0, lif::TILE_SIZE, lif::TILE_SIZE), - sf::IntRect(4 * lif::TILE_SIZE, 0, lif::TILE_SIZE, lif::TILE_SIZE), - sf::IntRect(5 * lif::TILE_SIZE, 0, lif::TILE_SIZE, lif::TILE_SIZE), - }) { - animated->getSprite().setColor(sf::Color(255, 255, 255, 180)); - } -}; - -} diff --git a/src/lifish/entities/Bomb.cpp b/src/lifish/entities/Bomb.cpp index 41e88cba..90cc3a59 100644 --- a/src/lifish/entities/Bomb.cpp +++ b/src/lifish/entities/Bomb.cpp @@ -5,7 +5,6 @@ #include "Explosion.hpp" #include "Fixed.hpp" #include "GameCache.hpp" -#include "LightSource.hpp" #include "Player.hpp" #include "Sounded.hpp" #include "Spawning.hpp" @@ -50,7 +49,6 @@ Bomb::Bomb(const sf::Vector2f& pos, const lif::Entity *const source, addComponent(*this, [this] () { return new lif::Explosion(position, radius, sourceEntity, incendiary, lif::conf::bomb::EXPL_DAMAGE); }); - addComponent(*this, 0); addComponent(*this, lif::conf::zindex::BOMBS); auto& a_normal_idle = animated->addAnimation("normal_idle", { diff --git a/src/lifish/entities/Boss.cpp b/src/lifish/entities/Boss.cpp index 6376c968..43cff39e 100644 --- a/src/lifish/entities/Boss.cpp +++ b/src/lifish/entities/Boss.cpp @@ -1,5 +1,4 @@ #include "Boss.hpp" -#include "Absorbable.hpp" #include "Animated.hpp" #include "Bonusable.hpp" #include "BossExplosion.hpp" @@ -54,7 +53,6 @@ Boss::Boss(const sf::Vector2f& pos) lif::cache.playSound(expl->get()->getSoundFile("explode")); return expl; }); - addComponent(*this); } lif::Entity* Boss::init() { diff --git a/src/lifish/entities/Enemy.cpp b/src/lifish/entities/Enemy.cpp index 9d7eae3f..eeeac4ef 100644 --- a/src/lifish/entities/Enemy.cpp +++ b/src/lifish/entities/Enemy.cpp @@ -1,6 +1,5 @@ #include "Enemy.hpp" #include "AI.hpp" -#include "Absorbable.hpp" #include "AlienSprite.hpp" #include "Animated.hpp" #include "AxisMoving.hpp" @@ -15,7 +14,6 @@ #include "Letter.hpp" #include "LevelManager.hpp" #include "Lifed.hpp" -#include "LightSource.hpp" #include "MovingAnimator.hpp" #include "Player.hpp" #include "RegularEntityDeath.hpp" @@ -80,7 +78,6 @@ Enemy::Enemy(const sf::Vector2f& pos, unsigned short id, const lif::EnemyInfo& i // on kill animated->getSprite().setLooped(true); death->kill(); - get()->setActive(true); }, [this] () { return death->isKillInProgress(); }); @@ -93,8 +90,6 @@ Enemy::Enemy(const sf::Vector2f& pos, unsigned short id, const lif::EnemyInfo& i death = addComponent(*this, lif::conf::enemy::DEATH_TIME); shooting = addComponent(*this, info.attack); sighted = addComponent(*this); - addComponent(*this); - addComponent(*this, 0)->setActive(false); drawProxy = std::make_unique(*this); // Keep this AFTER drawProxy!!! diff --git a/src/lifish/entities/Explosion.cpp b/src/lifish/entities/Explosion.cpp index b2f0a261..c21dc905 100644 --- a/src/lifish/entities/Explosion.cpp +++ b/src/lifish/entities/Explosion.cpp @@ -8,7 +8,6 @@ #include "GameCache.hpp" #include "Level.hpp" #include "LevelManager.hpp" -#include "LightSource.hpp" #include "Player.hpp" #include "Scored.hpp" #include "Sounded.hpp" @@ -34,7 +33,6 @@ Explosion::Explosion(const sf::Vector2f& pos, unsigned short _radius, , sourceEntity(source) { explosionC = addComponent(*this, lif::getAsset("graphics", "explosionC.png")); - lightSource = addComponent(*this, (radius + 0.5) * TILE_SIZE); addComponent(*this, lif::conf::zindex::EXPLOSIONS); explosionC->addAnimation("explode", { sf::IntRect(0, 0, TILE_SIZE, TILE_SIZE), @@ -81,8 +79,6 @@ Explosion::Explosion(const sf::Vector2f& pos, unsigned short _radius, void Explosion::update() { lif::Entity::update(); - lightSource->setColor(sf::Color(255, 255, 255, - (4 - std::abs(static_cast(explosionC->getSprite().getCurrentFrame()) - 3)) * 255 / 4.0)); if (!explosionH->isActive()) return; diff --git a/src/lifish/entities/Explosion.hpp b/src/lifish/entities/Explosion.hpp index d510275a..d6ad5cab 100644 --- a/src/lifish/entities/Explosion.hpp +++ b/src/lifish/entities/Explosion.hpp @@ -14,7 +14,6 @@ class Player; class Animated; class Explosion; class BufferedSpawner; -class LightSource; /** * A bomb's explosion; like in original BOOM, the explosion @@ -48,7 +47,6 @@ class Explosion : public lif::Entity, public sf::Drawable { /** This is only non-null if explosion is incendiary */ lif::BufferedSpawner *spawner = nullptr; - lif::LightSource *lightSource = nullptr; /** Colliders used to check explosion's hits */ lif::Collider *explColliderH = nullptr, diff --git a/src/lifish/entities/Grenade.cpp b/src/lifish/entities/Grenade.cpp deleted file mode 100644 index a87ddf03..00000000 --- a/src/lifish/entities/Grenade.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "Grenade.hpp" -#include "GuidedMoving.hpp" -#include "EnemyExplosion.hpp" -#include "Killable.hpp" -#include "Collider.hpp" -#include "Spawning.hpp" -#include "AxisMoving.hpp" -#include "utils.hpp" -#include - -using lif::Grenade; -using lif::TILE_SIZE; - -Grenade::Grenade(const sf::Vector2f& pos, const sf::Vector2f& target, - const lif::BulletInfo& info, const lif::Entity *const source) - : lif::GuidedBullet(pos, - _calculateEnd(pos, target, info.range), - info, - sf::seconds(1.0 / info.speed), - source) -{ - collider->setActive(false); // collide with nothing, not even level bounds - const auto bounce = [] (auto t) { - return sf::Vector2f(0, -lif::TILE_SIZE * std::abs(std::sin(t * 2 * lif::PI)) / std::pow(t + 1, 3)); - }; - static_cast(moving)->addModFunc(bounce, false, false); - addComponent(*this, [this] () { - return new lif::EnemyExplosion(lif::aligned2(position), 1, this->info.damage, this->source); - }); -} - -void Grenade::update() { - lif::Entity::update(); - - if (static_cast(moving)->getPerc() >= 1) { - get()->kill(); - } -} - -sf::Vector2f Grenade::_calculateEnd(const sf::Vector2f& pos, const sf::Vector2f& target, float range) const { - // Calculate motion params - auto dir = target - pos; - const auto len = lif::length(dir); - if (len > range) - dir *= range / len; - return lif::aligned2(pos + dir); -} diff --git a/src/lifish/entities/Grenade.hpp b/src/lifish/entities/Grenade.hpp deleted file mode 100644 index 6a0af36d..00000000 --- a/src/lifish/entities/Grenade.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "GuidedBullet.hpp" - -namespace lif { - -class Grenade : public lif::GuidedBullet { - sf::Vector2f _calculateEnd(const sf::Vector2f& pos,const sf::Vector2f& target, float range) const; -public: - explicit Grenade(const sf::Vector2f& pos, const sf::Vector2f& target, const lif::BulletInfo& info, - const lif::Entity *const source = nullptr); - - void update() override; -}; - -} diff --git a/src/lifish/entities/GuidedBullet.cpp b/src/lifish/entities/GuidedBullet.cpp deleted file mode 100644 index 997b3771..00000000 --- a/src/lifish/entities/GuidedBullet.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "GuidedBullet.hpp" - -using lif::GuidedBullet; - -GuidedBullet::GuidedBullet(const sf::Vector2f& pos, const sf::Vector2f& end, - const lif::BulletInfo& info, sf::Time timeTaken, - const lif::Entity *const source, - std::initializer_list funcs) - : lif::Bullet(pos, info, source) -{ - moving = addComponent(*this, pos, end, timeTaken, funcs); - _setup(); -} diff --git a/src/lifish/entities/GuidedBullet.hpp b/src/lifish/entities/GuidedBullet.hpp deleted file mode 100644 index c31df523..00000000 --- a/src/lifish/entities/GuidedBullet.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Bullet.hpp" -#include "GuidedMoving.hpp" - -namespace lif { - -/** A bullet with a GuidedMoving component. */ -class GuidedBullet : public lif::Bullet { -public: - explicit GuidedBullet(const sf::Vector2f& pos, const sf::Vector2f& end, - const lif::BulletInfo& info, sf::Time timeTaken, - const lif::Entity *const source = nullptr, - std::initializer_list modfuncs = {}); -}; - -} diff --git a/src/lifish/entities/Player.cpp b/src/lifish/entities/Player.cpp index 8e4f5b60..54bbf057 100644 --- a/src/lifish/entities/Player.cpp +++ b/src/lifish/entities/Player.cpp @@ -1,6 +1,5 @@ #include "Player.hpp" #include "Animated.hpp" -#include "ArmorFX.hpp" #include "AxisMoving.hpp" #include "Bonusable.hpp" #include "BufferedSpawner.hpp" @@ -257,18 +256,12 @@ void Player::_checkCollision(lif::Collider& cld) { } if (damage > 0) - dealDamage(damage, layer == L::EXPLOSIONS, shortShield); + dealDamage(damage, shortShield); } -void Player::dealDamage(int damage, bool ignoreArmor, bool shortShield) { +void Player::dealDamage(int damage, bool shortShield) { if (killable->isKilled()) return; - // Apply armor - if (!ignoreArmor && info.powers.armor > 0) { - damage = std::max(1, damage - info.powers.armor); - get()->addSpawned(new lif::ArmorFX(position - sf::Vector2f(TILE_SIZE / 4, 0))); - } - auto lifed = get(); lif::cache.playSound(get()->getSoundFile("hurt")); lifed->decLife(damage); diff --git a/src/lifish/entities/Player.hpp b/src/lifish/entities/Player.hpp index ecf77ee2..39cdf433 100644 --- a/src/lifish/entities/Player.hpp +++ b/src/lifish/entities/Player.hpp @@ -121,7 +121,7 @@ class Player : public lif::Entity { * This function also checks if player's HP becomes 0 and kills it in that case. * This function DOES NOT CHECK if the player has shield. */ - void dealDamage(int dmg, bool ignoreArmor = false, bool giveShortShield = false); + void dealDamage(int dmg, bool giveShortShield = false); }; } diff --git a/src/lifish/game_logic.cpp b/src/lifish/game_logic.cpp index c513068d..d933c898 100644 --- a/src/lifish/game_logic.cpp +++ b/src/lifish/game_logic.cpp @@ -1,7 +1,5 @@ #include "game_logic.hpp" #include "AI.hpp" -#include "AbsorbFX.hpp" -#include "Absorbable.hpp" #include "AxisMoving.hpp" #include "Bomb.hpp" #include "Bonus.hpp" @@ -124,21 +122,6 @@ void lif::game_logic::scoredKillablesLogic(lif::Entity& e, lif::BaseLevelManager lm.addScore(target, scored->givePoints()); } - // Apply absorb - if (e.get() != nullptr) { - for (int i = 0; i < lif::MAX_PLAYERS; ++i) { - if (target >= 0 && target != i + 1) continue; - auto& player = lm.getPlayer(i + 1); - if (player == nullptr) continue; - auto& powers = player->getPowers(); - if (powers.absorb > 0 && ++powers.absorbKillCount >= 3 - powers.absorb) { - powers.absorbKillCount = 0; - player->get()->decLife(-1); - tbspawned.emplace_back(new lif::AbsorbFX(e.getPosition(), player)); - } - } - } - auto points = is_boss ? new lif::Points(e.getPosition(), scored->getPointsGiven(), sf::Color::Magenta, 30) : new lif::Points(e.getPosition(), scored->getPointsGiven());